magicxor / delphi-detours-library

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

AV in hook TApplication.UnhookSynchronizeWakeup method #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What is the function that you are trying to hook ?

type
  TUnhookSynchronizeWakeupProc = procedure;

var
 TrampoUnhookSynchronizeWakeup : TUnhookSynchronizeWakeupProc = nil;

procedure MyUnhookSynchronizeWakeup;
begin
 TrampoUnhookSynchronizeWakeup; <--- this line raise AV
end;

initialization

@TrampoUnhookSynchronizeWakeup := 
InterceptCreate(@Forms.TApplication.UnhookSynchronizeWakeup, 
@MyUnhookSynchronizeWakeup);

What is the expected output? What do you see instead?

I get AV.

What version of the product are you using? On what operating system? Which
architecture x86 or x64 ?

Delphi XE7, Windows 7 x64

Original issue reported on code.google.com by jac....@gmail.com on 6 Nov 2014 at 4:45

GoogleCodeExporter commented 9 years ago
Hi,

This is not a bug ..
You are hooking a function that is declared in a class (TApplication).
When hooking such as function you need to include the object variable(Self) 
that represent the object as a first parameter of your hooked and trampo 
functions.

type
  TUnhookSynchronizeWakeupProc = procedure(Self:TObject);

var
  TrampoUnhookSynchronizeWakeup: TUnhookSynchronizeWakeupProc = nil;

procedure MyUnhookSynchronizeWakeup(Self:TObject);
begin
  TrampoUnhookSynchronizeWakeup(Self);
  ShowMessage('done!');
end;

Please take a look at Trunk.Demo.HookObject projects.

Original comment by ismspi...@gmail.com on 6 Nov 2014 at 10:55

GoogleCodeExporter commented 9 years ago

Original comment by ismspi...@gmail.com on 6 Nov 2014 at 10:58