aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/gameutils.cpp
diff options
context:
space:
mode:
authorp0358 <p0358@users.noreply.github.com>2021-12-29 05:48:33 +0100
committerp0358 <p0358@users.noreply.github.com>2021-12-29 05:48:33 +0100
commit8a1a2e97624d15617197248a5e292c5ead5e74a2 (patch)
treed236b5bd3c21db674c784239beb2404273498887 /NorthstarDedicatedTest/gameutils.cpp
parent2bb9e5b29ab08062614b2d52c430f9097bf2106f (diff)
downloadNorthstarLauncher-8a1a2e97624d15617197248a5e292c5ead5e74a2.tar.gz
NorthstarLauncher-8a1a2e97624d15617197248a5e292c5ead5e74a2.zip
add launcher.dll proxy option
Diffstat (limited to 'NorthstarDedicatedTest/gameutils.cpp')
-rw-r--r--NorthstarDedicatedTest/gameutils.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/NorthstarDedicatedTest/gameutils.cpp b/NorthstarDedicatedTest/gameutils.cpp
index 642c44e6..97011059 100644
--- a/NorthstarDedicatedTest/gameutils.cpp
+++ b/NorthstarDedicatedTest/gameutils.cpp
@@ -79,11 +79,17 @@ void InitialiseServerGameUtilFunctions(HMODULE baseAddress)
void InitialiseTier0GameUtilFunctions(HMODULE baseAddress)
{
baseAddress = GetModuleHandleA("tier0.dll");
-
- CreateGlobalMemAlloc = (CreateGlobalMemAllocType)GetProcAddress(baseAddress, "CreateGlobalMemAlloc");
- g_pMemAllocSingleton = CreateGlobalMemAlloc();
-
- Error = (ErrorType)GetProcAddress(baseAddress, "Error");
- CommandLine = (CommandLineType)GetProcAddress(baseAddress, "CommandLine");
- Plat_FloatTime = (Plat_FloatTimeType)GetProcAddress(baseAddress, "Plat_FloatTime");
+ if (!baseAddress)
+ throw "tier0.dll is not loaded";
+
+ CreateGlobalMemAlloc = reinterpret_cast<CreateGlobalMemAllocType>(GetProcAddress(baseAddress, "CreateGlobalMemAlloc"));
+ IMemAlloc** ppMemAllocSingleton = reinterpret_cast<IMemAlloc**>(GetProcAddress(baseAddress, "g_pMemAllocSingleton"));
+ if (!ppMemAllocSingleton || !*ppMemAllocSingleton)
+ g_pMemAllocSingleton = CreateGlobalMemAlloc();
+ else
+ g_pMemAllocSingleton = *ppMemAllocSingleton;
+
+ Error = reinterpret_cast<ErrorType>(GetProcAddress(baseAddress, "Error"));
+ CommandLine = reinterpret_cast<CommandLineType>(GetProcAddress(baseAddress, "CommandLine"));
+ Plat_FloatTime = reinterpret_cast<Plat_FloatTimeType>(GetProcAddress(baseAddress, "Plat_FloatTime"));
} \ No newline at end of file