From 5547834da9543827f3023619ae6c4cb2474bf949 Mon Sep 17 00:00:00 2001 From: Timoteo Rider Date: Thu, 26 Nov 2026 14:48:54 -0600 Subject: [PATCH] Simplify the hosted Rust detour API --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- README.md | 2 +- crates/highfleet-patchy-client/Cargo.toml | 2 +- crates/highfleet-patchy-client/src/lib.rs | 15 +-------------- crates/highfleet-patchy-client/src/tests.rs | 2 +- tests/fixtures/patchy-mod/src/lib.rs | 2 +- 7 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17d418a..af879d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -387,7 +387,7 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "patchy-code" version = "0.2.0" -source = "git+https://github.com/logdot/patchy-rs.git?rev=84993c490f7db47e915d7e0b4270eb3f36f614de#84993c490f7db47e915d7e0b4270eb3f36f614de" +source = "git+https://github.com/logdot/patchy-rs.git?rev=19e4f77b8987329fc46cfe6c886f11e4e67528a6#19e4f77b8987329fc46cfe6c886f11e4e67528a6" dependencies = [ "thiserror 1.0.69", ] @@ -395,7 +395,7 @@ dependencies = [ [[package]] name = "patchy-rs" version = "0.2.0" -source = "git+https://github.com/logdot/patchy-rs.git?rev=84993c490f7db47e915d7e0b4270eb3f36f614de#84993c490f7db47e915d7e0b4270eb3f36f614de" +source = "git+https://github.com/logdot/patchy-rs.git?rev=19e4f77b8987329fc46cfe6c886f11e4e67528a6#19e4f77b8987329fc46cfe6c886f11e4e67528a6" dependencies = [ "log", "mmap-rs", diff --git a/Cargo.toml b/Cargo.toml index a46acee..a890658 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ libc = "0.2.149" libloading = "0.8" log = "0.4.*" highfleet-mod-api = { path = "crates/highfleet-mod-api" } -patchy = { package = "patchy-rs", git = "https://github.com/logdot/patchy-rs.git", rev = "84993c490f7db47e915d7e0b4270eb3f36f614de" } +patchy = { package = "patchy-rs", git = "https://github.com/logdot/patchy-rs.git", rev = "19e4f77b8987329fc46cfe6c886f11e4e67528a6" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" sha2 = "0.10.*" diff --git a/README.md b/README.md index 8f0cdbb..c607a7c 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ manifest and call `patchy::export_patchy!()` once at the crate root. `PatchSession::new()` then returns a loader-owned session or an error if the service was unavailable or incompatible. `overwrite`, `patch_call`, and `install_permanently` use the usual Patchy call shape. `overwrite_named` -supplies a diagnostic name. `detour_trampoline_with` uses the shared Patchy +supplies a diagnostic name. `detour_trampoline` uses the shared Patchy builder on the mod side, while the loader resolves placement, replay, and resume. Replay is verbatim; it does not relocate displaced instructions. There is no local Patchy fallback. See the diff --git a/crates/highfleet-patchy-client/Cargo.toml b/crates/highfleet-patchy-client/Cargo.toml index 224fcd4..8d2e13f 100644 --- a/crates/highfleet-patchy-client/Cargo.toml +++ b/crates/highfleet-patchy-client/Cargo.toml @@ -6,7 +6,7 @@ publish = false [dependencies] highfleet-mod-api = { path = "../highfleet-mod-api" } -patchy-code = { git = "https://github.com/logdot/patchy-rs.git", rev = "84993c490f7db47e915d7e0b4270eb3f36f614de" } +patchy-code = { git = "https://github.com/logdot/patchy-rs.git", rev = "19e4f77b8987329fc46cfe6c886f11e4e67528a6" } thiserror = "2" [target.'cfg(windows)'.dependencies] diff --git a/crates/highfleet-patchy-client/src/lib.rs b/crates/highfleet-patchy-client/src/lib.rs index 38e1585..40d2077 100644 --- a/crates/highfleet-patchy-client/src/lib.rs +++ b/crates/highfleet-patchy-client/src/lib.rs @@ -282,19 +282,6 @@ impl PatchSession { } } - /// Stages an already built custom trampoline. - /// - /// # Safety - /// The site and trampoline must satisfy [`Self::detour_trampoline_with`]. - pub unsafe fn detour_trampoline( - &mut self, - address: usize, - size: usize, - trampoline: Trampoline, - ) -> Result { - unsafe { self.detour_trampoline_with(address, size, |_| Ok(trampoline)) } - } - /// Builds a custom trampoline locally, then sends the compiled plan to /// the loader. The host captures the source bytes and resolves placement. /// No closure crosses the ABI. @@ -305,7 +292,7 @@ impl PatchSession { /// The generated code must leave valid machine state on every exit. /// Any replay must satisfy [`DetourSite::replay_verbatim`], and referenced /// callbacks and data must stay live through process exit if installed. - pub unsafe fn detour_trampoline_with( + pub unsafe fn detour_trampoline( &mut self, address: usize, size: usize, diff --git a/crates/highfleet-patchy-client/src/tests.rs b/crates/highfleet-patchy-client/src/tests.rs index 1f39c1c..aa5c31d 100644 --- a/crates/highfleet-patchy-client/src/tests.rs +++ b/crates/highfleet-patchy-client/src/tests.rs @@ -128,7 +128,7 @@ fn custom_detour_sends_replay_and_resume_as_fixups() { let (calls, host) = mock(); let mut session = PatchSession::from_host(host).unwrap(); let patch = unsafe { - session.detour_trampoline_with(0x1000, 5, |site| { + session.detour_trampoline(0x1000, 5, |site| { let mut code = Trampoline::new(); site.replay_verbatim(&mut code); site.resume(&mut code); diff --git a/tests/fixtures/patchy-mod/src/lib.rs b/tests/fixtures/patchy-mod/src/lib.rs index 939ad51..7382f95 100644 --- a/tests/fixtures/patchy-mod/src/lib.rs +++ b/tests/fixtures/patchy-mod/src/lib.rs @@ -65,7 +65,7 @@ fn stage_conditional_replay(session: &mut PatchSession) -> patchy::Result { // SAFETY: The fixture owns the source and only calls it before or after // installation. The displaced instructions can be replayed verbatim. unsafe { - session.detour_trampoline_with(address, 5, |site| { + session.detour_trampoline(address, 5, |site| { let mut code = Trampoline::new(); let skip = code.new_label(); code.bytes(&[0x85, 0xc9]); // TEST ECX, ECX