Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix free list prev pointer when allocating new block #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mhook-lib/mhook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,12 @@ static MHOOKS_TRAMPOLINE* BlockAlloc(PBYTE pSystemFunction, PBYTE pbLower, PBYTE
pRetVal[s].pNextTrampoline = &pRetVal[s + 1];
}

// last entry points to the current head of the free list
// last entry points to the current head of the free list and
// the current head points back to the last entry of the new block
pRetVal[trampolineCount - 1].pNextTrampoline = g_pFreeList;
if (g_pFreeList) {
g_pFreeList->pPrevTrampoline = &pRetVal[trampolineCount - 1];
}
break;
}
}
Expand Down