[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-115072":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":13,"stars7d":16,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":10,"pushedAt":23,"updatedAt":24,"readmeContent":25,"aiSummary":26,"trendingCount":15,"starSnapshotCount":15,"syncStatus":27,"lastSyncTime":28,"discoverSource":29},115072,"erebus","uwu\u002Ferebus","uwu","hijacking low-level graphics APIs to theme GPUI apps","",null,"Rust",57,1,6,0,5,45.9,"MIT License",false,"main",true,[],"2026-11-23 17:26:56","2026-11-22 22:24:17","# erebus\n\nerebus is a proof-of-concept for a theme engine that can style Rust GPUI applications *after compilation* in a non-intrusive and stable [(albeit limited)](#caveats) fashion. It does this by hooking low-level graphics APIs used by GPUI's renderer like Vulkan and D3D11.\n\n\u003Cp align=\"center\">\n    \u003Cimg src=\".\u002Fassets\u002Fdemo.png\" \u002F>\n\u003C\u002Fp>\n\n## Why?\n\nDiscord has [announced](https:\u002F\u002Fx.com\u002Fsvishnevskiy\u002Fstatus\u002F2118081920194203799) that they are switching away from using [Electron](https:\u002F\u002Fwww.electronjs.org\u002F) in their desktop client in favor of [GPUI](https:\u002F\u002Fgpui.rs). This is a great net improvement for end-users, but it does pretty much kill the client modding scene, where people would modify Discord's JavaScript and CSS to load custom themes and plugins.\n\nGiven the recent surge of interest in the Rust UI ecosystem, I expect that more apps are going to be moving away from Electron, which is going to make these kinds of modifications much harder in the long run. You can't just inject your own code into Rust binaries, since Rust doesn't have a stable ABI (and likely never will). This means that even if you do string together an elaborate client modification for one version of an app, any update could break everything at any time if someone decided to bump `rustc`.\n\n*We need a solution that can modify Rust apps without touching the Rust ABI.*\n\n## How?\n\nThe C ABI, of course! C is the lingua franca of programming languages and, [for better or for worse](https:\u002F\u002Ffaultlore.com\u002Fblah\u002Fc-isnt-a-language\u002F), has had a stable ABI for decades. Some parts of GPUI need to use the C ABI for various reasons. One of those parts is the [`Scene` system](https:\u002F\u002Fgithub.com\u002Fzed-industries\u002Fzed\u002Fblob\u002Fmain\u002Fcrates\u002Fgpui\u002Fsrc\u002Fscene.rs).\n\nIn GPUI, a `Scene` is a complete plan for how to render a given frame of the application. It is built after the element tree has been evaluated right before data is uploaded to the GPU. And... that data uses the C ABI, because it has to when passing stuff to the GPU.\n\n```rs\n#[derive(Default, Debug, Copy, Clone)]\n#[repr(C)] \u002F\u002F \u003C--- waow\n#[expect(missing_docs)]\npub struct Quad {\n    pub order: DrawOrder,\n    pub border_style: BorderStyle,\n    pub bounds: Bounds\u003CScaledPixels>,\n    pub content_mask: ContentMask\u003CScaledPixels>,\n    pub background: Background,\n    pub border_color: Hsla,\n    pub corner_radii: Corners\u003CScaledPixels>,\n    pub border_widths: Edges\u003CScaledPixels>,\n}\n```\n\nWhen a GPUI `Renderer` implementation needs to send off these scene primitives to the GPU, it places them in a *memory-mapped buffer*, which is a chunk of VRAM mapped to the address space of the CPU. Doing this process involves calling down to a lower-level graphics API. On Linux, this is done through the `wgpu` crate, which will eventually call Vulkan's `vkCmdCopyBuffer` function. On Windows, they use Direct3D 11 which has this happen in `ID3D11DeviceContext::Unmap`.\n\nerebus intercepts these low-level graphics APIs and passes these `Scene` primitives to themes to modify before they reach the GPU. On Linux this is handled via a [Vulkan Layer](https:\u002F\u002Fdocs.vulkan.org\u002Fguide\u002Flatest\u002Flayers.html) (a small shared object that hooks functions exposed by the Vulkan API). On Windows, we use a technique [DLL Hijacking](https:\u002F\u002Fwww.upguard.com\u002Fblog\u002Fdll-hijacking) to load our own `d3d11.dll` inside of the app.\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"assets\u002Fdiagram-dark.png\">\n  \u003Csource media=\"(prefers-color-scheme: light)\" srcset=\"assets\u002Fdiagram-light.png\">\n  \u003Cimg alt=\"Diagram showing the process that erebus intercepts calls from a graphcis API. From left to right: GPUI's Renderer implementation, Graphics API, Erebus, GPU\" src=\"assets\u002Fdiagram-light.png\">\n\u003C\u002Fpicture>\n\n## Theme Format\n\nThemes are sandboxed [WebAssembly binaries](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FWebAssembly) running in the [`wasmtime`](https:\u002F\u002Fwasmtime.dev\u002F) runtime. A theme exports a set of functions for modifying paint primitives which is then called by the host erebus backend. The high-level Rust API currently looks like this:\n\n```rs\nstruct ThemeThatMakesEverythingBlack;\n\nimpl Theme for ThemeThatMakesEverythingBlack {\n    const MANIFEST: Manifest = Manifest {\n        name: \"My Theme\",\n        author: \"uwu\",\n        description: \"meow\",\n        version: Version::new(1, 0, 0),\n        settings: &[],\n    };\n\n    fn init(settings: &Settings) -> Self {\n        Self {}\n    }\n\n    fn quad(&mut self, quad: &mut Quad) {\n        quad.background = Rgba::from_rgb(0, 0, 0); \u002F\u002F make every quad black\n    }\n}\n\nerebus_theme::export_theme!(ThemeThatMakesEverythingBlack);\n```\n\n`erebus` also technically supports writing themes in other languages like C through a lower-level theme ABI.\n\n## Try It\n\nFirst, compile the example theme.\n\n```sh\ncargo build -p example-theme --target=wasm32-unknown-unknown --release\n```\n\nThis will give you a theme file in `target\u002Fwasm32-unknown-unknown\u002Frelease\u002Fexample_theme.wasm`.\n\n### Linux\n\n> [!IMPORTANT]\n> You will need a GPU that supports Vulkan, otherwise `wgpu` will fallback to its OpenGL backend and erebus won't work.\n\nThe example below injects into `zed` and should color everything black. You should be able to exchange `zed` for any GPUI app and get the same result.\n\n```sh\ncargo build -p erebus-vulkan --release\nVK_LAYER_PATH=. VK_INSTANCE_LAYERS=VK_LAYER_erebus EREBUS_THEME=.\u002Ftarget\u002Fwasm32-unknown-unknown\u002Frelease\u002Ftest_theme.wasm zed\n```\n\n### Windows\n\n> [!IMPORTANT]\n> You will need an installation of [MSVC build tools](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fcpp\u002Foverview\u002Facquire-msvc?view=msvc-170) in your `Path` environment variable to build erebus for Windows, since we do some DLL shenanigans in the postbuild.\n\nFirst, make a copy of `C:\\Windows\\System32\\d3d11.dll` named `d3d11_orig.dll` and place it in the same folder as the executable you want to inject into.\n\nAfter that, build erebus with this command:\n\n```sh\ncargo build -p erebus-d3d11 --release\n```\n\nThis will generate a `d3d11.dll` file in `target\u002Frelease\u002F`, which you should also move to the same folder as your executable. Your final folder layout should contain your executable, `d3d11_orig.dll`, and the `d3d11.dll` that erebus built. You can then launch the executable with the `EREBUS_THEME` environment variable pointing to a theme binary.\n\n## Caveats\n\nBecause themes operate on drawing primitives after the element tree has been evaluated, we don't get any semantic meaning to what we're themeing. This is distinctly different from something like CSS. There are no selectors, you're just modifying a list of paint operations. You can tell if a box being rendered is blue or red, but you can't tell if it's a button or a checkbox. This is a fundamental limitation of this system (and GPUI as a whole; it has no concept of a selector). I don't have a solution for this, and I don't think there is one without touching the Rust ABI.\n","erebus 是一个用于在运行时动态主题化 Rust GPUI 桌面应用的原型工具，无需修改源码或重新编译。它通过劫持底层图形 API（如 Vulkan 和 Direct3D 11）拦截 GPUI 渲染器提交的 Scene 数据（如 Quad、Bounds 等 C ABI 兼容结构），在 GPU 提交前注入主题逻辑实现样式重写。项目基于 Rust 实现，利用 C ABI 的稳定性规避 Rust ABI 不稳定问题，适用于 Electron 迁移后需维持第三方主题能力的场景（如 Discord 替代客户端），但受限于图形层 hook 的通用性与兼容性，目前为实验性方案。",2,"2026-11-24 04:50:15","CREATED_QUERY"]