Additional dedicated server patches. Pending big overhaul

'Changelevel 'concommand works consistently and indefinitely now

Huge strip down in resource usage. Few things to be fixed still so idle mem usage is still balooned due to a temporary solution brought in place to prevent crashing when loading texture and material assets.

Stripping texture and material assets preloading from the root caused issues in 'CStudioRenderContext' and 'ModelLoader'. This needs to be addressed in the future

Exact line of the issue: Line 177 in opcodes.cpp:
"gCSourceAppSystemGroup_Create.Offset(0x384).Patch({ 0x90, 0x90, 0x90 }); // PrecacheMaterial"
This commit is contained in:
Amos 2021-10-23 12:47:54 -07:00
parent d2c724786f
commit f6c6ab6768
2 changed files with 133 additions and 21 deletions

View File

@ -41,7 +41,7 @@ void DisableRenderer()
void DisableClient()
{
Sleep(5000);
//Sleep(2500);
//-------------------------------------------------------------------------
// JNZ --> JMP | Prevent EbisuSDK from initializing on the engine and server.
Origin_Init.Offset(0x0B).Patch({ 0xE9, 0x63, 0x02, 0x00, 0x00, 0x00 });
@ -71,6 +71,14 @@ void DisableClient()
c5.Patch({ 0xC3 });
c7.Patch({ 0xC3 });
//-------------------------------------------------------------------------
// JE --> JMP | Render?
//gHost_Init_2.Offset(0x5D8).Patch({ 0xEB, 0x05 });
//-------------------------------------------------------------------------
// FUN --> RET | Disable particle effects precaching on the server.
ParticleEffect_Init.Patch({ 0xC3 });
//-------------------------------------------------------------------------
// JNE --> JMP |
c6.Offset(0x23).Patch({ 0xEB, 0x23 });
@ -96,7 +104,6 @@ void Hooks::DedicatedPatch()
*(uintptr_t*)0x14B3800D7 = 0x1; // bDedicated
DisableRenderer();
DisableClient();
DisableVGUI();
@ -110,19 +117,19 @@ void Hooks::DedicatedPatch()
FairFight_Init.Offset(0x61).Patch({ 0xE9, 0xED, 0x00, 0x00, 0x00, 0x00 });
//-------------------------------------------------------------------------
// JNE --> JMP | Take dedicated initialization routine instead.
s0.Offset(0x19).Patch({ 0xEB, 0x6E });
gHost_Init_1.Offset(0x19).Patch({ 0xEB, 0x6E });
//-------------------------------------------------------------------------
// JE --> JMP | Skip client.dll Init_PostVideo() validation code.
s0.Offset(0x609).Patch({ 0xEB, 0x2B });
gHost_Init_1.Offset(0x609).Patch({ 0xEB, 0x2B });
//-------------------------------------------------------------------------
// JNE --> JMP | Skip client.dll Init_PostVideo() validation code.
s0.Offset(0x621).Patch({ 0xEB, 0x0C });
gHost_Init_1.Offset(0x621).Patch({ 0xEB, 0x0C });
//-------------------------------------------------------------------------
// JE --> JMP | Skip NULL call as client is never initialized.
s0.Offset(0x658).Patch({ 0xE9, 0x8C, 0x00, 0x00, 0x00 });
gHost_Init_1.Offset(0x658).Patch({ 0xE9, 0x8C, 0x00, 0x00, 0x00 });
//-------------------------------------------------------------------------
// JNE --> JMP | Skip shader preloading as cvar can't be checked due to client being NULL.
s0.Offset(0x6E9).Patch({ 0xE9, 0xB0, 0x00, 0x00, 0x00 });
gHost_Init_1.Offset(0x6E9).Patch({ 0xE9, 0xB0, 0x00, 0x00, 0x00 });
//-------------------------------------------------------------------------
// JNE --> JMP | Return early in _Host_RunFrame() for debugging perposes.
//s1.Offset(0x1C6).Patch({ 0xE9, 0xAD, 0x11, 0x00, 0x00 }); // <-- this one was only used to debug.
@ -138,10 +145,10 @@ void Hooks::DedicatedPatch()
//-------------------------------------------------------------------------
// CAL --> NOP | NOP call to UI texture asset preloading.
e0.Offset(0x182).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
gHost_Init_0.Offset(0x182).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
//-------------------------------------------------------------------------
// JNE --> JNP | Skip client.dll library initialization.
//e0.Offset(0xA7D).Patch({ 0xE9, 0xF0, 0x01, 0x00, 0x00 });
gHost_Init_0.Offset(0xA7D).Patch({ 0xE9, 0xF0, 0x01, 0x00, 0x00 });
//-------------------------------------------------------------------------
// JNE --> NOP | Skip settings field loading for client texture assets.
// TODO: this is also used by server.dll library.
@ -150,18 +157,105 @@ void Hooks::DedicatedPatch()
// CAL --> NOP | NOP call to unused VGUI code to prevent crash at SIGNONSTATE_PRESPAWN.
e3.Offset(0xFB0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
//MemoryAddress(0x140E157F0).Patch({ 0xC3 });
//-------------------------------------------------------------------------
// JNE --> JNP | Skip Video Mode initialization code.
gCEngineAPI_OnStartup.Offset(0x5E).Patch({ 0xE9, 0xC6, 0x01, 0x00, 0x00 });
//-------------------------------------------------------------------------
// JNE --> JNP | Skip Video Mode validation code.
gCEngineAPI_Init.Offset(0xB7).Patch({ 0xE9, 0xC7, 0x00, 0x00, 0x00 });
//-------------------------------------------------------------------------
// JNE --> JNP | Skip CreateWindow Initialization code.
//gCEngineAPI_ModInit.Offset(0x3DD).Patch({ 0xE9, 0xB5, 0x00, 0x00, 0x00, 0x00 });
//-------------------------------------------------------------------------
// CAL --> NOP | NOP call to texture and material preloading.
gCEngineAPI_Connect.Offset(0xDD).Patch({ 0x90, 0x90, 0x90 });
gCEngineAPI_Connect.Offset(0xF1).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
gCEngineAPI_Connect.Offset(0x1C6).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90});
//-------------------------------------------------------------------------
// CAL --> NOP | NOP call to texture and material preloading.
gCSourceAppSystemGroup_Create.Offset(0x35D).Patch({ 0x90, 0x90, 0x90 }); // joystickInit?
//gCSourceAppSystemGroup_Create.Offset(0x384).Patch({ 0x90, 0x90, 0x90 }); // PrecacheMaterial
gCSourceAppSystemGroup_Create.Offset(0x39E).Patch({ 0x90, 0x90, 0x90 }); // binkBlankTexture
//-------------------------------------------------------------------------
// FUN --> RET | Return early in 'CVideoMode_Common::DrawStartupGraphic'.
gCVideoMode_Common__DrawStartupGraphic.Patch({ 0xC3 });
//-------------------------------------------------------------------------
// FUN --> RET | Return early in 'CShaderSystem::Init' to prevent initialization.
//gCShaderSystem_Init.Patch({ 0xC3 });
//-------------------------------------------------------------------------
// JMP --> RET | Return early to prevent 'InitDebugMaterials' from being executed.
gInitMaterialSystem.Offset(0x7D).Patch({ 0xC3 });
//-------------------------------------------------------------------------
// FUN --> RET | Return early in 'RenderFrame?' (Called from VGUI and Host_Init).
e8.Offset(0x44).Patch({ 0xE9, 0x41, 0x04, 0x00, 0x00 });
//-------------------------------------------------------------------------
// CAL --> NOP | NOP call to prevent texture creation.
e9.Offset(0x6).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
//-------------------------------------------------------------------------
// CAL --> NOP | NOP call to prevent texture creation.
e9.Offset(0x4AB).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
//-------------------------------------------------------------------------
// JMP --> RET | RET early to prevent 'PIXVIS' code execution.
e9.Offset(0x4B5).Patch({ 0xC3 });
//-------------------------------------------------------------------------
// FUN --> RET | RET early to prevent '' code execution.
e10.Patch({ 0xC3 });
//-------------------------------------------------------------------------
// CAL --> NOP | Prevent memory allocation and population for shader assets.
//gShaderDispatch.Offset(0x25).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
gShaderDispatch.Offset(0x3C).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
gShaderDispatch.Offset(0x48).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
gShaderDispatch.Offset(0x56).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
gShaderDispatch.Offset(0x62).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
//-------------------------------------------------------------------------
// FUN --> RET | RET early to prevent 'ShaderCreate' code execution.
gShaderCreate.Patch({ 0xC3 });
//-------------------------------------------------------------------------
// FUN --> RET | RET early to prevent 'TextureCreate' code execution.
gTextureCreate.Patch({ 0xC3 });
//e4.Offset(0x20).Patch({ 0xE9, 0xE3, 0x00, 0x00, 0x00 });
//e5.Offset(0x21).Patch({ 0xE9, 0x35, 0x04, 0x00, 0x00 });
//e5.Offset(0x59).Patch({ 0xEB, 0x0A });
//e6.Offset(0x1B0).Patch({0x90, 0x90, 0x90});
OnLevelLoadingStarted.Offset(0x61).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
OnLevelLoadingStarted.Patch({ 0xC3 });
//-------------------------------------------------------------------------
// ??? 1403DFC30 = 0x94490 ??? // an expensive stuff that wasted many CPU cycles, this one seems to be the best candidate to return
// START TESTING BLOCK
//-------------------------------------------------------------------------
MemoryAddress t0 = 0x00000001401D71E0;
t0.Patch({ 0xC3 });
MemoryAddress t1 = 0x0000000140456B50;
t1.Offset(0x292).Patch({ 0xE9, 0xEE, 0x00, 0x00, 0x00 });
MemoryAddress t2 = 0x0000000140238DA0;
t2.Offset(0x4E0).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
MemoryAddress t3 = 0x0000000140312D80;
//t3.Offset(0xB3).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
MemoryAddress t4 = 0x0000000140312D80; // Patch Additional shader preloading.
//t4.Offset(0xB3).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
MemoryAddress t5 = 0x00000001403BBFD0;
t5.Offset(0x7D8).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 });
// BSP --------------------------------------------------------------------
MemoryAddress t6 = 0x00000001402546F0; // BSP.
t6.Offset(0x200).Patch({ 0xEB, 0xA9 }); // Skip SKYLIGHTS.
t6.Offset(0x352).Patch({ 0xEB, 0xA5 }); // Skip LUMP_LIGHTMAP.
t6.Offset(0xBF2).Patch({ 0x90, 0x90 }); // Skip WORLDLIGHTS
t6.Offset(0xDA9).Patch({ 0x90, 0x90 }); // Skip TWEAKLIGHTS
t6.Offset(0xEEB).Patch({ 0xE9, 0x3D, 0x01, 0x00, 0x00 });
//t6.Offset(0x61B).Patch({ 0xE9, 0xE2, 0x02, 0x00, 0x00 });
// CSHADERSYSTEM ----------------------------------------------------------
MemoryAddress t7 = 0x00000001403DFC30; // Unnecessary CShaderSystem call?
t7.Offset(0x3).Patch({ 0xE9, 0x95, 0x03, 0x00, 0x00 });
// UNKNOWN ----------------------------------------------------------------
MemoryAddress t8 = 0x00000001403C0480;
t8.Patch({ 0xC3 }); // Return from unknown call during ChangeLevel. (LATE)
MemoryAddress t9 = 0x00000001403EE420;
t9.Patch({ 0xC3 }); // Return from unknown call during ChangeLevel. (EARLY)
//-------------------------------------------------------------------------
// END TESTING BLOCK
//-------------------------------------------------------------------------
}
// TEST

