Skip to content

Commit

Permalink
Fix locallight not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Oct 22, 2022
1 parent 0b3e553 commit 31a66d9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Plugins/CaptionMod/privatefuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,12 @@ void Client_FillAddress(void)
{
g_bIsCounterStrike = true;

#define CS_CZ_GETTEXTCOLOR_SIG "\x8B\x44\x24\x04\x83\xE8\x03\x2A\x2A\x48"
if (1)
{
#define CS_CZ_GETTEXTCOLOR_SIG "\x8B\x44\x24\x04\x83\xE8\x03\x2A\x2A\x48"
gPrivateFuncs.GetTextColor = (decltype(gPrivateFuncs.GetTextColor))
g_pMetaHookAPI->SearchPattern(g_dwClientBase, g_dwClientSize, CS_CZ_GETTEXTCOLOR_SIG, Sig_Length(CS_CZ_GETTEXTCOLOR_SIG));
Sig_FuncNotFound(GetTextColor);
//Sig_FuncNotFound(GetTextColor);
}

#define CS_CZ_GETCLIENTCOLOR_SIG "\x0F\xBF\x2A\x2A\x2A\x2A\x2A\x2A\x48\x83\xF8\x03\x77\x2A\xFF\x24"
Expand Down
50 changes: 46 additions & 4 deletions Plugins/Renderer/gl_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3309,12 +3309,54 @@ void R_FillAddress(void)

if (1)
{
const char sigs[] = "\x8B\x04\x2A\x2A\x2A\x2A\x2A\x2A\xD9\x00";
typedef struct
{
int ZerodReg;
}R_LightStrength_Context;

R_LightStrength_Context ctx = { 0 };

g_pMetaHookAPI->DisasmRanges(gRefFuncs.R_LightStrength, 0x100, [](void *inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) {
auto ctx = (R_LightStrength_Context *)context;
auto pinst = (cs_insn *)inst;

if (!ctx->ZerodReg &&
pinst->id == X86_INS_XOR &&
pinst->detail->x86.op_count == 2 &&
pinst->detail->x86.operands[0].type == X86_OP_REG &&
pinst->detail->x86.operands[1].type == X86_OP_REG &&
pinst->detail->x86.operands[0].reg == pinst->detail->x86.operands[1].reg)
{
ctx->ZerodReg = pinst->detail->x86.operands[0].reg;
}
else if (ctx->ZerodReg &&
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.scale == 4 &&
pinst->detail->x86.operands[1].mem.index == ctx->ZerodReg &&
(PUCHAR)pinst->detail->x86.operands[1].mem.disp > (PUCHAR)g_dwEngineDataBase &&
(PUCHAR)pinst->detail->x86.operands[1].mem.disp < (PUCHAR)g_dwEngineDataBase + g_dwEngineDataSize)
{
//C7 05 60 66 00 08 01 00 00 00 mov scr_drawloading, 1
locallight = (decltype(locallight))pinst->detail->x86.operands[1].mem.disp;
}

if (locallight)
return TRUE;

addr = (DWORD)Search_Pattern_From(gRefFuncs.R_LightStrength, sigs);
Sig_AddrNotFound(locallight);
if (address[0] == 0xCC)
return TRUE;

if (pinst->id == X86_INS_RET)
return TRUE;

return FALSE;
}, 0, &ctx);

locallight = *(decltype(locallight) *)(addr + 3);
Sig_VarNotFound(locallight);
}
}

Expand Down

0 comments on commit 31a66d9

Please sign in to comment.