"""ADVERSARIAL BATCH 6 -- pin the service behind GUID 0xed84b11/0xed84b12 whose
vtable slot +0x270 is the OTHER gate on TO_TRADE_PILE. If that gate is an online /
transfer-market-availability check it may block the menu even with untradeable:false,
which is the single biggest risk to the headline recommendation.

METHOD: the class that implements an interface references the same GUID constant when
it registers. Scan .text for the 4-byte immediates and report every function.
CONTROL: the same scan for 0x10c80b95 (the CardInventory-ish service FUN_18003e370
uses) and 0xed80ed8 -- if those come back with registrars and 0xed84b11 does not, the
absence is about this GUID and not about the scan.
"""
import traceback, struct

OUT = "/tmp/claude-1000/-home-alex-Documents-OpenFUT/8e521ca1-ca3e-4138-bb96-df1744dd1d30/scratchpad/cards/adv2/q6_raw.txt"
try:
    f = open(OUT, "w")

    def P(*a):
        f.write(" ".join(str(x) for x in a) + "\n")

    for g in (0xED84B11, 0xED84B12, 0x10C80B95, 0x10C80B96, 0xED80ED8):
        pat = struct.pack("<I", g)
        hits = find_all(pat, blocks=(".text", ".rdata", ".data"))
        fns = {}
        for h in hits:
            fn = fm.getFunctionContaining(addr(h))
            k = fn.getName() if fn else "(data)"
            fns.setdefault(k, []).append(h)
        P("### GUID %#x : %d byte hits in %d functions" % (g, len(hits), len(fns)))
        for k, v in sorted(fns.items()):
            P("    %-24s %s" % (k, [hex(x) for x in v]))
        P()

    P("=" * 25, "the registrar bodies", "=" * 25)
    seen = set()
    for g in (0xED84B11, 0xED84B12):
        for h in find_all(struct.pack("<I", g), blocks=(".text",)):
            fn = fm.getFunctionContaining(addr(h))
            if fn is None:
                continue
            e = int(fn.getEntryPoint().getOffset())
            if e in seen:
                continue
            seen.add(e)
            P("### %s @%#x" % (fn.getName(), e))
            P(dec(e))
            P()

    f.close()
    print("WROTE", OUT)
except Exception:
    traceback.print_exc()
