martona / mhook

A Windows API hooking library
Other
728 stars 326 forks source link

I find a bug in Mhook 2.4 #10

Open flylinfan opened 9 years ago

flylinfan commented 9 years ago

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.

wbenny commented 9 years ago

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];
+}