Heavy dedicated cleanup

* Since the material mode is set to '2', all of the render loops and shader loading functions are no longer called. These have all been removed.
* Added description for patches that missed them
* Traced root caller/cause for certain patches to skip even more unnecessary code and save more memory.
This commit is contained in:
Amos 2021-12-30 22:13:15 +01:00
parent 22c0b5c867
commit 2c7ced128d
2 changed files with 129 additions and 222 deletions

View File

@ -10,99 +10,21 @@
#ifdef DEDICATED
void NoShaderApi_Init()
{
//-------------------------------------------------------------------------
// NOSHADERAPI
//-------------------------------------------------------------------------
CShaderSystem__Init.Patch({ 0xC3 }); // FUN --> RET | Return early in 'CShaderSystem::Init' to prevent initialization.
CGameServer__SpawnServer.Offset(0x43).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent call to unknown material/shader code.
CGameServer__SpawnServer.Offset(0x48).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // TODO: Research 'CIVDebugOverlay'.
CStudioRenderContext__LoadMaterials.Offset(0x28).Patch({ 0xE9, 0x80, 0x04, 0x00, 0x00 }); // FUN --> RET | 'CStudioRenderContext::LoadMaterials' is called virtually by the 'RMDL' streaming job.
// Note: The registers here seems to contains pointers to material data and 'CMaterial' class methods when the shader system is initialized.
CStudioRenderContext__LoadModel.Offset(0x17D).Patch({ 0x90, 0x90, 0x90, 0x90 }); // MOV --> NOP | RAX + RCX are both nullptrs.
CStudioRenderContext__LoadModel.Offset(0x181).Patch({ 0x90, 0x90, 0x90 }); // MOV --> NOP | RCX is nullptr when trying to dereference.
CStudioRenderContext__LoadModel.Offset(0x184).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | RAX is nullptr during virtual call resulting in exception 'C0000005'.
CModelLoader__Studio_LoadModel.Offset(0x325).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialSystem::FindMaterialEx' fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x33D).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialGlue' class method fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x359).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialGlue' class method fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x374).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialGlue' class method fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x38D).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'ReturnZero' fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x3A4).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialGlue' class method fails as RAX is nullptr.
CModelLoader__LoadModel.Offset(0x462).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent call to 'CStudioRenderContext::LoadMaterials'.
// Note: At [14028F3B0 + 0x5C7] RSP seems to contain a block of pointers to data for the static prop rmdl in question. [RSP + 0x70] is a pointer to (what seems to be) shader/material data. The pointer will be NULL without a shader system.
p_CalcPropStaticFrustumCulling.Offset(0x5E0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // MOV --> NOP | RSP + 0x70 is a nullptr which gets moved to R13, R13 gets used here resulting in exception 'C0000005'.
p_CalcPropStaticFrustumCulling.Offset(0x5EB).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | RAX is nullptr during virtual call resulting in exception 'C0000005'.
CollisionBSPData_LinkPhysics.Offset(0x129).Patch({ 0x90, 0x90, 0x90 }); // MOV --> NOP | RCX is nullptr during dereference since shadersystem isn't initialized. Exception 'C0000005'.
CollisionBSPData_LinkPhysics.Offset(0x12C).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CTexture' class member in RAX + 0x78 fails. Previous instruction could not dereference.
CollisionBSPData_LoadAllLumps.Offset(0x1045).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent call to 'Mod_LoadCubemapSamples()'.
}
void Dedicated_Init()
{
*(uintptr_t*)0x14D415040 = 0x1417304E8;
*(uintptr_t*)0x14B37C3C0 = 0x141F10CA0;
*(uintptr_t*)0x14B3800D7 = 0x1; // bDedicated
NoShaderApi_Init();
//-------------------------------------------------------------------------
// RESEARCH FOR IMPROVEMENT!
//-------------------------------------------------------------------------
e10.Patch({ 0xC3 }); // FUN --> RET | RET early to prevent '' code execution.
e8.Offset(0x44).Patch({ 0xE9, 0x41, 0x04, 0x00, 0x00 }); // FUN --> RET | Return early in 'RenderFrame?' (Called from VGUI and Host_Init).
gInitMaterialSystem.Offset(0x7D).Patch({ 0xC3 }); // JMP --> RET | Return early to prevent 'InitDebugMaterials' from being executed.
e3.Offset(0xFB0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP call to unused VGUI code to prevent crash at SIGNONSTATE_PRESPAWN.
addr_CEngine_Frame.Offset(0x410).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | CHLClient call inside eng->frame.
FairFight_Init.Offset(0x61).Patch({ 0xE9, 0xED, 0x00, 0x00, 0x00, 0x00 }); // JA --> JMP | Prevent FairFight anti-cheat from initializing on the server.
s1.Offset(0x1023).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP NULL call as client is never initialized.
s2.Offset(0xF).Patch({ 0xE9, 0x22, 0x01, 0x00, 0x00 }); // JS --> JMP | Skip ListenServer HeartBeat.
e1.Offset(0x213).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // JNE --> NOP | Skip settings field loading for client texture assets.
e9.Offset(0x6).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP call to prevent texture creation.
gShaderCreate.Patch({ 0xC3 }); // FUN --> RET | RET early to prevent 'ShaderCreate' code execution.
gTextureCreate.Patch({ 0xC3 }); // FUN --> RET | RET early to prevent 'TextureCreate' code execution.
c2.Offset(0x23C).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // JNE --> NOP | TODO: NOP 'particle_script' instead.
c2.Offset(0x2BD).Patch({ 0x90, 0x90, 0x90 }); // MOV --> NOP | TODO: NOP 'particle_script' instead.
c3.Offset(0xA9).Patch({ 0x90, 0x90, 0x90, 0x90 }); // MOV --> NOP | TODO: NOP 'highlight_system' instead.
//-------------------------------------------------------------------------
// CENGINEAPI
//-------------------------------------------------------------------------
gCEngineAPI__Init.Offset(0xB7).Patch({ 0xE9, 0xC7, 0x00, 0x00, 0x00 }); // JNE --> JNP | Skip Video Mode validation code.
//gCEngineAPI__Connect.Offset(0x3E).Patch({ 0xE9, 0x8F, 0x01, 0x00, 0x00 }); // JE --> JMP | NOP call to texture and material preloading.
//gCEngineAPI__Connect.Offset(0xDD).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP call to texture and material preloading.
//gCEngineAPI__Connect.Offset(0xF1).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP call to texture and material preloading.
//gCEngineAPI__Connect.Offset(0x1C6).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP call to texture and material preloading.
//gCEngineAPI__ModInit.Offset(0x3DD).Patch({ 0xE9, 0xB5, 0x00, 0x00, 0x00, 0x00 }); // JNE --> JNP | Skip CreateWindow Initialization code.
//gCEngineAPI__ModInit.Offset(0x44C).Patch({ 0xEB, 0x49 }); // JNZ --> JMP | Skip CreateGameWindow validation code.
//gCEngineAPI__ModInit.Offset(0x3DD).Patch({ 0xEB, 0x6D }); // JE --> JMP | Skip CreateGameWindow initialization code.
//-------------------------------------------------------------------------
// CENGINEVGUI
//-------------------------------------------------------------------------
gCEngineVGui__Init.Patch({ 0x48, 0x33, 0xC0, 0xC3, 0x90, 0x90, 0x90 }); // CMP --> XOR | Skip VGUI initialization jumptable.
gCEngineVGui__OnLevelLoadingStarted.Patch({ 0xC3 }); // FUN --> RET |
*(uintptr_t*)0x14D415040 = 0x1417304E8; // CEngineClient::CEngineClient().
*(uintptr_t*)0x14B37C3C0 = 0x141F10CA0; // CHLClient::CHLClient().
*(uintptr_t*)0x14B3800D7 = 0x1; // bool bDedicated = true.
//-------------------------------------------------------------------------
// CGAME
//-------------------------------------------------------------------------
gCGame__CreateGameWindow.Offset(0x2C).Patch({ 0xE9, 0x9A, 0x00, 0x00, 0x00 }); // PUS --> XOR | Prevent ShowWindow and CreateGameWindow from being initialized.
gCGame__CreateGameWindow.Offset(0x2C).Patch({ 0xE9, 0x9A, 0x00, 0x00, 0x00 }); // PUS --> XOR | Prevent ShowWindow and CreateGameWindow from being initialized (STGS RPak datatype is registered here).
//-------------------------------------------------------------------------
// CHLClIENT
//-------------------------------------------------------------------------
gCHLClient__1000.Patch({ 0xC3 }); // FUN --> RET | Return early in 'gCHLClient::unnamed' to prevent infinite loop.
gCHLClient__HudMessage.Patch({ 0xC3 }); // FUN --> RET | Return early from 'CHudMessage' call.
gCHLClient__1000.Patch({ 0xC3 }); // FUN --> RET | Return early in unknown 'CHLClient' function to prevent infinite loop.
//-------------------------------------------------------------------------
// CSOURCEAPPSYSTEMGROUP
@ -124,20 +46,49 @@ void Dedicated_Init()
gCSourceAppSystemGroup__Create.Offset(0x3E9).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | matEmbeddedPanel->Init().
gCSourceAppSystemGroup__Create.Offset(0x3F9).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | EAC_ClientInterface_Init().
//-------------------------------------------------------------------------
// CVIDEOMODE_COMMON
//-------------------------------------------------------------------------
gCVideoMode_Common__DrawStartupGraphic.Patch({ 0xC3 }); // FUN --> RET | Return early in 'CVideoMode_Common::DrawStartupGraphic'.
//-------------------------------------------------------------------------
// CMATERIALSYSTEM
//-------------------------------------------------------------------------
//gCMaterialSystem__MatsysMode_Init.Offset(0x22).Patch({ 0xEB, 0x66 }); // JE --> JMP | Matsys mode init (CMaterialSystem). // TODO: Needed?
CMaterialSystem__Init.Offset(0x406).Patch({ 0xE9, 0x55, 0x05, 0x00, 0x00 }); // MOV --> JMP | Jump over material KeyValue definitions and 'CMatRenderContextBase::sm_RenderData([x])'.
InitMaterialSystem.Offset(0x7D).Patch({ 0xC3 }); // JMP --> RET | Return early to prevent 'InitDebugMaterials' from being executed. // RESEARCH NEEDED.
//-------------------------------------------------------------------------
// CSHADERGLUE
// CSHADERSYSTEM
//-------------------------------------------------------------------------
//gCShaderGlue__Init.Patch({ 0xC3 }); // FUN --> RET | Skip ShaderSetup(). CShaderGlue.
CShaderSystem__Init.Patch({ 0xC3 }); // FUN --> RET | Return early in 'CShaderSystem::Init' to prevent initialization.
//-------------------------------------------------------------------------
// CSTUDIORENDERCONTEXT
//-------------------------------------------------------------------------
// Note: The registers here seems to contains pointers to material data and 'CMaterial' class methods when the shader system is initialized.
CStudioRenderContext__LoadModel.Offset(0x17D).Patch({ 0x90, 0x90, 0x90, 0x90 }); // MOV --> NOP | RAX + RCX are both nullptrs.
CStudioRenderContext__LoadModel.Offset(0x181).Patch({ 0x90, 0x90, 0x90 }); // MOV --> NOP | RCX is nullptr when trying to dereference.
CStudioRenderContext__LoadModel.Offset(0x184).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | RAX is nullptr during virtual call resulting in exception 'C0000005'.
CStudioRenderContext__LoadMaterials.Offset(0x28).Patch({ 0xE9, 0x80, 0x04, 0x00, 0x00 }); // FUN --> RET | 'CStudioRenderContext::LoadMaterials' is called virtually by the 'RMDL' streaming job.
//-------------------------------------------------------------------------
// CMODELLOADER
//-------------------------------------------------------------------------
CModelLoader__LoadModel.Offset(0x462).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent call to 'CStudioRenderContext::LoadMaterials'.
CModelLoader__Studio_LoadModel.Offset(0x325).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialSystem::FindMaterialEx' fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x33D).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialGlue' class method fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x359).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialGlue' class method fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x374).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialGlue' class method fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x38D).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'ReturnZero' fails as RAX is nullptr.
CModelLoader__Studio_LoadModel.Offset(0x3A4).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialGlue' class method fails as RAX is nullptr.
//-------------------------------------------------------------------------
// CGAMESERVER
//-------------------------------------------------------------------------
CGameServer__SpawnServer.Offset(0x43).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent call to unknown material/shader code.
CGameServer__SpawnServer.Offset(0x48).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // TODO: Research 'CIVDebugOverlay'.
//-------------------------------------------------------------------------
// MM_HEARTBEAT
//-------------------------------------------------------------------------
MM_Heartbeat__ToString.Offset(0xF).Patch({ 0xE9, 0x22, 0x01, 0x00, 0x00 }); // JS --> JMP | Skip ListenServer HeartBeat.
//-------------------------------------------------------------------------
// RUNTIME: SYS_INITGAME
@ -152,28 +103,25 @@ void Dedicated_Init()
gHost_Init_0.Offset(0x859).Patch({ 0xE9, 0x19, 0x04, 0x00, 0x00 }); // LEA --> RET | Disable 'client.dll' library initialization.
gHost_Init_0.Offset(0xC77).Patch({ 0xE8, 0x44, 0xCF, 0xFF, 0xFF }); // CAL --> CAL | Disable user config loading and call entitlements.rson initialization instead.
//gHost_Init_1.Offset(0x19).Patch({ 0xEB, 0x6E }); // JNE --> JMP | Take dedicated initialization routine instead. // REMOVE
gHost_Init_1.Offset(0x609).Patch({ 0xEB, 0x2B }); // JE --> JMP | Skip client.dll Init_PostVideo() validation code.
gHost_Init_1.Offset(0x621).Patch({ 0xEB, 0x0C }); // JNE --> JMP | Skip client.dll Init_PostVideo() validation code.
gHost_Init_1.Offset(0x658).Patch({ 0xE9, 0x8C, 0x00, 0x00, 0x00 }); // JE --> JMP | Skip NULL call as client is never initialized.
gHost_Init_1.Offset(0x6E9).Patch({ 0xE9, 0xB0, 0x00, 0x00, 0x00 }); // JNE --> JMP | Skip shader preloading as cvar can't be checked due to client being NULL.
//gHost_Init_2.Offset(0x5D8).Patch({ 0xEB, 0x05 }); // JE --> JMP | Render?
gHost_Init_2.Offset(0x26F).Patch({ 0xE9, 0x4D, 0x05, 0x00, 0x00 }); // JNE --> JMP | client.dll systems initialization.
//-------------------------------------------------------------------------
// RUNTIME: _HOST_RUNFRAME
//-------------------------------------------------------------------------
//s1.Offset(0x1C6).Patch({ 0xE9, 0xAD, 0x11, 0x00, 0x00 }); // JNE --> JMP | Return early in _Host_RunFrame() for debugging perposes.
//s1.Offset(0x1010).Patch({ 0xEB, 0x14 }); // JNE --> JMP | Return early in _Host_RunFrame() for debugging perposes.
//-------------------------------------------------------------------------
// RUNTIME: HOST_NEWGAME
//-------------------------------------------------------------------------
Host_NewGame.Offset(0x4E0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
Host_NewGame.Offset(0x637).Patch({ 0xE9, 0xC1, 0x00, 0x00, 0x00 }); // JNE --> JMP | Prevent connect localhost from being executed in Host_NewGame.
//-------------------------------------------------------------------------
// RUNTIME: _HOST_RUNFRAME
//-------------------------------------------------------------------------
_Host_RunFrame.Offset(0xFB0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP call to unused VGUI code to prevent crash at SIGNONSTATE_PRESPAWN.
_Host_RunFrame.Offset(0x1023).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP NULL call as client is never initialized.
//-------------------------------------------------------------------------
// RUNTIME: EBISUSDK
//-------------------------------------------------------------------------
@ -196,71 +144,30 @@ void Dedicated_Init()
CollisionBSPData_LoadAllLumps.Offset(0xAC0).Patch({ 0x90, 0x90 }); // JE --> NOP | INDICES.
CollisionBSPData_LoadAllLumps.Offset(0xBF2).Patch({ 0x90, 0x90 }); // JE --> NOP | WORLDLIGHTS.
CollisionBSPData_LoadAllLumps.Offset(0xDA9).Patch({ 0x90, 0x90 }); // JE --> NOP | TWEAKLIGHTS.
CollisionBSPData_LoadAllLumps.Offset(0xEEB).Patch({ 0xE9, 0x3D, 0x01, 0x00, 0x00 });
CollisionBSPData_LoadAllLumps.Offset(0x61B).Patch({ 0xE9, 0xE2, 0x02, 0x00, 0x00 });
CollisionBSPData_LoadAllLumps.Offset(0xEEB).Patch({ 0xE9, 0x3D, 0x01, 0x00, 0x00 }); // JLE --> JMP | Exception 0x57 in while trying to dereference [R15 + R14 *8 + 0x10].
CollisionBSPData_LoadAllLumps.Offset(0x61B).Patch({ 0xE9, 0xE2, 0x02, 0x00, 0x00 }); // JZ --> JMP | Prevent call to 'CMod_LoadTextures()'.
CollisionBSPData_LoadAllLumps.Offset(0x1045).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent call to 'Mod_LoadCubemapSamples()'.
CollisionBSPData_LinkPhysics.Offset(0x129).Patch({ 0x90, 0x90, 0x90 }); // MOV --> NOP | RCX is nullptr during dereference since shadersystem isn't initialized. Exception 'C0000005'.
CollisionBSPData_LinkPhysics.Offset(0x12C).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CTexture' class member in RAX + 0x78 fails. Previous instruction could not dereference.
//-------------------------------------------------------------------------
// RUNTIME: RENDERING
// RUNTIME: PROP_STATIC
//-------------------------------------------------------------------------
r0.Patch({ 0xC3 }); // FUN --> RET | Called from CEngineClient and CEngineVGUI (Init()?).
gMatSync.Patch({ 0xC3 }); // FUN --> RET | Skip Matsync. Called from CMaterialSystem. TODO: Return in root caller.
r4.Patch({ 0xC3 }); // FUN --> RET | Clear render buffer? Called from CMatRenderContext and CTexture.
r5.Patch({ 0xC3 }); // FUN --> RET | Heavy render stuff. Called from CMatRenderContext.
r6.Patch({ 0xC3 }); // FUN --> RET | Set shader resource.
r7.Patch({ 0xC3, 0x90, 0x90, 0x90, 0x90 }); // FUN --> RET | Return early in lightmap and post processing code.
r8.Patch({ 0xC3, 0x90, 0x90, 0x90, 0x90, 0x90 }); // FUN --> RET | Return early.
e9.Offset(0x4A6).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP call to prevent shader dispatch.
e9.Offset(0x4AB).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | NOP call to prevent texture creation.
e9.Offset(0x4B5).Patch({ 0xC3 }); // JMP --> RET | RET early to prevent 'PIXVIS' code execution.
// Note: At [14028F3B0 + 0x5C7] RSP seems to contain a block of pointers to data for the static prop rmdl in question. [RSP + 0x70] is a pointer to (what seems to be) shader/material data. The pointer will be NULL without a shader system.
p_CalcPropStaticFrustumCulling.Offset(0x5E0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // MOV --> NOP | RSP + 0x70 is a nullptr which gets moved to R13, R13 gets used here resulting in exception 'C0000005'.
p_CalcPropStaticFrustumCulling.Offset(0x5EB).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | RAX is nullptr during virtual call resulting in exception 'C0000005'.
//-------------------------------------------------------------------------
// RUNTIME: USERINTERFACE
//-------------------------------------------------------------------------
SCR_BeginLoadingPlaque.Offset(0x427).Patch({ 0xEB, 0x09 }); // JNE --> JMP | Skip call to VGUI 'SCR_BeginLoadingPlaque'.
//-------------------------------------------------------------------------
// RUNTIME: RPAK_DISPATCH
//-------------------------------------------------------------------------
//gShaderDispatch.Offset(0x25).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
gShaderDispatch.Offset(0x3C).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent memory allocation and population for shader assets.
gShaderDispatch.Offset(0x48).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent memory allocation and population for shader assets.
gShaderDispatch.Offset(0x56).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent memory allocation and population for shader assets.
gShaderDispatch.Offset(0x62).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent memory allocation and population for shader assets.
// UNKNOWN ----------------------------------------------------------------
ADDRESS t8 = 0x00000001403C0480;
t8.Patch({ 0xC3 }); // Return from unknown call during ChangeLevel. [LATE]
ADDRESS t9 = 0x00000001403EE420;
t9.Patch({ 0xC3 }); // Return from unknown call during ChangeLevel. [EARLY]
//-------------------------------------------------------------------------
// RUNTIME BLOCK
//-------------------------------------------------------------------------
ADDRESS t0 = 0x00000001401D71E0;
//t0.Patch({ 0xC3 }); // RPak unload?
ADDRESS t1 = 0x0000000140456B50;
t1.Offset(0x292).Patch({ 0xE9, 0xEE, 0x00, 0x00, 0x00 });
ADDRESS t2 = 0x0000000140238DA0;
t2.Offset(0x4E0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
ADDRESS t3 = 0x0000000140312D80;
//t3.Offset(0xB3).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
ADDRESS t4 = 0x0000000140312D80; // Patch Additional shader preloading.
//t4.Offset(0xB3).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
ADDRESS t5 = 0x00000001403BBFD0;
t5.Offset(0x7D8).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
//-------------------------------------------------------------------------
// END RUNTIME BLOCK
// RUNTIME: GL_SCREEN
//-------------------------------------------------------------------------
SCR_BeginLoadingPlaque.Offset(0x82).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // JNE --> JMP | virtual call to 'CHLClient::CHudMessage'.
SCR_BeginLoadingPlaque.Offset(0xA4).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // JNE --> JMP | virtual call to 'CEngineVGui::OnLevelLoadingStarted'.
}
#endif // DEDICATED
void RuntimePtc_Init() /* .TEXT */
{
#ifdef DEDICATED
//-------------------------------------------------------------------------
// JNZ --> JMP | Prevent OriginSDK from initializing on the server
Origin_Init.Offset(0x0B).Patch({ 0xE9, 0x63, 0x02, 0x00, 0x00, 0x00 });
Origin_SetState.Offset(0x0E).Patch({ 0xE9, 0xCB, 0x03, 0x00, 0x00, 0x00 });
#endif // DEDICATED
//-------------------------------------------------------------------------
// JNE --> JMP | Allow games to be loaded without the optional texture streaming file
//WriteProcessMemory(GameProcess, LPVOID(dst002 + 0x8E5), "\xEB\x19", 2, NULL);
@ -268,7 +175,7 @@ void RuntimePtc_Init() /* .TEXT */
// JNE --> JMP | Prevent connect command from crashing by invalid call to UI function
dst003.Offset(0x1D6).Patch({ 0xEB, 0x27 });
//-------------------------------------------------------------------------
// JA --> JMP | Prevent FairFight anti-cheat from initializing on the
// JA --> JMP | Prevent FairFight anti-cheat from initializing on the server.
FairFight_Init.Offset(0x61).Patch({ 0xE9, 0xED, 0x00, 0x00, 0x00, 0x00 });
}

View File

@ -41,88 +41,88 @@ namespace
namespace
{
// TODO: create patterns instead and rename to function names.
// Renderer
ADDRESS r0 = 0x00000001402FE280; //
ADDRESS gCShaderGlue__Init = 0x00000001403B3A50; //
ADDRESS gMatSync = 0x00000001403DEE90; //
ADDRESS gCMaterialSystem__MatsysMode_Init = 0x00000001403BD120; //
ADDRESS r4 = 0x0000000140404380; //
ADDRESS r5 = 0x000000014040D850; //
ADDRESS r6 = 0x0000000140413260; //
ADDRESS r7 = 0x00000001404093F0; //
ADDRESS r8 = 0x00000001403D2E60; //
ADDRESS d3d11init = 0x000000014043CDF0; //
// Engine
ADDRESS gHost_Init_0 = 0x0000000140236E40; // main Host_Init()?
ADDRESS e1 = 0x0000000140FB2F10; // also used by CServerGameDLL
ADDRESS addr_CEngine_Frame = 0x00000001402970E0;
ADDRESS e3 = 0x0000000140231C00;
ADDRESS e4 = 0x0000000140BE1970;
ADDRESS e5 = 0x0000000140DBBAF0;
ADDRESS e6 = 0x0000000140DBE610;
ADDRESS e8 = 0x000000014027EC50; // RenderFrame?
ADDRESS gCEngineAPI__Init = 0x0000000140342FB0; //
ADDRESS gCEngineAPI__ModInit = 0x0000000140343DE0; //
ADDRESS gCEngineAPI__Connect = 0x0000000140342BA0; //
ADDRESS gCEngineAPI__OnStartup = 0x0000000140343860; //
//-------------------------------------------------------------------------
// CGAME
//-------------------------------------------------------------------------
ADDRESS gCGame__CreateGameWindow = 0x0000000140299100; //
//-------------------------------------------------------------------------
// CHLClIENT
//-------------------------------------------------------------------------
ADDRESS gCHLClient__1000 = 0x00000001405C27B0; // CHLClient + 1000
//-------------------------------------------------------------------------
// CSOURCEAPPSYSTEMGROUP
//-------------------------------------------------------------------------
ADDRESS gCSourceAppSystemGroup__Create = 0x000000014044AFA0; //
//-------------------------------------------------------------------------
// MM_HEARTBEAT
//-------------------------------------------------------------------------
ADDRESS MM_Heartbeat__ToString = 0x00000001402312A0; // server HeartBeat? (baseserver.cpp).
//-------------------------------------------------------------------------
// RUNTIME: SYS_INITGAME
//-------------------------------------------------------------------------
ADDRESS Sys_InitGame = 0x1402958D0;
//-------------------------------------------------------------------------
// CSHADERSYSTEM
//-------------------------------------------------------------------------
ADDRESS CShaderSystem__Init = 0x00000001403DF870; //
ADDRESS gInitMaterialSystem = 0x000000014024B390; //
ADDRESS gCVideoMode_Common__DrawStartupGraphic = 0x000000014027F0F0; //
ADDRESS gShaderDispatch = 0x00000001403EE5C0;
ADDRESS gShaderCreate = 0x00000001403ECD00; //
ADDRESS gTextureCreate = 0x00000001403EDCD0;
ADDRESS gCShaderSystem__9 = 0x00000001403DFC30;
//-------------------------------------------------------------------------
// CMATERIALSYSTEM
//-------------------------------------------------------------------------
ADDRESS CMaterialSystem__Init = 0x1403BBFD0;
ADDRESS InitMaterialSystem = 0x000000014024B390; //
//-------------------------------------------------------------------------
// RUNTIME: BSP_LUMP
//-------------------------------------------------------------------------
ADDRESS CollisionBSPData_LoadAllLumps = 0x00000001402546F0; // BSP.
ADDRESS CollisionBSPData_LinkPhysics = 0x140256480; // case 1: only gets called on changelevel, needs more research, function gets called by CModelLoader virtual function.
//-------------------------------------------------------------------------
// CSTUDIORENDERCONTEXT
//-------------------------------------------------------------------------
ADDRESS CStudioRenderContext__LoadModel = 0x00000001404554C0;
ADDRESS CStudioRenderContext__LoadMaterials = 0x0000000140456B50;
ADDRESS CGameServer__SpawnServer = 0x0000000140312D80;
//-------------------------------------------------------------------------
// CMODELLOADER
//-------------------------------------------------------------------------
ADDRESS CModelLoader__FindModel = 0x140253530;
ADDRESS CModelLoader__LoadModel = 0x140253810;
ADDRESS CollisionBSPData_LinkPhysics = 0x140256480; // case 1: only gets called on changelevel, needs more research, function gets called by CModelLoader virtual function.
ADDRESS ParsePropStatic = 0x1402901E0;
ADDRESS CModelLoader__Studio_LoadModel = 0x140252F10;
//-------------------------------------------------------------------------
// CGAMESERVER
//-------------------------------------------------------------------------
ADDRESS CGameServer__SpawnServer = 0x0000000140312D80;
ADDRESS e9 = 0x00000001404066E0;
ADDRESS e10 = 0x00000001403B49E0; // CMaterialGlue?
// SERVER
//-------------------------------------------------------------------------
// RUNTIME: HOST_INIT
//-------------------------------------------------------------------------
ADDRESS gHost_Init_0 = 0x0000000140236E40; // main Host_Init()?
ADDRESS gHost_Init_1 = 0x0000000140237B00; // server Host_Init()?
ADDRESS s1 = 0x0000000140231C00; // _Host_RunFrame() with inlined CFrameTimer::MarkFrame()?
ADDRESS s2 = 0x00000001402312A0; // server HeartBeat? (baseserver.cpp)
ADDRESS s3 = 0x0000000140FB36D0; // TEMP??
// CLIENT
ADDRESS gHost_Init_2 = 0x0000000140236640; // client Host_Init()?
ADDRESS gCGame__CreateGameWindow = 0x0000000140299100; //
ADDRESS c2 = 0x00000001403F4360; // 1403DF870 --> 1403F4360
ADDRESS c3 = 0x00000001403F8A80; // 1403DF870 --> 1403F8A40
ADDRESS gCHLClient__1000 = 0x00000001405C27B0; // CHLClient + 1000
ADDRESS gCHLClient__HudMessage = 0x00000001405BAC00; // CHudMessage
ADDRESS c6 = 0x00000001403CA2D0; //
// VGUI
ADDRESS gCEngineVGui__Init = 0x0000000140282E40; // jumptable
ADDRESS gCEngineVGui__OnLevelLoadingStarted = 0x00000001402830D0;
ADDRESS SCR_BeginLoadingPlaque = 0x000000014023E870;
//-------------------------------------------------------------------------
// RUNTIME: _HOST_RUNFRAME
//-------------------------------------------------------------------------
ADDRESS _Host_RunFrame = 0x0000000140231C00; // _Host_RunFrame() with inlined CFrameTimer::MarkFrame()?
//-------------------------------------------------------------------------
// RUNTIME: GL_SCREEN
//-------------------------------------------------------------------------
ADDRESS SCR_BeginLoadingPlaque = 0x14022A4A0;
}
void PrintOAddress() // Test the sigscan results