MCH 3x: Small bug in GetCallingModule

c++ / delphi package - dll injection and api hooking
Post Reply
EaSy
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

MCH 3x: Small bug in GetCallingModule

Post by EaSy »

Hi,
I discovered small bug in your GetCallingModule function code (ModuleTools.cpp, 379).

Code: Select all

...
          if ( ((*g_pHookCollection)[i].pCodeHook != NULL) &&
               ((*g_pHookCollection)[i].pCodeHook->mpInUseCodeArray != NULL) &&
               (pReturnAddress >= (*g_pHookCollection)[i].pCodeHook->mpInUseCodeArray) &&
/*HERE----->*/ (pReturnAddress <  (*g_pHookCollection)[i].pCodeHook->mpInUseCodeArray + IN_USE_COUNT * IN_USE_SIZE) )
          {
...
This line should look like:

Code: Select all

               (pReturnAddress <  ((BYTE*)(*g_pHookCollection)[i].pCodeHook->mpInUseCodeArray) + IN_USE_COUNT * IN_USE_SIZE) )
or like:

Code: Select all

               (pReturnAddress <  (*g_pHookCollection)[i].pCodeHook->mpInUseCodeArray + IN_USE_COUNT) )
Otherwise it can lead to invalid memory access excetion. Thx for fixing it.

EaSy
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: MCH 3x: Small bug in GetCallingModule

Post by madshi »

Thank you - I'll fix that right away! :D
Post Reply