# VERIFICATION pass 3: resolve the address discrepancies in the suffix-string
# census and get the FROM address / ref type of each single-xref claim.
addrs = [0x1802262c0, 0x18022dd08, 0x180226700, 0x1802264e0, 0x18022e6d4,
         0x180226ec0, 0x18022e908, 0x180227300, 0x1802270e0, 0x18022bd88,
         0x180221728, 0x180225840, 0x18021e508, 0x18021e820, 0x180222320,
         0x1802252c8, 0x1802254c0, 0x180225638]
print("== what string actually lives at each address ==")
for a in addrs:
    try:
        print("  %#x  %r" % (a, rd_str(a, 60)))
    except Exception as e:
        print("  %#x  ERR %s" % (a, e))

print()
print("== from-address + reftype for the 'single xref' strings ==")
for s in ["/squadBuildingSets", "/loan/players", "/stats/staff", "ut/%s/sbs",
          "ut/%s/draft/mode", "/sets", "/setId/%d/challenges", "/challenge/%d",
          "/challenge/%d/squad", "/sets/tag", "/consumables/%s"]:
    for h in find_all(s.encode() + b"\x00", blocks=(".rdata", ".data", ".text")):
        for (fr, ty, fn, en) in xrefs_to(h):
            blk = mem.getBlock(addr(fr))
            print("  %-22s str@%#x  from %#x [%s] %s  fn=%s" %
                  (s, h, fr, blk.getName() if blk else "?", ty, fn))

print()
print("== vtable block around 0x1801f5968 (RANK 10 adjacency claim) ==")
for off in range(-5, 4):
    a = 0x1801f5968 + off * 8
    q = qword(a)
    f = fm.getFunctionAt(addr(q)) if 0x180000000 <= q < 0x181000000 else None
    print("   %#x  %#018x  %s" % (a, q, f.getName() if f else ""))
