1
0
mirror of https://github.com/Mauler125/r5sdk.git synced 2025-02-09 19:15:03 +01:00

Properly shutdown dedicated again

Small oversight during file refactor
This commit is contained in:
Kawe Mazidjatari 2022-03-25 01:19:27 +01:00
parent 378df25d4c
commit 9b511edbb2
4 changed files with 21 additions and 11 deletions

@ -105,6 +105,8 @@ void Dedicated_Init()
//-------------------------------------------------------------------------
{
p_CModelLoader__LoadModel.Offset(0x462).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent call to 'CStudioRenderContext::LoadMaterials'.
p_CModelLoader__UnloadModel.Offset(0x129).Patch({ 0x90, 0x90, 0x90 }); // MOV --> NOP | Virtual call to 'CShaderSystem' class method fails as RCX is nullptr.
p_CModelLoader__UnloadModel.Offset(0x12C).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CTexture' class member in RAX + 0x78 fails. Previous instruction could not dereference.
p_CModelLoader__Studio_LoadModel.Offset(0x325).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CMaterialSystem::FindMaterialEx' fails as RAX is nullptr.
p_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.
p_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.
@ -123,9 +125,6 @@ void Dedicated_Init()
p_CModelLoader__Map_LoadModelGuts.Offset(0xEEB).Patch({ 0xE9, 0x3D, 0x01, 0x00, 0x00 }); // JLE --> JMP | Exception 0x57 in while trying to dereference [R15 + R14 *8 + 0x10].
p_CModelLoader__Map_LoadModelGuts.Offset(0x61B).Patch({ 0xE9, 0xE2, 0x02, 0x00, 0x00 }); // JZ --> JMP | Prevent call to 'CMod_LoadTextures()'.
p_CModelLoader__Map_LoadModelGuts.Offset(0x1045).Patch({ 0x90, 0x90, 0x90, 0x90, 0x90 }); // CAL --> NOP | Prevent call to 'Mod_LoadCubemapSamples()'.
p_CModelLoader__Map_LoadModelGuts.Offset(0x129).Patch({ 0x90, 0x90, 0x90 }); // MOV --> NOP | RCX is nullptr during dereference since shadersystem isn't initialized. Exception 'C0000005'.
p_CModelLoader__Map_LoadModelGuts.Offset(0x12C).Patch({ 0x90, 0x90, 0x90 }); // CAL --> NOP | Virtual call to 'CTexture' class member in RAX + 0x78 fails. Previous instruction could not dereference.
}
//-------------------------------------------------------------------------

@ -12,10 +12,10 @@ __declspec(dllexport) void DummyExport()
const std::string R5R_LOGO[] =
{
R"(+-------------------------------------------------------------------+)",
R"(| ___ ___ ___ _ _ _ ___ __ ____ |)",
R"(| | _ \ __| _ \___| |___ __ _ __| |___ __| | __ _|_ ) / \ |__ / |)",
R"(| | /__ \ / -_) / _ \/ _` / _` / -_) _` | \ V // / | () | |_ \ |)",
R"(| |_|_\___/_|_\___|_\___/\__,_\__,_\___\__,_| \_//___(_)__(_)___/ |)",
R"(| ___ ___ ___ _ _ _ ___ __ _ _ |)",
R"(| | _ \ __| _ \___| |___ __ _ __| |___ __| | __ _|_ ) / \| | | |)",
R"(| | /__ \ / -_) / _ \/ _` / _` / -_) _` | \ V // / | () |_ _| |)",
R"(| |_|_\___/_|_\___|_\___/\__,_\__,_\___\__,_| \_//___(_)__(_)|_| |)",
R"(| |)",
R"(+-------------------------------------------------------------------+)"
};

@ -1,10 +1,14 @@
#pragma once
// !TODO: BUILD AGNOSTIC! //
namespace
{
ADDRESS CollisionBSPData_LinkPhysics = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xF9\x33\xED", "xxxx?xxxx?xxxx????xxxxx"); // case 1: only gets called on changelevel, needs more research, function gets called by CModelLoader virtual function.
// 0x140256480 // 48 89 5C 24 ? 48 89 6C 24 ? 57 48 81 EC ? ? ? ? 48 8B F9 33 ED //
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
ADDRESS p_CollisionBSPData_LinkPhysics = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x20\x48\x8B\xD9\x48\x83\xC1\x08\xE8\x00\x00\x00\x00\x48\x8D\x4B\x68", "xxxxxxxxxxxxxx????xxxx");
uint64_t(*CollisionBSPData_LinkPhysics)(void* thisptr) = (uint64_t(*)(void*))p_CollisionBSPData_LinkPhysics.GetPtr(); /*40 53 48 83 EC 20 48 8B D9 48 83 C1 08 E8 ? ? ? ? 48 8D 4B 68*/
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
ADDRESS p_CollisionBSPData_LinkPhysics = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xF9\x33\xED", "xxxx?xxxx?xxxx????xxxxx");
uint64_t(*CollisionBSPData_LinkPhysics)(void* thisptr) = (uint64_t(*)(void*))p_CollisionBSPData_LinkPhysics.GetPtr(); /*48 89 5C 24 ? 48 89 6C 24 ? 57 48 81 EC ? ? ? ? 48 8B F9 33 ED*/
#endif
}
void MOD_PreloadPak(const std::string& svSetFile);
@ -13,7 +17,7 @@ class HModel_BSP : public IDetour
{
virtual void debugp()
{
std::cout << "| FUN: CollisionBSPData_LinkPhysics : 0x" << std::hex << std::uppercase << CollisionBSPData_LinkPhysics.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: CollisionBSPData_LinkPhysics : 0x" << std::hex << std::uppercase << p_CollisionBSPData_LinkPhysics.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "+----------------------------------------------------------------+" << std::endl;
}
};

