library Project2; uses
SysUtils,
Classes,
windows,
Dialogs;
{$R *.res} function GetModuleHandleA(a: string): Integer; stdcall; external 'kernel32.dll'
{取程序或DLL句柄
a:DLL名
} function GetProcAddress(a: integer; b: string): Integer; stdcall; external 'kernel32.dll'
{取DLL函数地址
a:模块句柄
b:函数名
} function GetCurrentProcess: Integer; stdcall; external 'kernel32.dll'
{取伪句柄
} function Test11(aa: string): string;
begin Result := aa;
end;
var
b: array[..] of byte = ($C2, $, $);
function Test2(): Integer;
var
a: Integer;
c: Integer;
WriteByte: DWORD;
begin
//GetModuleHandleA('user32.dll');
a := GetModuleHandleA('user32.dll');
c := GetProcAddress(a, 'SetWindowsHookExA');
WriteProcessMemory(GetCurrentProcess(), Pointer(c), @b[], , WriteByte);
ShowMessage('hook成功');
Result := ;
end; exports
Test2;
begin
Test2();
end.