toizy-mr / delphi-detours-library

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

Update Hook #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I look through the wiki and couldn't find a way to update hook in fast way. Can 
you make such a method?

Original issue reported on code.google.com by david.lo...@gmail.com on 23 Jan 2015 at 7:15

GoogleCodeExporter commented 9 years ago
What do you mean by "update hook" ?

Original comment by ismspi...@gmail.com on 23 Jan 2015 at 7:45

GoogleCodeExporter commented 9 years ago
I receive the same com object multiple times so if i only patch it once not all 
events get received! It seems that library not patch the vtable? This StartEx 
function get called multiple time.

So have to patch it multiple times but then i get error:

First chance exception at $75514598. Exception class Exception with message 
'Exceed maximum allowed of hooks.'. Process Project.exe (7832)

Example:

class function TMonitor.StartEx(Self: IInternetProtocolRoot; Uri: IUri; 
OIProtSink: IInternetProtocolSink; OIBindInfo: IInternetBindInfo; grfPI, 
dwReserved: DWORD): HResult; stdcall;
begin
  BeginHooks();
  @Monitor.FSwitch := InterceptCreate(OIProtSink, 3, @TInternetProtocolSink.Switch);
  @Monitor.FReportProgress := InterceptCreate(OIProtSink, 4, @TInternetProtocolSink.ReportProgress);
  @Monitor.FReportData := InterceptCreate(OIProtSink, 5, @TInternetProtocolSink.ReportData);
  @Monitor.FReportResult := InterceptCreate(OIProtSink, 6, @TInternetProtocolSink.ReportResult);
  @Monitor.FGetBindString := InterceptCreate(OIBindInfo, 4, @TInternetBindInfo.GetBindString);
  @Monitor.FGetBindInfo := InterceptCreate(OIBindInfo, 3, @TInternetBindInfo.GetBindInfo);
  EndHooks();

    Monitor.FInternetProtocolRoot := Self;
  Monitor.FInternetProtocolSink := OIProtSink;
  Monitor.FInternetBindInfo := OIBindInfo;
  OIProtSink.QueryInterface(IServiceProvider, Monitor.FServiceProvider);
    Result := Monitor.FStartEx(Self, Uri, OIProtSink, OIBindInfo, grfPI, dwReserved);
end;

Original comment by david.lo...@gmail.com on 23 Jan 2015 at 7:48

GoogleCodeExporter commented 9 years ago
<if i only patch it once not all events get received!
Please provide more details about this point.

<It seems that library not patch the vtable?
Yes the library does not patch the vtable.It patch the method inside the class 
that implement the interface.

<So have to patch it multiple times but then i get error:
You don't need to do that .Once the hook is installed, the intercept proc will 
get fired every time the original method is called.

Original comment by ismspi...@gmail.com on 23 Jan 2015 at 8:01

GoogleCodeExporter commented 9 years ago
If I provide my own IInternetProtocolSink all events get fired all the time. 
But if I patch the original IInternetProtocolSink (OIProtSink) not all events 
get fired.

Original comment by david.lo...@gmail.com on 23 Jan 2015 at 8:04

GoogleCodeExporter commented 9 years ago
I will send you project on email for verify. :)

Original comment by david.lo...@gmail.com on 23 Jan 2015 at 8:06

GoogleCodeExporter commented 9 years ago
Can you include the full example ?

Original comment by ismspi...@gmail.com on 23 Jan 2015 at 8:06

GoogleCodeExporter commented 9 years ago
Ok

Original comment by ismspi...@gmail.com on 23 Jan 2015 at 8:07

GoogleCodeExporter commented 9 years ago

Original comment by ismspi...@gmail.com on 23 Jan 2015 at 9:29