hex-patch 1.12.5

HexPatch is a binary patcher and editor with terminal user interface (TUI), it's capable of disassembling instructions and assembling patches. It supports a variety of architectures and file formats. Also, it can edit remote files via SSH.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::error::Error;

use crate::headers::Header;

pub fn assemble(
    asm: &str,
    starting_virtual_address: u64,
    header: &Header,
) -> Result<Vec<u8>, Box<dyn Error>> {
    let encoder = header
        .get_encoder()
        .map_err(|e| t!("errors.create_encoder", e = e))?;

    let out = encoder
        .asm(asm.to_string(), starting_virtual_address)
        .map_err(|e| t!("errors.assemble", e = e))?;
    Ok(out.bytes)
}