GithubHelp home page GithubHelp logo

frida-rust's Introduction

frida-rust

Rust bindings for Frida.

Install

  • Build Frida, or download the devkits for your system (see frida-gum or frida-core README for verison)
  • For crate installation:
    • Move the frida-gum and frida-core devkits into rustc-link-search, e.g.: /usr/local/{include, lib} on Unix
  • For local development:
    • Move the frida-gum devkit into frida-gum-sys, and the frida-core devkit into frida-sys and cargo build in the root

frida-rust's People

Contributors

amaanq avatar andreafioraldi avatar aursen avatar aviramha avatar csnewman avatar domenukk avatar dzervas avatar erezto avatar fabianfreyer avatar icsaszar avatar iteroji avatar laomaiweng avatar meme avatar mrmaxmeier avatar r4ve1 avatar s1341 avatar t4lz avatar talliberman avatar tokatoka avatar worksbutnottested avatar wuhx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frida-rust's Issues

Returning a released pointer from RangeDetails::with_address

Hi,
I consistently encountered this in the code I'm debugging. There is a call to RangeDetails::with_address. The returned value is complete nonsense.
When I debug it, I can see that when the save_range_details_by_address is called, it is passed a pointer to a details struct with correct data. However when we get back to with_address, the pointer points to garbage. I can only assume that the native Gum has freed this object and don't see anything preventing it from doing so.

pub fn with_address(address: u64) -> Option<RangeDetails<'a>> {
    let mut context = SaveRangeDetailsByAddressContext {
        address,
        details: core::ptr::null_mut(),
    };
    unsafe {
        gum_sys::gum_process_enumerate_ranges(
            gum_sys::_GumPageProtection_GUM_PAGE_NO_ACCESS as u32,
            Some(save_range_details_by_address),
            &mut context as *mut _ as *mut c_void,
        );
    }

    if !context.details.is_null() {
        Some(RangeDetails::from_raw(context.details))
    } else {
        None
    }
}

compilation error for aarch64

   Compiling frida-gum v0.11.0 (https://github.com/frida/frida-rust?rev=e21fea1be069d9d891c683a745f275c84d393f3d#e21fea1b)
error[E0412]: cannot find type `Vec` in this scope
   --> /Users/aviramhassan/.cargo/git/checkouts/frida-rust-2ecc0d5911c42966/e21fea1/frida-gum/src/instruction_writer/aarch64/writer.rs:263:28
    |
263 |             let arguments: Vec<GumArgument> = arguments
    |                            ^^^ not found in this scope
    |
help: consider importing this struct
    |
1   | use alloc::vec::Vec;
    |

I guess this was done as part of #83 but wasn't tested on aarch64.

How to call original function from replacement?

Hi!
I have to say this library is amazing, both in structure and design and functionality.
I am now trying to figure out how to call the original function from the detour/function that replaced it.
I'd love to contribute my case as an example later on for it to be more accessible.

Thanks!

can not find any device on linux server

Here a some code

pub struct Runner<'a> {
    manager: DeviceManager<'a>,
}

impl<'a> Runner<'a> {
    pub fn new() -> Self {
        Self {
            manager: DeviceManager::obtain(&FRIDA),
        }
    }

    pub fn find_device(&self, name: &String) -> Option<Device> {
        self.manager.enumerate_all_devices().into_iter().find(|d| d.get_name() == name)
    }


    pub fn get_available_device(&self) -> Vec<String> {
        self.manager.enumerate_all_devices().iter().map(|d| String::from(d.get_name())).collect()
    }
}
let devices = runner.get_available_device();
    info!("devices:{:?}", devices);
    let name = tool.getprop(device, "ro.product.vendor.model")?;
    info!("sdk info device name:{:?}", name);
    let frida_device = runner.find_device(&name).ok_or_else(|| anyhow::Error::msg(format!("can not find device named {} found {:?}", name, devices)))?;

device find result
RUST: run error: can not find device named PGJM10 found ["Local System", "Local Socket"]

[root@****]# adb devices
List of devices attached
10091eb9        device
1e942224        device
3991a83f        device
53e4e14a        device
59OZPFEIZLZ5PJAI        device
8321ecd5        device
BYRSZLO7JBN7BAPN        device
EAZHLRZPE6VWMJCI        device
GARKNJL7QS9LQOEU        device
VC7PMFQWOJIVZPYT        device
Y54L6LDQ9T4D6HMZ        device
a662b01d        device
b62104d1        device
be24c414        device
be7351c2        device
c9cfb036        device
e10dee1d        device
e7394bcc        device
f244387b        device

serverA: Failed
Android Debug Bridge version 1.0.41
Version 30.0.4-6686687
java version "1.8.0_241"

serverB: Success
Android Debug Bridge version 1.0.39
Revision 5943271ace17-android

then I copy the serverB adb to serverA ,serverA device finder work as normaly , want to know the real reson of enumerate_all_devices can not find any device

frida-gum API allows some memory safety mistakes

Hi! Thank you so much for your work on this library, it seems to be among the highest quality hook implementations available in Rust and this is awesome.

I'm integrating frida_gum into a new project and I found some foot guns. I am not sure if I am going to get around to submitting patches, but I am writing these down for the sake of writing them down. Fixing these is going to need to break API.

I realize that this library exists to do wildly unsafe things, and indeed I intend to do wildly unsafe things with it, but I think that in the business of doing wildly unsafe things, cats can have little a compile-time enforced safety as a treat.

