magicxor / delphi-detours-library

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

InterceptRemove() always returns false (its call to VirtualFree always fails) #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What is the function that you are trying to use?
 - InterceptRemove, to remove a hook

What is the expected output? What do you see instead?
 - Expected: InterceptRemove returns True
 - Observed: InterceptRemove returns False

Please provide any additional information below.
The bug is in the call to VirtualFree.  It is called passing the size of the 
trampoline (eg, 42 bytes.)  However, according to MSDN's VirtualFree 
documentation:

"dwSize ... If the dwFreeType parameter is MEM_RELEASE, this parameter must be 
0 (zero)."

I can verify that if I change the DDetours code to pass a size of 0, instead of 
the TrampolineSize variable, VirtualFree succeeds.

Please note this issue was found by vitalyg2 of CnPack, not by me - see 
https://github.com/cnpack/cnwizards/pull/3 (a pull request from me to integrate 
DDetours into CnPack - halfway down you can see discussion about this method 
failing.)  However I have tested and can verify the problem and found the 
solution.

Original issue reported on code.google.com by vintaged...@gmail.com on 16 Aug 2014 at 11:03

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r40.

Original comment by ismspi...@gmail.com on 22 Nov 2014 at 6:59