Repository navigation
Conversation
Replace the hand-written bindings with bindings generated by frida_rust, which sits on Frida's shared frida-bindgen core and reads the frida-core.gir that ships in the devkit. The generated API is exported flat as `frida::*` (`DeviceManager`, `Device`, `Script`, `Session`, ...), with `frida::Variant` kept as the single GVariant type the generated marshalling uses. The hand-written modules, their tests and their examples are removed. The generator emits the whole surface — classes, enumerations, constructors, methods, properties and signals — and fails closed: `strict.py` rejects any GIR construct it does not know. The emitted code is held to the same quality gates as hand-written code (no unwrap/expect/panic, public errors, panics and unsafe documented, must_use where the return cannot be ignored), and `scripts/update-bindings.sh` regenerates and then runs rustfmt, clippy --fix and clippy.
- The unit tests did not compile on Windows: `Path` was imported for a test that only Unix has, and the crate denies warnings. The import is now inside that test. - `FileMonitorEvent::from_raw` cast the raw value to `i32`, which clippy rejects where the C enum is `i32` already (Windows). `Unknown` now holds an `i64` built with `i64::from`, as the generated enumerations do. - `attaching_to_a_pid_that_does_not_exist_is_process_not_found` took the pid of a child that had exited. Windows keeps a process, and its pid, while anything holds a handle to it, and frida-core 17.27.4 never returns from attaching to one: its Windows helper drops the Gum error it gets allocating memory in the process, so the call is never completed. On Windows the test now uses a pid that cannot exist; other systems reap a child as before.
The API is exported flat from the crate root and `gir` is a private module, so rustdoc refused the six links to it and, as the crate denies warnings, `cargo doc -p frida` failed.
`cargo fmt --all -- --check` and `taplo fmt --check`, which CI runs, failed on these.
- inject_lib_blob embedded libinject_example.so, or the .dylib on macOS; on Windows the library is inject_example.dll. - The injected function had Rust's calling convention. Frida calls it as a C function, so it is now `extern "C"`.
Under Git Bash or MSYS2: - Use the cache frida-build uses, which is under %LOCALAPPDATA% there, and turn it into a path tar accepts: it took the `C:` of a Windows path for a remote host. - Print the paths of --fetch-only as ones a Windows program can open. - Run `python` where `python3` is the Microsoft Store's stub. - Lint with auto-download, so that the binding is checked against the devkit of FRIDA_VERSION and not one placed in frida-sys/ by hand. $CURL names the curl to fetch with. The tests pass their stand-in that way, as Git Bash puts its own curl before anything in PATH, and the stand-in is a shell script that runs Python, as a `#!` line cannot hold a path with a space in it. test_core_usage.py looks in the same cache as the script.
What `cargo upgrade`, the last step of scripts/update-bindings.sh, gives.
The generated bindings cover frida-core only: there is no GIR for Gum in the devkits, and what uses Gum (an agent running inside the target, and libafl_frida) needs an in-process API that frida-core does not expose. So `frida-gum`, `frida-gum-sys` and the Gum examples return, exactly as they are on kkuehl/frida-rust-updates at 1013d09 (Frida 17.27.4), and this branch again holds every crate at one Frida version. With them come the workspace members, the Gum CI jobs (Test Gum, the no_std check, the iOS build, the Gum docs and its header check), the Gum half of scripts/update-headers.sh and scripts/api-coverage.py, and the README's wording. The Frida docs build added since stays, beside Gum's. Built and tested on Windows: frida-gum 127 tests on x86_64 and 126 on i686 with both feature sets, frida 88 on both, fmt, clippy and docs.
Synchronize all three version pins, vendor matching release headers, and regenerate the GIR bindings without unrelated dependency upgrades. Update release instructions and examples.
All three pins move to 17.28.0, the vendored headers are refreshed from the release's devkits, and the GIR bindings are regenerated. The release is a Gum release: the regenerated bindings differ only in the version they are stamped with, and the gum header gains the two module-registry replay entry points. **It also faults, and that is not ours.** A second `DeviceManager` after a script was loaded into this process crashes the agent container thread (`pthread_rwlock_rdlock` on an unmapped address) — through frida-rust, and identically through frida-python 17.28.0, so it is frida-core, not these bindings. 17.27.5 runs the same loop three times. Bisected in the fork to `2dd9ebd2` (darwin: keep the helper and agent in resource dirs); the harness and the table are on the fork's `kkuehl/fix-17.28-agent-container`. `a_second_device_manager_after_attaching_to_this_process` is that loop, ignored so CI stays green: run it with `--ignored` to see the fault. It passes at 17.27.5 and faults at 17.28.0.
17.28.1 adds the first async namespace function, `obtain_shared_agent_container`:
it takes a `Gio.AsyncReadyCallback` and is given no `_sync` form and no `_finish`.
The generator reads namespace functions through the core's readers with a finish
of `None`, so the function looked synchronous, and its callback was dropped from
the arguments like a closure — the generated wrapper then called the C function
with two of its four parameters:
frida_sys::frida_obtain_shared_agent_container(filename, cancellable)
`Function` now records whether the GIR gave it an `AsyncReadyCallback`, and
`blocking_c_identifier` refuses such a function rather than calling it as if the
callback were not there. Async functions are a later phase; the one in 17.28.1
is skipped by name with that reason until they are.
`mod gir` is private and its items are re-exported at the crate root, so `frida::gir::deinit()` did not compile: the test target has failed to build since it was added, and `cargo test --features auto-download` stopped at it before running anything.
`FRIDA_VERSION` and the vendored devkit headers move to 17.28.1, and the binding is regenerated from that release's GIR (116 files): the doc comments name 17.28.1, and `frida-sys/include/frida-core.h` gains the release's new declarations. `cargo update` and `cargo upgrade`, which the regeneration runs, move lazy_static to 1.5 in the examples, libc to 0.2.191 and bitflags to 2.13.2 in frida-gum. Checked with `cargo test --features auto-download` in frida: all suites and the doctests pass.
17.28.0 faulted in the agent container the first time a second device manager's session machinery ran, and this loop was ignored so CI stayed green while the fix was in frida-core. The fix is frida/frida-core#1306 (the agent container is shared across host sessions), which 17.28.1 carries: the loop passes on its devkit, so the test runs with the rest again.
`FRIDA_VERSION` (all three copies) and the vendored `frida-sys/include/frida-core.h` move to 17.29.0, and the binding is regenerated from that release's GIR (116 files). Besides the doc comments naming 17.29.0, the release changes the pattern API, and the binding follows it: - `PatternValueStatus` (complete, truncated, failed) is new; `PatternValue` has `status` and `error` in place of `truncated`. - `PatternModule` gains `measure`. - `PatternModule::call_function` takes the pattern and function before the type name, data and address. - `PatternDecodeOptions` gains `offset`. `frida-gum-sys/include/frida-gumjs.h` is the same in 17.29.0. `cargo update` and `cargo upgrade`, which the regeneration runs, changed nothing tracked. Checked with `cargo test --features auto-download` in frida: all suites and the doctests pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`FRIDA_VERSION` (all three copies) and the vendored headers move to 17.30.0, and the binding is regenerated from that release's GIR (116 files). Only the doc comments naming the release change: 17.30.0 adds and changes nothing in frida-core's GIR API. `frida-gum-sys/include/frida-gumjs.h` gains the release's one new C function, `gum_elf_module_find_dynamic_symbol_by_name()`. The release's behaviour changes (ELF and Android export lookups stay within the module; Node and XPC number marshalling) need nothing in the binding. `cargo update` and `cargo upgrade`, which the regeneration runs, changed nothing tracked. Checked with `cargo test --features auto-download` in frida and in frida-gum: all suites and the doctests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`indexing_slicing = "deny"` joins the workspace's clippy lints, which reach frida, and frida-gum, frida-gum-sys and frida-sys get it in their own `[lints.clippy]` tables: they do not take the workspace lints, and they are where buffers sized by Frida, Gum and capstone are read. clippy.toml already lets tests index. Hits outside tests: - frida-gum-sys `Insn::bytes()` sliced capstone's fixed 24-byte array by the instruction's `size`, which comes from C. It now uses `get()` and, should `size` ever exceed the array, returns the whole array instead of panicking. - frida-gum `CpuContext::reg()` and `set_reg()` (aarch64) index `x` after `assert!(index < 29)`, so they keep the assert and allow the lint with that reason; their docs now say when they panic. - The bindgen output frida-sys and frida-gum-sys include trips it in its bitfield helpers, so the `bindings` module allows it beside `clippy::all`, which leaves out restriction lints. - frida-gum's macho_module and pe_module integration tests index the images they build in helpers outside `#[test]` functions, so those files allow it. frida itself had no hits. Checked with `cargo clippy --all-targets -- -D warnings` for frida, frida-gum, frida-sys and frida-gum-sys with `--all-features` and with `--features auto-download` on aarch64-apple-darwin; with `--lib --all-features` on aarch64-linux-android (NDK sysroot for bindgen); `cargo fmt --check`; `taplo fmt --check`; `cargo test --features auto-download` in frida (90 passed) and frida-gum (118 passed), and `cargo test --all-features` in frida-gum (118 passed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`FRIDA_VERSION` (all three copies) and the vendored `frida-sys/include/frida-core.h` move to 17.30.2, and the binding is regenerated from that release's GIR (116 files). Only the doc comments naming the release change: 17.30.2 adds and changes nothing in frida-core's GIR API, and the header changes only in `FRIDA_VERSION` and `FRIDA_MICRO_VERSION`. `frida-gum-sys/include/frida-gumjs.h` is the same in 17.30.2. `cargo update` and `cargo upgrade`, which the regeneration runs, changed nothing tracked. Checked with `cargo test --features auto-download` in frida and in frida-gum: all suites and the doctests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…indings Rust 1.100 rejects two things in bindgen's output, so Clippy with -D warnings failed in frida-sys and frida-gum-sys: - `unnecessary_transmutes` in bindgen 0.72's bitfield accessors. bindgen 0.73.0 generates them without the transmutes (rust-bindgen #3335). - `suspicious_runtime_symbol_definitions`: the devkit headers pull in libc's bcmp and malloc, which bindgen declares with C's types (`c_ulong`, `c_uint`) where Rust's runtime expects `usize`. The build already blocklisted five of the symbols the lint checks (memcmp, memcpy, memmove, memset, strlen); it now blocklists all fourteen (adding bcmp, open, read, write, close, malloc, realloc, free and exit). Nothing here uses them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cargo 1.100 warns about every member without a `[lints]` table now that the workspace has `[workspace.lints]`. The examples unwrap to stay short, and frida-build is a build-script helper whose way to fail is a panic, so each gets an empty `[lints]` table with a comment saying why, rather than the workspace's no-panic library lints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…odules used Cargo 1.100 reports both as unused: the generated bindings and their runtime use neither. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It only defines a function, like the crate's other examples, which are all compile-only. Run, it was linked as a program: on the i686 Linux job rustdoc linked it with the host's 64-bit linker and the job failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gum never answers with no register. When an instruction uses every candidate (ESI and EDI on 32-bit x86), the register is given back before the instruction runs. The ia32 failure of this test was a Gum bug there: frida/frida-gum, "stalker: Fix x86 user data reg for insns touching all candidates". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Linked as a plain library, frida's tests crashed at startup on i686-unknown-linux-gnu: the devkit's Go runtime faults in runtime.rt0_go on its first TLS store. Linked as static=, as auto-download links it, they pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t from The examples table takes a method too, whose example follows its errors. Adds ScriptOptions, Bus, Injector, PortalService, EndpointParameters and Compiler, and DeviceManager.find_device_by_type and add_remote_device, Device.enable_spawn_gating and input, and Session.compile_script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Error's docs no longer mention the older crate::Error, which is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guide in gir's module docs never rendered, as the module is private. The crate root now has it: getting started, the DeviceManager to Script flow, spawning, messages and RPC, blocking calls and async, owners and signals, errors, the C API underneath, and where the generated and hand-written code live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On nightly, with --cfg docsrs, doc_cfg shows "Available on non-Windows only" on what the generator puts under #[cfg]. docs.rs passes the cfg. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Builds frida's and frida-sys's docs on nightly with --cfg docsrs as docs.rs does, denying rustdoc warnings, on every pull request, and deploys them on pushes to kkuehl/gir-bindings. The READMEs link them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs(frida): a guide, examples, platform badges, and published docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We know this is huge
We realize this is a very large PR. We think it's worth it, because generating the bindings puts frida-rust on the same footing as Frida's other language bindings, and keeping up with Frida becomes much easier.
frida_bindgen_coreholds the introspection model parsed from Frida's.girfiles, the naming helpers, and the loader.frida/frida_bindgenin frida-python,src/frida_bindgenin frida-node, andfrida_swift/codegen.pyin frida-swift.Frida/Generated.swiftsays it is "produced from Frida's .gir files by the shared frida_bindgen_core package".frida_rust/here is the same kind of layer, for Rust.The hand-written bindings miss much of frida-core. On
main,frida/srccalls 55 distinct frida-core functions and defines 21 public types. The generated bindings call 552 and define 151. Among whatmainlacks entirely:Compiler,PackageManagerandFileMonitorAPIs;PortalService,ControlService,Relay,EndpointParametersand the authentication services;BusandService;Spawn,Child),Crash, andApplication;That gap only grows by hand.
So a new frida-core release becomes a regeneration (
scripts/update-bindings.sh) instead of hand-porting each API change. frida-rust then gets new API when the other bindings do, and its surface matches theirs.What stays hand-written, and why
Only frida-core's API is generated. Two things stay hand-written on purpose:
frida-gumandfrida-gum-sys, unchanged in approach.frida-gumandfrida-gum-sys(not onfrida).frida(frida/src/gir/*.rsoutsidegenerated/):Errortype;rpc.exports(the way frida-python and frida-node do it);Injecttrait shared byDeviceandInjector;*_extmodules that add conveniences on top of generated classes, or work around frida-core. For example,LinuxSystemMap::from_blobreads past the blob's end unless it ends in a NUL.What
This replaces the hand-written
fridabindings with bindings generated from thefrida-core.girthat ships in each devkit, and brings every crate to Frida 17.30.2.frida_rust/:frida::*(DeviceManager,Device,Session,Script, ...).frida::Variantis the single GVariant type the marshalling uses.strict.pyrejects any GIR construct it doesn't know._syncform is refused rather than called without its callback. The first one appeared in 17.28.1 (obtain_shared_agent_container) and is skipped by name with that reason.unwrap,expectorpanic; public errors; panics andunsafedocumented;must_usewhere a result can't be ignored.scripts/update-bindings.shregenerates the bindings, then runs rustfmt,clippy --fixand clippy. It runs on Windows as well.frida-gum,frida-gum-sys, their examples and their CI jobs stay, at the same Frida version as the rest.clippy::indexing_slicingis denied outside tests. It applies across the workspace and in frida-sys, frida-gum and frida-gum-sys, where buffers sized by C are read. One real fix came out of it:Insn::bytes()no longer panics if capstone reports a size larger than its 24-byte array.Size
frida/src.fridamodules, their tests and their examples are removed.CI fixes for current Rust
unnecessary_transmuteslint rejects.memcpy,malloc,open,exitand the other symbols rustc'ssuspicious_runtime_symbol_definitionschecks are left out of both -sys crates. The devkit headers leak them in with C's types, and nothing uses them.frida-buildopt out of the workspace's no-panic lints: examples unwrap to stay short, and a build script fails by panicking.fridadrops its unusedthiserrorandserdedependencies.A Gum bug this found: frida/frida-gum#1235
On linux-x86,
reserves_a_register_for_user_data_while_following_a_threadcomputes 0 instead of 499500. The bug is in Gum's IA-32 Stalker, not here:mov [esi], edi, ran with EDI holding the user data.user_data_regnow say what Gum does: an instruction always gets a register.Testing
cargo test --features auto-downloadpasses forfridaandfrida-gumon aarch64-apple-darwin.cargo clippy --all-targets -- -D warnings, with--all-featuresand with--features auto-download;cargo fmt --checkandtaplo fmt --check.cargo clippy --lib --all-features.a_second_device_manager_after_attaching_to_this_processfaulted in frida-core 17.28.0, and frida-python faulted the same way. It was ignored while the fix landed in darwin: give the agent a file per session frida-core#1306, and it runs with the rest again from 17.28.1.🤖 Generated with Claude Code