This is a brief list of the things I found while lightly auditing the library to learn how to use it:

  • Module::enumerate_modules() segfaults if you don't initialize Gum but is marked safe.

    Suggested fix: take a & reference to the Gum instance on all functions that require it to be initialized. This will not restrict use cases because you can just stick the Gum in a static OnceCell, lazy_static, etc and get a &'static to it. It should compile down to nothing since Gum is zero sized.

    Secondary question to ask here: are there frida-gum-sys functions that are thread-unsafe? Should there be a zero sized GumThreadToken or something that isn't Sync that you can pull one of out of the Gum instance with an unsafe fn, then put in a static mutex or such, where you can prove that you are the right thread to invoke them?

  • The Gum destructor deinitializes the Gum library, which should be documented. This has surprising behaviour and implies that you probably should not have more than one Gum: if you obtain() a second Gum and then drop it, the gum C library will be deinitialized. Confusingly, the docs say that calling obtain() more times is fine, which it is, but only if you mem::forget() the further instances.

    Suggested fix: This fact should be documented and probably a suggestion given to use something like a OnceCell in a static and initialize it at startup. Maybe a second version of obtain() should give you an Arc.

  • The Interceptor transaction system should probably use a guard object to automatically end the transaction when it falls out of scope

    Suggested fix: create a guard object that is DerefMut to the inner Interceptor, assuming that nested transactions are acceptable [edit: they are] (as it would allow creating a nested transaction). If not, move the operations of Interceptor into a trait and impl it on both the guard and the Interceptor.

frida-gum Transformer callback API is unsound

LibAFL's frida module is currently running into this issue:

use frida_gum as gum;
use frida_gum::stalker::{Stalker, Transformer};
use gum::stalker::NoneEventSink;
use lazy_static::lazy_static;

lazy_static! {
    static ref GUM: gum::Gum = unsafe { gum::Gum::obtain() };
}

fn make_transformer<'a>() -> Transformer<'a> {
    let mut arr = [0u64; 64];
    // the callback captures arr from the local scope, but arr is dangling after we return
    Transformer::from_callback(&GUM, |basic_block, _output| {
        arr.fill(0x42);
        for instr in basic_block {
            instr.keep();
        }
    })
}

fn main() {
    let transformer = make_transformer();
    let mut stalker = Stalker::new(&GUM);
    stalker.follow_me::<NoneEventSink>(&transformer, None);
    stalker.unfollow_me();
}
$ cargo run
   Compiling frida-gum v0.12.0 (/tmp/frida-rust/frida-gum)
   Compiling stalker v0.1.0 (/tmp/frida-rust/examples/gum/stalker)
    Finished dev [unoptimized + debuginfo] target(s) in 0.30s
     Running `/tmp/frida-rust/target/debug/stalker`
fish: Job 1, 'cargo run' terminated by signal SIGSEGV (Address boundary error)

As far as I can tell, the fix is simple:

diff --git a/frida-gum/src/stalker/transformer.rs b/frida-gum/src/stalker/transformer.rs
index 8183b29..2090260 100644
--- a/frida-gum/src/stalker/transformer.rs
+++ b/frida-gum/src/stalker/transformer.rs
@@ -174,7 +174,7 @@ pub struct Transformer<'a> {
 impl<'a> Transformer<'a> {
     pub fn from_callback<'b>(
         _gum: &'b Gum,
-        callback: impl FnMut(StalkerIterator, StalkerOutput),
+        callback: impl FnMut(StalkerIterator, StalkerOutput) + 'a,
     ) -> Transformer<'a>
     where
         'b: 'a,

This'll break some consumers of the API though. (i.e. the reproducer will fail to compile with something like this:)

error[E0373]: closure may outlive the current function, but it borrows `arr`, which is owned by the current function
  --> examples/gum/stalker/src/main.rs:13:38
   |