View File

@ -51,22 +51,39 @@ namespace
MemoryAddress d3d11init = 0x000000014043CDF0; //
// Engine
MemoryAddress e0 = 0x0000000140236E40; // main Host_Init()?
MemoryAddress gHost_Init_0 = 0x0000000140236E40; // main Host_Init()?
MemoryAddress e1 = 0x0000000140FB2F10; // also used by CServerGameDLL
MemoryAddress addr_CEngine_Frame = 0x00000001402970E0;
MemoryAddress e3 = 0x0000000140231C00;
MemoryAddress e4 = 0x0000000140BE1970;
MemoryAddress e5 = 0x0000000140DBBAF0;
MemoryAddress e6 = 0x0000000140DBE610;
MemoryAddress e7 = 0x000000014044AFA0;
MemoryAddress e8 = 0x000000014027EC50; // RenderFrame?
MemoryAddress gCEngineAPI_Init = 0x0000000140342FB0; //
MemoryAddress gCEngineAPI_ModInit = 0x0000000140343DE0; //
MemoryAddress gCEngineAPI_Connect = 0x0000000140342BA0; //
MemoryAddress gCEngineAPI_OnStartup = 0x0000000140343860; //
MemoryAddress gCSourceAppSystemGroup_Create = 0x000000014044AFA0; //
MemoryAddress gCShaderSystem_Init = 0x00000001403DF870; //
MemoryAddress gInitMaterialSystem = 0x000000014024B390; //
MemoryAddress gCVideoMode_Common__DrawStartupGraphic = 0x000000014027F0F0; //
MemoryAddress gShaderDispatch = 0x00000001403EE5C0;
MemoryAddress gShaderCreate = 0x00000001403ECD00; //
MemoryAddress gTextureCreate = 0x00000001403EDCD0;
MemoryAddress e9 = 0x00000001404066E0;
MemoryAddress e10 = 0x00000001403B49E0; // CMaterialGlue?
// SERVER
MemoryAddress s0 = 0x0000000140237B00; // server Host_Init()?
MemoryAddress gHost_Init_1 = 0x0000000140237B00; // server Host_Init()?
MemoryAddress s1 = 0x0000000140231C00; // _Host_RunFrame() with inlined CFrameTimer::MarkFrame()?
MemoryAddress s2 = 0x00000001402312A0; // server HeartBeat? (baseserver.cpp)
MemoryAddress s3 = 0x0000000140FB36D0; // TEMP??
// CLIENT
MemoryAddress c0 = 0x0000000140236640; // client Host_Init()?
MemoryAddress gHost_Init_2 = 0x0000000140236640; // client Host_Init()?
MemoryAddress c1 = 0x0000000140299100; // CreateGameWindowInit()?
MemoryAddress c2 = 0x00000001403F4360; // 1403DF870 --> 1403F4360
MemoryAddress c3 = 0x00000001403F8A80; // 1403DF870 --> 1403F8A40
@ -74,6 +91,7 @@ namespace
MemoryAddress c5 = 0x00000001405BAC00; // CHudMessage
MemoryAddress c6 = 0x00000001403CA2D0; //
MemoryAddress c7 = 0x00000001403CC750; // LightmapsInit
MemoryAddress ParticleEffect_Init = 0x0000000140235F30;
MemoryAddress CreateGameWindow = 0x0000000140343DE0;
// VGUI