Page 1 of 1

UnHookCode causes access violation

Posted: Tue Mar 29, 2016 9:37 am
by TCS
Hey,

This is somewhat continuation of "Unhooking on process destroy and manual uninject issues" thread.

In the PROCESS_DETACH I am unhooking all the hooks using UnHookCode().
In case the hooks have been unhooked before PROCESS_DETACH the UnHookCode() function simply fails.

The problem is that in a reproducable scenario unhook of CoCreateInstance causes access violation. The call stack is the following:
ntdll.dll!000000007789afba() Unknown
KernelBase.dll!000007fefd6d1592() Unknown
my_dll.dll!CCodeHook::~CCodeHook(void) C++
my_dll.dll!CCodeHook::`vector deleting destructor'(unsigned int) C++
my_dll.dll!AutoUnhookUninject(struct HINSTANCE__ *) C++
my_dll.dll!UnhookCode() C++

p.s.
IsHookInUse() returns 0.

Re: UnHookCode causes access violation

Posted: Tue Mar 29, 2016 9:42 am
by madshi
Does this still happen with madCodeHook 3.1.11? If so, is there a way for me to reproduce the problem somehow? Or can you somehow find out which source code line in the destructor produces that crash?

Re: UnHookCode causes access violation

Posted: Tue Mar 29, 2016 10:47 am
by TCS
1. I do use the latest version. btw, is there a way to verify what is the installed version?

2. I did not succeed in reproducing it on a small scale demo, and I don't have the source code. I can try and produce a dump if you like.

Re: UnHookCode causes access violation

Posted: Tue Mar 29, 2016 12:19 pm
by madshi
What happens if you compile a debug version? Maybe the stack trace then contains line numbers or something?

Re: UnHookCode causes access violation

Posted: Wed Mar 30, 2016 6:42 am
by TCS
no...

Re: UnHookCode causes access violation

Posted: Wed Mar 30, 2016 6:51 am
by madshi
Oh well. Please send me a crash dump then. If possible, please use the debug version of your hook dll, and please include the PDB also. Thanks!

Re: UnHookCode causes access violation

Posted: Wed Mar 30, 2016 3:08 pm
by TCS
Sending by mail...

Re: UnHookCode causes access violation

Posted: Wed Mar 30, 2016 8:27 pm
by TCS
Also, I've use an IPC mechanism I have to try and unhook before the dll main (before uninjecting the libraries) and it still crashes.