expose exec_path to Rust
This commit is contained in:
parent
5454307a15
commit
8627b808a0
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "qemu_libafl_bridge"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
authors = ["Andrea Fioraldi <andreafioraldi@gmail.com>"]
|
||||
description = "QEMU and LibAFL bridge lib"
|
||||
repository = "https://github.com/AFLplusplus/qemu-libafl-bridge/"
|
||||
|
@ -1,5 +1,6 @@
|
||||
use core::{convert::Into, mem::transmute, ptr::copy_nonoverlapping};
|
||||
use num::Num;
|
||||
use std::{slice::from_raw_parts, str::from_utf8_unchecked};
|
||||
|
||||
pub mod amd64;
|
||||
pub mod x86;
|
||||
@ -20,6 +21,9 @@ extern "C" {
|
||||
fn libafl_qemu_remove_breakpoint(addr: u64) -> i32;
|
||||
fn libafl_qemu_run() -> i32;
|
||||
|
||||
fn strlen(s: *const u8) -> usize;
|
||||
|
||||
static exec_path: *const u8;
|
||||
static guest_base: isize;
|
||||
}
|
||||
|
||||
@ -95,6 +99,10 @@ impl QemuEmulator {
|
||||
unsafe { transmute(addr - guest_base) }
|
||||
}
|
||||
|
||||
pub fn exec_path(&self) -> &str {
|
||||
unsafe { from_utf8_unchecked(from_raw_parts(exec_path, strlen(exec_path) + 1)) }
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -31,4 +31,5 @@ __attribute__((weak)) int libafl_qemu_run() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((weak)) char* exec_path = NULL;
|
||||
__attribute__((weak)) size_t guest_base = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user