library APIHook;


{$MODE Delphi}

uses
  windows,HookUnit in '../HookUnit.pas', LoadGlobal;

//--------------Test
type TMessageBox=function (wnd: HWND; text:pchar; cap:pchar; typ:cardinal):integer;stdcall;
var oldMessageBox:TMessageBox=nil;

function NewMessageBoxA(wnd: HWND; text:pansichar; cap:pansichar; typ:cardinal):integer;stdcall;
begin
  if @oldMessageBox<>nil then
    result:=oldMessageBox(wnd,text,'hooked',typ)
   else
    result:=0;
end;
procedure BeginFunctionHooking;
begin

  oldMessageBox:=HookFunction(@MessageBoxA,@NewMessageBoxA,'MessageBoxA','user32.dll');
 // oldMessageBox:=HookFunction(GetProcAddress(LoadLibrary('user32.dll'),'MessageBoxA'),@NewMessageBoxA,'MessageBoxA','user32.dll');
  HookGetProcAddressFunction;         ;
end;
//---------------Test//


exports StartHook, StopHook;

begin
  BeginFunctionHooking;
end.
