Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ authors = [
"Keegan Saunders <keegan@undefinedbehaviour.org>",
"Shmarya Rubenstein <github@shmarya.net>",
]
edition = "2021"
edition = "2024"
license = "wxWindows"
repository = "https://github.com/frida/frida-rust"
description = "Rust bindings for Frida"
2 changes: 1 addition & 1 deletion FRIDA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.9.5
17.15.3
4 changes: 2 additions & 2 deletions frida-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ description.workspace = true
auto-download = []

[dependencies]
reqwest = { version = "0.12.24", default-features = false, features = [
reqwest = { version = "0.13", default-features = false, features = [
"blocking",
"rustls-tls",
"rustls",
] }
tar = "0.4.44"
xz = "0.1.0"
6 changes: 3 additions & 3 deletions frida-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use std::{
env,
fs::{remove_file, File},
fs::{File, remove_file},
io::{self, Error},
path::Path,
};
Expand Down Expand Up @@ -42,7 +42,7 @@ fn download_and_use_devkit_internal(
let devkit_name = format!("frida-{kind}-devkit-{version}-{os}-{target_arch}",);

let devkit_path = out_dir_path.join(&devkit_name);
let devkit_tar = out_dir_path.join(format!("{}.tar.xz", &devkit_name));
let devkit_tar = out_dir_path.join(format!("{devkit_name}.tar.xz"));

if force_download {
drop(remove_file(&devkit_tar));
Expand All @@ -58,7 +58,7 @@ fn download_and_use_devkit_internal(

println!(
"cargo:warning=Frida {} devkit not found, downloading from {}...",
kind, &frida_url,
kind, frida_url,
);
// Download devkit
let mut resp =
Expand Down
2 changes: 1 addition & 1 deletion frida-gum-sys/FRIDA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.9.5
17.15.3
6 changes: 4 additions & 2 deletions frida-gum-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ impl Insn {
///
/// The caller is fully responsible for the backing allocations lifetime, including freeing.
pub unsafe fn from_raw(insn: *const cs_insn) -> Self {
Self {
insn: core::ptr::read(insn),
unsafe {
Self {
insn: core::ptr::read(insn),
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions frida-gum/src/backtracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {core::mem::MaybeUninit, frida_gum_sys as gum_sys};

// The following function is not exposed through the `frida-gum.h` header, so we don't have an
// auto-generated binding for it. This may change in a future version.
extern "C" {
unsafe extern "C" {
// On some platforms `ucontext` contains a u128 which does not have a defined ABI. In this case,
// we disable the error as we assume the behaviour is correct (all other platforms are unaffected).
#[cfg(target_os = "linux")]
Expand Down Expand Up @@ -109,7 +109,7 @@ impl Backtracer {
/// Generate a fuzzy backtrace as a list of return addresses for the supplied cpu
/// context.
pub fn fuzzy_with_context(context: &gum_sys::GumCpuContext) -> Vec<usize> {
Self::fuzzy_with_context_and_limit(&context, gum_sys::GUM_MAX_BACKTRACE_DEPTH)
Self::fuzzy_with_context_and_limit(context, gum_sys::GUM_MAX_BACKTRACE_DEPTH)
}

/// Generate a fuzzy backtrace as a list of return addresses for the supplied cpu
Expand Down
2 changes: 1 addition & 1 deletion frida-gum/src/debug_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use {
core::{fmt, mem::MaybeUninit, str::Utf8Error},
cstr_core::{CStr, CString},
frida_gum_sys as gum_sys,
gum_sys::{gum_find_function, gum_symbol_details_from_address, GumDebugSymbolDetails},
gum_sys::{GumDebugSymbolDetails, gum_find_function, gum_symbol_details_from_address},
};

pub struct Symbol {
Expand Down
16 changes: 8 additions & 8 deletions frida-gum/src/instruction_writer/aarch64/relocator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::instruction_writer::{Aarch64InstructionWriter, Relocator},
core::ffi::c_void,
frida_gum_sys::{cs_insn, Insn},
frida_gum_sys::{Insn, cs_insn},
};

pub struct Aarch64Relocator {
Expand All @@ -10,7 +10,7 @@ pub struct Aarch64Relocator {

impl Relocator for Aarch64Relocator {
fn new(input_code: u64, output: &mut Aarch64InstructionWriter) -> Self {
extern "C" {
unsafe extern "C" {
fn gum_arm64_relocator_new(
input_code: *const c_void,
output: *mut c_void,
Expand All @@ -24,7 +24,7 @@ impl Relocator for Aarch64Relocator {
}

fn read_one(&mut self) -> (u32, Insn) {
extern "C" {
unsafe extern "C" {
fn gum_arm64_relocator_read_one(
relocator: *mut c_void,
instruction: *mut *const cs_insn,
Expand All @@ -37,31 +37,31 @@ impl Relocator for Aarch64Relocator {
}

fn eoi(&mut self) -> bool {
extern "C" {
unsafe extern "C" {
fn gum_arm64_relocator_eoi(relocator: *mut c_void) -> u32;
}

unsafe { gum_arm64_relocator_eoi(self.inner) != 0 }
}

fn write_all(&mut self) {
extern "C" {
unsafe extern "C" {
fn gum_arm64_relocator_write_all(relocator: *mut c_void);
}

unsafe { gum_arm64_relocator_write_all(self.inner) }
}

fn write_one(&mut self) -> bool {
extern "C" {
unsafe extern "C" {
fn gum_arm64_relocator_write_one(relocator: *mut c_void) -> i32;
}

unsafe { gum_arm64_relocator_write_one(self.inner) != 0 }
}

fn skip_one(&mut self) -> bool {
extern "C" {
unsafe extern "C" {
fn gum_arm64_relocator_skip_one(relocator: *mut c_void) -> i32;
}

Expand All @@ -71,7 +71,7 @@ impl Relocator for Aarch64Relocator {

impl Drop for Aarch64Relocator {
fn drop(&mut self) {
extern "C" {
unsafe extern "C" {
fn gum_arm64_relocator_unref(relocator: *mut c_void);
}

Expand Down
18 changes: 9 additions & 9 deletions frida-gum/src/instruction_writer/x86_64/relocator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::instruction_writer::{Relocator, X86InstructionWriter},
core::ffi::c_void,
frida_gum_sys::{cs_insn, Insn},
frida_gum_sys::{Insn, cs_insn},
};

pub struct X86Relocator {
Expand All @@ -10,9 +10,9 @@ pub struct X86Relocator {

impl Relocator for X86Relocator {
fn new(input_code: u64, output: &mut X86InstructionWriter) -> Self {
extern "C" {
unsafe extern "C" {
fn gum_x86_relocator_new(input_code: *const c_void, output: *mut c_void)
-> *mut c_void;
-> *mut c_void;
}
Self {
inner: unsafe {
Expand All @@ -22,7 +22,7 @@ impl Relocator for X86Relocator {
}

fn read_one(&mut self) -> (u32, Insn) {
extern "C" {
unsafe extern "C" {
fn gum_x86_relocator_read_one(
relocator: *mut c_void,
instruction: *mut *const cs_insn,
Expand All @@ -35,31 +35,31 @@ impl Relocator for X86Relocator {
}

fn eoi(&mut self) -> bool {
extern "C" {
unsafe extern "C" {
fn gum_x86_relocator_eoi(relocator: *mut c_void) -> u32;
}

unsafe { gum_x86_relocator_eoi(self.inner) != 0 }
}

fn write_all(&mut self) {
extern "C" {
unsafe extern "C" {
fn gum_x86_relocator_write_all(relocator: *mut c_void);
}

unsafe { gum_x86_relocator_write_all(self.inner) }
}

fn write_one(&mut self) -> bool {
extern "C" {
unsafe extern "C" {
fn gum_x86_relocator_write_one(relocator: *mut c_void) -> i32;
}

unsafe { gum_x86_relocator_write_one(self.inner) != 0 }
}

fn skip_one(&mut self) -> bool {
extern "C" {
unsafe extern "C" {
fn gum_x86_relocator_skip_one(relocator: *mut c_void) -> i32;
}

Expand All @@ -69,7 +69,7 @@ impl Relocator for X86Relocator {

impl Drop for X86Relocator {
fn drop(&mut self) {
extern "C" {
unsafe extern "C" {
fn gum_x86_relocator_unref(relocator: *mut c_void);
}

Expand Down
2 changes: 1 addition & 1 deletion frida-gum/src/instruction_writer/x86_64/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use {
crate::instruction_writer::{Argument, InstructionWriter, X86BranchCondition, X86Register},
core::ffi::c_void,
frida_gum_sys as gum_sys,
gum_sys::{gssize, GumArgument, GumBranchHint},
gum_sys::{GumArgument, GumBranchHint, gssize},
};

#[cfg(not(any(
Expand Down
13 changes: 7 additions & 6 deletions frida-gum/src/interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Interceptor {
) -> Result<Listener> {
let listener = invocation_listener_transform(listener);
match unsafe {
gum_sys::gum_interceptor_attach(self.interceptor, f.0, listener, ptr::null_mut(), 0)
gum_sys::gum_interceptor_attach(self.interceptor, f.0, listener, ptr::null())
} {
gum_sys::GumAttachReturn_GUM_ATTACH_OK => {
Ok(Listener(NativePointer(listener as *mut c_void)))
Expand Down Expand Up @@ -100,7 +100,7 @@ impl Interceptor {
) -> Result<Listener> {
let listener = probe_listener_transform(listener);
match unsafe {
gum_sys::gum_interceptor_attach(self.interceptor, instr.0, listener, ptr::null_mut(), 0)
gum_sys::gum_interceptor_attach(self.interceptor, instr.0, listener, ptr::null())
} {
gum_sys::GumAttachReturn_GUM_ATTACH_OK => {
Ok(Listener(NativePointer(listener as *mut c_void)))
Expand Down Expand Up @@ -145,16 +145,16 @@ impl Interceptor {
&mut self,
function: NativePointer,
replacement: NativePointer,
replacement_data: NativePointer,
_replacement_data: NativePointer,
) -> Result<NativePointer> {
let mut original_function = NativePointer(ptr::null_mut());
unsafe {
match gum_sys::gum_interceptor_replace(
self.interceptor,
function.0,
replacement.0,
replacement_data.0,
&mut original_function.0,
ptr::addr_of_mut!(original_function.0),
ptr::null(),
) {
gum_sys::GumReplaceReturn_GUM_REPLACE_OK => Ok(original_function),
gum_sys::GumReplaceReturn_GUM_REPLACE_WRONG_SIGNATURE => {
Expand Down Expand Up @@ -194,7 +194,8 @@ impl Interceptor {
self.interceptor,
function.0,
replacement.0,
&mut original_function.0,
ptr::addr_of_mut!(original_function.0),
ptr::null(),
) {
gum_sys::GumReplaceReturn_GUM_REPLACE_OK => Ok(original_function),
gum_sys::GumReplaceReturn_GUM_REPLACE_WRONG_SIGNATURE => {
Expand Down
18 changes: 12 additions & 6 deletions frida-gum/src/interceptor/invocation_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,20 @@ unsafe extern "C" fn call_on_enter<I: InvocationListener>(
user_data: *mut c_void,
context: *mut gum_sys::GumInvocationContext,
) {
let listener: &mut I = &mut *(user_data as *mut I);
listener.on_enter(InvocationContext::from_raw(context));
unsafe {
let listener: &mut I = &mut *(user_data as *mut I);
listener.on_enter(InvocationContext::from_raw(context));
}
}

unsafe extern "C" fn call_on_leave<I: InvocationListener>(
user_data: *mut c_void,
context: *mut gum_sys::GumInvocationContext,
) {
let listener: &mut I = &mut *(user_data as *mut I);
listener.on_leave(InvocationContext::from_raw(context));
unsafe {
let listener: &mut I = &mut *(user_data as *mut I);
listener.on_leave(InvocationContext::from_raw(context));
}
}

pub(crate) fn invocation_listener_transform<I: InvocationListener>(
Expand All @@ -59,8 +63,10 @@ unsafe extern "C" fn call_on_hit<I: ProbeListener>(
user_data: *mut c_void,
context: *mut gum_sys::GumInvocationContext,
) {
let listener: &mut I = &mut *(user_data as *mut I);
listener.on_hit(InvocationContext::from_raw(context));
unsafe {
let listener: &mut I = &mut *(user_data as *mut I);
listener.on_hit(InvocationContext::from_raw(context));
}
}

pub(crate) fn probe_listener_transform<I: ProbeListener>(
Expand Down
2 changes: 1 addition & 1 deletion frida-gum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern crate num;
extern crate num_derive;

use core::{
ffi::{c_char, c_void, CStr},
ffi::{CStr, c_char, c_void},
fmt::{Debug, Display, Formatter, LowerHex, UpperHex},
};

Expand Down
8 changes: 4 additions & 4 deletions frida-gum/src/memory_access_monitor.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{memory_range::MemoryRange, range_details::PageProtection};
use crate::{error::GumResult, NativePointer};
use crate::{NativePointer, error::GumResult};
use core::{ffi::c_void, ptr::null_mut};
use frida_gum_sys::{
_GumMemoryOperation_GUM_MEMOP_EXECUTE, _GumMemoryOperation_GUM_MEMOP_INVALID,
_GumMemoryOperation_GUM_MEMOP_READ, _GumMemoryOperation_GUM_MEMOP_WRITE, _GumMemoryRange,
false_, gum_memory_access_monitor_disable, gum_memory_access_monitor_enable,
gum_memory_access_monitor_new, GError, GumMemoryAccessDetails, GumMemoryAccessMonitor,
GumPageProtection,
GError, GumMemoryAccessDetails, GumMemoryAccessMonitor, GumPageProtection, false_,
gum_memory_access_monitor_disable, gum_memory_access_monitor_enable,
gum_memory_access_monitor_new,
};

pub trait CallbackFn: Fn(&mut MemoryAccessMonitor, &MemoryAccessDetails) {}
Expand Down
Loading
Loading