Registriert seit: 20. Jun 2004
Ort: Berlin
89 Beiträge
Delphi 7 Enterprise
|
Re: Parameter aus externer Anwendung auslesen
1. Mär 2007, 17:36
Delphi-Quellcode:
function AufrufParameter(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;
Thomas H.
|
|
Zitat
|