Fix patterns for S1 and removed redundant code

This commit is contained in:
Kawe Mazidjatari 2022-04-19 00:00:45 +02:00
parent 642d852e69
commit 3d32346b39
18 changed files with 26 additions and 64 deletions

View File

@ -26,47 +26,10 @@ void CHLClient::FrameStageNotify(CHLClient* pHLClient, ClientFrameStage_t frameS
{
case ClientFrameStage_t::FRAME_START: // FrameStageNotify gets called every frame by CEngine::Frame with the stage being FRAME_START. We can use this to check/set global variables.
{
static bool bInitialized = false;
if (!bInitialized)
{
KeyValues::Init();
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) // !TEMP UNTIL CHOSTSTATE IS BUILD AGNOSTIC! //
if (!CommandLine()->CheckParm("-devsdk"))
{
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_server.cfg\"", cmd_source_t::kCommandSrcCode);
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_server.cfg\"", cmd_source_t::kCommandSrcCode);
#ifndef DEDICATED
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_client.cfg\"", cmd_source_t::kCommandSrcCode);
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_client.cfg\"", cmd_source_t::kCommandSrcCode);
#endif // !DEDICATED
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec.cfg\"", cmd_source_t::kCommandSrcCode);
}
else // Development configs.
{
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_server_dev.cfg\"", cmd_source_t::kCommandSrcCode);
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_server_dev.cfg\"", cmd_source_t::kCommandSrcCode);
#ifndef DEDICATED
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_client_dev.cfg\"", cmd_source_t::kCommandSrcCode);
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_client_dev.cfg\"", cmd_source_t::kCommandSrcCode);
#endif // !DEDICATED
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_dev.cfg\"", cmd_source_t::kCommandSrcCode);
}
Cbuf_Execute();
if (net_userandomkey->GetBool())
{
HNET_GenerateKey();
}
g_pCVar->FindVar("net_usesocketsforloopback")->SetValue(1);
g_pRConClient->Init();
#endif // GAMEDLL_S0 || GAMEDLL_S1 || GAMEDLL_S2
bInitialized = true;
}
break;
}
case ClientFrameStage_t::FRAME_NET_UPDATE_POSTDATAUPDATE_END:
{
g_pBanSystem->BanListCheck();
gHLClient->PatchNetVarConVar();
break;
}
@ -76,7 +39,6 @@ void CHLClient::FrameStageNotify(CHLClient* pHLClient, ClientFrameStage_t frameS
}
}
g_pIConsole->Think();
g_pRConClient->RunFrame();
CHLClient_FrameStageNotify(pHLClient, frameStage);
}

View File

@ -163,10 +163,7 @@ void Systems_Init()
CServer_Attach(); // S1 and S2 CServer functions require work.
#endif // !CLIENT_DLL && GAMEDLL_S3
// !TEMP UNTIL CHOSTSTATE IS BUILD AGNOSTIC! //
#if defined (DEDICATED) || defined (GAMEDLL_S3)
CHostState_Attach();
#endif // DEDICATED || GAMEDLL_S3
//CModelLoader_Attach();
NET_Attach();
@ -270,10 +267,7 @@ void Systems_Shutdown()
CServer_Detach(); // S1 and S2 CServer functions require work.
#endif // !CLIENT_DLL && GAMEDLL_S3
// !TEMP UNTIL CHOSTSTATE IS BUILD AGNOSTIC! //
#if defined (DEDICATED) || defined (GAMEDLL_S3)
CHostState_Detach(); // Dedicated only for now until backwards compatible with S1.
#endif // DEDICATED || GAMEDLL_S3
CHostState_Detach();
//CModelLoader_Detach();
NET_Detach();

View File

@ -34,7 +34,7 @@ class HGL_Screen : public IDetour
scr_drawloading = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x0F\xB6\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x83\xEC\x28"), "xxx????xxxxxxxxxxxxx")
.ResolveRelativeAddressSelf(0x3, 0x7).RCast<bool*>();
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
scr_engineevent_loadingstarted = SCR_BeginLoadingPlaque.Offset(0x130).FindPatternSelf("C6 05 ?? ?? ?? ?? 01", CMemory::Direction::DOWN).ResolveRelativeAddress(0x2, 0x7).RCast<char*>();
scr_engineevent_loadingstarted = SCR_BeginLoadingPlaque.Offset(0x130).FindPatternSelf("C6 05 ?? ?? ?? ?? 01", CMemory::Direction::DOWN).ResolveRelativeAddress(0x2, 0x7).RCast<bool*>();
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
scr_engineevent_loadingstarted = SCR_BeginLoadingPlaque.Offset(0x60).FindPatternSelf("C6 05 ?? ?? ?? ?? 01", CMemory::Direction::DOWN).ResolveRelativeAddress(0x2, 0x7).RCast<bool*>();
#endif

