From a316c6e87916853c0e8f31bc73503e469cd77e96 Mon Sep 17 00:00:00 2001 From: Jose Fonseca Date: Fri, 10 Jul 2015 11:07:10 +0100 Subject: trace,inject: Don't increment refcount on GetModuleHandleExA. --- inject/injectee.cpp | 7 ++++--- wrappers/trace.py | 3 ++- 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);' -- cgit v1.2.3