macOS code injection for fun and no profit (2024)

Mac dev pokes live apps like a Game Genie — comments go feral

TLDR: A Mac dev demoed live code injection that tweaks a running app’s behavior using Apple’s debugging permissions, stirring hopes of faster iteration on macOS. Comments erupted into a native-vs-web brawl, with nostalgia for Cheat Engine and calls for real Mac hot‑reload driving the hype.

A bored-on-vacation Mac dev just showed how to “poke” a running app and change what it does on the fly — swapping values and even dropping in a new function — all with Apple’s system tools and a special “debugger” permission. It’s not full hot‑reload like the beloved Windows tool Live++ (which the author gushes over), but it’s a flashy proof‑of‑concept with code on GitHub. And the crowd? Utterly divided.

On one side, frustrated builders cheered anything that speeds iteration. User fny delivered the big mood: compiled languages are “a pain” for fast changes, so folks flee to Electron or React Native — the web techs that ship desktop apps — for instant gratification. Native diehards clapped back that this is the first step toward true Mac hot‑reload glory. Meanwhile, nostalgia washed over the thread as old‑school hackers reminisced about sneaking “infinite gold” into games with Cheat Engine. One commenter called it the “gateway drug” that taught a generation to love assembly.

There were jokes, too: the author’s “Stefan hates capitalism” quip became a meme, and the “macOS boi (don’t @ me)” line got spammed with winks. A few nervously joked about Apple’s security sheriffs, but the vibe stayed giddy: live code surgery is back, baby — and everyone’s arguing over whether it’s genius or chaos.

Key Points

  • The article demonstrates building a macOS code-injection tool that attaches to a running process, edits memory, and replaces a function at runtime.
  • It uses Mach APIs (e.g., task_for_pid) and requires the com.apple.security.cs.debugger entitlement to modify another process.
  • A simple C test program repeatedly prints a function’s return value; the injector changes a global variable and replaces the function.
  • CMake is used to build both test and injection programs, with the test compiled using -O0 -g and -fpatchable-function-entry=4,0.
  • The injector is codesigned using Xcode’s codesign tool with entitlements, and the full project is available on GitHub (badlogic/macinject).

Hottest takes

"I never understood how people use compiled languages for video games let alone simple GUIs." — fny
"using Cheat Engine to inject code into GunBound" — talkvoix
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.