Prevent dedicated server from overwriting videoconfig file

This commit is contained in:
Kawe Mazidjatari 2022-03-31 17:22:46 +02:00
parent 66146f6590
commit 83fc611a48
2 changed files with 8 additions and 0 deletions

View File

@ -270,6 +270,7 @@ void Dedicated_Init()
CL_ClearState.Offset(0x0).Patch({ 0xC3 }); // FUN --> RET | Invalid 'CL_ClearState()' call from Host_Shutdown causing segfault.
}
#endif
UpdateCurrentVideoConfig.Offset(0x0).Patch({ 0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3 }); // FUN --> RET | Return early to prevent the server from writing a videoconfig.txt file to the disk (overwriting the existing one).
// This mandatory pak file should only exist on the client.
if (!FileExists("vpk\\client_frontend.bsp.pak000_000.vpk"))

View File

@ -103,6 +103,10 @@ namespace
#ifndef CLIENT_DLL
ADDRESS Server_S2C_CONNECT_1 = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x3B\x05\x00\x00\x00\x00\x74\x0C", "xxx????xx");
#endif // !CLIENT_DLL
//-------------------------------------------------------------------------
// RUNTIME: VIDEO_CFG
//-------------------------------------------------------------------------
ADDRESS UpdateCurrentVideoConfig = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x55\x00\x41\x56\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00\x4C\x8B\xF1", "xx?xxxxxx????xxx????xxx????xxx");
//-------------------------------------------------------------------------
// .RDATA
@ -135,6 +139,9 @@ class HOpcodes : public IDetour
std::cout << "| FUN: Host_Disconnect : 0x" << std::hex << std::uppercase << Host_Disconnect.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: _Host_RunFrame : 0x" << std::hex << std::uppercase << _Host_RunFrame.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "+----------------------------------------------------------------+" << std::endl;
std::cout << "| FUN: Server_S2C_CONNECT_1 : 0x" << std::hex << std::uppercase << Server_S2C_CONNECT_1.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: UpdateCurrentVideoConfig : 0x" << std::hex << std::uppercase << UpdateCurrentVideoConfig.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "+----------------------------------------------------------------+" << std::endl;
std::cout << "| CON: g_pClientVPKDir : 0x" << std::hex << std::uppercase << g_pClientVPKDir.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| CON: g_pClientBSP : 0x" << std::hex << std::uppercase << g_pClientBSP.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| CON: g_pClientCommonBSP : 0x" << std::hex << std::uppercase << g_pClientCommonBSP.GetPtr() << std::setw(npad) << " |" << std::endl;