frida_rs/plumbing/
interceptor.rs1use crate::plumbing::nativepointer::NativePointer;
2use std::fmt;
3use wasm_bindgen::prelude::*;
4use wasm_bindgen::JsCast;
5
6#[wasm_bindgen]
7extern "C" {
8 #[wasm_bindgen(js_namespace = Interceptor, js_name = attach)]
9 pub fn attach(target: NativePointer, callbacks: js_sys::Object);
10
11 #[wasm_bindgen(js_name = InvocationArg)]
19 #[derive(Debug)]
20 pub type InvocationArgs;
21
22 #[wasm_bindgen(js_name = InvocationContext)]
23 #[derive(Debug)]
24 pub type InvocationContext;
25
26 #[wasm_bindgen(method, getter, js_name = returnAddress)]
27 pub fn return_address(this: &InvocationContext) -> NativePointer;
28
29 #[wasm_bindgen(method, getter, js_name = context)]
30 pub fn context(this: &InvocationContext) -> crate::plumbing::cpu::CpuContext;
31
32 #[wasm_bindgen(method, getter, js_name = threadId)]
33 pub fn thread_id(this: &InvocationContext) -> u32;
34
35 #[wasm_bindgen(method, getter, js_name = depth)]
36 pub fn depth(this: &InvocationContext) -> u32;
37
38 #[wasm_bindgen(method, structural, indexing_getter)]
39 pub fn get(this: &InvocationContext, prop: &str) -> JsValue;
40
41 #[wasm_bindgen(method, structural, indexing_setter)]
42 pub fn set(this: &InvocationContext, prop: &str, val: JsValue);
43
44 #[wasm_bindgen(js_name = InvocationReturnValue, extends = NativePointer)]
52 #[derive(Debug)]
53 pub type InvocationReturnValue;
54
55 #[wasm_bindgen(constructor)]
56 fn new(s: &str) -> InvocationReturnValue;
57
58 #[wasm_bindgen(method, js_name = replace)]
60 pub fn replace(this: &InvocationReturnValue, value: NativePointer);
61}
62
63impl InvocationArgs {
64 pub fn get(&self, index: u32) -> NativePointer {
65 let a: &js_sys::Array = &self.unchecked_ref();
66 a.get(index).unchecked_into()
67 }
68}
69
70impl fmt::Display for InvocationReturnValue {
71 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
72 let p: &NativePointer = self.as_ref();
73 write!(f, "{}", p.to_string())
74 }
75}