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

Conversation

ducsonnguyen
Copy link

When FindTrampolineInRange() can't locate a suitable trampoline in the existing
free list, TrampolineAlloc() calls BlockAlloc() to create a new pool of
trampolines. BlockAlloc() links the last node of the new free list to the
beginning of the existing free list. But it did NOT link the head of the
existing free list back to the tail of the new list via the pPrevTrampoline
pointer.

If that old head node was ever used for a trampoline, ListRemove() was unable
to update its predecessor to properly remove it from the free list. That node
would get pulled for use again if a hook needed another trampoline in its
address range. Changing the hook address could misdirect the previous
function(s) that used the same trampoline.

When FindTrampolineInRange() can't locate a suitable trampoline in the existing
free list, TrampolineAlloc() calls BlockAlloc() to create a new pool of
trampolines. BlockAlloc() links the last node of the new free list to the
beginning of the existing free list. But it did NOT link the head of the
existing free list back to the tail of the new list via the pPrevTrampoline
pointer.

If that old head node was ever used for a trampoline, ListRemove() was unable
to update its predecessor to properly remove it from the free list. That node
would get pulled for use again if a hook needed another trampoline in its
address range. Changing the hook address could misdirect the previous
function(s) that used the same trampoline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant