Most cursed way to embed a Windows XML manifest

52 points careye 6 comments

I have a crate that can embed an XML manifest in a Windows executable from a build script by building an object file from scratch, but I realised a while ago that there’s a way to do this with no build scripts, no dependencies and no shame. The linked file does this with global_asm!, and should work with MSVC or GNU build tools and even when cross-compiling.

Remarkably, neither the build script nor the inline assembly need the unsafe keyword anywhere.

I learnt a lot about Windows executable file formats to get to this point, without any LLM help, so I hope reading this makes someone else as happy as I was to write it.