![]() |
Aufruf von CreateProcessA aus kopierter Kernel schlägt fehl
Hi,
um einige API Hooks zu umgehen, wurde mir vorgeschlagen einfach die kernel32.dll ins Temp Verzeichniss zu kopieren und daraus die original APIs zu importieren. Für WriteProcessMemory, ReadProcessMemory, VirtualAllocEx, etc funktioniert dies auch wunderbar. Bei CreateProcessA allerdings führt ein Aufruf der API zu keinem Ergebniss --> es wird kein Programm gestartet. Kernel kopieren:
Delphi-Quellcode:
Funktion laden:
TmpKernel := GetTempFilename(GetTempDir, 'knl');
Result := CopyFile(PChar(GetSysDir + '\kernel32.dll'), PChar(TmpKernel), false); KernelHandle := LoadLibrary(PChar(TmpKernel));
Delphi-Quellcode:
Der Aufruf von CreateProcess ist erfolgreich, allerdings startet kein Programm .. Setze ich statt KernelHandle GetModuleHandle('kernel32') ein funktioniert auch diese API wunderbar.
function CreateProcess(lpApplicationName: PChar; lpCommandLine: PChar;
const lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PChar; const lpStartupInfo: TStartupInfo; out lpProcessInformation: TProcessInformation): BOOL; stdcall; var pCreateProcess: function(lpApplicationName: PChar; lpCommandLine: PChar; const lpProcessAttributes, lpThreadAttributes: PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: PChar; const lpStartupInfo: TStartupInfo; out lpProcessInformation: TProcessInformation): BOOL; stdcall; begin pCreateProcess := GetProcAddress(KernelHandle, 'CreateProcessA'); if Assigned(pCreateProcess) then Result := pCreateProcess(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation) else Result := Windows.CreateProcessA(lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation); end; Wie es scheint wird der Prozess sogar für einen Sekundenbruchteil lang erstellt, dann aber sofort wieder terminiert. Muss ich eventuell mit einer weiteren API irgendwelche Rechte oder sowas setzen? |
Re: Aufruf von CreateProcessA aus kopierter Kernel schlägt f
Kann das daran liegen, daß seit Windows NT4 oder 2000 jeder Win32-Prozess einen Import von Kernel32.dll haben muß und du u.U. in dem neu erzeugten Prozeß statt der eigentlichen ursprünglichen Kernel32 (im Systemverzeichnis) die im Tempverzeichnis importierst, weil bspw. das zu startende Programm auch in diesem Verzeichnis liegt?
|
Re: Aufruf von CreateProcessA aus kopierter Kernel schlägt f
Maybe you can try to keep the copy of kernel32.dll in the Windows\System32 directory (eg as Kernel32Ex.dll)?
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz