Live data from Hacker News

macOS code injection for fun and no profit (2024)

mariozechner.at

11–20 of 24 posts

Re: macOS code injection for fun and no profit (2024)

#11
post #2

I never understood how people use compiled languages for video games let alone simple GUIs. Even though I'm now competent in a few, and I have LLMs at my disposal, I fall back to electron or React Native just because it's such a pain in the ass to iterate with anything static. Native devs: what are your go to quality of live improvements?

Having a faster build step helps: I just stepped back into C recently, and I don't even want to imagine doing it without ccache and meson.

Why not ninja?

Re: macOS code injection for fun and no profit (2024)

#12

Earlier quoted context omitted.

Having a faster build step helps: I just stepped back into C recently, and I don't even want to imagine doing it without ccache and meson.

Why not ninja?

Meson uses ninja under the hood.

Re: macOS code injection for fun and no profit (2024)

#13
post #9
post #4

Earlier quoted context omitted.

what does compilation have to do with iteration speed? There's a lot of ways to get a similar feedback loop that youd get in something like react, like separating out your core gameplay loop into its own compilation unit / dll and reloading it on any changes inside your application

Yeah... that's way, way, way more complex than npm run dev

if i wrap a bunch of abstractions in a `make run` command whats the difference

Re: macOS code injection for fun and no profit (2024)

#14
post #2

I never understood how people use compiled languages for video games let alone simple GUIs. Even though I'm now competent in a few, and I have LLMs at my disposal, I fall back to electron or React Native just because it's such a pain in the ass to iterate with anything static. Native devs: what are your go to quality of live improvements?

Having a visual builder tool in an IDE like Delphi or Visual Basic or any of the others.

They ship with an existing library of components, you drag and drop them onto a blank canvas, move them around, live preview how they’ll change at different screen sizes, etc… then switch to the code to wire up all the event handlers etc.

All the iteration on design happens before you start compiling, let alone running.

Re: macOS code injection for fun and no profit (2024)

#15
post #13
post #9

Earlier quoted context omitted.

Yeah... that's way, way, way more complex than npm run dev

if i wrap a bunch of abstractions in a `make run` command whats the difference

Hot reloading is about the only difference if you're doing incremental builds.

For that, some languages are blocked by runtimes that don't support it. C can do it [0] so it's not a limitation of the static/dynamic divide.

[0] https://www.slembcke.net/blog/HotLoadC/

Re: macOS code injection for fun and no profit (2024)

#16
post #2

I never understood how people use compiled languages for video games let alone simple GUIs. Even though I'm now competent in a few, and I have LLMs at my disposal, I fall back to electron or React Native just because it's such a pain in the ass to iterate with anything static. Native devs: what are your go to quality of live improvements?

Having a visual builder tool in an IDE like Delphi or Visual Basic or any of the others. They ship with an existing library of components, you drag and drop them onto a blank canvas, move them around, live preview how they’ll change at different screen sizes, etc… then switch to the code to wire up all the event handlers etc. All the iteration on design happens before you start compiling, let alone running.

[dead]

Re: macOS code injection for fun and no profit (2024)

#17
One important thing the article glosses over: even if you sign your binary with task_for_pid, that does NOT mean you can attach to arbitrary processes on modern macOS, especially on Apple Silicon machines.

There are two separate layers people often confuse:

1) Having the task_for_pid entitlement 2) Being allowed to obtain a task port for a target process

AMFI and the kernel enforce the second one.

Even if your binary has the entitlement, the kernel will still refuse task_for_pid() for many targets (Apple platform binaries, hardened runtime processes, protected tasks, etc). In those cases the call simply fails.

Older blog posts and guides often mention disabling AMFI with a boot argument like:

    amfi_get_out_of_my_way=1
    (also seen as amfi=0x80)
Historically that worked because AMFI behavior could be weakened via NVRAM boot arguments. The flag effectively disabled entitlement validation and allowed processes to obtain otherwise restricted capabilities. :contentReference[oaicite:0]{index=0}

That advice is now largely outdated on Apple Silicon.

On modern M-series Macs the boot chain is tied into Secure Boot and the Secure Enclave. The kernel image, boot policy, and security configuration are verified during boot, and the system enforces what boot arguments are allowed to affect security policy.

In practice this means:

• You cannot freely change security-sensitive boot args from a normal system. • Boot policy is enforced by the secure boot chain. • Root does not get to override it.

Changing these policies requires booting into Recovery and modifying the machine’s security mode (Reduced Security). Even then, many AMFI protections remain active.

So the old “just set amfi_get_out_of_my_way and reboot” trick that worked on older Intel systems does not translate cleanly to Apple Silicon machines.

As a result, signing a tool with task_for_pid does not magically give you the ability to attach to arbitrary system processes on modern macOS. Without weakening the system’s boot security policy or patching the kernel, AMFI-protected processes remain non-attachable by design.

Re: macOS code injection for fun and no profit (2024)

#18
post #2

I never understood how people use compiled languages for video games let alone simple GUIs. Even though I'm now competent in a few, and I have LLMs at my disposal, I fall back to electron or React Native just because it's such a pain in the ass to iterate with anything static. Native devs: what are your go to quality of live improvements?

re, iteration: Have you encountered ImGui [0]? It's basically standard when prototyping any sort of graphical application. re, GUIs in statically typed languages: As you might expect, folks typically use a library. See Unreal Engine, raylib, godot, qt, etc. Sans that, any sort of 2D graphics library can get the job done with a little work. You might also take a look at SwiftUI if you have an Apple device. [0]: https:…

> It's basically standard when prototyping any sort of graphical application.

while imgui is super-cool, this is wildly overstating its reach or significance. It also embodies a very particular style of GUI programming (so-called "immediate mode", hence the "Im" part of the name) that is very well suited to some sorts of GUI applications and less so for others. The other style, often called "deferred mode", is the one used by most native toolkits, and it is very far from trivial to just switch an application between the two.

So, while there are plenty of good reasons to consider imgui for a graphical application, there are also many reasons why you would not want to use it too. It is very far from "standard" in terms of prototyping such apps.

Re: macOS code injection for fun and no profit (2024)

#19
post #17

One important thing the article glosses over: even if you sign your binary with task_for_pid, that does NOT mean you can attach to arbitrary processes on modern macOS, especially on Apple Silicon machines. There are two separate layers people often confuse: 1) Having the task_for_pid entitlement 2) Being allowed to obtain a task port for a target process AMFI and the kernel enforce the second one. Even if your binary…

For JIT you self-manage run protections for code segments. That isn’t free editing of arbitrary executables out of the gate, but you could develop code running in a self-harness supporting arbitrary runtime changes during development.

There would be indirection somewhere, but that could be high up the code tree, so zero impact on downstream performance sensitive code.

Re: macOS code injection for fun and no profit (2024)

#20
post #2

I never understood how people use compiled languages for video games let alone simple GUIs. Even though I'm now competent in a few, and I have LLMs at my disposal, I fall back to electron or React Native just because it's such a pain in the ass to iterate with anything static. Native devs: what are your go to quality of live improvements?

Video games generally have various editors and that is where the major iteration happens. It's not like HTML where you type some tags and refresh. Instead you have/make editors to design your levels, UIs, characters.

Most video game teams are < 30% programmers.

Post reply on HN