feat(ess): reconstruct+verify wave 4 5 functions

This commit is contained in:
ulw-execute committed 2026-11-29 10:51:35 -05:00
1 parent 19955cc67d
commit a144f5e2ed
5 files changed
+104 -5

No files matched your search

+5 -5
View File
@@ -226131,7 +226131,7 @@
"owning_module_guess": "unknown",
"rva": "0x00022b60",
"signature": "undefined FUN_10022b60(void)",
"status": "orig"
"status": "verified"
},
{
"callees": [
@@ -228346,7 +228346,7 @@
"owning_module_guess": "unknown",
"rva": "0x00025b10",
"signature": "undefined FUN_10025b10(void)",
"status": "orig"
"status": "verified"
},
{
"callees": [],
@@ -228360,7 +228360,7 @@
"owning_module_guess": "unknown",
"rva": "0x00025b20",
"signature": "undefined FUN_10025b20(void)",
"status": "orig"
"status": "verified"
},
{
"callees": [
@@ -231786,7 +231786,7 @@
"owning_module_guess": "unknown",
"rva": "0x00029b3b",
"signature": "undefined FUN_10029b3b(void)",
"status": "orig"
"status": "verified"
},
{
"callees": [
@@ -236850,7 +236850,7 @@
"owning_module_guess": "unknown",
"rva": "0x00035354",
"signature": "undefined FUN_10035354(void)",
"status": "orig"
"status": "verified"
},
{
"callees": [
+68
View File
@@ -473,6 +473,71 @@ def prove_wave3_nonvacuity(image: PeImage, log: list[str]) -> None:
log.append("NON-VACUITY (wave 3): PASS (injected reconstruction bugs caught)")
# wave 4: constant-zero return + same-image pointer returns (Todo-23 channel).
_WAVE4_PTR_RETURNS = (
(0x25B10, "ptr_55650", 0x55650),
(0x25B20, "ptr_557a0", 0x557A0),
(0x29B3B, "ptr_53470", 0x53470),
(0x35354, "ptr_540c0", 0x540C0),
)
def prove_wave4_ret0(image: PeImage, log: list[str], exe: Path = RECON) -> None:
eax, _, _ = emulate(image, 0x22B60)
assert eax == 0, eax
r = struct.unpack("<I", run_recon(exe, "ret0_22b60", b""))[0]
eax_equal("0x22b60 sub_10022b60", eax, r, log, "EAX=0x0")
def prove_wave4_ptr_returns(image: PeImage, log: list[str], exe: Path = RECON) -> None:
for rva, mode, want in _WAVE4_PTR_RETURNS:
eax, _, _ = emulate(image, rva)
norm = (eax - image.image_base) & 0xFFFFFFFF
assert norm == want, (mode, hex(eax), hex(norm))
recon = struct.unpack("<I", run_recon(exe, mode, b""))[0]
eax_equal(f"{rva:#x} ess_{mode}", norm, recon, log, f"ptr_rva={norm:#x}")
def prove_wave4_nonvacuity(image: PeImage, log: list[str]) -> None:
source = SRC.read_text(encoding="utf-8")
cases = [
("22b60 ret0->1",
"std::uint32_t GK_CDECL sub_10022b60() { return 0u; }",
"std::uint32_t GK_CDECL sub_10022b60() { return 1u; }",
0x22B60, "ret0_22b60", None),
("25b10 ptr+1",
"std::uint32_t GK_CDECL sub_10025b10() { return kEssPtr55650Rva; }",
"std::uint32_t GK_CDECL sub_10025b10() { return kEssPtr55650Rva + 1u; }",
0x25B10, "ptr_55650", 0x55650),
("25b20 ptr+1",
"std::uint32_t GK_CDECL sub_10025b20() { return kEssPtr557a0Rva; }",
"std::uint32_t GK_CDECL sub_10025b20() { return kEssPtr557a0Rva + 1u; }",
0x25B20, "ptr_557a0", 0x557A0),
("29b3b ptr+1",
"std::uint32_t GK_CDECL sub_10029b3b() { return kEssPtr53470Rva; }",
"std::uint32_t GK_CDECL sub_10029b3b() { return kEssPtr53470Rva + 1u; }",
0x29B3B, "ptr_53470", 0x53470),
("35354 ptr+1",
"std::uint32_t GK_CDECL sub_10035354() { return kEssPtr540c0Rva; }",
"std::uint32_t GK_CDECL sub_10035354() { return kEssPtr540c0Rva + 1u; }",
0x35354, "ptr_540c0", 0x540C0),
]
for label, old, new, rva, mode, want in cases:
bug = source.replace(old, new)
assert bug != source, f"injection anchor not found: {label}"
with tempfile.TemporaryDirectory() as td:
exe = build_variant(bug, td)
eax, _, _ = emulate(image, rva)
orig_val = eax if want is None else (eax - image.image_base) & 0xFFFFFFFF
r = struct.unpack("<I", run_recon(exe, mode, b""))[0]
orig, ref = RunResult(eax=orig_val, st0=None), RunResult(eax=r, st0=None)
report = diff(orig, ref)
assert report.verdict is Verdict.DIFF, (label, orig, ref)
log.append(f" injected bug [{label}] -> {report.verdict.value} "
f"{report.differences[0]}")
log.append("NON-VACUITY (wave 4): PASS (injected reconstruction bugs caught)")
def prove_injected_bug(image: PeImage, log: list[str]) -> None:
source = SRC.read_text(encoding="utf-8")
real = struct.pack("<II", 0xFFFFFFFF, 0xFFFFFFFF)
@@ -590,9 +655,12 @@ def main() -> int:
prove_wave3_ret0(image, log)
prove_wave3_retthis(image, log)
prove_wave3_fields(image, log)
prove_wave4_ret0(image, log)
prove_wave4_ptr_returns(image, log)
prove_injected_bug(image, log)
prove_wave2_nonvacuity(image, log)
prove_wave3_nonvacuity(image, log)
prove_wave4_nonvacuity(image, log)
log.append("ALL DIFFERENTIALS PASS")
print("\n".join(log))
return 0
+5
View File
@@ -228,6 +228,11 @@ int main(int argc, char **argv) {
if (mode == "field_8c90") return RunThisByte<gk::ess::sub_10008c90>(in);
if (mode == "field_35338") return RunThisDword<gk::ess::sub_10035338>(in);
if (mode == "field_3533c") return RunThisDword<gk::ess::sub_1003533c>(in);
if (mode == "ret0_22b60") return RunRetU32<gk::ess::sub_10022b60>();
if (mode == "ptr_55650") return RunRetU32<gk::ess::sub_10025b10>();
if (mode == "ptr_557a0") return RunRetU32<gk::ess::sub_10025b20>();
if (mode == "ptr_53470") return RunRetU32<gk::ess::sub_10029b3b>();
if (mode == "ptr_540c0") return RunRetU32<gk::ess::sub_10035354>();
std::fprintf(stderr, "unknown mode %s\n", argv[1]);
return 2;
}
+12
View File
@@ -210,5 +210,17 @@ std::uint32_t GK_THISCALL sub_1003533c(const std::uint8_t *self) {
return *reinterpret_cast<const std::uint32_t *>(self + 8);
}
// rva=0x10022b60 (orig FUN_10022b60): xor eax,eax; ret. Returns 0 (cdecl, no args).
std::uint32_t GK_CDECL sub_10022b60() { return 0u; }
// rva=0x10025b10/0x10025b20/0x10029b3b/0x10035354 (orig FUN_*): each is
// `mov eax, <same-image pointer>; ret`, returning an absolute pointer into the
// module's own image (a static table / vftable slot). Reconstructed as the
// offset-normalized same-image rva (Todo-23 channel).
std::uint32_t GK_CDECL sub_10025b10() { return kEssPtr55650Rva; }
std::uint32_t GK_CDECL sub_10025b20() { return kEssPtr557a0Rva; }
std::uint32_t GK_CDECL sub_10029b3b() { return kEssPtr53470Rva; }
std::uint32_t GK_CDECL sub_10035354() { return kEssPtr540c0Rva; }
}
}
+14
View File
@@ -71,5 +71,19 @@ std::uint8_t GK_THISCALL sub_10008c90(const std::uint8_t *self);
std::uint32_t GK_THISCALL sub_10035338(const std::uint8_t *self);
std::uint32_t GK_THISCALL sub_1003533c(const std::uint8_t *self);
// wave 4 reconstructions (constant-zero return + same-image pointer returns).
// Each pointer return is an offset-normalized same-image pointer (Todo-23
// channel): the original does `mov eax, <absolute image pointer>; ret`.
inline constexpr std::uint32_t kEssPtr55650Rva = 0x00055650u;
inline constexpr std::uint32_t kEssPtr557a0Rva = 0x000557a0u;
inline constexpr std::uint32_t kEssPtr53470Rva = 0x00053470u;
inline constexpr std::uint32_t kEssPtr540c0Rva = 0x000540c0u;
std::uint32_t GK_CDECL sub_10022b60();
std::uint32_t GK_CDECL sub_10025b10();
std::uint32_t GK_CDECL sub_10025b20();
std::uint32_t GK_CDECL sub_10029b3b();
std::uint32_t GK_CDECL sub_10035354();
}
}