summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2015-07-10 11:07:10 +0100
committerJose Fonseca <jfonseca@vmware.com>2015-07-13 15:53:34 +0100
commita316c6e87916853c0e8f31bc73503e469cd77e96 (patch)
treeaa58d5ac388d417c0e5efd81c66db62ad293f26b
parent2ec73fad5120d57ebd0f63841373c8858e5dd43d (diff)
trace,inject: Don't increment refcount on GetModuleHandleExA.
-rw-r--r--inject/injectee.cpp7
-rw-r--r--wrappers/trace.py3
2 files changed, 6 insertions, 4 deletions
diff --git a/inject/injectee.cpp b/inject/injectee.cpp
index 4ed8488d..89cd6129 100644
--- a/inject/injectee.cpp
+++ b/inject/injectee.cpp
@@ -747,9 +747,10 @@ MyLoadLibraryA(LPCSTR lpLibFileName)
void *caller = __builtin_return_address (0);
HMODULE hModule = 0;
- BOOL bRet = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
- (LPCTSTR)caller,
- &hModule);
+ BOOL bRet = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+ (LPCTSTR)caller,
+ &hModule);
assert(bRet);
char szCaller[MAX_PATH];
DWORD dwRet = GetModuleFileNameA(hModule, szCaller, sizeof szCaller);
diff --git a/wrappers/trace.py b/wrappers/trace.py
index 6f5dab42..a7a0a0b0 100644
--- a/wrappers/trace.py
+++ b/wrappers/trace.py
@@ -896,7 +896,8 @@ class Tracer:
print r' riid.Data4[0], riid.Data4[1], riid.Data4[2], riid.Data4[3], riid.Data4[4], riid.Data4[5], riid.Data4[6], riid.Data4[7]);'
print r' void * pVtbl = *(void **)pvObj;'
print r' HMODULE hModule = 0;'
- print r' BOOL bRet = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,'
+ print r' BOOL bRet = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |'
+ print r' GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,'
print r' (LPCTSTR)pVtbl,'
print r' &hModule);'
print r' assert(bRet);'