mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 21:30:53 +00:00
In Win32 ApplyHooks get module baseAddress from the call to LoadLibrary
If the module is unloaded, reloaded during the hooking process the base address might have changed and the original baseAddress will be pointing to invalid memory
This commit is contained in:
@@ -280,8 +280,6 @@ struct CachedHookData
|
||||
if(ignores.find(lowername) != ignores.end())
|
||||
return;
|
||||
|
||||
byte *baseAddress = (byte *)module;
|
||||
|
||||
// the module could have been unloaded after our toolhelp snapshot, especially if we spent a
|
||||
// long time
|
||||
// dealing with a previous module (like adding our hooks).
|
||||
@@ -296,6 +294,7 @@ struct CachedHookData
|
||||
// and FreeLibrary that I want to avoid. Worst case, we load a dll, hook it, then unload it
|
||||
// again.
|
||||
HMODULE refcountModHandle = LoadLibraryW(modpath);
|
||||
byte *baseAddress = (byte *)refcountModHandle;
|
||||
|
||||
PIMAGE_DOS_HEADER dosheader = (PIMAGE_DOS_HEADER)baseAddress;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user