Skip to content
Permalink
Browse files

Revert previous 4 commits

This reverts commit 6375d89.
Revert "protect pAssociationArray instead of iIDOffset member (CreateAnimAssocGroups hook)"

This reverts commit 91ca881.
Revert "Addendum to previous commit"

This reverts commit 48878af.
Revert "Set HW Breakpoint to find cause of Misc13 crash"

This reverts commit e8ddd2c.
  • Loading branch information...
codenulls committed Jun 29, 2019
1 parent 6375d89 commit 48f2c99c9bc511a3ea8473371f8b59ad933a21eb
@@ -50,8 +50,6 @@ unsigned long CMultiplayerSA::ADDR_GotFocus;

unsigned long CMultiplayerSA::FUNC_CPlayerInfoBase;

std::array<unsigned int, 3> CMultiplayerSA::arrGroupsToProtect = {{ANIM_GROUP_BBBAT_1, ANIM_GROUP_MUSCULAR, ANIM_GROUP_SWORD_1}};

#define HOOKPOS_FxManager_CreateFxSystem 0x4A9BE0
#define HOOKPOS_FxManager_DestroyFxSystem 0x4A9810

@@ -288,11 +288,10 @@ class CMultiplayerSA : public CMultiplayer
DWORD GetLastStaticAnimationID() { return m_dwLastStaticAnimID; }
DWORD GetLastAnimArrayAddress() { return m_dwLastAnimArrayAddress; }

CVector m_vecAkimboTarget;
bool m_bAkimboTargetUp;
static char* ms_PlayerImgCachePtr;
static std::array<unsigned int, 3> arrGroupsToProtect;
bool m_bBadDrivebyHitboxesDisabled;
CVector m_vecAkimboTarget;
bool m_bAkimboTargetUp;
static char* ms_PlayerImgCachePtr;
bool m_bBadDrivebyHitboxesDisabled;

private:
bool m_bSuspensionEnabled;
@@ -13,7 +13,6 @@
#include "../game_sa/CTasksSA.h"
#include "../game_sa/CAnimBlendSequenceSA.h"
#include "../game_sa/CAnimBlendHierarchySA.h"
#include "../game_sa/CAnimBlendAssocGroupSA.h"

void CPlayerPed__ProcessControl_Abort();

@@ -1464,10 +1463,10 @@ void OnMY_CAnimBlendNode_GetCurrentTranslation(CAnimBlendNodeSAInterface* pInter
// Crash will occur at offset 0xCFCD6
OnCrashAverted(32);
CAnimBlendAssociationSAInterface* pAnimAssoc = pInterface->pAnimBlendAssociation;
CAnimBlendSequenceSAInterface* pAnimSequence = pInterface->pAnimSequence;
CAnimBlendHierarchySAInterface* pAnimHierarchy = pAnimAssoc->pAnimHierarchy;
CAnimBlendSequenceSAInterface* pAnimSequence = pInterface->pAnimSequence;
CAnimBlendHierarchySAInterface* pAnimHierarchy = pAnimAssoc->pAnimHierarchy;

bool bSequenceExistsInHierarchy = false;
bool bSequenceExistsInHierarchy = false;
CAnimBlendSequenceSAInterface* pAnimHierSequence = pAnimHierarchy->pSequences;
for (int i = 0; i < pAnimHierarchy->usNumSequences; i++)
{
@@ -1480,12 +1479,13 @@ void OnMY_CAnimBlendNode_GetCurrentTranslation(CAnimBlendNodeSAInterface* pInter
}

LogEvent(588, "GetCurrentTranslation", "Incorrect endKeyFrameIndex",
SString("m_endKeyFrameId = %d | pAnimAssoc = %p | GroupID = %d | AnimID = %d | \
SString("m_endKeyFrameId = %d | pAnimAssoc = %p | GroupID = %d | AnimID = %d | \
pAnimSeq = %p | BoneID = %d | BoneHash = %u | \
pAnimHier = %p | HierHash = %u | SequenceExistsInHierarchy: %s",
pInterface->m_endKeyFrameId, pAnimAssoc, pAnimAssoc->sAnimGroup, pAnimAssoc->sAnimID, pAnimSequence, pAnimSequence->m_boneId,
pAnimSequence->m_hash, pAnimHierarchy, pAnimHierarchy->uiHashKey, bSequenceExistsInHierarchy ? "Yes" : "No"),
588);
pInterface->m_endKeyFrameId, pAnimAssoc, pAnimAssoc->sAnimGroup, pAnimAssoc->sAnimID,
pAnimSequence, pAnimSequence->m_boneId, pAnimSequence->m_hash, pAnimHierarchy,
pAnimHierarchy->uiHashKey, bSequenceExistsInHierarchy ? "Yes" : "No"), 588);

}

// Hook info
@@ -1521,67 +1521,6 @@ void _declspec(naked) HOOK_CAnimBlendNode_GetCurrentTranslation()
}
}

