Expand description
Attach to a CoreCLR game’s already-running runtime from a native mod loaded
before the runtime starts (via LD_PRELOAD on Linux, or an injected DLL on
Windows).
CoreCLR has no public “attach to the running runtime” C API:
coreclr_create_delegate needs the host handle and domain id the game’s host
created, and the runtime initialises only once per process. So we capture
them as the game creates them — inline-hooking the loader to see coreclr
arrive (it is loaded late and resolved dynamically, so symbol interposition
misses it), then inline-hooking coreclr_initialize to read its output.
The loader differs per platform (dlopen / LoadLibraryExW); everything
else, including the coreclr_initialize hook, is shared. Requires x86_64,
where the inline-hook trampoline works. With the captured ClrHost,
ClrHost::attach builds a Runtime bound to that CLR.
Structs§
- ClrHost
- A handle to the game’s running CoreCLR, captured from
coreclr_initialize.
Functions§
- on_
clr_ init - Runs
callbackonce the game’s CoreCLR host has been captured. Call it from a mod’s entry point (which the loader runs before the game starts the runtime).