"""DIMENSION 3 SEASONS q8 (final): confirm the SeasonList deser is the SOLE populator
of the season-list vector by enumerating every call [reg+0x898] site; confirm
FUN_180174630 is the massinfo body handler; resolve atom names for the season keys.
"""
import traceback, struct
try:
    print("### all call [reg+0x898] sites (season-vector consumers) ###")
    for modrm in range(0x90, 0x98):
        pat = bytes([0xff, modrm]) + struct.pack("<i", 0x898)
        for h in find_all(pat, blocks=(".text",)):
            f = fm.getFunctionContaining(addr(h))
            print("   ", hex(h), "in", f.getName() if f else "?")

    print("\n### FUN_180174630 identity: does it parse the massinfo body? head ###")
    d = dec(0x180174630)
    print("LEN", len(d))
    # print the first 1500 chars to see the member dispatch + userInfo/settings/season calls
    print(d[:1800])

    print("\n### resolve atom names via fut_atoms.tsv ###")
    import os as _os
    tsv = "/home/alex/Documents/OpenFUT/fifa17-recon/docs/fut_atoms.tsv"
    want = {0x2ad,0x354,0x35e,0x24b,0x27b,0xdd,0xdc,0x253,0x1b8,0x330,0x11c,0x2d4}
    try:
        with open(tsv) as f:
            for line in f:
                parts = line.rstrip("\n").split("\t")
                if len(parts) >= 2:
                    try:
                        v = int(parts[0], 0)
                    except ValueError:
                        try:
                            v = int(parts[1], 0)
                        except (ValueError, IndexError):
                            continue
                        parts = [parts[1], parts[0]] + parts[2:]
                    if v in want:
                        print("   ", hex(v), parts[1] if len(parts) > 1 else parts)
    except Exception as e:
        print("  tsv err", e)

    sys.stdout.flush()
    os._exit(0)
except Exception:
    traceback.print_exc()
    sys.stdout.flush()
    os._exit(0)