//////////////////////////////////////////////////////////////////////////////////////////
//
// CAnimManager_CreateAnimAssocGroups
//
// Protect `pAssociationsArray` member of specific anim groups (CAnimBlendAssocGroupSAInterface)
// from corruption by placing a WRITE operation breakpoint on its address.
//
//////////////////////////////////////////////////////////////////////////////////////////
void __cdecl OnMY_CAnimManager_CreateAnimAssocGroups_Protect(CAnimBlendAssocGroupSAInterface* pGroupInterface)
{
static std::set<unsigned int> setOfGroupBreakpointsAdded;

void* ppAssociationsArray = reinterpret_cast<void*>(&pGroupInterface->pAssociationsArray);
for (auto groupID : CMultiplayerSA::arrGroupsToProtect)
{
if (pGroupInterface->groupID == groupID && !MapContains(setOfGroupBreakpointsAdded, groupID))
{
HANDLE mainThread = OpenThread(THREAD_ALL_ACCESS, TRUE, SharedUtil::GetMainThreadId());
assert(mainThread != NULL);

SetHardwareBreakpoint(mainThread, HWBRK_TYPE_WRITE, HWBRK_SIZE_4, ppAssociationsArray);

CloseHandle(mainThread);

setOfGroupBreakpointsAdded.insert(groupID);

LogEvent(511, "Breakpoint", "Hardware Breakpoint set on WRITE access",
SString("groupID: %u | pGroupInterface: %#.8x, ppAssociationsArray = %#.8x | pAssociationsArray: %p", groupID, pGroupInterface,
ppAssociationsArray, pGroupInterface->pAssociationsArray),
511);
return;
}
}

LogEvent(512, "GroupLoaded", "Anim group loaded",
SString("groupID: %u | pGroupInterface: %#.8x, ppAssociationsArray = %#.8x | pAssociationsArray: %p", pGroupInterface->groupID, pGroupInterface,
ppAssociationsArray, pGroupInterface->pAssociationsArray),
512);
}

// Hook info
#define HOOKPOS_CAnimManager_CreateAnimAssocGroups_Protect 0x4D3DAD
#define HOOKSIZE_CAnimManager_CreateAnimAssocGroups_Protect 6
DWORD RETURN_CAnimManager_CreateAnimAssocGroups_Protect = 0x4D3DB3;
void _declspec(naked) HOOK_CAnimManager_CreateAnimAssocGroups_Protect()
{
_asm
{
pushad
add eax, esi
push eax
call OnMY_CAnimManager_CreateAnimAssocGroups_Protect
add esp, 0x4
popad

mov ecx, [esi + eax + 8]
xor edi, edi
jmp RETURN_CAnimManager_CreateAnimAssocGroups_Protect
}
}

//////////////////////////////////////////////////////////////////////////////////////////
//
// Setup hooks for CrashFixHacks
@@ -1627,7 +1566,6 @@ void CMultiplayerSA::InitHooks_CrashFixHacks()
EZHookInstallChecked(CVolumetricShadowMgr_Update);
EZHookInstallChecked(CAnimManager_CreateAnimAssocGroups);
EZHookInstall(CAnimBlendNode_GetCurrentTranslation);
EZHookInstall(CAnimManager_CreateAnimAssocGroups_Protect);
EZHookInstall(CTaskComplexCarSlowBeDraggedOut_CreateFirstSubTask);
EZHookInstallChecked(printf);
EZHookInstallChecked(RwMatrixMultiply);
@@ -547,46 +547,6 @@ void _declspec(naked) HOOK_CTaskSimpleRunNamedAnimDestructor()
}
}

void _cdecl OnCAnimBlendAssocGroupDestructor(CAnimBlendAssocGroupSAInterface* pGroupInterface)
{
for (auto groupID : CMultiplayerSA::arrGroupsToProtect)
{
if (pGroupInterface->groupID == groupID)
{
void* ppAssociationsArray = reinterpret_cast<void*>(&pGroupInterface->pAssociationsArray);
LogEvent(519, "groupUnload", "Unloading anim group",
SString("groupID: %u | pGroupInterface: %#.8x, ppAssociationsArray = %#.8x | pAssociationsArray: %p", groupID, pGroupInterface,
ppAssociationsArray, pGroupInterface->pAssociationsArray),
519);

// crash it to get the stack
void* pPointer = nullptr;
assert(pPointer != nullptr);
}
}
}

// Hook info
#define HOOKPOS_CAnimBlendAssocGroupDestructor 0x4CE1D0
#define HOOKSIZE_CAnimBlendAssocGroupDestructor 6
DWORD RETURN_CAnimBlendAssocGroupDestructor = 0x4CE1D6;
void _declspec(naked) HOOK_CAnimBlendAssocGroupDestructor()
{
_asm
{
pushad
push ecx
call OnCAnimBlendAssocGroupDestructor
add esp, 0x4
popad

push esi
mov esi, ecx
mov ecx, [esi + 0x4]
jmp RETURN_CAnimBlendAssocGroupDestructor
}
}

//////////////////////////////////////////////////////////////////////////////////////////
//
// Set handlers
@@ -634,7 +594,6 @@ void CMultiplayerSA::SetGameRunNamedAnimDestructorHandler(GameRunNamedAnimDestru
//////////////////////////////////////////////////////////////////////////////////////////
void CMultiplayerSA::InitHooks_HookDestructors()
{
EZHookInstall(CAnimBlendAssocGroupDestructor);
EZHookInstall(CTaskSimpleRunNamedAnimDestructor);
EZHookInstall(CObjectDestructor);
EZHookInstall(CVehicleDestructor);
@@ -39,7 +39,6 @@
#include "..\game_sa\CEntitySA.h"
#include "..\game_sa\CBuildingSA.h"
#include "..\game_sa\CPedSA.h"
#include "..\game_sa\CAnimBlendAssocGroupSA.h"
#include "..\game_sa\common.h"
#include "..\core\CCrashDumpWriter.h"

0 comments on commit 48f2c99

Please sign in to comment.
You can’t perform that action at this time.