aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorF1F7Y <64418963+F1F7Y@users.noreply.github.com>2024-09-05 10:10:07 +0200
committerGitHub <noreply@github.com>2024-09-05 10:10:07 +0200
commit68d374dbac1e0fa6fefa67db1e54d7d1eb9dc433 (patch)
tree094e930a2e10d72defab687d426dfa8e77840ace
parente5c9e5d699fa5bf8fbf69426511f4b697edc15d2 (diff)
downloadNorthstarLauncher-68d374dbac1e0fa6fefa67db1e54d7d1eb9dc433.tar.gz
NorthstarLauncher-68d374dbac1e0fa6fefa67db1e54d7d1eb9dc433.zip
game: Add more ways to crash to the `crash_test` concommand (#807)
Adds more types of crashes to the `crash_test` concommand
-rw-r--r--primedev/Northstar.cmake1
-rw-r--r--primedev/game/client/clientmode_shared.cpp66
2 files changed, 67 insertions, 0 deletions
diff --git a/primedev/Northstar.cmake b/primedev/Northstar.cmake
index 05c3c72a..4e8ec973 100644
--- a/primedev/Northstar.cmake
+++ b/primedev/Northstar.cmake
@@ -69,6 +69,7 @@ add_library(
"engine/r2engine.cpp"
"engine/r2engine.h"
"engine/runframe.cpp"
+ "game/client/clientmode_shared.cpp"
"logging/crashhandler.cpp"
"logging/crashhandler.h"
"logging/logging.cpp"
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);
+}