aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/securitypatches.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-09-09 16:01:01 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-09-09 16:01:01 +0100
commitfc0e6630fb6dccbeeca6ea65c061824cd7a848e1 (patch)
tree04965579e99b5920f9bbd2c5b6e8b5d12d79b7bb /NorthstarDedicatedTest/securitypatches.cpp
parentfb82ecfec5893b00f68b72f912c6b3975b5fdb4f (diff)
downloadNorthstarLauncher-fc0e6630fb6dccbeeca6ea65c061824cd7a848e1.tar.gz
NorthstarLauncher-fc0e6630fb6dccbeeca6ea65c061824cd7a848e1.zip
add IsValveMod patches
Diffstat (limited to 'NorthstarDedicatedTest/securitypatches.cpp')
-rw-r--r--NorthstarDedicatedTest/securitypatches.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/securitypatches.cpp b/NorthstarDedicatedTest/securitypatches.cpp
new file mode 100644
index 00000000..23c96520
--- /dev/null
+++ b/NorthstarDedicatedTest/securitypatches.cpp
@@ -0,0 +1,51 @@
+#include "pch.h"
+#include "securitypatches.h"
+#include "hookutils.h"
+#include "concommand.h"
+
+typedef bool(*IsValveModType)();
+IsValveModType IsValveMod;
+
+bool IsValveModHook()
+{
+ // basically: by default r2 isn't set as a valve mod, meaning that m_bRestrictServerCommands is false
+ // this is HORRIBLE for security, because it means servers can run arbitrary concommands on clients
+ // especially since we have script commands this could theoretically be awful
+
+ // todo: possibly have a commandline arg to disable this
+ return true;
+}
+
+void InitialiseClientEngineSecurityPatches(HMODULE baseAddress)
+{
+ HookEnabler hook;
+
+ // note: this could break some things
+ ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x1C6360, &IsValveModHook, reinterpret_cast<LPVOID*>(&IsValveMod));
+
+ // patches to make commands run from client/ui script still work
+ {
+ void* ptr = (char*)baseAddress + 0x4FB65;
+ TempReadWrite rw(ptr);
+
+ *((char*)ptr) = (char)0xEB;
+ *((char*)ptr + 1) = (char)0x11;
+ }
+
+ {
+ void* ptr = (char*)baseAddress + 0x4FBAC;
+ TempReadWrite rw(ptr);
+
+ *((char*)ptr) = (char)0xEB;
+ *((char*)ptr + 1) = (char)0x16;
+ }
+
+ // byte patches to patch concommands that this messes up that we need
+ {
+ // disconnect concommand
+ void* ptr = (char*)baseAddress + 0x5ADA2D;
+ TempReadWrite rw(ptr);
+
+ *((int*)ptr) |= FCVAR_SERVER_CAN_EXECUTE;
+ }
+} \ No newline at end of file