summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Gjenero <boris.gjenero@gmail.com>2014-10-20 11:46:53 -0400
committerJose Fonseca <jfonseca@vmware.com>2016-09-12 16:24:04 +0100
commit6ac0bf2007b5af10532504e2183fbd0cfedaa59f (patch)
treec755ef5679d1497cf387f67d0d4f69ecb6852ffc
parentff5a585edca3a56aa7d42285f0e75a048993b23e (diff)
mhook: Fixes to make Mhook_Unhook() work.
This fixes ListRemove() when deleting the last trampoline in a list, and fixes TrampolineGet() so it can find trampolines. https://github.com/martona/mhook/pull/3
-rw-r--r--thirdparty/mhook/mhook-lib/mhook.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/thirdparty/mhook/mhook-lib/mhook.cpp b/thirdparty/mhook/mhook-lib/mhook.cpp
index 7249ad5d..9bf0e70e 100644
--- a/thirdparty/mhook/mhook-lib/mhook.cpp
+++ b/thirdparty/mhook/mhook-lib/mhook.cpp
@@ -187,7 +187,9 @@ static VOID ListRemove(MHOOKS_TRAMPOLINE** pListHead, MHOOKS_TRAMPOLINE* pNode)
if ((*pListHead) == pNode) {
(*pListHead) = pNode->pNextTrampoline;
- assert((*pListHead)->pPrevTrampoline == NULL);
+ if (*pListHead != NULL) {
+ assert((*pListHead)->pPrevTrampoline == NULL);
+ }
}
pNode->pPrevTrampoline = NULL;
@@ -445,7 +447,7 @@ static MHOOKS_TRAMPOLINE* TrampolineGet(PBYTE pHookedFunction) {
MHOOKS_TRAMPOLINE* pCurrent = g_pHooks;
while (pCurrent) {
- if (pCurrent->pHookFunction == pHookedFunction) {
+ if ((PBYTE)&(pCurrent->codeTrampoline) == pHookedFunction) {
return pCurrent;
}