1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| var
FnMafonction : function (lpUsername: PWideChar; lpDomain: PWideChar; lpPassword: PWideChar; dwLogonFlags: DWORD; lpApplicationName: PWideChar; lpCommandLine: PWideChar; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PWideChar; const lpStartupInfo: TStartupInfo; var lpProcessInfo: TProcessInformation): Bool;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
LDLLhandle: THandle;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
bval: Boolean;
begin
//.Ici, je charge la DLL.
LDLLhandle:= LoadLibrary(PChar(ExtractFilePath(Application.ExeName) + 'advapi32.dll'));
try
if LDLLhandle<>0 then
begin
//.La fonction qui m'intéresse.
@FnMafonction:= GetProcAddress(LDLLhandle,'CreateProcessWithLogonW');
if @FnMafonction<>nil then
begin
FillChar(StartupInfo, SizeOf(StartupInfo), 0);
StartupInfo.cb := SizeOf(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := SW_SHOWNORMAL;
// VIOLATION D'ACCES ICI.
bval := FnMafonction('Admin', 'Domaine', 'MDP', 1, nil, 'regedit', CREATE_DEFAULT_ERROR_MODE, nil, nil, StartupInfo, ProcessInfo);
if not bval then
ShowMessage('Erreur');
end;
end
else
MessageBoxA(0, PChar('Erreur de chargement de dll'),'',MB_ICONSTOP);
finally
if LDLLhandle<>0 then
FreeLibrary(LDLLhandle);
end; |
Partager