MCH 3x: Small bug in GetCallingModule

c++ / delphi package - dll injection and api hooking

MCH 3x: Small bug in GetCallingModule

Postby EaSy » Wed Apr 18, 2018 6:24 am

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
EaSy
 
Posts: 150
Joined: Tue Oct 23, 2012 12:33 pm

Re: MCH 3x: Small bug in GetCallingModule

Postby madshi » Mon Apr 23, 2018 6:24 pm

Thank you - I'll fix that right away! :D
madshi
Site Admin
 
Posts: 9774
Joined: Sun Mar 21, 2004 5:25 pm


Return to madCodeHook

Who is online

Users browsing this forum: Google [Bot] and 8 guests