"""Tests for tools/rtti_scan.py covering synthetic MSVC RTTI structures. python -I tests/test_rtti_scan.py Tests synthetic MSVC TypeDescriptors, CompleteObjectLocators, ClassHierarchyDescriptors, BaseClassDescriptors, and vtable slot recovery against synthetic PE images. No game data or proprietary binaries are used. """ import json import os import shutil import struct import subprocess import sys import tempfile import unittest sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "tools")) import rtti_scan ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) TOOL = os.path.join(ROOT, "tools", "rtti_scan.py") def make_synthetic_pe(text_bytes: bytes = b"", rdata_bytes: bytes = b"", image_base: int = 0x140000000) -> bytes: """Build a minimal valid 64-bit PE image in memory with .text and .rdata sections.""" sec_align = 0x1000 file_align = 0x200 def align_up(x: int, a: int) -> int: return (x + a - 1) & ~(a - 1) text_len = max(align_up(len(text_bytes), sec_align), sec_align) text_data = text_bytes.ljust(text_len, b"\xc3") rdata_len = max(align_up(len(rdata_bytes), sec_align), sec_align) rdata_data = rdata_bytes.ljust(rdata_len, b"\x00") text_rva = 0x1000 rdata_rva = text_rva + text_len size_of_image = rdata_rva + rdata_len dos = b"MZ" + b"\x00" * 0x3A + struct.pack(" vtable at 0x2200 (2 slots) rdata[0x1F8:0x200] = struct.pack(" vtable at 0x2220 (1 slot) rdata[0x218:0x220] = struct.pack("