View File

@ -46,8 +46,13 @@ class HHost : public IDetour
}
virtual void GetVar(void) const
{
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
g_bAbortServerSet = p_Host_Error.FindPattern("40 38 3D", CMemory::Direction::DOWN, 512, 2).ResolveRelativeAddress(3, 7).RCast<bool*>();
host_abortserver = p_Host_Error.FindPattern("48 8D 0D", CMemory::Direction::DOWN, 512, 3).ResolveRelativeAddress(3, 7).RCast<jmp_buf*>();
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
g_bAbortServerSet = p_Host_Error.FindPattern("40 38 3D", CMemory::Direction::DOWN, 512, 4).ResolveRelativeAddress(3, 7).RCast<bool*>();
host_abortserver = p_Host_Error.FindPattern("48 8D 0D", CMemory::Direction::DOWN, 512, 5).ResolveRelativeAddress(3, 7).RCast<jmp_buf*>();
#endif
}
virtual void GetCon(void) const { }
virtual void Attach(void) const { }

View File

@ -202,6 +202,7 @@ FORCEINLINE void CHostState::Setup(void) const
const char* szNoMap = "main_menu";
#endif
snprintf(const_cast<char*>(m_levelName), sizeof(m_levelName), szNoMap);
KeyValues::Init();
}
//-----------------------------------------------------------------------------

View File

@ -83,7 +83,7 @@ class HHostState : public IDetour
p_CHostState_FrameUpdate = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x20\xF3\x0F\x11\x54\x24\x18"), "xxxxxxxxxxxxxxxx");
p_CHostState_State_Run = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x8B\xC4\x48\x89\x58\x10\x48\x89\x70\x18\x48\x89\x78\x20\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8D\xA8\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x0F\x29\x70\xC8\x45\x33\xE4"), "xxxxxxxxxxxxxxxxxxxxxxxxxxx????xxx????xxxxxxx");
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
p_CHostState_GameShutDown = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x56\x48\x83\xEC\x20\x8B\x05\x00\x00\x00\x00\x48\x8B\xF1"), "xxxx?xxxxxxx????xxx");
p_CHostState_State_GameShutDown = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x56\x48\x83\xEC\x20\x8B\x05\x00\x00\x00\x00\x48\x8B\xF1"), "xxxx?xxxxxxx????xxx");
#elif defined (GAMEDLL_S2)
p_CHostState_State_GameShutDown = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x8B\x05\x00\x00\x00\x00\x33\xFF\x48\x8B\xF1"), "xxxx?xxxx?xxxxxxx????xxxxx");
#elif defined (GAMEDLL_S3)

View File

@ -79,7 +79,7 @@ class HModelLoader : public IDetour
{
g_pModelLoader = g_mGameDll.FindPatternSIMD(
reinterpret_cast<rsig_t>("\x48\x89\x4C\x24\x00\x53\x55\x56\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x00\x00\x00\x00"),
"xxxx?xxxxxxxxxxxxxx????").FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(3, 7);
"xxxx?xxxxxxxxxxxxxx????").FindPatternSelf("48 ?? 0D", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(3, 7);
}
virtual void GetCon(void) const { }
virtual void Attach(void) const { }

View File

@ -25,7 +25,7 @@ int CModAppSystemGroup::Main(CModAppSystemGroup* pModAppSystemGroup)
HEbisuSDK_Init(); // Not here in retail. We init EbisuSDK here though.
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) // !TODO: rebuild does not work for S1 (CModAppSystemGroup and CEngine member offsets do align with all other builds).
return CModAppSystemGroup_Main(modAppSystemGroup);
return CModAppSystemGroup_Main(pModAppSystemGroup);
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
g_pEngine->SetQuitting(EngineDllQuitting_t::QUIT_NOTQUITTING);

View File

