aboutsummaryrefslogtreecommitdiff
path: root/primedev/thirdparty/silver-bun/module.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2024-08-27 07:48:33 +0100
committerGitHub <noreply@github.com>2024-08-27 08:48:33 +0200
commitf1288350c729d63aeeb0a6bdab0746b865131668 (patch)
treebcad7f52872c962b47969df3a2f07ee3fec90ef2 /primedev/thirdparty/silver-bun/module.cpp
parent932735e0500f6fc4d43ee949754c6a6a7c48d3e2 (diff)
downloadNorthstarLauncher-f1288350c729d63aeeb0a6bdab0746b865131668.tar.gz
NorthstarLauncher-f1288350c729d63aeeb0a6bdab0746b865131668.zip
hooking: run callbacks for imported modules (#780)v1.27.3-rc6v1.27.3
Previously we only ran callbacks for modules loaded using WinAPI. This now also runs callbacks for modules imported by those loaded by WinAPI. This fixes callbacks for miles and bink dlls.
Diffstat (limited to 'primedev/thirdparty/silver-bun/module.cpp')
-rw-r--r--primedev/thirdparty/silver-bun/module.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/primedev/thirdparty/silver-bun/module.cpp b/primedev/thirdparty/silver-bun/module.cpp
index 84f4da9e..dceb602a 100644
--- a/primedev/thirdparty/silver-bun/module.cpp
+++ b/primedev/thirdparty/silver-bun/module.cpp
@@ -66,6 +66,21 @@ void CModule::Init()
m_ModuleSections.push_back(ModuleSections_t(reinterpret_cast<const char*>(hCurrentSection.Name),
static_cast<uintptr_t>(m_pModuleBase + hCurrentSection.VirtualAddress), hCurrentSection.SizeOfRawData)); // Push back a struct with the section data.
}
+
+ // Get the location of IMAGE_IMPORT_DESCRIPTOR for this module by adding the IMAGE_DIRECTORY_ENTRY_IMPORT relative virtual address onto our
+ // module base address.
+ IMAGE_IMPORT_DESCRIPTOR* pImageImportDescriptors = reinterpret_cast<IMAGE_IMPORT_DESCRIPTOR*>(
+ m_pModuleBase + m_pNTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
+ if (!pImageImportDescriptors)
+ return;
+
+ for (IMAGE_IMPORT_DESCRIPTOR* pIID = pImageImportDescriptors; pIID->Name != 0; pIID++)
+ {
+ // Get virtual relative Address of the imported module name. Then add module base Address to get the actual location.
+ const char* szImportedModuleName = reinterpret_cast<char*>(reinterpret_cast<DWORD*>(m_pModuleBase + pIID->Name));
+
+ m_vImportedModules.push_back(szImportedModuleName);
+ }
}
//-----------------------------------------------------------------------------