Hacker News new | ask | show | jobs
by cedws 21 days ago
How does it actually recompile, does it use an existing tool? I can’t imagine the agent combs through every routine and hand translates the assembly.
2 comments

Yes, it uses two already existing tools for the heavy lifting. Remill lifts the x86 machine code to LLVM IR, and LLVM then compiles that IR to ARM64. And no, nobody translates the assembly by hand luckily, not me nor the agent. All of these 150k functions go through this automatic chain I explained before.

What I wrote with Claude is basically everything else: custom LLVM passes, a hand-written runtime that replaces the Windows calls, a Direct3D 11 to Metal layer and the shader translation! Plus fixing the crashes one by one by iterating and playing. All details are in the Pipeline section of the README if you're interested: https://github.com/adrbn/bo2-mac#pipeline

My big question: How did you get Claude to do reverse engineering work on a game without it getting cold feet and telling you it can't do that due to breaking ToS?
Probably by starting 4 months ago.

The restraint Anthropic added to Claude to stop it from reverse engineering commercial games is recently added

Thanks.
Out of curiosity, why not adopt Wine instead of hand rolling the Win32 API layer, and also why not use MoltenVK + dxvk for rendering? Have you tried these alternatives to compare the performance?
The thing is that both Wine and DXVK would still need the original x86 code to run through Rosetta. Which is exactly what I wanted gone. Here it’s all ARM64 before the game even starts. DXVK is also a Windows DLL that reaches Vulkan through Wine so without Wine I can’t really use it. And BO2 is 32-bit, so every Windows and D3D11 call has to be adapted anyway! Going straight to Metal ended up simpler :) No benchmark against them yet but it’s on my list! There is a short explanation in the README too if you're curious: https://github.com/adrbn/bo2-mac#pipeline
Especially since Rosetta is EOL in the next macOS. I've been playing with D3DMetal recently which depends on Rosetta. I wonder if Apple are going to just drop support for this.
Uh it's a cool project for sure even if its getting hard to keep these apart and seems kind of strange to do all that targeted solely on game ... but cool!

This is very confusing to read, though:

What I wrote with Claude: [...] a hand-written runtime

To me you have to pick one or the other. Claude has no hands.

Haha fair. I meant written from scratch, not taken from Wine. Claude did the typing, I did the steering and the playtesting :)
Well, ask Claude to fix that sentence then.
> Remill lifts each function to LLVM IR, a chain of our own passes rewrites that IR, and the result is linked with a Win32 runtime written by hand, whose Direct3D 11 is drawn by Metal. There is no Wine and no JIT: the game runs as native code, in one process. About 150,000 functions are translated across the three executables. Only the short sequences that the copy protection hides run in a small x86 interpreter, and so does any code the translation missed, so a hole is built to cost speed rather than crash the game.