aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/ExploitFixes.cpp
diff options
context:
space:
mode:
authorEmma Miler <27428383+emma-miler@users.noreply.github.com>2022-06-15 01:10:39 +0200
committerGitHub <noreply@github.com>2022-06-15 01:10:39 +0200
commitd9f39f14fa0b0e8d025a8deef1d0c85da89c31f6 (patch)
treef592344f35a3aac50109170a4f1aae08b341f686 /NorthstarDedicatedTest/ExploitFixes.cpp
parentc5725b7855ea211af05963d5b5c8217a906dd9f9 (diff)
downloadNorthstarLauncher-d9f39f14fa0b0e8d025a8deef1d0c85da89c31f6.tar.gz
NorthstarLauncher-d9f39f14fa0b0e8d025a8deef1d0c85da89c31f6.zip
Fix bug where emit wouldn't be blocked if uppercase (#192)v1.8.1-rc2
* Fix bug where emit wouldnt be blocked if uppercase * Moved emit blocker to ExploitFixes.cpp * Format change * Use `strnicmp` instead of a custom functions * Resolve merge conflicts * Format changes
Diffstat (limited to 'NorthstarDedicatedTest/ExploitFixes.cpp')
-rw-r--r--NorthstarDedicatedTest/ExploitFixes.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/ExploitFixes.cpp b/NorthstarDedicatedTest/ExploitFixes.cpp
index 277475f6..af7d48ac 100644
--- a/NorthstarDedicatedTest/ExploitFixes.cpp
+++ b/NorthstarDedicatedTest/ExploitFixes.cpp
@@ -5,6 +5,9 @@
#include "NSMem.h"
#include "cvar.h"
+typedef char(__fastcall* function_containing_emit_t)(uint64_t a1, uint64_t a2);
+function_containing_emit_t function_containing_emit;
+ConVar* sv_cheats;
ConVar* ns_exploitfixes_log;
#define SHOULD_LOG (ns_exploitfixes_log->m_Value.m_nValue > 0)
#define BLOCKED_INFO(s) \
@@ -409,6 +412,18 @@ void DoBytePatches()
}
}
+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 && !_strnicmp(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 ExploitFixes::LoadCallback(HMODULE baseAddress)
{
spdlog::info("ExploitFixes::LoadCallback ...");
@@ -433,5 +448,9 @@ void ExploitFixes::LoadCallback(HMODULE baseAddress)
new ConVar("ns_exploitfixes_log", "1", FCVAR_GAMEDLL, "Whether to log whenever ExploitFixes.cpp blocks/corrects something");
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));
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x2a8a50, &GetEntByIndexHook, reinterpret_cast<LPVOID*>(&GetEntByIndex));
}