How I can get CMDLine from other application?
I'm write down this code:
Code: Select all
library HLRPI;
uses
madRemote;
{$R *.res}
const
MAX_PATH = 260;
kernel32 = 'kernel32.dll';
type
DWORD = LongWord;
function GetCommandLineW: PWideChar; stdcall; external kernel32 name 'GetCommandLineW'; //For perfect results of all chars from cmd. Like /english /Русский /こんにちは /Empfehlung etc.
function GetCmdLineThread(buffer: PWideChar): DWORD; stdcall;
var
cl: PWideChar;
begin
cl := GetCommandLineW;
for result := 0 to MAX_PATH - 1 do
begin
buffer[result] := cl[result];
if buffer[result] = #0 then
break;
end;
end;
function GetProcessCdLine(aProcID: Cardinal): string; cdecl;
var
arrCh: array[0..MAX_PATH - 1] of WideChar;
len: dword;
begin
if RemoteExecute(aProcID, @GetCmdLineThread, len, @arrCh, MAX_PATH) then
SetString(result, arrCh, len)
else
result := '';
end;
exports GetProcessCmdLine;
begin
end.
Code: Select all
const
HLRPI = 'HLRPI.dll';
type
TGetProcessCMDLine = function(aValue: Cardinal): string;
function GetProcessCMD(aProcID: Cardinal; var aReturnStr: string): Boolean;
implementation
function GetProcessCMD(aProcID: Cardinal; var aReturnStr: string): Boolean;
var
hDLL: THandle;
hFunc: TGetProcessCMDLine;
begin
Result := False;
if (aProcID <= 0) then Exit;
aReturnStr := '';
hDLL := 0;
hFunc := nil;
try
hDLL := LoadLibrary(PAnsiChar(HLRPI));
if (hDLL <> 0) then
begin
@hFunc := GetProcAddress(hDLL, PAnsiChar('GetProcessCmdLine'));
if Addr(hFunc) <> nil then
begin
aReturnStr := hFunc(aProcID);
Result:=True;
end
else
Result := False;
end
else
begin
Result := False;
end;
finally
FreeLibrary(hDLL);
end;
end;
GetProcessCMD work's fine. But GetProcessCmdLine function return is empty. Why?
I don't have a commercial license.
Or may be, how I can get CMD line without using madCHook.dll+mchEvaluation.exe?