Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/unicorn/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ extern "C" {
prot: u32,
paddr: *mut u64,
) -> uc_error;
pub fn uc_vmem_write(
ungine: uc_handle,
address: u64,
prot: u32,
bytes: *const u8,
size: u64,
) -> uc_error;
pub fn uc_mem_map(engine: uc_handle, address: u64, size: u64, perms: u32) -> uc_error;
pub fn uc_mem_map_ptr(
engine: uc_handle,
Expand Down
14 changes: 14 additions & 0 deletions crates/unicorn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,20 @@ impl<'a, D> Unicorn<'a, D> {
.into()
}

/// Write the data in `bytes` to the emulated virtual address
pub fn vmem_write(&mut self, address: u64, prot: Prot, bytes: &[u8]) -> Result<(), uc_error> {
unsafe {
uc_vmem_write(
self.get_handle(),
address,
prot,
bytes.as_ptr().cast(),
bytes.len().try_into().unwrap(),
)
}
.into()
}

/// translate virtual to physical address
pub fn vmem_translate(&mut self, address: u64, prot: Prot) -> Result<u64, uc_error> {
let mut physical: u64 = 0;
Expand Down