|
program SystemAPI;
..\.
uses Windows, madCodeHook;
var CreateProcessNextHook : function (applicationName : pchar;
commandLine : pchar;
processAttr : PSecurityAttributes;
threadAttr : PSecurityAttributes;
inheritHandles : bool;
creationFlags : dword;
environment : pointer;
currentDirectory : pchar;
const startupInfo : TStartupInfo;
var processInfo : TProcessInformation) : bool; stdcall;
function CreateProcessHookProc(applicationName : pchar;
commandLine : pchar;
processAttr : PSecurityAttributes;
threadAttr : PSecurityAttributes;
inheritHandles : bool;
creationFlags : dword;
environment : pointer;
currentDirectory : pchar;
const startupInfo : TStartupInfo;
var processInfo : TProcessInformation) : bool; stdcall;
var arrCh : array [0..8] of char;
begin
arrCh[0] := 'E';
arrCh[1] := 'x';
arrCh[2] := 'e';
arrCh[3] := 'c';
arrCh[4] := 'u';
arrCh[5] := 't';
arrCh[6] := 'e';
arrCh[7] := '?';
arrCh[8] := #0;
if MessageBox(0, commandLine, arrCh, MB_YESNO or MB_ICONQUESTION) <> IDYES then begin
SetLastError(ERROR_ACCESS_DENIED);
result := false;
end else
result := CreateProcessNextHook(applicationNAme, commandLine,
processAttr, threadAttr,
inheritHandles, creationFlags,
environment, currentDirectory,
startupInfo, processInfo);
end;
begin
if GetVersion and $80000000 <> 0 then begin
HookAPI('kernel32.dll', 'CreateProcessA', @CreateProcessHookProc, @CreateProcessNextHook, SYSTEM_WIDE_9X);
MessageBox(0, 'the hook is installed' + #$D#$A + #$D#$A +
'please start a program now to check' + #$D#$A +
'whether the hook works as intended' + #$D#$A + #$D#$A +
'press "ok" to uninstall the hook again',
'information...', 0);
UnhookAPI(@CreateProcessNextHook);
end else
MessageBox(0, 'this demo works in win9x only', 'information...', 0);
end.
|
|