@ -81,7 +81,7 @@ class HApplication : public IDetour
p_CModAppSystemGroup_Create = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x8B\xC4\x55\x41\x54\x41\x55\x41\x56\x41\x57\x48\x8B\xEC\x48\x83\xEC\x60"), "xxxxxxxxxxxxxxxxxxx");
#endif
p_CSourceAppSystemGroup__PreInit = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x74\x24\x00\x55\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00"), "xxxx?xxxxx????xxx????xxx????");
p_CSourceAppSystemGroup__Create = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xF9\xE8\x00\x00\x00\x00\x33\xC9"), "xxxx?xxxx?xxxxxxxxx????xx");
p_CSourceAppSystemGroup__Create = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x83\xEC\x20\x48\x8B\xF9\xE8\x00\x00\x00\x00\x33\xC9"), "xxxx?xxxx?xxxx?xxxxxxxxx????xx");
CModAppSystemGroup_Main = p_CModAppSystemGroup_Main.RCast<int(*)(CModAppSystemGroup*)>(); /*40 53 48 83 EC 20 80 B9 ?? ?? ?? ?? ?? BB ?? ?? ?? ??*/
CModAppSystemGroup_Create = p_CModAppSystemGroup_Create.RCast<bool(*)(CModAppSystemGroup*)>(); /*48 8B C4 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 60*/

View File

@ -163,7 +163,7 @@ void Launcher_Attatch()
{
DetourAttach((LPVOID*)&v_WinMain, &HWinMain);
DetourAttach((LPVOID*)&v_LauncherMain, &LauncherMain);
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
DetourAttach((LPVOID*)&v_RemoveSpuriousGameParameters, &RemoveSpuriousGameParameters);
#endif
}
@ -172,7 +172,7 @@ void Launcher_Detatch()
{
DetourDetach((LPVOID*)&v_WinMain, &HWinMain);
DetourDetach((LPVOID*)&v_LauncherMain, &LauncherMain);
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
DetourDetach((LPVOID*)&v_RemoveSpuriousGameParameters, &RemoveSpuriousGameParameters);
#endif
}

View File

@ -7,7 +7,7 @@ inline auto v_WinMain = p_WinMain.RCast<int (*)(HINSTANCE hInstance, HINSTANCE h
inline CMemory p_LauncherMain;
inline auto v_LauncherMain = p_LauncherMain.RCast<int(*)(HINSTANCE hInstance)>();
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
inline CMemory p_RemoveSpuriousGameParameters;
inline auto v_RemoveSpuriousGameParameters = p_RemoveSpuriousGameParameters.RCast<void* (*)(void)>();
#endif // !GAMEDLL_S0 || !GAMEDLL_S1
@ -27,8 +27,8 @@ class HLauncher : public IDetour
{
std::cout << "| FUN: WinMain : 0x" << std::hex << std::uppercase << p_WinMain.GetPtr() << std::setw(nPad) << " |" << std::endl;
std::cout << "| FUN: LauncherMain : 0x" << std::hex << std::uppercase << p_LauncherMain.GetPtr() << std::setw(nPad) << " |" << std::endl;
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
std::cout << "| FUN: RemoveSpuriousGameParameters::Create : 0x" << std::hex << std::uppercase << p_RemoveSpuriousGameParameters.GetPtr() << std::setw(nPad) << " |" << std::endl;
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
std::cout << "| FUN: RemoveSpuriousGameParameters : 0x" << std::hex << std::uppercase << p_RemoveSpuriousGameParameters.GetPtr() << std::setw(nPad) << " |" << std::endl;
#endif // !GAMEDLL_S0 || !GAMEDLL_S1
std::cout << "+----------------------------------------------------------------+" << std::endl;
}
@ -40,7 +40,7 @@ class HLauncher : public IDetour
p_LauncherMain = g_mGameDll.GetExportedFunction("LauncherMain");
v_LauncherMain = p_LauncherMain.RCast<int(*)(HINSTANCE)>();
#if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1)
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1)
p_RemoveSpuriousGameParameters = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x33\xED\x48\x8D\x3D\x00\x00\x00\x00"), "xxxx?xxxx?xxxx?xxxx????xxxxx????");
v_RemoveSpuriousGameParameters = p_RemoveSpuriousGameParameters.RCast<void* (*)(void)>();
#endif // !GAMEDLL_S0 || !GAMEDLL_S1

View File

