aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj2
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters21
-rw-r--r--NorthstarDedicatedTest/dllmain.cpp2
-rw-r--r--NorthstarDedicatedTest/emit_blocker.cpp26
-rw-r--r--NorthstarDedicatedTest/emit_blocker.h3
5 files changed, 48 insertions, 6 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index ea9ccbb3..cddbd3a7 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -117,6 +117,7 @@
<ClInclude Include="debugoverlay.h" />
<ClInclude Include="clientruihooks.h" />
<ClInclude Include="clientvideooverrides.h" />
+ <ClInclude Include="emit_blocker.h" />
<ClInclude Include="localchatwriter.h" />
<ClInclude Include="ns_version.h" />
<ClInclude Include="plugins.h" />
@@ -586,6 +587,7 @@
<ClCompile Include="dedicated.cpp" />
<ClCompile Include="dedicatedmaterialsystem.cpp" />
<ClCompile Include="dllmain.cpp" />
+ <ClCompile Include="emit_blocker.cpp" />
<ClCompile Include="filesystem.cpp" />
<ClCompile Include="gameutils.cpp" />
<ClCompile Include="hooks.cpp" />
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index da8f064e..8e429c9f 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -133,6 +133,9 @@
<Filter Include="Source Files\Shared\Exploit Fixes\UTF8Parser">
<UniqueIdentifier>{b30e08b1-b962-4264-8cbb-a0a31924b93e}</UniqueIdentifier>
</Filter>
+ <Filter Include="Header Files\Shared\ExploitFixes">
+ <UniqueIdentifier>{7f609cee-d2c0-46a2-b06e-83b9f0511915}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
@@ -1494,12 +1497,6 @@
<ClInclude Include="clientvideooverrides.h">
<Filter>Header Files\Client</Filter>
</ClInclude>
- <ClInclude Include="ExploitFixes.h">
- <Filter>Source Files\Shared\Exploit Fixes</Filter>
- </ClInclude>
- <ClInclude Include="NSMem.h">
- <Filter>Source Files\Shared\Exploit Fixes</Filter>
- </ClInclude>
<ClInclude Include="ExploitFixes_UTF8Parser.h">
<Filter>Source Files\Shared\Exploit Fixes\UTF8Parser</Filter>
</ClInclude>
@@ -1512,6 +1509,15 @@
<ClInclude Include="ns_version.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="ExploitFixes.h">
+ <Filter>Header Files\Shared\ExploitFixes</Filter>
+ </ClInclude>
+ <ClInclude Include="NSMem.h">
+ <Filter>Header Files\Shared\ExploitFixes</Filter>
+ </ClInclude>
+ <ClInclude Include="emit_blocker.h">
+ <Filter>Header Files\Shared\ExploitFixes</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@@ -1679,6 +1685,9 @@
<ClCompile Include="clientruihooks.cpp">
<Filter>Source Files\Client</Filter>
</ClCompile>
+ <ClCompile Include="emit_blocker.cpp">
+ <Filter>Source Files\Shared\Exploit Fixes</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<MASM Include="audio_asm.asm">
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index fc403e95..62094b4e 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -51,6 +51,7 @@
#include "rapidjson/writer.h"
#include "rapidjson/error/en.h"
#include "ExploitFixes.h"
+#include "emit_blocker.h"
typedef void (*initPluginFuncPtr)(void* getPluginObject);
@@ -287,6 +288,7 @@ bool InitialiseNorthstar()
// activate exploit fixes
AddDllLoadCallback("server.dll", ExploitFixes::LoadCallback);
+ AddDllLoadCallback("server.dll", InitialiseServerEmit_Blocker);
// run callbacks for any libraries that are already loaded by now
CallAllPendingDLLLoadCallbacks();
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
diff --git a/NorthstarDedicatedTest/emit_blocker.h b/NorthstarDedicatedTest/emit_blocker.h
new file mode 100644
index 00000000..43991927
--- /dev/null
+++ b/NorthstarDedicatedTest/emit_blocker.h
@@ -0,0 +1,3 @@
+#pragma once
+
+void InitialiseServerEmit_Blocker(HMODULE baseAddress); \ No newline at end of file