1mod nativepointer;
10mod plumbing;
11
12pub mod console;
13pub mod cpu;
14pub mod interceptor;
15pub mod module;
16pub mod process;
17pub mod range;
18pub mod thread;
19
20pub use nativepointer::NativePointer;
21pub use plumbing::frida::ArrayBuffer;
22pub use plumbing::frida::RecvMessage;
23
24use wasm_bindgen::prelude::*;
25use wasm_bindgen::JsCast;
26
27#[cfg(feature = "wee_alloc")]
30#[global_allocator]
31static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
32
33pub fn version() -> &'static str {
37 &*crate::plumbing::frida::version
38}
39
40pub fn heap_size() -> usize {
44 *crate::plumbing::frida::heap_size
45}
46
47pub fn runtime() -> &'static str {
51 &*crate::plumbing::script::runtime
52}
53
54pub fn hexdump(target: &nativepointer::NativePointer) -> String {
58 crate::plumbing::frida::hexdump(target)
59}
60
61pub fn hexdump_arraybuffer(target: &ArrayBuffer) -> String {
65 crate::plumbing::frida::hexdump_arraybuffer(target)
66}
67
68pub fn send<T>(message: &T)
72where
73 T: serde::Serialize + ?Sized,
74{
75 crate::plumbing::frida::send(&JsValue::from_serde(&message).unwrap(), &JsValue::NULL);
76}
77
78pub fn send_with_byte_array<T>(message: &T, data: &[u8])
83where
84 T: serde::Serialize + ?Sized,
85{
86 let data = js_sys::Uint8Array::from(data);
87 crate::plumbing::frida::send(
88 &JsValue::from_serde(&message).unwrap(),
89 &data.unchecked_into(),
90 );
91}
92
93pub fn recv(callback: Box<dyn FnMut(RecvMessage, Option<ArrayBuffer>)>) {
97 let c = Closure::wrap(callback);
98 let f: &js_sys::Function = c.as_ref().unchecked_ref();
99 crate::plumbing::frida::recv(f);
100 c.forget();
101}
102
103pub fn recv_with_type(
108 type_filter: &str,
109 callback: Box<dyn FnMut(RecvMessage, Option<ArrayBuffer>)>,
110) {
111 let c = Closure::wrap(callback);
112 let f: &js_sys::Function = c.as_ref().unchecked_ref();
113 crate::plumbing::frida::recv_with_type(type_filter, f);
114 c.forget();
115}