Files
WoW-Hybrid-gateway/ops/inspect_windows_ui.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

22 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Query ordinary Win32 controls without hooks or reading any field contents."""
import json,os,subprocess
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
def inspect():
out=ROOT/'build/ui-metadata';out.mkdir(exist_ok=True)
source=ROOT/'ops/windows_ui_metadata.c';exe=out/'ui-metadata.exe';obj=out/'ui-metadata.obj'
if not exe.exists() or exe.stat().st_mtime<source.stat().st_mtime:
subprocess.run(['clang','--target=x86_64-pc-windows-msvc','-I/usr/include/wine/windows','-I/usr/include/wine/msvcrt','-O2','-ffreestanding','-fno-stack-protector','-c',str(source),'-o',str(obj)],check=True)
subprocess.run(['lld-link','/entry:ui_metadata_start','/subsystem:console','/nodefaultlib','/timestamp:0','/out:'+str(exe),str(obj),'/usr/lib/wine/x86_64-windows/libkernel32.a','/usr/lib/wine/x86_64-windows/libuser32.a'],check=True)
prefix=ROOT/'runtime/native-wine-prefix'
if not (prefix/'gateway-private-prefix.json').exists():raise RuntimeError('Read-only probe requires the existing disposable prefix')
env=dict(os.environ,WINEPREFIX=str(prefix),WINEDEBUG='-all')
for key in ('LD_PRELOAD','GW_NATIVE_BOOTSTRAP','GW_NATIVE_EXPECTED_EXE','GW_NATIVE_REGISTER'):env.pop(key,None)
with (ROOT/'runtime/windows-ui-metadata.log').open('wb') as log:
result=subprocess.run(['wine',str(exe)],env=env,capture_output=False,stdout=subprocess.PIPE,stderr=log,timeout=15,check=True)
rows=[json.loads(line) for line in result.stdout.decode().splitlines() if line.startswith('{')]
(ROOT/'runtime/windows-ui-metadata.json').write_text(json.dumps(rows,indent=2)+'\n')
print(json.dumps({'window_metadata':rows,'standard_edit_controls':sum(r['standard_edit'] for r in rows),'field_contents_read':False}))
if __name__=='__main__':inspect()