Analysis
Triage Windows game executable for static recompilation feasibility
- Analysis:
- Wrote and staged a PE triage tool and DXBC scanner, described key issues and workflow concisely.
- Conclusion:
- If GoW.exe (and DLLs) show no packer/DRM and RenderDoc/CrossOver run OK, static recompilation + D3D11-on-Metal is viable; otherwise stop.
Tools: list_files
Run it yourselfSince you'll be building it on a Mac, here's how I'd approach it. It's the same method as your NBA 2K18 port (static recompilation to C), just bigger, with x86-64 instead of ARM32 and DirectX instead of GLES.
- Find the upper limit first (1–2 days) Run the game on the Mac with CrossOver or Apple's Game Porting Toolkit before writing any code.
If it plays well there, Apple Silicon can handle the game, and you've also learned which DirectX and Windows features it really uses. If it struggles on an M-series Mac, an iPad version will struggle too. Stop there or scale the plan down.
- Look at what you're dealing with Inspect the Windows executable (GoW.exe) and anything the game installs alongside it:
Copy protection and packing: check for DRM or a packer. If the code is encrypted or obfuscated, static translation dies right away. What it imports: list the Windows functions it calls (kernel32, user32, dxgi/d3d11, xinput, Steam API, audio middleware like Wwise, compression libraries like Oodle or Bink). That list is the Windows surface you'll have to rewrite yourself. Shader format: DX11 games ship shaders as DXBC. Apple's Metal Shader Converter only reads DXIL, so you'd need DXBC → SPIR-V (vkd3d-shader or dxbc-spirv) → Metal (SPIRV-Cross). GPU features: capture a frame with RenderDoc on a Windows PC. Check whether it uses geometry shaders, tessellation, stream-out or UAV-heavy compute. Each one is a hard problem on Metal. 2. Pick how the code runs Approach Works on iPad? Problem Wine + x86 emulator (Box64/FEX) + DXVK/MoltenVK Only with JIT enabled through debugger tricks Wine doesn't run on iOS, JIT is fragile on recent iPadOS, two translation layers cost speed D3DMetal (part of Apple's porting toolkit) No macOS-only, and its license forbids redistributing it Static recompilation of x86-64 → C → arm64 Yes, no JIT needed Huge one-time job Static recompilation is the only option that's stable on an iPad. You've already done it once.
- Build the recompiler Disassemble the executable and find every function: start from the exception tables (.pdata, which most x64 Windows code has), exports, vtables, and the targets of indirect calls. Convert each function to C, or to LLVM IR if you want better optimisation. Plan for: SSE/AVX instructions: map them to ARM NEON. Flags and x87: x86 condition flags and old floating-point code need exact emulation. Jump tables and indirect jumps: resolve them where you can, and fall back to a lookup table at runtime. Windows exception handling: support the game's crash handlers, or stub them out. Fix up memory: the game expects its own image base, so either keep a big memory region at the same layout or translate addresses.
- Rewrite the Windows layer (the biggest part) Basics: threads, memory, files (pointed at your game-data folder), timing, synchronisation primitives. Input: XInput → Apple's Game Controller framework. Window and video: DXGI/swapchain → a Metal layer you draw into. Graphics: write your own D3D11-on-Metal layer that only covers what the RenderDoc captures show the game using. That's less work than a general one. Audio: XAudio2 or WASAPI → Apple's AVAudioEngine. Steam API: stub it out.
- Get it running on macOS first, then iPadOS Build a native ARM Mac app first. You get debuggers, no sandbox, and plenty of memory. Get to gameplay there. Then move to iPadOS: Ask for the increased-memory-limit entitlement. Copy your own Steam game files into the app's folder through the Files app. Never put game files inside the IPA. Sign it with your developer account. Lower settings for the iPad's GPU: drop resolution and turn quality down, the same way you've done it in your other ports.
- Realistic expectations Scale: this is several times the work of NBA 2K18. The executable is larger, it's x86 instead of ARM32, and the graphics layer is DirectX 11 instead of GLES. Hardware: an M-series iPad Pro is the realistic minimum. Effort: count it in months, not weeks. Legal: keep it to personal use with your own copy, and never distribute the IPA or the game data. Go/no-go: do steps 0 and 1 first. If the game is protected/packed, or step 0 runs badly on your Mac, stop there before writing the recompiler.
Plan's sound — right order, right go/no-go gates, and static recompilation is indeed the only path that doesn't live or die on JIT entitlements. Before you drop the exe in, a few corrections and sharpeners, then I've staged the step-1 tooling in the workspace.
Corrections / things that will bite
- Scale changes the method, not just the effort. A 2018-era AAA exe is 30–80 MB with tens of thousands of functions. Nobody hand-converts that; the recompiler must be automated (like UnleashedRecomp/N64Recomp: emit one C function per discovered function, function-pointer table for indirect branches).
.pdatagives you ~90% of function boundaries for free on x64 — that's your discovery backbone; recurse from there (vtables, reloc targets, call targets). - Map the image at its preferred ImageBase with
MAP_FIXED. Then base relocations mostly vanish and absolute addresses in the code just work. You still need a mini PE loader to bind imports to your own re implementations. - The
gssegment is the hidden boss. x64 code reaches the TEB throughgs:[0x30]etc. (TLS slots, stack info, SEH chain). You need a per-thread fake TEB block with the right layout. Same family of problems:__chkstk,__CxxFrameHandler3, SEH unwinding. Decide up front: emulate TEB, stub crash handlers. - Flags: don't emulate EFLAGS eagerly — lazy/deferred flags computation is what keeps the SSE→NEON translation fast.
- D3D11 is COM, so your graphics layer is literally a set of vtables the recompiled code calls through. That's actually good news — it's a clean ABI boundary. RenderDoc's capture decides scope: geometry shaders (no Metal equivalent — needs compute emulation), D3D11-style hull/domain (Metal tessellation is shaped differently), stream-out (compute or CPU). One cheap proxy: if GPTK/CrossOver translates the game cleanly, those features almost certainly aren't there — that's your step-0 signal too.
- Middlewares linked statically are free wins. If Wwise or Oodle is compiled into the exe (look for
AK::,Wwise,oo2corestrings, not just imports), the recompiler carries them over and you skip reimplementing them. The triage script checks both. - vkd3d-shader can emit DXIL from DXBC (recent versions, experimental) — that can collapse your DXBC→SPIR-V→Metal chain to DXBC→DXIL→Metal. Worth testing before committing to the three-hop pipeline.
What I've staged (workspace is empty, so I wrote the step-1 triage tools now)
tools/pe_triage.py— pure-python PE parser, no deps: machine/ImageBase/entry, per-section entropy (packer detection at >7.2), full import table with middleware classification,.pdatafunction count, exports, TLS callbacks, DIR64 relocation count, overlay size, and string probes for Denuvo/VMProtect/Themida/Steam DRM/Oodle/Wwise/Bink/AK::.tools/dxbc_scan.py— walks a game-data tree, finds everyDXBCcontainer, and counts shader models seen (cs_5_0→ compute,hs/ds→ tessellation,gs→ geometry shaders). Caveat: if shaders live inside a compressed .pak, this sees nothing — that's itself a finding.
The DRM point stays your stop condition as written: if the Steam wrapper or Denuvo shows up, the plaintext code doesn't exist without circumvention, and that's both a technical dead end for static translation and a legal no-go — I can help analyze structure but not unpack it.
What to give me: drop GoW.exe here (plus steam_api64.dll and any game DLLs, or just a dir /s /b of the install folder) and tell me which title — 2018 vs. Ragnarök changes what I expect to find. First command will be:
python3 tools/pe_triage.py GoW.exe
and we'll know within a minute whether to proceed or stop.
