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 1d065006..8f969d3e 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -115,6 +115,7 @@
<ClInclude Include="chatcommand.h" />
<ClInclude Include="clientchathooks.h" />
<ClInclude Include="clientvideooverrides.h" />
+ <ClInclude Include="emit_blocker.h" />
<ClInclude Include="localchatwriter.h" />
<ClInclude Include="ns_version.h" />
<ClInclude Include="plugins.h" />
@@ -582,6 +583,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 c6815227..0424fcf6 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">
@@ -1491,12 +1494,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>
@@ -1506,6 +1503,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">
@@ -1667,6 +1673,9 @@
<ClCompile Include="version.cpp">
<Filter>Source Files</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 c0674d94..1b98105c 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -49,6 +49,7 @@
#include "rapidjson/writer.h"
#include "rapidjson/error/en.h"
#include "ExploitFixes.h"
+#include "emit_blocker.h"
typedef void (*initPluginFuncPtr)(void* getPluginObject);
@@ -283,6 +284,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