From d1f88e08191383bb6bd7f0f0e3877379da3cd921 Mon Sep 17 00:00:00 2001 From: xen Date: Sat, 22 Feb 2025 18:50:50 +0200 Subject: [PATCH] Update sig+patch but disable them It's really cursed and I don't wanna deal with that for now, we can make do without the ONE plugin that needs it --- extension.cpp | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/extension.cpp b/extension.cpp index e3f0a3e..89e77f4 100644 --- a/extension.cpp +++ b/extension.cpp @@ -68,8 +68,8 @@ struct SrcdsPatch #if SOURCE_ENGINE == SE_CSS && defined PLATFORM_LINUX { "Physics_RunThinkFunctions", - (unsigned char *)"\x8B\x04\x9E\x85\xC0\x74\x13\xA1\x00\x00\x00\x00\x89\x78\x0C\x8B\x04\x9E\x89\x04\x24\xE8\x00\x00\x00\x00", - "xxxxxxxx????xxxxxxxxxx????", + (unsigned char *)"\x8B\x14\x9E\x85\xD2\x74\x00\xA1\x00\x00\x00\x00\x83\xEC\x00\xF3\x0F\x10\x55\x00\xF3\x0F\x11\x50\x00\xFF", + "xxxxxx?x????xx?xxxx?xxxx?x", NULL, 0, 0, 0, false } @@ -153,7 +153,7 @@ void (__fastcall *g_pPhysics_SimulateEntity)(CBaseEntity *pEntity) = NULL; void Physics_SimulateEntity_CustomLoop(CBaseEntity **ppList, int Count, float Startime) { - CBaseEntity *apPlayers[g_iMaxPlayers]; + CUtlVectorFixed apPlayers; int iPlayers = 0; // Remove players from list and put into apPlayers @@ -497,19 +497,22 @@ bool PhysHooks::SDK_OnLoad(char *error, size_t maxlength, bool late) } #if SOURCE_ENGINE == SE_CSS && defined PLATFORM_LINUX - // mov [esp+8], edi ; startime - // mov [esp+4], eax ; count - // mov [esp], esi ; **list + // sub esp, 4 ; allocate room on stack for starttime + // movss [esp], xmm2 ; startime + // push eax ; count + // push esi ; **list // call NULL ; <- our func here - // jmp +16 ; jump over useless instructions - static unsigned char aPatch[] = "\x89\x7C\x24\x08\x89\x44\x24\x04\x89\x34\x24\xE8\x00\x00\x00\x00\xEB\x10\x90\x90\x90\x90\x90\x90\x90\x90"; + // add esp, 12 ; fix up stack + // jmp +24 ; jump over useless instructions + //"\x8B\x14\x9E\x85\xD2\x74\x00\xA1\x00\x00\x00\x00\x83\xEC\x00\xF3\x0F\x10\x55\x00\xF3\x0F\x11\x50\x00\xFF" + static unsigned char aPatch[] = "\x83\xEC\x04\xF3\x0F\x11\x14\x24\x50\x56\xE8\x00\x00\x00\x00\x83\xC4\x0C\xEB\x18\x90\x90\x90\x90\x90\x90"; gs_Patches[0].pPatch = aPatch; // put our function address into the relative call instruction // relative call: new PC = PC + imm1 - // call is at + 11 after pPatchAddress + // call is at + 10 after pPatchAddress // PC will be past our call instruction so + 5 - *(uintptr_t *)&aPatch[12] = (uintptr_t)Physics_SimulateEntity_CustomLoop - (pPatchAddress + 11 + 5); + *(uintptr_t *)&aPatch[11] = (uintptr_t)Physics_SimulateEntity_CustomLoop - (pPatchAddress + 10 + 5); #elif SOURCE_ENGINE == SE_CSGO && defined PLATFORM_LINUX // mov [esp+8], edi ; startime // mov [esp+4], eax ; count @@ -545,6 +548,10 @@ bool PhysHooks::SDK_OnLoad(char *error, size_t maxlength, bool late) #error "Unsupported platform" #endif + bool bSuccess = true; + + // TODO: Fix this cursed patch + /* // Apply all patches for(size_t i = 0; i < sizeof(gs_Patches) / sizeof(*gs_Patches); i++) { @@ -553,17 +560,17 @@ bool PhysHooks::SDK_OnLoad(char *error, size_t maxlength, bool late) if(!g_pGameConf->GetMemSig(pPatch->pSignature, (void **)&pPatch->pAddress) || !pPatch->pAddress) { - snprintf(error, maxlength, "Could not find symbol: %s", pPatch->pSignature); - SDK_OnUnload(); - return false; + g_pSM->LogError(myself, "Could not find symbol: %s", pPatch->pSignature); + bSuccess = false; + continue; } pPatch->pPatchAddress = FindPattern(pPatch->pAddress, pPatch->pPatchSignature, pPatch->pPatchPattern, 1024); if(!pPatch->pPatchAddress) { - snprintf(error, maxlength, "Could not find patch signature for symbol: %s", pPatch->pSignature); - SDK_OnUnload(); - return false; + g_pSM->LogError(myself, "Could not find patch signature for symbol: %s", pPatch->pSignature); + bSuccess = false; + continue; } pPatch->pOriginal = (unsigned char *)malloc(PatchLen * sizeof(unsigned char)); @@ -576,10 +583,17 @@ bool PhysHooks::SDK_OnLoad(char *error, size_t maxlength, bool late) } SourceHook::SetMemAccess((void *)pPatch->pPatchAddress, PatchLen, SH_MEM_READ|SH_MEM_EXEC); } + */ + + if (!bSuccess) + { + SDK_OnUnload(); + return false; + } g_pOnRunThinkFunctions = forwards->CreateForward("OnRunThinkFunctions", ET_Ignore, 1, NULL, Param_Cell); g_pOnPrePlayerThinkFunctions = forwards->CreateForward("OnPrePlayerThinkFunctions", ET_Ignore, 0, NULL); - g_pOnPostPlayerThinkFunctions = forwards->CreateForward("OnPostPlayerThinkFunctions", ET_Ignore, 0, NULL); + g_pOnPostPlayerThinkFunctions = forwards->CreateForward("OnPostPlayerThinkFunctions", ET_Ignore, 0, NULL); // NOTE: This relies on the cursed patch above g_pOnRunThinkFunctionsPost = forwards->CreateForward("OnRunThinkFunctionsPost", ET_Ignore, 1, NULL, Param_Cell); return true;