diff --git a/src/main.rs b/src/main.rs index b8c8ac2..aa63830 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ pub unsafe extern "C" fn Java_com_alterdekim_frida_FridaLib_fetchLogs( mut env: JNIEnv, _clazz: JClass ) -> jstring { - String::from_utf8_lossy(simple_log::fetch_logs()[..]) + String::from_utf8_lossy(&simple_log::fetch_logs()[..]) } #[no_mangle] diff --git a/src/simple_log.rs b/src/simple_log.rs index 4a9790c..38b87fd 100644 --- a/src/simple_log.rs +++ b/src/simple_log.rs @@ -1,27 +1,22 @@ use crossbeam_channel::unbounded; use crossbeam_channel::{ Sender, Receiver }; -struct ll { - pub tx: Sender>, - pub rx: Receiver> -} - -static mut l2: ll; +static tx: Sender>; +static rx: Receiver>; pub fn init_logger() { - let (tx, rx) = unbounded::>(); - l2 = ll{tx, rx}; + (tx, rx) = unbounded::>(); } pub fn fetch_logs() -> Vec { - if let Ok(bytes) = l2.rx.recv() { + if let Ok(bytes) = rx.recv() { return bytes; } Vec::new() } pub fn push_log(data: Vec) { - l2.tx.send(data); + tx.send(data); } #[derive(Debug, Clone, PartialEq, Eq, Default)] @@ -54,6 +49,6 @@ impl SimpleLogger { record.module_path().unwrap_or(""), record.args() ); - push_log(msg.to_vec()); + push_log(msg.as_bytes()); } } \ No newline at end of file