Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions examples/gum/debug_symbol/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use frida_gum::DebugSymbol;
use frida_gum::{Gum, Module};
use std::iter::Once;
use std::sync::OnceLock;

fn main() {
static CELL: OnceLock<Gum> = OnceLock::new();
let gum = CELL.get_or_init(|| Gum::obtain());
let _gum = CELL.get_or_init(|| Gum::obtain());

let module = Module::obtain(gum);
let symbol = module.find_export_by_name(None, "mmap").unwrap();
let symbol = Module::find_global_export_by_name("mmap").unwrap();
let symbol_details = DebugSymbol::from_address(symbol).unwrap();
println!(
"address={:#x?} module_name={:?} symbol_name={:?} file_name={:?} line_number={:?}",
Expand Down
3 changes: 1 addition & 2 deletions examples/gum/hook_instruction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ fn init() {
static CELL: OnceLock<Gum> = OnceLock::new();
let gum = CELL.get_or_init(|| Gum::obtain());
let mut interceptor = Interceptor::obtain(gum);
let module = Module::obtain(gum);
let open = module.find_export_by_name(None, "open").unwrap();
let open = Module::find_global_export_by_name("open").unwrap();
let mut listener = OpenProbeListener;
interceptor.attach_instruction(open, &mut listener).unwrap();
}
3 changes: 1 addition & 2 deletions examples/gum/hook_open/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ unsafe extern "C" fn open_detour(name: *const c_char, flags: c_int) -> c_int {
fn init() {
static CELL: OnceLock<Gum> = OnceLock::new();
let gum = CELL.get_or_init(|| Gum::obtain());
let module = Module::obtain(gum);
let mut interceptor = Interceptor::obtain(gum);
let open = module.find_export_by_name(None, "open").unwrap();
let open = Module::find_global_export_by_name("open").unwrap();
unsafe {
*ORIGINAL_OPEN.lock().unwrap().get_mut() = Some(std::mem::transmute::<
*mut libc::c_void,
Expand Down
5 changes: 4 additions & 1 deletion examples/gum/open/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ publish = false
crate-type = ["cdylib"]

[dependencies]
frida-gum = { path = "../../../frida-gum", features = ["invocation-listener"] }
frida-gum = { path = "../../../frida-gum", features = [
"invocation-listener",
"std",
] }
12 changes: 7 additions & 5 deletions examples/gum/open/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use frida_gum as gum;
use gum::{
interceptor::{Interceptor, InvocationContext, InvocationListener},
Gum, Module,
Gum, Module, Process,
};
use std::os::raw::{c_int, c_void};
use std::sync::OnceLock;
Expand All @@ -30,15 +30,17 @@ extern "C" fn example_agent_main(_user_data: *const c_void, resident: *mut c_int
let mut interceptor = Interceptor::obtain(gum);
let mut listener = OpenListener {};

let module = Module::obtain(gum);
let modules = module.enumerate_modules();
let process = Process::obtain(gum);
let modules = process.enumerate_modules();
for module in modules {
println!(
"{}@{:#x}/{:#x}",
module.name, module.base_address, module.size
module.name(),
module.range().base_address(),
module.range().size()
);
}

let open = module.find_export_by_name(None, "open").unwrap();
let open = Module::find_global_export_by_name("open").unwrap();
interceptor.attach(open, &mut listener).unwrap();
}
3 changes: 2 additions & 1 deletion examples/gum/script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ pub fn main() {
let payload = include_str!("script.js");
println!("payload: {}", payload);

let backend = Backend::obtain_v8(&GUM);
//let backend = Backend::obtain_v8(&GUM); // obtain_v8 cannot Script::load. `Err` value: Failed to create script
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the issue here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thread 'main' panicked at examples/gum/script/src/main.rs:33:79:
called Result::unwrap() on an Err value: Failed to create script

I have no idea why Script::load failed with v8 backend.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works for me. Are you using the auto-download feature?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I manually downloaded frida-gumjs-devkit-17.2.12 and frida-gum-devkit-17.2.12. Extract them to frida-gum-sys

Should I use auto-download? How to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just specify the 'auto-download' feature flag and it will automatically download and use the correct devkits.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto-download still the same error.
It download from where I manually did. https://github.com/frida/frida/releases/download/17.2.12/frida-gumjs-devkit-17.2.12-linux-x86_64.tar.xz
I guess they build these devkit without v8 enable.

let backend = Backend::obtain_qjs(&GUM); // qjs works fine except failed to attach test2 on release mode
let script = Script::load(&backend, "script.js", payload, Some(callback)).unwrap();

let t2 = test2(987);
Expand Down
4 changes: 2 additions & 2 deletions examples/gum/script/src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ console.log("[*] Hello, world!");
/* Test a message containing some bytes */
send("message", [0x10, 0x20, 0x30, 0x40]);

const test1 = Module.getExportByName(null, "test1");
const test1 = Module.getGlobalExportByName("test1");
console.log(`[*] test1: ${test1}`);

const test2 = Module.getExportByName(null, "test2");
const test2 = Module.getGlobalExportByName("test2");
console.log(`[*] test2: ${test2}`);

/* Call test1 from our script */
Expand Down
Loading