(Gast)
n/a Beiträge
|
Re: Startparameter fremder Anwendung auslesen
1. Mär 2010, 15:31
Hallo,
ja, da hast du allerdings Recht
Vielleicht sollte man nicht immer alles gleichzeitig machen...
Delphi-Quellcode:
function GetStartParameter(ProcessID: DWORD): String;
var
MBI : TMemoryBasicInformation;
Buffer,PosCmdLine : Pointer;
SystemInfo : TSystemInfo;
Size : DWORD;
CmdLine : WideString;
LengthCmdLine : Word;
ProcessHandle : THandle;
begin
Result := '';
FillChar(SystemInfo, SizeOf(TSystemInfo), 0);
GetSystemInfo(SystemInfo);
GetMem(Buffer, SystemInfo.dwPageSize);
Size := SizeOf(TMemoryBasicInformation);
FillChar(MBI, Size, 0);
ProcessHandle := OpenProcess(PROCESS_VM_READ or PROCESS_QUERY_INFORMATION, False, ProcessId);
if VirtualQueryEx(ProcessHandle, Pointer($20000), MBI, Size) = Size then if ReadProcessMemory(ProcessHandle, MBI.BaseAddress, Buffer, SystemInfo.dwPageSize, DWORD(nil^)) then
begin
LengthCmdLine := PWord(Longint(Buffer) + $42)^;
if LengthCmdLine < 520 then
begin
SetLength(CmdLine,LengthCmdLine);
PosCmdLine := Pointer(PLongint(Longint(Buffer) + $44)^);
if ReadProcessMemory(ProcessHandle, PosCmdLine, PWideChar(CmdLine), LengthCmdLine, DWORD(nil^)) then Result := Copy(CmdLine, 1, Pos(#0,CmdLine) - 1);
end;
end;
CloseHandle(Processhandle);
FreeMem(Buffer);
end;
So, dass ist die Funktion.
Danke!
Gruß,
Michael
|
|
Zitat
|