mod nativepointer;
mod plumbing;
pub mod console;
pub mod cpu;
pub mod interceptor;
pub mod module;
pub mod process;
pub mod range;
pub mod thread;
pub use nativepointer::NativePointer;
pub use plumbing::frida::ArrayBuffer;
pub use plumbing::frida::RecvMessage;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
pub fn version() -> &'static str {
&*crate::plumbing::frida::version
}
pub fn heap_size() -> usize {
*crate::plumbing::frida::heap_size
}
pub fn runtime() -> &'static str {
&*crate::plumbing::script::runtime
}
pub fn hexdump(target: &nativepointer::NativePointer) -> String {
crate::plumbing::frida::hexdump(target)
}
pub fn hexdump_arraybuffer(target: &ArrayBuffer) -> String {
crate::plumbing::frida::hexdump_arraybuffer(target)
}
pub fn send<T>(message: &T)
where
T: serde::Serialize + ?Sized,
{
crate::plumbing::frida::send(&JsValue::from_serde(&message).unwrap(), &JsValue::NULL);
}
pub fn send_with_byte_array<T>(message: &T, data: &[u8])
where
T: serde::Serialize + ?Sized,
{
let data = js_sys::Uint8Array::from(data);
crate::plumbing::frida::send(
&JsValue::from_serde(&message).unwrap(),
&data.unchecked_into(),
);
}
pub fn recv(callback: Box<dyn FnMut(RecvMessage, Option<ArrayBuffer>)>) {
let c = Closure::wrap(callback);
let f: &js_sys::Function = c.as_ref().unchecked_ref();
crate::plumbing::frida::recv(f);
c.forget();
}
pub fn recv_with_type(
type_filter: &str,
callback: Box<dyn FnMut(RecvMessage, Option<ArrayBuffer>)>,
) {
let c = Closure::wrap(callback);
let f: &js_sys::Function = c.as_ref().unchecked_ref();
crate::plumbing::frida::recv_with_type(type_filter, f);
c.forget();
}