"""Locate event 0x753c users and category-listener registration/removal paths."""

import struct

EVENT = 0x753C
NOTIFIER = 0x18017AA80

print("=== immediate/data occurrences of event 0x753c ===")
seen = set()
for hit in find_all(struct.pack("<I", EVENT)):
    print("hit", hex(hit))
    owner = func(hit)
    if owner is not None:
        entry = int(owner.getEntryPoint().getOffset())
        print("   containing", hex(entry), owner.getName())
        seen.add(entry)
    for row in xrefs_to(hit):
        print("  ", row)
        if row[3]:
            seen.add(row[3])

print("\n=== decompile functions referencing event literal ===")
for entry in sorted(seen):
    print("\n--- %#x %s ---" % (entry, fname(entry)))
    print(dec(entry))

print("\n=== category request ctor/dtor and notifier neighborhood ===")
for target in (0x18017A7C0, 0x18017AA10, NOTIFIER, 0x18017AAF0, 0x18017B1C0):
    print("\n--- %#x %s ---" % (target, fname(target)))
    print("callers", callers(target))
    print("xrefs", xrefs_to(target))
