aboutsummaryrefslogtreecommitdiff
path: root/primedev/windows
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2024-09-20 14:24:56 +0200
committerGitHub <noreply@github.com>2024-09-20 14:24:56 +0200
commita4b09bc42d5f79ef86697c893efc9e3b7d966502 (patch)
treed4c7b2b8cc04361ddf7b9c942e5f9462bb55e0b9 /primedev/windows
parenta9d2ce8a692f7890f4e4bfc21458332890605a5f (diff)
parent6737a344c012c0f7fd19cd593949dd3dbe5a0cb7 (diff)
downloadNorthstarLauncher-a4b09bc42d5f79ef86697c893efc9e3b7d966502.tar.gz
NorthstarLauncher-a4b09bc42d5f79ef86697c893efc9e3b7d966502.zip
Merge branch 'main' into feat/overhaul-mod-loading-locations
Diffstat (limited to 'primedev/windows')
-rw-r--r--primedev/windows/libsys.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/primedev/windows/libsys.cpp b/primedev/windows/libsys.cpp
index 501eae68..0aff820b 100644
--- a/primedev/windows/libsys.cpp
+++ b/primedev/windows/libsys.cpp
@@ -18,15 +18,31 @@ ILoadLibraryExW o_LoadLibraryExW = nullptr;
//-----------------------------------------------------------------------------
void LibSys_RunModuleCallbacks(HMODULE hModule)
{
+ // Modules that we have already ran callbacks for.
+ // Note: If we ever hook unloading modules, then this will need updating to handle removal etc.
+ static std::vector<HMODULE> vCalledModules;
+
if (!hModule)
{
return;
}
+ // If we have already ran callbacks for this module, don't run them again.
+ if (std::find(vCalledModules.begin(), vCalledModules.end(), hModule) != vCalledModules.end())
+ {
+ return;
+ }
+ vCalledModules.push_back(hModule);
+
// Get module base name in ASCII as noone wants to deal with unicode
CHAR szModuleName[MAX_PATH];
GetModuleBaseNameA(GetCurrentProcess(), hModule, szModuleName, MAX_PATH);
+ // Run calllbacks for all imported modules
+ CModule cModule(hModule);
+ for (const std::string& svImport : cModule.GetImportedModules())
+ LibSys_RunModuleCallbacks(GetModuleHandleA(svImport.c_str()));
+
// DevMsg(eLog::NONE, "%s\n", szModuleName);
// Call callbacks