@ -26,7 +26,7 @@ void HPakFile_UnloadAsset(int64_t a1, int64_t a2) // This ain't related to RTech
return;
}
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
return RTech_UnloadAsset(a1);
return CPakFile_UnloadAsset(a1);
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
return CPakFile_UnloadAsset(a1, a2);
#endif

View File

@ -24,7 +24,7 @@ enum class ePakStatus : int
/* ==== RTECH_GAME ====================================================================================================================================================== */
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
inline CMemory p_RTech_UnloadAsset;
inline CMemory p_CPakFile_UnloadAsset;
inline auto CPakFile_UnloadAsset = p_CPakFile_UnloadAsset.RCast<void (*)(int64_t a1)>();
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)

View File

@ -49,7 +49,7 @@ SQRESULT HSQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
#ifdef GAMEDLL_S3
context = *reinterpret_cast<SQCONTEXT*>(reinterpret_cast<std::uintptr_t>(v) + 0x18);
#else // TODO [ AMOS ]: nothing equal to 'rdx + 18h' exist in the vm structs for anything below S3.
vmIdx = 3;
context = SQCONTEXT::NONE;
#endif
break;
}
@ -205,7 +205,7 @@ void HSQVM_CompileError(HSQUIRRELVM v, const SQChar* pszError, const SQChar* psz
#ifdef GAMEDLL_S3
context = *reinterpret_cast<SQCONTEXT*>(reinterpret_cast<std::uintptr_t>(v) + 0x18);
#else // TODO [ AMOS ]: nothing equal to 'rdx + 18h' exist in the vm structs for anything below S3.
vmIdx = 3;
context = SQCONTEXT::NONE;
#endif
SQVM_GetErrorLine(pszFile, nLine, szContextBuf, sizeof(szContextBuf));

View File

@ -16,7 +16,7 @@
#define MAX_PLAYERS 128 // Max R5 players.
#define SDK_VERSION "beta 1.6" // Increment this with every /breaking/ SDK change (i.e. security/backend changes breaking compatibility).
#define SDK_VERSION "beta 1.6"/*"VGameSDK001"*/ // Increment this with every /breaking/ SDK change (i.e. security/backend changes breaking compatibility).
#ifndef DEDICATED
#define SDK_DEFAULT_CFG "platform\\cfg\\startup_default.cfg"

View File

@ -26,7 +26,7 @@ class HMatSystemSurface : public IDetour
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
g_pMatSystemSurface = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>(
"\x48\x83\x3D\x00\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00\x48\x89\x05\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00"),
"xxx?????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????").Offset(0x0).FindPatternSelf("48 83 3D", CMemory::Direction::DOWN, 40).ResolveRelativeAddressSelf(0x3, 0x8).GetPtr();
"xxx?????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????xxx????").ResolveRelativeAddressSelf(0x3, 0x8).GetPtr();
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
g_pMatSystemSurface = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>(
"\x48\x83\xEC\x28\x48\x83\x3D\x00\x00\x00\x00\x00\x48\x8D\x05\x00\x00\x00\x00"), "xxxxxxx?????xxx????")

View File

@ -111,7 +111,7 @@ void KeyValues::InitPlaylist(void)
{
while (true)
{
if ((*g_pPlaylistKeyValues))
if (*g_pPlaylistKeyValues)
{
KeyValues* playlists = (*g_pPlaylistKeyValues)->FindKey("Playlists", false);
if (playlists)

View File

@ -53,7 +53,7 @@ class HKeyValuesSystem : public IDetour
{
g_pKeyValuesSystem = g_mGameDll.FindPatternSIMD(
reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x56\x57\x41\x56\x48\x83\xEC\x40\x48\x8B\xF1"), "xxxx?xxxx?xxxxxxxxxxx")
.FindPatternSelf("48 8D 0D", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast<CKeyValuesSystem*>();
.FindPatternSelf("48 8D 0D ?? ?? ?? 01", CMemory::Direction::DOWN).ResolveRelativeAddressSelf(0x3, 0x7).RCast<CKeyValuesSystem*>();
g_pKeyValuesMemPool = g_mGameDll.FindPatternSIMD(
reinterpret_cast<rsig_t>("\x48\x8B\x05\x00\x00\x00\x00\xC3\xCC\xCC\xCC\xCC\xCC\xCC\xCC\xCC\x48\x85\xD2"), "xxx????xxxxxxxxxxxx").