"""Find static assignments/usages of completion status 999 (0x3e7)."""

patterns = []
for modrm in (0x40, 0x41, 0x42, 0x43, 0x46, 0x47, 0x80, 0x81, 0x82, 0x83, 0x86, 0x87):
    patterns.append(bytes((0xC7, modrm, 0x1C, 0xE7, 0x03, 0x00, 0x00)))
patterns.extend((bytes.fromhex("b8 e7 03 00 00"), bytes.fromhex("b9 e7 03 00 00"),
                 bytes.fromhex("ba e7 03 00 00"), bytes.fromhex("41 b8 e7 03 00 00")))

seen = set()
for pattern in patterns:
    for hit in find_all(pattern):
        f = func(hit)
        entry = int(f.getEntryPoint().getOffset()) if f else 0
        key = (entry, hit)
        if key in seen:
            continue
        seen.add(key)
        print("\n=== pattern %s hit %#x function %#x %s ===" %
              (pattern.hex(), hit, entry, f.getName() if f else "?"))
        if f:
            print(dec(f, 240)[:10000])
            print("callers", callers(f)[:80])
