Skip to content

Commit 3d4d2ae

Browse files
ujicoswidberg
andcommitted
fix(xlive): port debugger attach PEVerifyHash bypass
src: https://github.com/widberg/xlive-research/ Co-Authored-By: widberg <contact@widberg.me>
1 parent edbd86b commit 3d4d2ae

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

src/component/engine/patches/xlive.cpp

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,41 @@ namespace xlive
368368
patch_isdebugger(base, sz);
369369

370370
// -------------------------------------------------------------------
371-
// Fix 2: NOP PEB.BeingDebugged pointer corruption
371+
// Fix 2: xlive-research PEVerifyHash bypass (xlive 3.5.95.0)
372+
//
373+
// Upstream patch:
374+
// 000F36B3: 8B FF 55 8B EC -> 31 C0 C2 0C 00
375+
//
376+
// This returns success from PEVerifyHash without touching the xlive
377+
// exports or replacing the dll, so normal GFWL/xlive behavior keeps
378+
// flowing through the retail implementation.
379+
{
380+
constexpr std::uintptr_t rva = 0x000F36B3;
381+
static const uint8_t expected[] = { 0x8B, 0xFF, 0x55, 0x8B, 0xEC };
382+
static const uint8_t ret_success[] = { 0x31, 0xC0, 0xC2, 0x0C, 0x00 };
383+
384+
if (rva + sizeof(expected) <= sz)
385+
{
386+
auto* const target = base + rva;
387+
if (!std::memcmp(target, expected, sizeof(expected)))
388+
{
389+
mem_write(target, ret_success, sizeof(ret_success));
390+
dbg("patch [F2 PEVerifyHash]: applied at +0x%X", static_cast<unsigned>(rva));
391+
++patch_count;
392+
}
393+
else if (!std::memcmp(target, ret_success, sizeof(ret_success)))
394+
{
395+
dbg("patch [F2 PEVerifyHash]: already applied");
396+
}
397+
else
398+
{
399+
dbg("patch [F2 PEVerifyHash]: signature mismatch at +0x%X", static_cast<unsigned>(rva));
400+
}
401+
}
402+
}
403+
404+
// -------------------------------------------------------------------
405+
// Fix 3: NOP PEB.BeingDebugged pointer corruption
372406
{
373407
static const uint8_t pat[] = {
374408
0x81,0xEF,0x35,0x01,0x00,0x00,
@@ -550,4 +584,4 @@ namespace xlive
550584

551585
#ifdef DEBUG
552586
//REGISTER_COMPONENT(xlive::component)
553-
#endif
587+
#endif

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace
142142
{
143143
#ifdef DEBUG
144144
configure_debug_crt();
145-
//xlive::apply_early(); // attemp at patching xlive FIRST, before a debugger can attach
145+
xlive::apply_early(); // Patch xlive before attaching a debugger.
146146
//MessageBoxA(NULL, "ATTACH DEBUGGER NOW", "DEBUG", MB_DEFBUTTON1);
147147
#endif
148148

0 commit comments

Comments
 (0)