diff options
author | geni <me@geni.site> | 2021-12-31 14:38:54 +0200 |
---|---|---|
committer | geni <me@geni.site> | 2021-12-31 14:38:54 +0200 |
commit | ae2f240d4f5e0d0c6da777838a42bd3e457d2711 (patch) | |
tree | b1629f7a23868e51a21c1bc54c8ff7a5e174a634 /NorthstarDedicatedTest/dedicated.cpp | |
parent | 4f7c3d02943a38941b79a638c5607b2b7f668956 (diff) | |
download | NorthstarLauncher-ae2f240d4f5e0d0c6da777838a42bd3e457d2711.tar.gz NorthstarLauncher-ae2f240d4f5e0d0c6da777838a42bd3e457d2711.zip |
Replace Tier0_InitOrigin hook with patch
Diffstat (limited to 'NorthstarDedicatedTest/dedicated.cpp')
-rw-r--r-- | NorthstarDedicatedTest/dedicated.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp index 851ab861..0ecc1dba 100644 --- a/NorthstarDedicatedTest/dedicated.cpp +++ b/NorthstarDedicatedTest/dedicated.cpp @@ -13,7 +13,7 @@ bool IsDedicated() // CDedidcatedExports defs struct CDedicatedExports; // forward declare -typedef void (*DedicatedSys_PrintfType)(CDedicatedExports* dedicated, char* msg); +typedef void (*DedicatedSys_PrintfType)(CDedicatedExports* dedicated, const char* msg); typedef void (*DedicatedRunServerType)(CDedicatedExports* dedicated); // would've liked to just do this as a class but have not been able to get it to work @@ -27,7 +27,7 @@ struct CDedicatedExports DedicatedRunServerType RunServer; }; -void Sys_Printf(CDedicatedExports* dedicated, char* msg) +void Sys_Printf(CDedicatedExports* dedicated, const char* msg) { spdlog::info("[DEDICATED PRINT] {}", msg); } @@ -36,7 +36,7 @@ typedef void(*CHostState__InitType)(CHostState* self); void RunServer(CDedicatedExports* dedicated) { - Sys_Printf(dedicated, (char*)"CDedicatedExports::RunServer(): starting"); + Sys_Printf(dedicated, "CDedicatedExports::RunServer(): starting"); // init hoststate, if we don't do this, we get a crash later on CHostState__InitType CHostState__Init = (CHostState__InitType)((char*)GetModuleHandleA("engine.dll") + 0x16E110); @@ -383,23 +383,18 @@ void InitialiseDedicated(HMODULE engineAddress) CommandLine()->AppendParm("+exec", "autoexec_ns_server"); } -typedef void(*Tier0_InitOriginType)(); -Tier0_InitOriginType Tier0_InitOrigin; -void Tier0_InitOriginHook() +void InitialiseDedicatedOrigin(HMODULE baseAddress) { // disable origin on dedicated // for any big ea lawyers, this can't be used to play the game without origin, game will throw a fit if you try to do anything without an origin id as a client // for dedi it's fine though, game doesn't care if origin is disabled as long as there's only a server - Tier0_InitOrigin(); -} -void InitialiseDedicatedOrigin(HMODULE baseAddress) -{ if (!IsDedicated()) return; - HookEnabler hook; - ENABLER_CREATEHOOK(hook, GetProcAddress(GetModuleHandleA("tier0.dll"), "Tier0_InitOrigin"), &Tier0_InitOriginHook, reinterpret_cast<LPVOID*>(&Tier0_InitOrigin)); + char* ptr = (char*)GetProcAddress(GetModuleHandleA("tier0.dll"), "Tier0_InitOrigin"); + TempReadWrite rw(ptr); + *ptr = (char)0xC3; } typedef void(*PrintFatalSquirrelErrorType)(void* sqvm); |