DAISY: how a Windows .exe is rewritten into a 64-bit Mac app

9 steps · about 9 h 55 min · Intermediate

  1. Binary translation (reference, Wikipedia, 15 min)

    It sets out the core idea first: static (ahead-of-time) translation versus dynamic translation, which is the choice DAISY makes.

  2. Architecture 1001 - Intel x86-64 Assembly (video, OpenSecurityTraining2 (via Class Central), 5 h 50 min)

    A rewriter has to read instructions, registers, the stack and control flow, so this teaches the machine code you will be rewriting. Watch the early lectures first and skim the rest.

  3. A dive into the PE file format - PE file structure - Part 1: Overview (article, 0xRick's Blog, 25 min)

    The Windows .exe is the input. Its headers, sections and entry point are what any rewriter parses first.

  4. The Anatomy of a Mach-O: Structure, Code Signing, and PAC (article, Olivia A. Gallucci, 25 min)

    The Mac app is the output. This covers its header, load commands and 64-bit format, plus code signing, which a generated app needs.

  5. Universal binary (reference, Wikipedia, 10 min)

    It explains why old 32-bit Mac apps stopped launching and how Apple's multi-architecture binaries came about.

  6. Tech Notes: Theseus, a static Windows emulator (blog, neugierig.org, 30 min)

    A readable, concrete example of translating an .exe ahead of time into a native program that calls reimplemented Windows APIs, which is close to DAISY's approach.

  7. Deterministic Fully-Static Whole-Binary Translation without Heuristics (article, arXiv, 1 h)

    It is a research view of the hard parts, such as finding all the code and handling calls between translated and native code. Skim the intro and design sections.

  8. Nancy Drew issues · Issue #6 · nullmoth/daisy (article, GitHub, 20 min)

    A real bug report. It shows code discovery failing on an .exe with no relocation table, and the patch that fixes it. It makes the theory concrete before you open the source.

  9. nullmoth/daisy (repo, GitHub (NullMoth Systems), 1 h)

    Last, read the real project: a full-source C tool that rewrites Windows programs, old 32-bit Mac apps and VST plug-ins into 64-bit Mac apps. By now its pieces (pe2mac, runtime, m32) should make sense.