Fix SDK for S2 bin

This commit is contained in:
Kawe Mazidjatari 2022-05-18 01:00:46 +02:00
parent ddfdb4ffd8
commit 32487b4230
5 changed files with 40 additions and 17 deletions

View File

@ -94,7 +94,7 @@ studiohdr_t* CMDLCache::FindMDL(CMDLCache* cache, MDLHandle_t handle, void* a3)
//-----------------------------------------------------------------------------
// Purpose: finds an MDL cached
// Input : *this -
// *a2 -
// *pStudioData -
// *a3 -
//-----------------------------------------------------------------------------
void CMDLCache::FindCachedMDL(CMDLCache* cache, studiodata_t* pStudioData, void* a3)
@ -117,7 +117,7 @@ void CMDLCache::FindCachedMDL(CMDLCache* cache, studiodata_t* pStudioData, void*
// Purpose: finds an MDL uncached
// Input : *this -
// handle -
// *a3 -
// *pStudioData -
// *a4 -
// Output : a pointer to the studiohdr_t object
//-----------------------------------------------------------------------------
@ -202,7 +202,7 @@ studiohdr_t* CMDLCache::FindUncachedMDL(CMDLCache* cache, MDLHandle_t handle, st
}
else
{
v_CMDLCache__FindCachedMDL(cache, pStudioData, a4);
FindCachedMDL(cache, pStudioData, a4);
if ((__int64)*(studiohdr_t**)pStudioData)
{
if ((__int64)*(studiohdr_t**)pStudioData == 0xDEADFEEDDEADFEED)
@ -333,7 +333,7 @@ void* CMDLCache::GetMaterialTable(CMDLCache* cache, MDLHandle_t handle)
//-----------------------------------------------------------------------------
studiohdr_t* CMDLCache::GetErrorModel(void)
{
old_gather_props->SetValue(true); // mdl/error.rmdl fallback is not supported (yet) in the new GatherProps solution!
old_gather_props->SetValue(true); // !TODO [AMOS]: mdl/error.rmdl fallback is not supported (yet) in the new GatherProps solution!
return g_pMDLFallback->m_pErrorHDR;
}
@ -350,17 +350,25 @@ bool CMDLCache::IsKnownBadModel(MDLHandle_t handle)
void MDLCache_Attach()
{
DetourAttach((LPVOID*)&v_CMDLCache__FindMDL, &CMDLCache::FindMDL);
#ifdef GAMEDLL_S3 // !!! DECLARED INLINE IN < S3 !!!
DetourAttach((LPVOID*)&v_CMDLCache__FindCachedMDL, &CMDLCache::FindCachedMDL);
DetourAttach((LPVOID*)&v_CMDLCache__FindUncachedMDL, &CMDLCache::FindUncachedMDL);
#endif // GAMEDLL_S3
#ifdef GAMEDLL_S3 // !TODO:
DetourAttach((LPVOID*)&v_CMDLCache__GetHardwareData, &CMDLCache::GetHardwareData);
DetourAttach((LPVOID*)&v_CMDLCache__GetStudioHDR, &CMDLCache::GetStudioHDR);
#endif
}
void MDLCache_Detach()
{
DetourDetach((LPVOID*)&v_CMDLCache__FindMDL, &CMDLCache::FindMDL);
#ifdef GAMEDLL_S3 // !!! DECLARED INLINE IN < S3 !!!
DetourDetach((LPVOID*)&v_CMDLCache__FindCachedMDL, &CMDLCache::FindCachedMDL);
DetourDetach((LPVOID*)&v_CMDLCache__FindUncachedMDL, &CMDLCache::FindUncachedMDL);
#endif // GAMEDLL_S3
#ifdef GAMEDLL_S3 // !TODO:
DetourDetach((LPVOID*)&v_CMDLCache__GetHardwareData, &CMDLCache::GetHardwareData);
DetourDetach((LPVOID*)&v_CMDLCache__GetStudioHDR, &CMDLCache::GetStudioHDR);
#endif
}

View File

@ -76,13 +76,13 @@ public:
inline CMemory p_CMDLCache__FindMDL;
inline auto v_CMDLCache__FindMDL = p_CMDLCache__FindMDL.RCast<studiohdr_t* (*)(CMDLCache* pCache, void* a2, void* a3)>();
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
inline CMemory p_CMDLCache__FindCachedMDL;
inline auto v_CMDLCache__FindCachedMDL = p_CMDLCache__FindCachedMDL.RCast<void(*)(CMDLCache* pCache, void* a2, void* a3)>();
inline CMemory p_CMDLCache__FindUncachedMDL;
inline auto v_CMDLCache__FindUncachedMDL = p_CMDLCache__FindUncachedMDL.RCast<studiohdr_t* (*)(CMDLCache* pCache, MDLHandle_t handle, void* a3, void* a4)>();
#endif
inline CMemory p_CMDLCache__GetStudioHDR;
inline auto v_CMDLCache__GetStudioHDR = p_CMDLCache__GetStudioHDR.RCast<studiohdr_t* (*)(CMDLCache* pCache, MDLHandle_t handle)>();
@ -106,8 +106,10 @@ class VMDLCache : public IDetour
virtual void GetAdr(void) const
{
spdlog::debug("| FUN: CMDLCache::FindMDL : {:#18x} |\n", p_CMDLCache__FindMDL.GetPtr());
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
spdlog::debug("| FUN: CMDLCache::FindCachedMDL : {:#18x} |\n", p_CMDLCache__FindCachedMDL.GetPtr());
spdlog::debug("| FUN: CMDLCache::FindUncachedMDL : {:#18x} |\n", p_CMDLCache__FindUncachedMDL.GetPtr());
#endif
spdlog::debug("| FUN: CMDLCache::GetStudioHDR : {:#18x} |\n", p_CMDLCache__GetStudioHDR.GetPtr());
spdlog::debug("| FUN: CMDLCache::GetHardwareData : {:#18x} |\n", p_CMDLCache__GetHardwareData.GetPtr());
spdlog::debug("| FUN: CStudioHWDataRef::SetFlags : {:#18x} |\n", p_CStudioHWDataRef__SetFlags.GetPtr());
@ -119,6 +121,10 @@ class VMDLCache : public IDetour
}
virtual void GetFun(void) const
{
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
p_CMDLCache__FindMDL = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x83\xEC\x20\x4C\x8B\xF1\x0F\xB7\xDA"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxx");
v_CMDLCache__FindMDL = p_CMDLCache__FindMDL.RCast<studiohdr_t* (*)(CMDLCache*, void*, void*)>(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC 20 4C 8B F1 0F B7 DA*/
#else
p_CMDLCache__FindMDL = 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\xF1\x0F\xB7\xEA"), "xxxx?xxxx?xxxx?xxxxxxxxxxx");
v_CMDLCache__FindMDL = p_CMDLCache__FindMDL.RCast<studiohdr_t* (*)(CMDLCache*, void*, void*)>(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B F1 0F B7 EA*/
@ -126,8 +132,8 @@ class VMDLCache : public IDetour
v_CMDLCache__FindCachedMDL = p_CMDLCache__FindCachedMDL.RCast<void(*)(CMDLCache*, void*, void*)>(); /*4D 85 C0 74 7A 48 89 6C 24 ?*/
p_CMDLCache__FindUncachedMDL = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x48\x89\x5C\x24\x00\x48\x89\x6C\x24\x00\x48\x89\x74\x24\x00\x48\x89\x7C\x24\x00\x41\x56\x48\x83\xEC\x20\x48\x8B\xE9\x0F\xB7\xFA"), "xxxx?xxxx?xxxx?xxxx?xxxxxxxxxxxx");
v_CMDLCache__FindUncachedMDL = p_CMDLCache__FindUncachedMDL.RCast<studiohdr_t* (*)(CMDLCache*, MDLHandle_t , void*, void*)>(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC 20 48 8B E9 0F B7 FA*/
v_CMDLCache__FindUncachedMDL = p_CMDLCache__FindUncachedMDL.RCast<studiohdr_t* (*)(CMDLCache*, MDLHandle_t, void*, void*)>(); /*48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC 20 48 8B E9 0F B7 FA*/
#endif
p_CMDLCache__GetStudioHDR = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\x40\x53\x48\x83\xEC\x20\x48\x8D\x0D\x00\x00\x00\x00\x0F\xB7\xDA\xFF\x15\x00\x00\x00\x00\x48\x8B\x05\x00\x00\x00\x00\x48\x8D\x14\x5B\x48\x8D\x0D\x00\x00\x00\x00\x48\x8B\x5C\xD0\x00\xFF\x15\x00\x00\x00\x00\x48\x8B\x03\x48\x8B\x48\x08"), "xxxxxxxxx????xxxxx????xxx????xxxxxxx????xxxx?xx????xxxxxxx");
v_CMDLCache__GetStudioHDR = p_CMDLCache__GetStudioHDR.RCast<studiohdr_t* (*)(CMDLCache*, MDLHandle_t)>(); /*40 53 48 83 EC 20 48 8D 0D ? ? ? ? 0F B7 DA FF 15 ? ? ? ? 48 8B 05 ? ? ? ? 48 8D 14 5B 48 8D 0D ? ? ? ? 48 8B 5C D0 ? FF 15 ? ? ? ? 48 8B 03 48 8B 48 08*/

View File

@ -128,7 +128,7 @@ void MOD_ProcessPakQueue()
{
return;
}
if ((*(unsigned __int8(__fastcall**)(__int64))(*(_QWORD*)*(_QWORD*)g_pFileSystem_Stdio + 696i64))(*(_QWORD*)g_pFileSystem_Stdio) && !*dword_1634F445C)
if ((*(unsigned __int8(__fastcall**)(__int64))(*(_QWORD*)*(_QWORD*)g_pFileSystem_Stdio + 696i64 - FSTDIO_OFS))(*(_QWORD*)g_pFileSystem_Stdio) && !*dword_1634F445C)
{
v1 = &*off_141874660;
for (i = 0; i < 5; ++i)
@ -241,8 +241,8 @@ void MOD_ProcessPakQueue()
JT_ReleaseFifoLock((JobFifoLock_s*)&*qword_167ED7BE0);
v23 = *qword_1671061C8;
}
(*(void(__fastcall**)(__int64, __int64))(*(_QWORD*)*(_QWORD*)g_pFileSystem_Stdio + 656i64))(*(_QWORD*)g_pFileSystem_Stdio, 256i64);
(*(void(__fastcall**)(__int64, __int64))(*(_QWORD*)*(_QWORD*)g_pFileSystem_Stdio + 648i64))(*(_QWORD*)g_pFileSystem_Stdio, v23);
(*(void(__fastcall**)(__int64, __int64))(*(_QWORD*)*(_QWORD*)g_pFileSystem_Stdio + 656i64 - FSTDIO_OFS))(*(_QWORD*)g_pFileSystem_Stdio, 256i64);
(*(void(__fastcall**)(__int64, __int64))(*(_QWORD*)*(_QWORD*)g_pFileSystem_Stdio + 648i64 - FSTDIO_OFS))(*(_QWORD*)g_pFileSystem_Stdio, v23);
}
}
}
@ -264,7 +264,11 @@ void MOD_ProcessPakQueue()
v21 = *(_DWORD*)v15;
if (*(_DWORD*)v15 != -1)
{
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
v22 = 232i64 * (v21 & 0x1FF);
#else
v22 = 184i64 * (v21 & 0x1FF);
#endif
if (*(_DWORD*)((char*)&*g_pLoadedPakInfo + v22) != v21 || ((*(_DWORD*)((char*)&*g_pLoadedPakInfo + v22 + 4) - 9) & 0xFFFFFFFB) != 0)
{
*byte_16709DDDF = 0; return;

View File

@ -1,4 +1,9 @@
#pragma once
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2)
constexpr int64_t FSTDIO_OFS = 16i64;
#else
constexpr int64_t FSTDIO_OFS = 0i64;
#endif
inline CMemory p_CollisionBSPData_LinkPhysics;
inline auto CollisionBSPData_LinkPhysics = p_CollisionBSPData_LinkPhysics.RCast<uint64_t(*)(void* thisptr)>();

View File

@ -20,14 +20,14 @@ public:
return v_MutexInternal_ReleaseWaiter(this);
}
uint32 GetOwnerId(void) const { return m_ownerID; }
int GetDepth(void) const { return m_depth; }
int GetAddend(void) const { return m_lAddend; }
HANDLE GetSemaphore(void) const { return m_hSemaphore; }
inline uint32 GetOwnerId(void) const { return m_nOwnerID; }
inline int GetDepth(void) const { return m_nDepth; }
inline int GetAddend(void) const { return m_lAddend; }
inline HANDLE GetSemaphore(void) const { return m_hSemaphore; }
private:
volatile uint32_t m_ownerID;
int m_depth;
volatile uint32_t m_nOwnerID;
int m_nDepth;
volatile int m_lAddend;
HANDLE m_hSemaphore;
};