我最亲爱的说

子非鱼,焉知鱼之乐.

导航

[delphi]SetWindowsHookExA函数入口处修改

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[1..3] of byte = ($C2, $10, $0);
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[1], 3, WriteByte);
  ShowMessage('hook成功');
  Result := 1;
end;



exports
  Test2;
begin
  Test2();
end.

 

posted on 2013-06-23 10:20  我最亲爱的说  阅读(896)  评论(0编辑  收藏  举报