From 08d718a90d3f6437eebcddd0ec3ca8079a26ef60 Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Sat, 12 Oct 2024 16:13:38 +0800 Subject: [PATCH] Fix "Could not found GameStudioRenderer_StudioCalcAttachments_vftable_index" error in HLMMOD --- Plugins/BulletPhysics/exportfuncs.cpp | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Plugins/BulletPhysics/exportfuncs.cpp b/Plugins/BulletPhysics/exportfuncs.cpp index c8f0091d..56a8ef67 100644 --- a/Plugins/BulletPhysics/exportfuncs.cpp +++ b/Plugins/BulletPhysics/exportfuncs.cpp @@ -877,12 +877,16 @@ void EngineStudio_FillAddress(int version, struct r_studio_interface_s** ppinter std::set branches; std::vector walks; int index; + bool bFoundD4h; + bool bFoundD8h; }StudioCalcAttachments_SearchContext; StudioCalcAttachments_SearchContext ctx; ctx.base = (void*)vftable[i]; ctx.index = i; + ctx.bFoundD4h = false; + ctx.bFoundD8h = false; ctx.max_insts = 1000; ctx.max_depth = 16; @@ -922,6 +926,46 @@ void EngineStudio_FillAddress(int version, struct r_studio_interface_s** ppinter } } + if (address < (PUCHAR)ctx->base + 0x60) + { + if (!ctx->bFoundD4h) + { + if ((pinst->id == X86_INS_MOV || pinst->id == X86_INS_CMP) && + pinst->detail->x86.op_count == 2 && + pinst->detail->x86.operands[0].type == X86_OP_MEM && + pinst->detail->x86.operands[0].mem.base != 0 && + pinst->detail->x86.operands[0].mem.disp == 0xD4) + { + ctx->bFoundD4h = true; + } + else if ((pinst->id == X86_INS_MOV || pinst->id == X86_INS_CMP) && + pinst->detail->x86.op_count == 2 && + pinst->detail->x86.operands[1].type == X86_OP_MEM && + pinst->detail->x86.operands[1].mem.base != 0 && + pinst->detail->x86.operands[1].mem.disp == 0xD4) + { + ctx->bFoundD4h = true; + } + } + if (!ctx->bFoundD8h) + { + if (pinst->id == X86_INS_MOV && + pinst->detail->x86.op_count == 2 && + pinst->detail->x86.operands[0].type == X86_OP_REG && + pinst->detail->x86.operands[1].type == X86_OP_MEM && + pinst->detail->x86.operands[1].mem.base != 0 && + pinst->detail->x86.operands[1].mem.disp == 0xD8) + { + ctx->bFoundD8h = true; + } + } + + if (ctx->bFoundD4h && ctx->bFoundD8h) + { + gPrivateFuncs.GameStudioRenderer_StudioCalcAttachments_vftable_index = ctx->index; + } + } + if (gPrivateFuncs.GameStudioRenderer_StudioCalcAttachments_vftable_index) return TRUE;