@ -14,6 +14,9 @@ namespace
ADDRESS p_CModelLoader__Map_LoadModelGuts = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x54\x24\x00\x48\x89\x4C\x24\x00\x55\x53\x41\x54\x41\x55\x48\x8D\xAC\x24\x00\x00\x00\x00\x48\x81\xEC\x00\x00\x00\x00\xFF\x05\x00\x00\x00\x00", "xxxx?xxxx?xxxxxxxxxx????xxx????xx????"); // BSP.
uint64_t(*CModelLoader__Map_LoadModelGuts)(void* thisptr, void* mod) = (uint64_t(*)(void*, void*))p_CModelLoader__Map_LoadModelGuts.GetPtr(); /*48 89 54 24 ? 48 89 4C 24 ? 55 53 41 54 41 55 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? FF 05 ? ? ? ? */
ADDRESS p_CModelLoader__UnloadModel = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x8B\xC4\x48\x89\x58\x18\x55\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xDA", "xxxxxxxxxxx????xxx");
uint64_t(*CModelLoader__UnloadModel)(void* thisptr, void* pModel) = (uint64_t(*)(void*, void*))p_CModelLoader__UnloadModel.GetPtr(); /*48 8B C4 48 89 58 18 55 48 81 EC ? ? ? ? 48 8B DA*/
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
ADDRESS p_CModelLoader__FindModel = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x55\x41\x57\x48\x83\xEC\x48\x80\x3A\x2A", "xxxxxxxxxxx");
void*(*CModelLoader__FindModel)(void* thisptr, const char* pszModelName) = (void* (*)(void*, const char*))p_CModelLoader__FindModel.GetPtr(); /*40 55 41 57 48 83 EC 48 80 3A 2A*/
@ -26,6 +29,9 @@ namespace
ADDRESS p_CModelLoader__Map_LoadModelGuts = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x54\x24\x00\x48\x89\x4C\x24\x00\x55\x53\x56\x57\x41\x54\x41\x55\x41\x57", "xxxx?xxxx?xxxxxxxxxx"); // BSP.
uint64_t(*CModelLoader__Map_LoadModelGuts)(void* thisptr, void* mod) = (uint64_t(*)(void*, void*))p_CModelLoader__Map_LoadModelGuts.GetPtr(); /*48 89 54 24 ? 48 89 4C 24 ? 55 53 56 57 41 54 41 55 41 57*/
ADDRESS p_CModelLoader__UnloadModel = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x48\x8B\xF9\x33\xED", "xxxx?xxxx?xxxx????xxxxx");
uint64_t(*CModelLoader__UnloadModel)(void* thisptr, void* pModel) = (uint64_t(*)(void*, void*))p_CModelLoader__UnloadModel.GetPtr(); /*48 89 5C 24 ? 48 89 6C 24 ? 57 48 81 EC ? ? ? ? 48 8B F9 33 ED*/
#endif
}
@ -39,6 +45,7 @@ class HModelLoader : public IDetour
{
std::cout << "| FUN: CModelLoader::FindModel : 0x" << std::hex << std::uppercase << p_CModelLoader__FindModel.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: CModelLoader::LoadModel : 0x" << std::hex << std::uppercase << p_CModelLoader__LoadModel.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: CModelLoader::UnloadModel : 0x" << std::hex << std::uppercase << p_CModelLoader__UnloadModel.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: CModelLoader::Map_LoadModelGuts : 0x" << std::hex << std::uppercase << p_CModelLoader__Map_LoadModelGuts.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "| FUN: CModelLoader::Studio_LoadModel : 0x" << std::hex << std::uppercase << p_CModelLoader__Studio_LoadModel.GetPtr() << std::setw(npad) << " |" << std::endl;
std::cout << "+----------------------------------------------------------------+" << std::endl;