diff options
author | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-05-12 02:33:01 +0100 |
---|---|---|
committer | BobTheBob <32057864+BobTheBob9@users.noreply.github.com> | 2022-05-12 02:33:01 +0100 |
commit | 6768e46b200c63d758bd6e92bd500f3c754c3245 (patch) | |
tree | 47a0e90999cd8fc933301197f7104a94d567471c /NorthstarDedicatedTest/hooks.cpp | |
parent | 8a33725513d7dae6a0be3b8366976e17661d2e2e (diff) | |
download | NorthstarLauncher-6768e46b200c63d758bd6e92bd500f3c754c3245.tar.gz NorthstarLauncher-6768e46b200c63d758bd6e92bd500f3c754c3245.zip |
formatting changes
Diffstat (limited to 'NorthstarDedicatedTest/hooks.cpp')
-rw-r--r-- | NorthstarDedicatedTest/hooks.cpp | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/NorthstarDedicatedTest/hooks.cpp b/NorthstarDedicatedTest/hooks.cpp index 7e697701..82485e0e 100644 --- a/NorthstarDedicatedTest/hooks.cpp +++ b/NorthstarDedicatedTest/hooks.cpp @@ -15,40 +15,6 @@ namespace fs = std::filesystem; -typedef LPSTR (*GetCommandLineAType)(); -LPSTR GetCommandLineAHook(); - -typedef HMODULE (*LoadLibraryExAType)(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); -HMODULE LoadLibraryExAHook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); - -typedef HMODULE (*LoadLibraryAType)(LPCSTR lpLibFileName); -HMODULE LoadLibraryAHook(LPCSTR lpLibFileName); - -typedef HMODULE (*LoadLibraryExWType)(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); -HMODULE LoadLibraryExWHook(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); - -typedef HMODULE (*LoadLibraryWType)(LPCWSTR lpLibFileName); -HMODULE LoadLibraryWHook(LPCWSTR lpLibFileName); - -GetCommandLineAType GetCommandLineAOriginal; -LoadLibraryExAType LoadLibraryExAOriginal; -LoadLibraryAType LoadLibraryAOriginal; -LoadLibraryExWType LoadLibraryExWOriginal; -LoadLibraryWType LoadLibraryWOriginal; - -void InstallInitialHooks() -{ - if (MH_Initialize() != MH_OK) - spdlog::error("MH_Initialize (minhook initialization) failed"); - - HookEnabler hook; - ENABLER_CREATEHOOK(hook, &GetCommandLineA, &GetCommandLineAHook, reinterpret_cast<LPVOID*>(&GetCommandLineAOriginal)); - ENABLER_CREATEHOOK(hook, &LoadLibraryExA, &LoadLibraryExAHook, reinterpret_cast<LPVOID*>(&LoadLibraryExAOriginal)); - ENABLER_CREATEHOOK(hook, &LoadLibraryA, &LoadLibraryAHook, reinterpret_cast<LPVOID*>(&LoadLibraryAOriginal)); - ENABLER_CREATEHOOK(hook, &LoadLibraryExW, &LoadLibraryExWHook, reinterpret_cast<LPVOID*>(&LoadLibraryExWOriginal)); - ENABLER_CREATEHOOK(hook, &LoadLibraryW, &LoadLibraryWHook, reinterpret_cast<LPVOID*>(&LoadLibraryWOriginal)); -} - // called from the ON_DLL_LOAD macros __dllLoadCallback::__dllLoadCallback( eDllLoadCallbackSide side, const std::string dllName, DllLoadCallbackFuncType callback, std::string uniqueStr, std::string reliesOn) @@ -75,6 +41,8 @@ __dllLoadCallback::__dllLoadCallback( } } +typedef LPSTR (*GetCommandLineAType)(); +GetCommandLineAType GetCommandLineAOriginal; LPSTR GetCommandLineAHook() { static char* cmdlineModified; @@ -266,6 +234,9 @@ void CallAllPendingDLLLoadCallbacks() } } + +typedef HMODULE (*LoadLibraryExAType)(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); +LoadLibraryExAType LoadLibraryExAOriginal; HMODULE LoadLibraryExAHook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) { HMODULE moduleAddress = LoadLibraryExAOriginal(lpLibFileName, hFile, dwFlags); @@ -278,6 +249,8 @@ HMODULE LoadLibraryExAHook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) return moduleAddress; } +typedef HMODULE (*LoadLibraryAType)(LPCSTR lpLibFileName); +LoadLibraryAType LoadLibraryAOriginal; HMODULE LoadLibraryAHook(LPCSTR lpLibFileName) { HMODULE moduleAddress = LoadLibraryAOriginal(lpLibFileName); @@ -290,6 +263,8 @@ HMODULE LoadLibraryAHook(LPCSTR lpLibFileName) return moduleAddress; } +typedef HMODULE (*LoadLibraryExWType)(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); +LoadLibraryExWType LoadLibraryExWOriginal; HMODULE LoadLibraryExWHook(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) { HMODULE moduleAddress = LoadLibraryExWOriginal(lpLibFileName, hFile, dwFlags); @@ -302,6 +277,8 @@ HMODULE LoadLibraryExWHook(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) return moduleAddress; } +typedef HMODULE (*LoadLibraryWType)(LPCWSTR lpLibFileName); +LoadLibraryWType LoadLibraryWOriginal; HMODULE LoadLibraryWHook(LPCWSTR lpLibFileName) { HMODULE moduleAddress = LoadLibraryWOriginal(lpLibFileName); @@ -312,4 +289,17 @@ HMODULE LoadLibraryWHook(LPCWSTR lpLibFileName) } return moduleAddress; +} + +void InstallInitialHooks() +{ + if (MH_Initialize() != MH_OK) + spdlog::error("MH_Initialize (minhook initialization) failed"); + + HookEnabler hook; + ENABLER_CREATEHOOK(hook, &GetCommandLineA, &GetCommandLineAHook, reinterpret_cast<LPVOID*>(&GetCommandLineAOriginal)); + ENABLER_CREATEHOOK(hook, &LoadLibraryExA, &LoadLibraryExAHook, reinterpret_cast<LPVOID*>(&LoadLibraryExAOriginal)); + ENABLER_CREATEHOOK(hook, &LoadLibraryA, &LoadLibraryAHook, reinterpret_cast<LPVOID*>(&LoadLibraryAOriginal)); + ENABLER_CREATEHOOK(hook, &LoadLibraryExW, &LoadLibraryExWHook, reinterpret_cast<LPVOID*>(&LoadLibraryExWOriginal)); + ENABLER_CREATEHOOK(hook, &LoadLibraryW, &LoadLibraryWHook, reinterpret_cast<LPVOID*>(&LoadLibraryWOriginal)); }
\ No newline at end of file |