"""Exact-build compatibility inspection and closed-game update reconciliation. No executable is ever modified. A reviewed profile is necessary but not sufficient: the executable, stock scripts, import hooks, WNB signature/relative targets and owned dependency chain must agree. Static agreement is not live ABI qualification. """ import hashlib import json import os from pathlib import Path import re import struct import time from . import support from .debug_journal import durable_json from .pe_image import PEImage PROFILE_PATH = support.ROOT / 'native/compatibility.json' REGISTRATION = ( 'BA F8 00 00 00 48 8D 4D F0 41 B8 10 00 00 00 E8 ?? ?? ?? ?? ' '48 8B 7D F0 33 D2 4C 8B 45 F8 48 8B CF E8 ?? ?? ?? ?? ' '48 85 FF 74 ?? E8 ?? ?? ?? ?? 48 8D 15 ?? ?? ?? ?? ' '48 8B C8 E8 ?? ?? ?? ?? 4C 8D 05 ?? ?? ?? ?? ' '89 45 10 48 8D 55 10 48 8B CF E8 ?? ?? ?? ?? ' '48 8B F8 EB ?? 48 8B FB E8 ?? ?? ?? ?? 48 8B D7 48 8B C8 E8 ?? ?? ?? ??') STRING_HELPER = ( '8B 15 ?? ?? ?? ?? 33 C9 41 B9 0E 00 00 00 89 54 24 ?? ' '41 B8 01 00 00 00 E8 ?? ?? ?? ?? 44 8B 44 24 ?? 48 8B C8 ' '48 8B 15 ?? ?? ?? ?? 48 89 44 24 ?? E8 ?? ?? ?? ??') OLD_STRING_HELPER = STRING_HELPER.replace( '41 B8 01 00 00 00 E8', '41 B8 01 00 00 00 48 C7 44 24 20 00 00 00 00 E8') CALL_OFFSETS = dict(alloc=15, memset=33, name_pool=43, add_name=58, function_ctor=80, script_system=93, register_global=104) REGISTRAR_PROLOGUE = bytes.fromhex('48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20') REQUIRED_IMPORTS = { 'xinput9_1_0.dll': ['XInputGetState'], 'ws2_32.dll': [2], # bind is imported by ordinal; PathInput explicitly supports ordinal 2. 'user32.dll': ['CreateWindowExA', 'GetForegroundWindow', 'SetCursorPos', 'ClipCursor', 'SetCapture', 'SetForegroundWindow', 'GetAsyncKeyState'], } def sha(data): return hashlib.sha256(data).hexdigest() def relative(image, site, displacement, length): return site + length + struct.unpack('