jumaris / delphi-detours-library

Automatically exported from code.google.com/p/delphi-detours-library
0 stars 1 forks source link

Hook Fails.. #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Fails on 32 & 64..

program Project3;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  Winapi.Windows,
  Winapi.Wininet,
  DDetours;

var
  FHttpAddRequestHeadersW: function(hRequest: HINTERNET; lpszHeaders: LPWSTR; dwHeadersLength: DWORD; dwModifiers: DWORD): BOOL; stdcall;

function HttpAddRequestHeadersW(hRequest: HINTERNET; lpszHeaders: LPWSTR; 
dwHeadersLength: DWORD; dwModifiers: DWORD): BOOL; stdcall;
begin
  Result := FHttpAddRequestHeadersW(hRequest, lpszHeaders, dwHeadersLength, dwModifiers);
end;

begin
   @FHttpAddRequestHeadersW := InterceptCreate('wininet.dll', 'HttpAddRequestHeadersW', @FHttpAddRequestHeadersW, tRUE); // ERROR!!
end.

{
  First chance exception at $75514598. Exception class Exception with message 'Invalid InterceptProc Pointer.'. Process Project3.exe (4296)
}

Original issue reported on code.google.com by david.lo...@gmail.com on 20 Jan 2015 at 11:33

GoogleCodeExporter commented 9 years ago
Ah remove this report. :)

Original comment by david.lo...@gmail.com on 20 Jan 2015 at 11:37

GoogleCodeExporter commented 9 years ago
That's because you are passing a nil InterceptProc .
//------------------------------
 @FHttpAddRequestHeadersW := InterceptCreate('wininet.dll', 'HttpAddRequestHeadersW', @HttpAddRequestHeadersW, tRUE); // ERROR!!

I use always trampo prefix and hook/Intercept suffix to just not get confused!

Original comment by ismspi...@gmail.com on 20 Jan 2015 at 3:34