#!/usr/bin/env python3 """Exercise the actual loader ADT parser on the host; no UEFI allocation claim.""" import hashlib import importlib.util import json from pathlib import Path import struct import subprocess ROOT=Path(__file__).resolve().parents[1] out=ROOT/'build/cpu-desktop/window-parser';out.mkdir(parents=True,exist_ok=True) p=ROOT/'drivers/DarwinBoot/DarwinBootPkg/Driver/DarwinBoot.c' s=p.read_text();start=s.index('STATIC\nBOOLEAN\nAdtNode (');end=s.index('\nSTATIC\nBOOLEAN\nValidTrustCaches',start) spec=importlib.util.spec_from_file_location('adt',ROOT/'scripts/make-sheng-adt.py') m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m) prelude='''#include #include #include #include #include #include "WindowSize.h" typedef uint8_t UINT8;typedef uint32_t UINT32;typedef uint64_t UINT64; typedef size_t UINTN;typedef int BOOLEAN;typedef char CHAR8; #define STATIC static #define CONST const #define TRUE 1 #define FALSE 0 #define MAX_UINTN SIZE_MAX #define ALIGN_VALUE(a,b) (((a)+(b)-1)&~((b)-1)) #define AsciiStrCmp strcmp #define CompareMem memcmp static const void *ScanMem8(const void *p,size_t n,int v){return memchr(p,v,n);} static UINT32 U32(const void *p){UINT32 v;memcpy(&v,p,4);return v;} static UINT64 U64(const void *p){UINT64 v;memcpy(&v,p,8);return v;} ''' code=prelude+s[start:end]+'\nint main(void){\n' checks=[] for value in [0,0xfffffff,0x10000000,0xe0000000,0x100000000,0x130000000,0x200000000,0x200200000,0x130001000,0xffffffffffffffff]: for variant in ['chosen','duplicate','misplaced']: props=[('darwinboot-memory-size',struct.pack('