Skip to content

Commit

Permalink
fix sigs for 3266
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Feb 5, 2024
1 parent 2d4d9e1 commit 13db417
Showing 1 changed file with 78 additions and 73 deletions.
151 changes: 78 additions & 73 deletions Plugins/VGUI2Extension/GameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3000,110 +3000,117 @@ void ServerBrowser_FillAddress(void)

if (g_iEngineType != ENGINE_GOLDSRC_HL25)
{
typedef struct
const char sigs1[] = "servers/%sPage_Filters.res";
auto sPage_Filters_String = g_pMetaHookAPI->SearchPattern(ServerBrowserRdataBase, ServerBrowserRdataSize, sigs1, sizeof(sigs1) - 1);
if (!sPage_Filters_String)
sPage_Filters_String = g_pMetaHookAPI->SearchPattern(ServerBrowserDataBase, ServerBrowserDataSize, sigs1, sizeof(sigs1) - 1);
if (sPage_Filters_String)
{
std::set<PVOID> insnSets;
typedef struct
{
std::set<PVOID> insnSets;

int instCount_push270h;
int instCount_push270h;

}OnButtonToggledSearchContext;
}OnButtonToggledSearchContext;

OnButtonToggledSearchContext ctx = { };
OnButtonToggledSearchContext ctx = { };

char pattern[] = "\x68\x16\x01\x00\x00\x68\x70\x02\x00";
auto CBaseGamesPage_OnButtonToggled_SetSizeImm = g_pMetaHookAPI->SearchPattern(ServerBrowserTextBase, ServerBrowserTextSize, pattern, sizeof(pattern) - 1);
Sig_VarNotFound(CBaseGamesPage_OnButtonToggled_SetSizeImm);
char pattern[] = "\x68\x16\x01\x00\x00\x68\x70\x02\x00";
auto CBaseGamesPage_OnButtonToggled_SetSizeImm = g_pMetaHookAPI->SearchPattern(ServerBrowserTextBase, ServerBrowserTextSize, pattern, sizeof(pattern) - 1);
Sig_VarNotFound(CBaseGamesPage_OnButtonToggled_SetSizeImm);

//gPrivateFuncs.CServerBrowserDialog_ctor = (decltype(gPrivateFuncs.CServerBrowserDialog_ctor))g_pMetaHookAPI->ReverseSearchFunctionBegin(DialogServerBrowser_Call, 0x800);
//Sig_FuncNotFound(CServerBrowserDialog_ctor);
//gPrivateFuncs.CServerBrowserDialog_ctor = (decltype(gPrivateFuncs.CServerBrowserDialog_ctor))g_pMetaHookAPI->ReverseSearchFunctionBegin(DialogServerBrowser_Call, 0x800);
//Sig_FuncNotFound(CServerBrowserDialog_ctor);

g_pMetaHookAPI->DisasmRanges(CBaseGamesPage_OnButtonToggled_SetSizeImm, 0x80, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) {
g_pMetaHookAPI->DisasmRanges(CBaseGamesPage_OnButtonToggled_SetSizeImm, 0x80, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) {

auto pinst = (cs_insn*)inst;
auto ctx = (OnButtonToggledSearchContext*)context;
auto pinst = (cs_insn*)inst;
auto ctx = (OnButtonToggledSearchContext*)context;

if (address[0] == 0xE8 && instCount <= 8)
{
gPrivateFuncs.ServerBrowser_Panel_SetSize = (decltype(gPrivateFuncs.ServerBrowser_Panel_SetSize))GetCallAddress(address);
if (address[0] == 0xE8 && instCount <= 8)
{
gPrivateFuncs.ServerBrowser_Panel_SetSize = (decltype(gPrivateFuncs.ServerBrowser_Panel_SetSize))GetCallAddress(address);

ctx->insnSets.emplace(address);
ctx->insnSets.emplace(address);

return TRUE;
}
return TRUE;
}

if (address[0] == 0xCC)
return TRUE;
if (address[0] == 0xCC)
return TRUE;

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

return FALSE;
return FALSE;

}, 0, &ctx);
}, 0, &ctx);

Sig_FuncNotFound(ServerBrowser_Panel_SetSize);
Sig_FuncNotFound(ServerBrowser_Panel_SetSize);

