https://github.com/fossable/resplice
Taking "rewrite it in Rust" to a new level
https://github.com/fossable/resplice
reverse-engineering
Last synced: 2 days ago
JSON representation
Taking "rewrite it in Rust" to a new level
- Host: GitHub
- URL: https://github.com/fossable/resplice
- Owner: fossable
- License: unlicense
- Created: 2023-09-24T02:21:17.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2026-04-20T02:39:01.000Z (2 months ago)
- Last Synced: 2026-04-20T04:42:11.452Z (2 months ago)
- Topics: reverse-engineering
- Language: Rust
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Declarative binary patching with Rust
**resplice** takes "rewrite it in Rust" to a whole new level. It's a macro that
makes re-implementing sections of machine code in Rust (a little) more fun.
## Illustrative example
Take a trivial example that adds 1 + 1 in assembly:
```
0000000000001670 :
1670: d10043ff sub sp, sp, #0x10
1674: b9000fff str wzr, [sp, #12]
1678: 52800040 mov w0, #0x2
167c: 910043ff add sp, sp, #0x10
1680: d65f03c0 ret
```
Now let's reimplement it in Rust (probably with the help of a decompiler, in
practice):
```rust
use resplice::Splice;
#[Splice(begin = 0x1670, end = 0x1680)]
fn add_one_plus_one() -> i32 {
1 + 1
}
```
What we get now is the original binary augmented with our custom function! If
we're adequately motivated, we can repeat this step iteratively until our entire
program is reverse engineered in Rust.
But, most likely, we only care about reversing a few specific sections.
## How it works
As you may have guessed by the name, `Splice` forcibly inserts the machine code
for Rust functions into a target binary (either via direct substitution or via
trampolines).
## Usage
```rust
use resplice::Splice;
#[Splice(begin = 0x1000, end = 0x1020)]
fn my_replacement_function() -> i32 {
// Your Rust implementation here
42
}
```