#!/usr/bin/env python3 """Read-only heading evidence and bounded projection of OMT2 vector::angles. This module executes no original code. --emit-probe emits a separate component probe for the existing isolated copied-DLL reference-capture harness. """ from functools import lru_cache from pathlib import Path import argparse import hashlib import json import math import struct from pe_inspect import PE EXE_SHA256 = 'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8' DLL_SHA256 = '3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943' ANGLE_EXPORT = '?angles@OMedia3DVector@@QAEXAAF0@Z' UNITS_TO_DEGREES = 0.02197265625 def f32(value): return struct.unpack(' len(pe.data): raise ValueError('source range outside file') return pe.data[offset:offset + length] def evidence(executable, dll): pe, omt = PE(executable), PE(dll) for binary, expected in [(pe, EXE_SHA256), (omt, DLL_SHA256)]: if hashlib.sha256(binary.data).hexdigest() != expected: raise ValueError('source hash mismatch') imported = next(i for i in pe.imports() if int(i['iat'], 16) == 0x48d108) exported = next(e for e in omt.exports() if e['name'] == ANGLE_EXPORT) if imported['name'] != ANGLE_EXPORT or int(exported['va'], 16) != 0x1001fda0: raise ValueError('heading import/export mismatch') guards = [ (pe, 0x4270bf, 'ff1508d14800'), (pe, 0x4270d7, '0fbf542416'), (pe, 0x4270df, 'd82550d94800'), (pe, 0x4270ed, 'd80db4e54800'), (pe, 0x4270f7, 'f6c4410f8510020000'), (pe, 0x42711a, 'd80550d94800'), (pe, 0x427132, 'f6c4010f84d5010000'), (omt, 0x1001fdf5, '668b0c4d301e1410'), (omt, 0x1001fe32, '8b542414f7d825ff3f0000668902'), (omt, 0x10104e13, '80cc0c'), (omt, 0x10104e1d, 'df7df4'), (omt, 0x100edcaf, 'e850710100'), (omt, 0x100edd0d, '6689ae08800200'), ] for binary, va, pattern in guards: if _read(binary, va, len(pattern) // 2).hex() != pattern: raise ValueError(f'instruction mismatch at {va:#x}') for binary, va, fmt, expected in [ (pe, 0x48d950, ' #include #include #include #include typedef void (__attribute__((thiscall)) *Angles)(const float*,short*,short*); int main(void) { setbuf(stdout,NULL); HMODULE h=LoadLibraryA("Z:\\work\\game\\OMT2.dll"); if(!h){fprintf(stderr,"LoadLibrary failed %lu\n",GetLastError());return 2;} Angles angles=(Angles)GetProcAddress(h,"?angles@OMedia3DVector@@QAEXAAF0@Z"); if(!angles)return 3; float vectors[][4]={{0,0,0,0},{0,0,1,0},{-1,0,0,0},{0,0,-1,0},{1,0,0,0}, {-1,0,1,0},{-1,0,-1,0},{1,0,-1,0},{1,0,1,0}, {1,100,1000,0},{-1,-100,1000,0},{1000,0,1,0},{-1000,0,1,0}, {.1234567f,88,.7654321f,0},{-99.1f,-20,15.7f,0}}; for(unsigned i=0;i