char pattern2[] = "\x68\x16\x01\x00\x00";
PUCHAR SearchBegin = (PUCHAR)ServerBrowserTextBase;
PUCHAR SearchLimit = (PUCHAR)ServerBrowserTextBase + ServerBrowserTextSize;
while (SearchBegin < SearchLimit)
{
PUCHAR pFound = (PUCHAR)Search_Pattern_From_Size(SearchBegin, SearchLimit - SearchBegin, pattern2);
if (pFound)
char pattern2[] = "\x68\x16\x01\x00\x00";
PUCHAR SearchBegin = (PUCHAR)ServerBrowserTextBase;
PUCHAR SearchLimit = (PUCHAR)ServerBrowserTextBase + ServerBrowserTextSize;
while (SearchBegin < SearchLimit)
{
if (ctx.insnSets.find(pFound) == ctx.insnSets.end())
PUCHAR pFound = (PUCHAR)Search_Pattern_From_Size(SearchBegin, SearchLimit - SearchBegin, pattern2);
if (pFound)
{
ctx.instCount_push270h = 0;
g_pMetaHookAPI->DisasmRanges(pFound, 0x80, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) {

auto pinst = (cs_insn*)inst;
auto ctx = (OnButtonToggledSearchContext*)context;
if (ctx.insnSets.find(pFound) == ctx.insnSets.end())
{
ctx.instCount_push270h = 0;
g_pMetaHookAPI->DisasmRanges(pFound, 0x80, [](void* inst, PUCHAR address, size_t instLen, int instCount, int depth, PVOID context) {

if (!ctx->instCount_push270h &&
pinst->id == X86_INS_PUSH &&
pinst->detail->x86.op_count == 1 &&
pinst->detail->x86.operands[0].type == X86_OP_IMM &&
pinst->detail->x86.operands[0].imm == 0x270)
{
ctx->instCount_push270h = instCount;
}
auto pinst = (cs_insn*)inst;
auto ctx = (OnButtonToggledSearchContext*)context;

if (address[0] == 0xE8 && instCount > ctx->instCount_push270h && instCount <= ctx->instCount_push270h + 5)
{
PVOID calladdr = GetCallAddress(address);
if (!ctx->instCount_push270h &&
pinst->id == X86_INS_PUSH &&
pinst->detail->x86.op_count == 1 &&
pinst->detail->x86.operands[0].type == X86_OP_IMM &&
pinst->detail->x86.operands[0].imm == 0x270)
{
ctx->instCount_push270h = instCount;
}

if (gPrivateFuncs.ServerBrowser_Panel_SetSize == calladdr)
if (address[0] == 0xE8 && instCount > ctx->instCount_push270h && instCount <= ctx->instCount_push270h + 5)
{
ctx->insnSets.emplace(address);
return TRUE;
PVOID calladdr = GetCallAddress(address);

if (gPrivateFuncs.ServerBrowser_Panel_SetSize == calladdr)
{
ctx->insnSets.emplace(address);
return TRUE;
}
}
}

if (address[0] == 0xCC)
return TRUE;
if (address[0] == 0xCC)
return TRUE;

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

return FALSE;
return FALSE;

}, 0, &ctx);
}
}, 0, &ctx);
}

SearchBegin = pFound + Sig_Length(pattern2);
SearchBegin = pFound + Sig_Length(pattern2);
}
else
{
break;
}
}
else

for (auto insn : ctx.insnSets)
{
break;
auto addr = (PUCHAR)insn;
int rva = (PUCHAR)CBaseGamesPage_OnButtonToggled_ServerBrowser_Panel_SetSize - (addr + 5);
g_pMetaHookAPI->WriteMemory(addr + 1, &rva, 4);
}
}

for (auto insn : ctx.insnSets)
{
auto addr = (PUCHAR)insn;
int rva = (PUCHAR)CBaseGamesPage_OnButtonToggled_ServerBrowser_Panel_SetSize - (addr + 5);
g_pMetaHookAPI->WriteMemory(addr + 1, &rva, 4);
}
}

if (1)
Expand Down Expand Up @@ -3206,8 +3213,6 @@ void ServerBrowser_FillAddress(void)

Sig_FuncNotFound(ServerBrowser_KeyValues_ctor);
Sig_FuncNotFound(ServerBrowser_KeyValues_LoadFromFile);

//gPrivateFuncs.CBaseGamesPage_OnButtonToggled = (decltype(gPrivateFuncs.CBaseGamesPage_OnButtonToggled))((PUCHAR)ServerBrowserBase + 0x3450);
}

gPrivateFuncs.ServerBrowser_Panel_Init = (decltype(gPrivateFuncs.ServerBrowser_Panel_Init))VGUI2_FindPanelInit(ServerBrowserTextBase, ServerBrowserTextSize);
Expand Down

0 comments on commit 13db417

Please sign in to comment.