aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/tier0.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-07-08 15:33:31 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-07-08 15:33:31 +0100
commit4c4d605d10109e02708984755405bbe0947ef5c4 (patch)
tree1d5ffe7909b24b6c79fd444b420741e85f6c2b57 /NorthstarDedicatedTest/tier0.cpp
parent8dfb8e866119f653802609b24165b0458149c4cc (diff)
downloadNorthstarLauncher-4c4d605d10109e02708984755405bbe0947ef5c4.tar.gz
NorthstarLauncher-4c4d605d10109e02708984755405bbe0947ef5c4.zip
initial commit
Diffstat (limited to 'NorthstarDedicatedTest/tier0.cpp')
-rw-r--r--NorthstarDedicatedTest/tier0.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/tier0.cpp b/NorthstarDedicatedTest/tier0.cpp
new file mode 100644
index 00000000..a52c72ce
--- /dev/null
+++ b/NorthstarDedicatedTest/tier0.cpp
@@ -0,0 +1,33 @@
+#include "pch.h"
+#include "tier0.h"
+#include <stdio.h>
+#include <iostream>
+
+void* ResolveTier0Function(const char* name)
+{
+ HMODULE tier0 = GetModuleHandle(L"tier0.dll");
+
+ // todo: maybe cache resolved funcs? idk the performance hit of getprocaddress
+ std::cout << "ResolveTier0Function " << name << " " << tier0 << "::" << GetProcAddress(tier0, name) << std::endl;
+ return GetProcAddress(tier0, name);
+}
+
+typedef void(*Tier0Error)(const char* fmt, ...);
+void Error(const char* fmt, ...)
+{
+ Tier0Error tier0Func = (Tier0Error)ResolveTier0Function("Error");
+
+ // reformat args because you can't pass varargs between funcs
+ char buf[1024];
+
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, args);
+ va_end(args);
+
+ // tier0 isn't loaded yet
+ if (tier0Func)
+ tier0Func(buf);
+ else
+ std::cout << "FATAL ERROR " << buf << std::endl;
+} \ No newline at end of file