13 |     Transformer::from_callback(&GUM, |basic_block, _output| {
   |                                      ^^^^^^^^^^^^^^^^^^^^^^ may outlive borrowed value `arr`
14 |         arr.fill(0x42);
   |         --- `arr` is borrowed here
   |
note: closure is returned here
  --> examples/gum/stalker/src/main.rs:13:5
   |
13 | /     Transformer::from_callback(&GUM, |basic_block, _output| {
14 | |         arr.fill(0x42);
15 | |         for instr in basic_block {
16 | |             instr.keep();
17 | |         }
18 | |     })
   | |______^
help: to force the closure to take ownership of `arr` (and any other referenced variables), use the `move` keyword
   |
13 |     Transformer::from_callback(&GUM, move |basic_block, _output| {
   |                                      ++++

frida_sys::g_signal_connect_object

Hi,

Is there a way to read the GCallback output from g_signal_connect_object? for example the c_hanlder member in the mentioned function allows me only to declare an unsafe "callback_on_message" function that doesn't take arguments?

frida_sys::g_signal_connect_object(
                        frida_script as *mut c_void,
                        message_string.as_ptr(),
                        callback_on_message,
                        data,
                        connect_flags,
        
                    ); 

I got the error message:

    |
137 |                     let callback_on_message: frida_sys::GCallback = Some(on_message);
    |                                                                          ^^^^^^^^^^ incorrect number of function parameters
    |
    = note: expected fn pointer `unsafe extern "C" fn()`
                  found fn item `unsafe extern "C" fn(String) {on_message}`
    |
161 |                         Some(fnptr),
    |                              ^^^^^ incorrect number of function parameters
    |
    = note: expected fn pointer `unsafe extern "C" fn()`
               found fn pointer `unsafe extern "C" fn(String)`

Thanks in advance,
b1twis3

use rustls for downloading?

We have an issue where we don't want to require openssl while building, and Frida doesn't really respect the use of rustls in reqwest if not changing it explicitly in Frida.
I want to suggest to use rustls by default for the build script - it's egoistic but I think rustls is nicer anyway :D

Request for Windows Example for Hooking Functions

I've gone through the example provided for hooking open from libc on macOS and Linux. It's very informative, but I noticed there isn't a corresponding example for Windows.

Would it be possible to provide an example or some guidance on how this could be achieved on Windows? This would be greatly beneficial for those of us working on windows. Thank you!

Frida-rust links multiple versions of capstone.

After a long debugging session of LibAFL, it was discovered that Stalker was not working correctly as a result of being linked against multiple different versions of capstone. AFLplusplus/LibAFL#1018. One version was as a result of dependency on the capstone-rs crate and the other as a result of linking against the frida-gum-devkit of which capstone is an embedded component (indeed it is built from a FRIDA hosted fork of the next branch of capstone). Frida-rust also makes use of capstone-rs and also introduces the same version conflict in its own right.

The proposed solution (which has also been tested in LibAFL) is to substitute the capstone-rs crate with a fork (https://github.com/domenukk/capstone-rs) built using FRIDA's fork of capstone so that the versions match. Given that frida-rust, and the native FRIDA fork of capstone are both hosted by FRIDA in github, it seems that this would be a natural place for this fork of capstone-rs to be hosted also. I've discuss this approach with @oleavr and he seems in agreement, though obviously happy to discuss if you think there is a better option.

The suggested fix is therefore:

  • Host the capstone-rs fork above in FRIDA's organisation in github
  • Replace frida-rust's dependency on capstone-rs with the above.

backtrace is not supported on Windows. Why?

I'm currently working on a project where I need to intercept an ABI and gather backtrace information in pure Rust. I noticed that the Thread.backtrace method is not available on Windows platforms due to frida-gum disabling the Backtracer-related APIs.

Questions:

  1. Is there a specific reason why these APIs are disabled on Windows?
  2. Are there any workarounds or alternative methods to accomplish this in pure Rust?
  3. Is there anything I can contribute to help enable this feature on Windows?

Thanks for your patience, and btw this is a really cool project!

instable build becuase of incomplete download

The following error will appear when you have an incomplete download of devkit tar.gz, please add some completeness check when downloading.

Caused by:
  process didn't exit successfully: `/home/xxx/git/LibAFL/target/release/build/frida-gum-sys-04cb55fc4f28c053/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=event_sink.c
  cargo:rerun-if-changed=event_sink.h
  cargo:rerun-if-changed=invocation_listener.c
  cargo:rerun-if-changed=invocation_listener.h
  cargo:rustc-link-search=/home/xxx/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/frida-gum-sys-0.3.4

  --- stderr
  thread 'main' panicked at 'cannot extract the devkit tar.gz: Custom { kind: UnexpectedEof, error: TarError { desc: "failed to unpack `/home/xxx/git/LibAFL/target/release/build/frida-gum-sys-c7ba850327226163/out/libfrida-gum.a`", io: Custom { kind: UnexpectedEof, error: TarError { desc: "failed to unpack `libfrida-gum.a` into `/home/xxx/git/LibAFL/target/release/build/frida-gum-sys-c7ba850327226163/out/libfrida-gum.a`", io: Custom { kind: UnexpectedEof, error: "premature eof" } } } } }', /home/xxx/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/frida-build-0.2.0/src/lib.rs:55:14
  stack backtrace:
     0:     0x558de358fead - std::backtrace_rs::backtrace::libunwind::trace::h8f9ba895f18b09d0
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
     1:     0x558de358fead - std::backtrace_rs::backtrace::trace_unsynchronized::hc6a14c0ffe629597
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
     2:     0x558de358fead - std::sys_common::backtrace::_print_fmt::h0bced23525216d79
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/sys_common/backtrace.rs:66:5
     3:     0x558de358fead - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::heb53bc5f6fd72de1
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/sys_common/backtrace.rs:45:22
     4:     0x558de35b686c - core::fmt::write::h9eead92cdcbde24c
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/core/src/fmt/mod.rs:1198:17
     5:     0x558de35895f1 - std::io::Write::write_fmt::h4b47f879edc26800
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/io/mod.rs:1672:15
     6:     0x558de35917b5 - std::sys_common::backtrace::_print::hdda4f6fb9c1bea83
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/sys_common/backtrace.rs:48:5
     7:     0x558de35917b5 - std::sys_common::backtrace::print::h1334fdcbaa6ee9eb
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/sys_common/backtrace.rs:35:9
     8:     0x558de35917b5 - std::panicking::default_hook::{{closure}}::h4527c1ef3d428396
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panicking.rs:295:22
     9:     0x558de35914d6 - std::panicking::default_hook::hf30182a640d582ac
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panicking.rs:314:9
    10:     0x558de3591d46 - std::panicking::rust_panic_with_hook::h068be8eb179d2d55
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panicking.rs:698:17
    11:     0x558de3591c37 - std::panicking::begin_panic_handler::{{closure}}::h85625522130dfde4
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panicking.rs:588:13
    12:     0x558de3590364 - std::sys_common::backtrace::__rust_end_short_backtrace::hff27c063627d1102
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/sys_common/backtrace.rs:138:18
    13:     0x558de3591969 - rust_begin_unwind
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panicking.rs:584:5
    14:     0x558de2bd0063 - core::panicking::panic_fmt::hd728e2e35c66173a
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/core/src/panicking.rs:142:14
    15:     0x558de2bd01b3 - core::result::unwrap_failed::h1ff2879aca4f2f36
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/core/src/result.rs:1805:5
    16:     0x558de2f2f7cb - core::result::Result<T,E>::expect::h787e3e62754604b1
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/core/src/result.rs:1055:23
    17:     0x558de2c45f46 - frida_build::download_and_use_devkit::hf4218296eb375a8a
                                 at /home/xxx/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/frida-build-0.2.0/src/lib.rs:53:9
    18:     0x558de2bd09a0 - build_script_build::main::h032a7d6807c3bb79
                                 at /home/xxx/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/frida-gum-sys-0.3.4/build.rs:33:9
    19:     0x558de2bd11db - core::ops::function::FnOnce::call_once::ha296e293bdc10bf9
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/core/src/ops/function.rs:248:5
    20:     0x558de2bd16ce - std::sys_common::backtrace::__rust_begin_short_backtrace::h9e18af1ce3097940
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/sys_common/backtrace.rs:122:18
    21:     0x558de2bd14b1 - std::rt::lang_start::{{closure}}::ha77f430a4b7103ad
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/rt.rs:145:18
    22:     0x558de35840ee - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hcfe9c7d52c619978
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/core/src/ops/function.rs:280:13
    23:     0x558de35840ee - std::panicking::try::do_call::h8c4b802eb6e4184d
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panicking.rs:492:40
    24:     0x558de35840ee - std::panicking::try::h21616baf87e7165e
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panicking.rs:456:19
    25:     0x558de35840ee - std::panic::catch_unwind::h9080cdb55f15d458
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panic.rs:137:14
    26:     0x558de35840ee - std::rt::lang_start_internal::{{closure}}::hafbde1270c26291b
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/rt.rs:128:48
    27:     0x558de35840ee - std::panicking::try::do_call::h9d136e710d805d87
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panicking.rs:492:40
    28:     0x558de35840ee - std::panicking::try::h98e01b141a9fc81b
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panicking.rs:456:19
    29:     0x558de35840ee - std::panic::catch_unwind::h3ce8852ba8102f96
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/panic.rs:137:14
    30:     0x558de35840ee - std::rt::lang_start_internal::hf9507c4da6858514
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/rt.rs:128:20
    31:     0x558de2bd1480 - std::rt::lang_start::h04414e23e1cca25e
                                 at /rustc/7425fb293f510a6f138e82a963a3bc599a5b9e1c/library/std/src/rt.rs:144:17
    32:     0x558de2bd111c - main
    33:     0x7f37294fbd90 - __libc_start_call_main
                                 at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    34:     0x7f37294fbe40 - __libc_start_main_impl
                                 at ./csu/../csu/libc-start.c:392:3
    35:     0x558de2bd03b5 - _start
    36:                0x0 - <unknown>
    ```

Frida-core bindings

I'm curious if you have any plans to work on bindings to frida-core? I've been trying to do this myself, but I've had an extraordinarily difficult time fighting various errors bindgen has been throwing. I'm curious if you have any insights on this?

I also notice you're cited in the 14.1.0 frida news for

Support linking against system GLib and libffi. Thanks @meme!
Support GObject Introspection. Thanks @meme!

Were these changes part of getting the build process to work? If so, must similar changes be made to frida-core?

Thanks

Keeping the original functions

Hi,
I am wondering if there's a way to keep the original functions that are hooked in some kind of structure so we can call it directly, avoiding relying on the infinite recursion fix that frida provides out of the box.
Our problem is that from our code we get to the hook and then we sometimes have deadlocks.. if we could just call the original functions directly when desired it'd be great!

Rust+JS

Hi guys,
any idea about how can I expose things written with frida-rust to JS using them alongside the frida-js API?
Linking the gumjs devkit and exposing the bindings should be enough or not?

Windows support

I'm using gcc in msys2 on Windows. I create a new cargo project and add frida-gum-sys="0.3" in [dependencies], following is the error.

Caused by:
  process didn't exit successfully: `E:\git\gum-test\target\debug\build\frida-gum-sys-050afd60ff0623a6\build-script-build` (exit code: 101)
  --- stdout
  cargo:rustc-link-search=C:\Users\xxx\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\frida-gum-sys-0.3.3
  cargo:rustc-link-lib=frida-gum

  --- stderr
  ./event_sink.h:9:10: fatal error: 'frida-gum.h' file not found
  ./event_sink.h:9:10: fatal error: 'frida-gum.h' file not found, err: true
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ()', C:\Users\xxx\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\frida-gum-sys-0.3.3\build.rs:63:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I can find frida-gum.h in frida-gum-devkit, but I have no idea where to put the .lib and .h. I'm new to frida so sorry if I just raise a dummy question.

cargo build fails

I followed the instructions for local development. Unfortunately the build responds with this error

./event_sink.h:9:10: fatal error: 'frida-gum.h' file not found
./event_sink.h:9:10: fatal error: 'frida-gum.h' file not found, err: true
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ()', frida-gum-sys/build.rs:64:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The file frida.gum.h is in the include folder. I do not get whats wrong, can someone provide help?

Thx!

Port: armv7

Hey,

I am trying to cross-compile the gum and gum-sys crates from x64 to armv7-unknown-linux-gnueabihf and running into
multiple build environment failures, wondered if you could point me in the right direction.

This is the error message I am getting:

process didn't exit successfully: `/home/target/debug/build/frida-gum-sys-8f9597fdb6792049/build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-changed=event_sink.c
  cargo:rerun-if-changed=event_sink.h
  cargo:rerun-if-changed=invocation_listener.c
  cargo:rerun-if-changed=invocation_listener.h
  cargo:rustc-link-search=/home/pr0me/.cargo/registry/src/frida-gum-sys-0.2.3
  cargo:rustc-link-lib=frida-gum-linux-arm
  cargo:rustc-link-lib=pthread

  --- stderr
  tar: This does not look like a tar archive
  xz: (stdin): File format not recognized
  tar: Child returned status 1
  tar: Error is not recoverable: exiting now
  mv: cannot stat 'libfrida-gum.a': No such file or directory
  ./frida-gum.h:7579:3: error: static_assert failed due to requirement 'sizeof(unsigned long long) == sizeof(unsigned long)' "Expression evaluates to false"
  /usr/include/pthread.h:675:6: error: 'regparm' is not valid on this platform
  /usr/include/pthread.h:687:3: error: 'regparm' is not valid on this platform
  /usr/include/pthread.h:728:6: error: 'regparm' is not valid on this platform
  ./frida-gum.h:7579:3: error: static_assert failed due to requirement 'sizeof(unsigned long long) == sizeof(unsigned long)' "Expression evaluates to false", err: true
  /usr/include/pthread.h:675:6: error: 'regparm' is not valid on this platform, err: true
  /usr/include/pthread.h:687:3: error: 'regparm' is not valid on this platform, err: true
  /usr/include/pthread.h:728:6: error: 'regparm' is not valid on this platform, err: true
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ()'
  1. I am using the "auto-download" feature, the build script apparently still has problems locating libfrida-gum.a, even after manually downloading the devkit and placing the files in usr/local/{include, lib}.

  2. Also the assert fails for some reason. Is this part of bindgen, not being aware of the cc target? I'd assume that rustc
    should handle the linking correctly.

3.The build script is trying to link the local pthread.h. How do you handle this on your systems, just by adjusting the build script to look for a local copy of pthread for arm or is there a smoother way?

Any help/heads-up at all is appreciated,
Thanks

Cross Compile x86_64-linux-android

Hi, I am struggling to be able to cross compile frida-sys to x86_64-linux-android.
I have setup my toolchain for compiling from windows to x86_64-linux-android successfully, but frida-sys's bindgen is having an issue where it is missing header files. While I do not believe this is a issue in the frida-rust library, I figured this could still be relevant to the repo and I expect others might run into my same issue.

Here is my x86_64-linux-android target specific ar/linker

[target.x86_64-linux-android]
ar = "foo/android-ndk-r21e/toolchains/llvm/prebuilt/windows-x86_64/bin/x86_64-linux-android-ar"
linker = "foo/android-ndk-r21e/toolchains/llvm/prebuilt/windows-x86_64/bin/x86_64-linux-android21-clang.cmd"

Dependency specification

[dependencies]
frida-sys = { version = "0.2.1", features = ["auto-download"] }

Error

error: failed to run custom build command for `frida-sys v0.2.1`

Caused by:
  process didn't exit successfully: `foobar\target\debug\build\frida-sys-4879466b7c9a7868\build-script-build` (exit code: 101)
  --- stdout
  cargo:rustc-link-search=C:\Users\chase\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-sys-0.2.1
  cargo:rustc-link-search=foobar\target\x86_64-linux-android\debug\build\frida-sys-e0555988199852af\out
  cargo:rustc-link-lib=static=frida-core

  --- stderr
  foobar\target\x86_64-linux-android\debug\build\frida-sys-e0555988199852af\out\frida-core.h:8298:10: fatal error: 'time.h' file not found
  foobar\target\x86_64-linux-android\debug\build\frida-sys-e0555988199852af\out\frida-core.h:8298:10: fatal error: 'time.h' file not found, err: true
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ()', C:\Users\chase\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-sys-0.2.1\build.rs:56:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

In the directory "foo/android-ndk-r21e/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include", I can see time.h ; But have been unable to figure out to specify to use the headers.

Any help would be greatly appreciated, thank you.

Build errors

After copying the latest devkit and running cargo build, I get the error

  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_x86_64-unknown-linux-gnu = None
  CC_x86_64_unknown_linux_gnu = None
  HOST_CC = None
  CC = None
  CFLAGS_x86_64-unknown-linux-gnu = None
  CFLAGS_x86_64_unknown_linux_gnu = None
  HOST_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-Werror" "-o" "/home/oem/github/opencrs/deps/frida-rust/target/debug/build/frida-gum-sys-d1b430b7d2894094/out/event_sink.o" "-c" "event_sink.c"
  cargo:warning=event_sink.c: In function ‘gum_rust_event_sink_iface_init’:
  cargo:warning=event_sink.c:52:18: error: assignment to ‘void (*)(GumEventSink *, const GumEvent *, GumCpuContext *)’ {aka ‘void (*)(struct _GumEventSink *, const union _GumEvent *, struct _GumX64CpuContext *)’} from incompatible pointer type ‘void (*)(GumEventSink *, const GumEvent *)’ {aka ‘void (*)(struct _GumEventSink *, const union _GumEvent *)’} [-Werror=incompatible-pointer-types]
  cargo:warning=   52 |   iface->process = gum_rust_event_sink_process;
  cargo:warning=      |                  ^
  cargo:warning=cc1: all warnings being treated as errors
  exit code: 1

  --- stderr


  error occurred: Command "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-Werror" "-o" "/home/oem/github/opencrs/deps/frida-rust/target/debug/build/frida-gum-sys-d1b430b7d2894094/out/event_sink.o" "-c" "event_sink.c" with args "cc" did not execute successfully (status code exit code: 1).

Do you know the fix?

Can't cross-compile for `x86_64-pc-windows-gnu` target

When I cargo build --bins --target x86_64-pc-windows-gnu I get:

   Compiling frida-sys v0.4.0
   Compiling frida v0.4.0
error: could not find native static library `frida-core`, perhaps an -L flag is missing?

The following warnings were emitted during compilation:

warning: Frida core devkit not found, downloading from https://github.com/frida/frida/releases/download/16.0.7/frida-core-devkit-16.0.7-windows-x86_64.tar.xz...

error: could not compile `frida-sys` due to previous error

Compiling the same code for linux (the default target) I don't have that problem - my code is portable so that ain't a problem
I've got the auto-download feature enabled for both frida and frida-sys (using the upstream 0.4.0 versions)

`Stalker` does not ensure the life-time of the transformer passed to `follow_me`.

The transformer provided to Stalker.follow_me should remain in scope until the corresponding unfollow_me is called. It does not appear that this life-time constraint is described by the wrapper class here...

transformer: &Transformer,

Perhaps the follow_me function should return a handle which calls unfollow_me when it falls out of scope and its Drop is called and whose lifetime is tied to the provided transformer? Or perhaps it is just simpler to ensure that the transformer outlives the stalker instance?

Its probably worth checking for other instances of the same issue elsewhere as I may have done the same for the observer stuff I was working on?

`cargo test` fails

cargo test fails on main even after the changes in 82804f4 and 71be15f
To reproduce:

$ sudo docker run --rm -ti --entrypoint /bin/bash ubuntu
# apt update
# apt -y install curl clang git pkg-config libssl-dev
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.rs && sh /tmp/rustup.rs -y
# source "$HOME/.cargo/env"
# git clone https://github.com/frida/frida-rust.git
# cd frida-rust
# cargo test --features auto-download --features invocation-listener
...
   Compiling capstone v0.11.0
warning: Frida gum devkit not found, downloading from https://github.com/frida/frida/releases/download/15.2.2/frida-gum-devkit-15.2.2-linux-x86_64.tar.xz...
   Compiling frida-gum v0.8.1 (/frida-rust/frida-gum)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/tmp/rustcMdgm8e/symbols.o" "/frida-rust/target/debug/deps/frida_gum_sys-4d322fb27616b05c.15dd5yvh2rgng99v.rcgu.o" "/frida-rust/target/debug/deps/frida_gum_sys-4d322fb27616b05c.1rvbx14yg46olqvc.rcgu.o" "/frida-rust/target/debug/deps/frida_gum_sys-4d322fb27616b05c.354nccdb7dl74v51.rcgu.o" "/frida-rust/target/debug/deps/frida_gum_sys-4d322fb27616b05c.40y402csrsey4m22.rcgu.o" "/frida-rust/target/debug/deps/frida_gum_sys-4d322fb27616b05c.4jm7uagmwv5rplw8.rcgu.o" "/frida-rust/target/debug/deps/frida_gum_sys-4d322fb27616b05c.5f7ygf2sjh9qiaz5.rcgu.o" "/frida-rust/target/debug/deps/frida_gum_sys-4d322fb27616b05c.l2hgein05500qdq.rcgu.o" "/frida-rust/target/debug/deps/frida_gum_sys-4d322fb27616b05c.1pw2e05btdj0hkka.rcgu.o" "-Wl,--as-needed" "-L" "/frida-rust/target/debug/deps" "-L" "/frida-rust/frida-gum-sys" "-L" "/frida-rust/target/debug/build/frida-gum-sys-efbc75af0c2417a1/out" "-L" "/frida-rust/target/debug/build/frida-gum-sys-efbc75af0c2417a1/out" "-L" "/frida-rust/target/debug/build/frida-gum-sys-efbc75af0c2417a1/out" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-lfrida-gum" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-lpthread" "-Wl,-Bstatic" "-Wl,--whole-archive" "-levent_sink" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "-linvocation_listener" "-Wl,--no-whole-archive" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-50b9616eedb811b7.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-754da76e30d40e26.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-abff7c50c58df25c.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-89f1a8c8e39f4a91.rlib" "-Wl,--start-group" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-8f1929c73c3f8167.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-e359d865975ccf21.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-b886fd10c5a7c7c0.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-9d7c322d48daa475.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-08ae1606a951cabe.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-682a81c4b2133b72.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-a73b3512c88de071.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-7b5ec4c918d9f957.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-65c63cf3af0af657.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-4a53f0a2785abc6a.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-868e2d515c28d027.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-394ad2d73aede76a.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-19c77e4dc3dcb87e.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-fb44a42088c9369a.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-61a7402e61a5b0e0.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-63f8356c87a0d0e8.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-a506e577d917828c.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-fc1fb63210fdafad.rlib" "-Wl,--end-group" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-c21be34a5cae8449.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/frida-rust/target/debug/deps/frida_gum_sys-4d322fb27616b05c" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: /frida-rust/target/debug/build/frida-gum-sys-efbc75af0c2417a1/out/libfrida-gum.a(.._glib_gtrace.c.o): in function `g_trace_mark':
          /worker/frida-manylinux-x86_64/build/build/fs-tmp-linux-x86_64/glib/../../../deps/glib/glib/gtrace.c:98: multiple definition of `_frida_g_trace_mark'; /frida-rust/target/debug/build/frida-gum-sys-efbc75af0c2417a1/out/libfrida-gum.a(gtrace.c.o):/worker/frida-manylinux-x86_64/build/build/fs-tmp-linux-x86_64/glib/../../../deps/glib/glib/gtrace.c:98: first defined here
          /usr/bin/ld: /frida-rust/target/debug/build/frida-gum-sys-efbc75af0c2417a1/out/libfrida-gum.a(.._glib_gtrace.c.o): in function `g_trace_define_int64_counter':
          /worker/frida-manylinux-x86_64/build/build/fs-tmp-linux-x86_64/glib/../../../deps/glib/glib/gtrace.c:147: multiple definition of `_frida_g_trace_define_int64_counter'; /frida-rust/target/debug/build/frida-gum-sys-efbc75af0c2417a1/out/libfrida-gum.a(gtrace.c.o):/worker/frida-manylinux-x86_64/build/build/fs-tmp-linux-x86_64/glib/../../../deps/glib/glib/gtrace.c:147: first defined here
          /usr/bin/ld: /frida-rust/target/debug/build/frida-gum-sys-efbc75af0c2417a1/out/libfrida-gum.a(.._glib_gtrace.c.o): in function `g_trace_set_int64_counter':
          /worker/frida-manylinux-x86_64/build/build/fs-tmp-linux-x86_64/glib/../../../deps/glib/glib/gtrace.c:177: multiple definition of `_frida_g_trace_set_int64_counter'; /frida-rust/target/debug/build/frida-gum-sys-efbc75af0c2417a1/out/libfrida-gum.a(gtrace.c.o):/worker/frida-manylinux-x86_64/build/build/fs-tmp-linux-x86_64/glib/../../../deps/glib/glib/gtrace.c:177: first defined here
          clang: error: linker command failed with exit code 1 (use -v to see invocation)
          

The following warnings were emitted during compilation:

warning: Frida gum devkit not found, downloading from https://github.com/frida/frida/releases/download/15.2.2/frida-gum-devkit-15.2.2-linux-x86_64.tar.xz...

error: could not compile `frida-gum-sys` due to previous error
warning: build failed, waiting for other jobs to finish...
warning: Frida core devkit not found, downloading from https://github.com/frida/frida/releases/download/15.2.2/frida-core-devkit-15.2.2-linux-x86_64.tar.xz...

windows build fail

Compiling frida-gum-sys v0.3.4 (C:\Users\aaaaaa\Desktop\frida-rust-master_win\frida-gum-sys)
Compiling reqwest v0.11.10
error: failed to run custom build command for frida-sys v0.2.3 (C:\Users\aaaaaa\Desktop\frida-rust-master_win\frida-sys)

Caused by:
process didn't exit successfully: C:\Users\aaaaaa\Desktop\frida-rust-master_win\target\debug\build\frida-sys-fb2d4601b8fdea16\build-script-build (exit code: 101)
--- stdout
cargo:rustc-link-search=C:\Users\aaaaaa\Desktop\frida-rust-master_win\frida-sys
cargo:rustc-link-lib=frida-core

--- stderr
C:\Users\aaaaaa\Desktop\frida-rust-master_win\frida-sys/frida-core.h:2748:10: fatal error: 'time.h' file not found
C:\Users\aaaaaa\Desktop\frida-rust-master_win\frida-sys/frida-core.h:2748:10: fatal error: 'time.h' file not found, err: true
thread 'main' panicked at 'called Result::unwrap() on an Err value: ()', frida-sys\build.rs:57:10
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for frida-gum-sys v0.3.4 (C:\Users\aaaaaa\Desktop\frida-rust-master_win\frida-gum-sys)

Caused by:
process didn't exit successfully: C:\Users\aaaaaa\Desktop\frida-rust-master_win\target\debug\build\frida-gum-sys-77daf7a450c2d1ee\build-script-build (exit code: 101)
--- stdout
cargo:rerun-if-changed=event_sink.c
cargo:rerun-if-changed=event_sink.h
cargo:rerun-if-changed=invocation_listener.c
cargo:rerun-if-changed=invocation_listener.h
cargo:rustc-link-search=C:\Users\aaaaaa\Desktop\frida-rust-master_win\frida-gum-sys
cargo:rustc-link-lib=frida-gum

--- stderr
C:\Users\aaaaaa\Desktop\frida-rust-master_win\frida-gum-sys/frida-gum.h:2812:10: fatal error: 'time.h' file not found
C:\Users\aaaaaa\Desktop\frida-rust-master_win\frida-gum-sys/frida-gum.h:2812:10: fatal error: 'time.h' file not found, err: true
thread 'main' panicked at 'called Result::unwrap() on an Err value: ()', frida-gum-sys\build.rs:63:10
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

windows x86-64 rust
local build

undefined symbol: __aarch64_swp4_sync on ubuntu - arm64 since Frida 16

I'm getting this error after the update to Frida 16 (frida-gum 0.9, but from that branch, because otherwise it cannot build on linux-arm64). I've also seen this error before, when at some point I tried to use frida-gum 0.8 without auto-download and downloaded the lib+header of Frida 16 instead of 15.

This is what it looks like:

root@7208b8efa450:~/going/going/hooks# LD_PRELOAD="target/debug/libhooks.so" ../go-target/go-target
../go-target/go-target: symbol lookup error: target/debug/libhooks.so: undefined symbol: __aarch64_swp4_sync

The target code and the hooking lib can both be found in this repo.

I do not get this error with frida-gum 0.8.

Can't use `frida-gum` crate on arm64 linux (docker container on Mac with apple chip)

Trying to build a project with frida-gum as a dependency, the build fails with the following error:

error[E0432]: unresolved import `_frida_g_object_unref`
  --> /root/.cargo/git/checkouts/frida-rust-573843e2226aec3c/3d9308a/frida-gum-sys/src/lib.rs:25:9
   |
25 | pub use _frida_g_object_unref as g_object_unref;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no external crate `_frida_g_object_unref`

This happens both with or without auto-download.

I tried to understand why this happens, but I'm not sure yet so I also made a repo to help people reproduce it.
On a Mac with an apple chip, you reproduce it with:

git clone [email protected]:t4lz/use-frida.git && cd use-frida && docker build -t rust-use-frida . && docker run -t rust-use-frida

or

git clone -b manually [email protected]:t4lz/use-frida.git && cd use-frida && docker build -t rust-use-frida . && docker run -t rust-use-frida

for a version without auto-download.

If I have time I'll try to find a fix, but I'm new to Frida and to its codebase.

Doesn't compile on 32-bit x86

error[E0432]: unresolved import `crate::instruction_writer::TargetInstructionWriter`
 --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\stalker\transformer.rs:7:13
  |
7 | use crate::{instruction_writer::TargetInstructionWriter, CpuContext, Gum};
  |             ^^^^^^^^^^^^^^^^^^^^-----------------------
  |             |                   |
  |             |                   help: a similar name exists in the module: `InstructionWriter`
  |             no `TargetInstructionWriter` in `instruction_writer`

error[E0425]: cannot find value `writer` in this scope
   --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\stalker\transformer.rs:138:13
    |
138 |             writer
    |             ^^^^^^ not found in this scope

error[E0412]: cannot find type `TargetRegister` in this scope
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\instruction_writer.rs:41:14
   |
41 |     Register(TargetRegister),
   |              ^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `TargetInstructionWriter` in this scope
    --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\instruction_writer.rs:1294:42
     |
420  | pub trait InstructionWriter {
     | --------------------------- similarly named trait `InstructionWriter` defined here
...
1294 |     fn new(input_code: u64, output: &mut TargetInstructionWriter) -> Self;
     |                                          ^^^^^^^^^^^^^^^^^^^^^^^ help: a trait with a similar name exists: `InstructionWriter`

error[E0308]: mismatched types
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\module_map.rs:53:23
   |
53 |     let end = start + (*range).size;
   |                       ^^^^^^^^^^^^^ expected `u64`, found `u32`

error[E0277]: cannot add `u32` to `u64`
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\module_map.rs:53:21
   |
53 |     let end = start + (*range).size;
   |                     ^ no implementation for `u64 + u32`
   |
   = help: the trait `Add<u32>` is not implemented for `u64`
   = help: the following other types implement trait `Add<Rhs>`:
             <&'a f32 as Add<Complex<f32>>>
             <&'a f32 as Add<f32>>
             <&'a f64 as Add<Complex<f64>>>
             <&'a f64 as Add<f64>>
             <&'a i128 as Add<BigInt>>
             <&'a i128 as Add<Complex<i128>>>
             <&'a i128 as Add<i128>>
             <&'a i16 as Add<BigInt>>
           and 176 others

error[E0308]: mismatched types
   --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\memory_range.rs:88:22
    |
88  |                 Some(callback),
    |                 ---- ^^^^^^^^ expected `u32`, found `u64`
    |                 |
    |                 arguments to this enum variant are incorrect
    |
    = note: expected fn pointer `unsafe extern "C" fn(_, u32, _) -> _`
                  found fn item `extern "C" fn(_, u64, _) -> _ {memory_range::MemoryRange::scan::callback}`
note: tuple variant defined here
   --> C:\Users\Khang\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\option.rs:526:5
    |
526 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^^^

error[E0308]: mismatched types
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\range_details.rs:57:18
   |
56 |     pub fn size(&self) -> u64 {
   |                           --- expected `u64` because of return type
57 |         unsafe { (*self.file_mapping).size }
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found `u32`
   |
help: you can convert a `u32` to a `u64`
   |
57 |         unsafe { (*self.file_mapping).size.into() }
   |                                           +++++++

error[E0308]: mismatched types
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\range_details.rs:73:23
   |
73 |     let end = start + (*range).size;
   |                       ^^^^^^^^^^^^^ expected `u64`, found `u32`

error[E0277]: cannot add `u32` to `u64`
  --> C:\Users\Khang\.cargo\registry\src\github.com-1ecc6299db9ec823\frida-gum-0.8.1\src\range_details.rs:73:21
   |
73 |     let end = start + (*range).size;
   |                     ^ no implementation for `u64 + u32`
   |
   = help: the trait `Add<u32>` is not implemented for `u64`
   = help: the following other types implement trait `Add<Rhs>`:
             <&'a f32 as Add<Complex<f32>>>
             <&'a f32 as Add<f32>>
             <&'a f64 as Add<Complex<f64>>>
             <&'a f64 as Add<f64>>
             <&'a i128 as Add<BigInt>>
             <&'a i128 as Add<Complex<i128>>>
             <&'a i128 as Add<i128>>
             <&'a i16 as Add<BigInt>>
           and 176 others

Some errors have detailed explanations: E0277, E0308, E0412, E0425, E0432.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `frida-gum` due to 10 previous errors

Seems to be a combination of using #[cfg(target_arch = "x86_64")] and not using usize where applicable. Not sure if that's all that would be required for full 32-bit support, though.

frida-gum: Cannot find function `g_object_unref` in crate `gum_sys` on aarch64-linux-android

g_object_unref is not available for certain architectures.

#[cfg(not(any(target_os = "windows", target_os = "android", target_vendor = "apple",)))]
pub use _frida_g_object_unref as g_object_unref;

While in the following drops, it calls without performing the target check.

impl Drop for ModuleMap {
fn drop(&mut self) {
unsafe { gum_sys::g_object_unref(self.module_map as *mut c_void) }
}
}

impl<'a> Drop for Transformer<'a> {
fn drop(&mut self) {
unsafe { frida_gum_sys::g_object_unref(self.transformer as *mut c_void) }
}
}

impl<'a> Drop for Stalker<'a> {
fn drop(&mut self) {
unsafe { gum_sys::g_object_unref(self.stalker as *mut c_void) };
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.