Skip to main content

apply_patch

Function apply_patch 

Source
pub unsafe fn apply_patch(
    table: JumpTable,
) -> Result<Vec<*const ()>, PatchError>
Expand description

Apply the patch using a given jump table.

§Safety

This function is unsafe because it detours existing functions in memory. This is wildly unsafe, especially if the JumpTable is malformed. Only run this if you know what you’re doing.

If the pointers are incorrect, function type signatures will be incorrect and the program will crash, sometimes in a way that requires a restart of your entire computer. Be careful.

§Warning

This function will load the library and thus allocates. In cannot be used when the program is stopped (ie in a signal handler).

§Returns

On success, returns the list of host (pre-patch) function pointers that were rewritten by this patch — already shifted to the live ASLR slide, so they can be compared against fn_name as *const () values held in Whisker’s runtime component_owners map. The Strategy C hot-reload path (Whisker A6+) uses this list to find live component owners whose body is now stale and re-mount them.