aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/emit_blocker.cpp
diff options
context:
space:
mode:
authorEmma Miler <27428383+emma-miler@users.noreply.github.com>2022-05-13 01:53:22 +0200
committerGitHub <noreply@github.com>2022-05-13 01:53:22 +0200
commitd333eabc1bc7f8f29c3e5ccd13b62997235285c4 (patch)
tree50222e52d13d78cfd9595d0dddc664e68c0f3708 /NorthstarDedicatedTest/emit_blocker.cpp
parent0c8994686185fe04e6a6748e5808df17aa9214a4 (diff)
downloadNorthstarLauncher-d333eabc1bc7f8f29c3e5ccd13b62997235285c4.tar.gz
NorthstarLauncher-d333eabc1bc7f8f29c3e5ccd13b62997235285c4.zip
Block `emit` command when sv_cheats is disabled (#170)
Diffstat (limited to 'NorthstarDedicatedTest/emit_blocker.cpp')
-rw-r--r--NorthstarDedicatedTest/emit_blocker.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/emit_blocker.cpp b/NorthstarDedicatedTest/emit_blocker.cpp
new file mode 100644
index 00000000..3f996c69
--- /dev/null
+++ b/NorthstarDedicatedTest/emit_blocker.cpp
@@ -0,0 +1,26 @@
+#include "pch.h"
+#include "cvar.h"
+
+ConVar* sv_cheats;
+
+typedef char(__fastcall* function_containing_emit_t)(uint64_t a1, uint64_t a2);
+function_containing_emit_t function_containing_emit;
+
+char function_containing_emit_hook(uint64_t unknown_value, uint64_t command_ptr)
+{
+ char* command_string = *(char**)(command_ptr + 1040); // From decompile
+ if (!sv_cheats->m_Value.m_nValue && !strncmp(command_string, "emit", 5))
+ {
+ spdlog::info("Blocking command \"emit\" because sv_cheats was 0");
+ return 1;
+ }
+ return function_containing_emit(unknown_value, command_ptr);
+}
+
+void InitialiseServerEmit_Blocker(HMODULE baseAddress)
+{
+ HookEnabler hook;
+ sv_cheats = g_pCVar->FindVar("sv_cheats");
+ ENABLER_CREATEHOOK(
+ hook, (char*)baseAddress + 0x5889A0, &function_containing_emit_hook, reinterpret_cast<LPVOID*>(&function_containing_emit));
+} \ No newline at end of file