aboutsummaryrefslogtreecommitdiff
path: root/primedev/game/client
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/game/client
parenta9d2ce8a692f7890f4e4bfc21458332890605a5f (diff)
parent6737a344c012c0f7fd19cd593949dd3dbe5a0cb7 (diff)
downloadNorthstarLauncher-a4b09bc42d5f79ef86697c893efc9e3b7d966502.tar.gz
NorthstarLauncher-a4b09bc42d5f79ef86697c893efc9e3b7d966502.zip
Merge branch 'main' into feat/overhaul-mod-loading-locations
Diffstat (limited to 'primedev/game/client')
-rw-r--r--primedev/game/client/clientmode_shared.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/primedev/game/client/clientmode_shared.cpp b/primedev/game/client/clientmode_shared.cpp
new file mode 100644
index 00000000..e5793261
--- /dev/null
+++ b/primedev/game/client/clientmode_shared.cpp
@@ -0,0 +1,66 @@
+
+//-----------------------------------------------------------------------------
+// Some explanation might be needed for this. The crash is caused by
+// us calling a pure virtual function in the constructor.
+// The order goes like this:
+// ctor
+// -> vftable = IPureCall::vftable
+// -> IPureCall::Ok()
+// -> IPureCall::CallMeIDareYou()
+// -> purecall_handler
+// -> crash :(
+class IPureCall
+{
+public:
+ IPureCall() { Ok(); }
+
+ virtual void CallMeIDareYou() = 0;
+
+ void Ok() { CallMeIDareYou(); }
+};
+
+class CPureCall : IPureCall
+{
+ virtual void CallMeIDareYou() {}
+};
+
+static void (*o_pCC_crash_test_f)(const CCommand& args);
+static void h_CC_crash_test_f(const CCommand& args)
+{
+ int crashtype = 0;
+ int dummy;
+ if (args.ArgC() > 1)
+ {
+ crashtype = atoi(args.Arg(1));
+ }
+ switch (crashtype)
+ {
+ case 0:
+ dummy = *((int*)NULL);
+ spdlog::info("Crashed! {}", dummy);
+ break;
+ case 1:
+ *((int*)NULL) = 24122021;
+ break;
+ case 2:
+ throw std::exception("Crashed!");
+ break;
+ case 3:
+ RaiseException(7, 0, 0, NULL);
+ break;
+ case 4:
+ {
+ CPureCall PureCall;
+ break;
+ }
+ default:
+ spdlog::info("Unknown variety of crash. You have now failed to crash. I hope you're happy.");
+ break;
+ }
+}
+
+ON_DLL_LOAD("engine.dll", ClientModeShared, (CModule module))
+{
+ o_pCC_crash_test_f = module.Offset(0x15BEE0).RCast<decltype(o_pCC_crash_test_f)>();
+ HookAttach(&(PVOID&)o_pCC_crash_test_f, (PVOID)h_CC_crash_test_f);
+}