Skip to content

Commit

Permalink
Fix "Could not found GameStudioRenderer_StudioCalcAttachments_vftable…
Browse files Browse the repository at this point in the history
…_index" error in HLMMOD
  • Loading branch information
hzqst committed Oct 12, 2024
1 parent f92b45f commit 08d718a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Plugins/BulletPhysics/exportfuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,12 +877,16 @@ void EngineStudio_FillAddress(int version, struct r_studio_interface_s** ppinter
std::set<PVOID> branches;
std::vector<walk_context_t> 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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 08d718a

Please sign in to comment.