martona/mhook

I find a bug in Mhook 2.4

flylinfan opened this issue · 1 comments

The follow statement will cause crash when allocate the second block trampoline area in win7 x64.
// last entry points to the current head of the free list
pRetVal[trampolineCount - 1].pNextTrampoline = g_pFreeList;
in mhook.cpp BlockAlloc function.This statement repeat use the first trampoline in the first block.

Fix for anyone who stumbles upon the same problem:

// last entry points to the current head of the free list
pRetVal[trampolineCount - 1].pNextTrampoline = g_pFreeList;

+if (g_pFreeList) {
+   g_pFreeList->pPrevTrampoline = &pRetVal[trampolineCount - 1];
+}