aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/hooks.cpp
diff options
context:
space:
mode:
authorp0358 <p0358@users.noreply.github.com>2021-12-31 22:46:45 +0100
committerp0358 <p0358@users.noreply.github.com>2021-12-31 22:46:45 +0100
commit9b13df7bc6f4c09c3fdab27cd51fe76d30b756b8 (patch)
treed273fbc7942b46497f056fd9c68b8b21e6d19fee /NorthstarDedicatedTest/hooks.cpp
parentdcba96bcc4b02639e859b0dcdc863391cb54684f (diff)
downloadNorthstarLauncher-9b13df7bc6f4c09c3fdab27cd51fe76d30b756b8.tar.gz
NorthstarLauncher-9b13df7bc6f4c09c3fdab27cd51fe76d30b756b8.zip
some post-merge changes combined with my local changes
Diffstat (limited to 'NorthstarDedicatedTest/hooks.cpp')
-rw-r--r--NorthstarDedicatedTest/hooks.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/NorthstarDedicatedTest/hooks.cpp b/NorthstarDedicatedTest/hooks.cpp
index 19010e83..0e653d4e 100644
--- a/NorthstarDedicatedTest/hooks.cpp
+++ b/NorthstarDedicatedTest/hooks.cpp
@@ -8,12 +8,11 @@
#include <fstream>
#include <sstream>
#include <filesystem>
+#include <Psapi.h>
typedef LPSTR(*GetCommandLineAType)();
LPSTR GetCommandLineAHook();
-// note that these load library callbacks only support explicitly loaded dynamic libraries
-
typedef HMODULE(*LoadLibraryExAType)(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
HMODULE LoadLibraryExAHook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
@@ -138,6 +137,29 @@ void CallLoadLibraryWCallbacks(LPCWSTR lpLibFileName, HMODULE moduleAddress)
}
}
+void CallAllPendingDLLLoadCallbacks()
+{
+ HMODULE hMods[1024];
+ HANDLE hProcess = GetCurrentProcess();
+ DWORD cbNeeded;
+ unsigned int i;
+
+ // Get a list of all the modules in this process.
+ if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
+ {
+ for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
+ {
+ wchar_t szModName[MAX_PATH];
+
+ // Get the full path to the module's file.
+ if (GetModuleFileNameExW(hProcess, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR)))
+ {
+ CallLoadLibraryWCallbacks(szModName, hMods[i]);
+ }
+ }
+ }
+}
+
HMODULE LoadLibraryExAHook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
{
HMODULE moduleAddress = LoadLibraryExAOriginal(lpLibFileName, hFile, dwFlags);