8000 feat(frida): generate the bindings from frida-core's GIR, and Frida 17.30.2 by kkuehl · Pull Request #252 · frida/frida-rust · GitHub
[go: up one dir, main page]

Skip to content 7FFF
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3394a85
feat(frida): generate the bindings from frida-core's GIR
kkuehl Nov 23, 2026
940874b
fix(frida): build, lint and pass the tests on Windows
kkuehl Nov 23, 2026
08c4c8d
docs(frida): link to the crate, not the private gir module
kkuehl Nov 23, 2026
b5ae6a3
style: cargo fmt and taplo fmt
kkuehl Nov 23, 2026
d9790c3
fix(examples): build and run the inject examples on Windows
kkuehl Nov 23, 2026
ace3ed7
fix(scripts): run update-bindings.sh on Windows
kkuehl Nov 23, 2026
9ddd009
chore(deps): bump tar to 0.4.46 and serde_json to 1.0.154
kkuehl Nov 23, 2026
1c5a643
feat: bring back the hand-written frida-gum crates
kkuehl Nov 23, 2026
78d7934
chore: update Frida devkits and GIR bindings to 17.27.5
kkuehl Nov 24, 2026
d4c1cbe
chore: Frida 17.28.0, with the second-manager fau 8000 lt pinned
kkuehl Nov 27, 2026
e7814ca
frida_rust: refuse an async function, which has no `_sync` form to call
kkuehl Nov 28, 2026
4ff8a7b
test(frida): call deinit where the crate exports it
kkuehl Nov 28, 2026
52ad710
chore: Frida 17.28.1
kkuehl Nov 28, 2026
26a7e2f
test(frida): run the second-manager loop again
kkuehl Nov 29, 2026
4237369
chore: Frida 17.29.0
kkuehl Nov 30, 2026
e3adee0
chore: Frida 17.30.0
kkuehl Dec 1, 2026
0962590
chore(clippy): deny indexing_slicing outside tests
kkuehl Dec 1, 2026
7eb037d
chore: Frida 17.30.2
kkuehl Dec 4, 2026
3865c95
fix(sys): bindgen 0.73.2, and keep the C runtime symbols out of the b…
kkuehl Dec 4, 2026
b30c657
chore: say which members do not take the workspace lints
kkuehl Dec 4, 2026
d3288c6
chore(frida): drop serde and thiserror, which only the hand-written m…
kkuehl Dec 4, 2026
3c67167
docs(frida): compile the error module's example without running it
kkuehl Dec 4, 2026
20684d1
docs(frida-gum): user_data_reg always gets a register
kkuehl Dec 4, 2026
7b03cec
fix(frida-sys): link a hand-placed devkit statically, like auto-download
kkuehl Dec 4, 2026
a8034ea
frida_rust: examples on methods, and on more of the types people star…
kkuehl Dec 4, 2026
40c8f3f
docs(frida): examples for on_message, call_export, Cancellable and Error
kkuehl Dec 4, 2026
94d2b8b
docs(frida): a guide on the crate's front page
kkuehl Dec 4, 2026
262af78
docs(frida): mark platform-only items under docsrs
kkuehl Dec 4, 2026
b6646c2
ci: publish the docs to GitHub Pages from kkuehl/gir-bindings
kkuehl Dec 4, 2026
2e71605
Merge pull request #2 from kkuehl/kkuehl/docs
kkuehl Dec 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 19 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Frida's prebuilt devkit static libraries (frida-gum, frida-gumjs,
# frida-core) are built against the static MSVC CRT (LIBCMT). Rust links the
# dynamic CRT (MSVCRT) by default, so the linker emits
# `LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs` and the
# process ends up with two CRTs (separate heaps/globals).
#
# Build with the same CRT as the devkits on Windows MSVC. This is also the
# right choice for injecting the resulting DLLs (no MSVC runtime dependency).
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

# The 32-bit frida-core devkit has objects built by Go and by MinGW, which carry
# no table of safe exception handlers. Rust asks the linker for a SAFESEH
# image, which it refuses to make from them (LNK2026, LNK1281).
[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static", "-C", "link-arg=/SAFESEH:NO"]

[target.aarch64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
frida-gum-sys/include/frida-gum.h linguist-vendored binary
frida-gum-sys/include/frida-gumjs.h linguist-vendored binary
frida-sys/include/frida-core.h linguist-vendored binary
8000
12 changes: 12 additions & 0 deletions .github/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>frida-rust documentation</title>
<meta http-equiv="refresh" content="0; url=frida/index.html">
<link rel="canonical" href="frida/index.html">
</head>
<body>
<p>The documentation of the <code>frida</code> crate is at <a href="frida/index.html">frida/index.html</a>.</p>
</body>
</html>
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,51 @@ jobs:
profile: minimal
toolchain: nightly
override: true
- name: Download FRIDA
run: |
export FRIDA_VERSION=$(cat FRIDA_VERSION)
cd frida-gum-sys && mkdir -p include && wget https://github.com/frida/frida/releases/download/$FRIDA_VERSION/frida-gum-devkit-$FRIDA_VERSION-linux-x86_64.tar.xz -O frida-gum.tar.xz && tar xJvf frida-gum.tar.xz -C include
cd ..
cd frida-sys && mkdir -p include && wget https://github.com/frida/frida/releases/download/$FRIDA_VERSION/frida-core-devkit-$FRIDA_VERSION-linux-x86_64.tar.xz -O frida-core.tar.xz && tar xJvf frida-core.tar.xz -C include
- name: Build Gum documentation
run: |
cd frida-gum
cargo rustdoc --features "event-sink invocation-listener"
- name: Build Frida documentation
run: |
cd frida
cargo rustdoc
headers:
name: Committed headers match FRIDA_VERSION
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check the FRIDA_VERSION files agree
run: |
version=$(cat FRIDA_VERSION)
for file in FRIDA_VERSION frida-gum-sys/FRIDA_VERSION frida-sys/FRIDA_VERSION; do
if [ "$(cat "$file")" != "$version" ]; then
echo "::error file=$file::$file is $(cat "$file"), but FRIDA_VERSION is $version"
exit 1
fi
done
- name: Compare the committed headers with the pinned devkits
run: |
set -euo pipefail
version=$(cat FRIDA_VERSION)
base="https://github.com/frida/frida/releases/download/$version"
work=$(mktemp -d)
curl -fsSL -o "$work/frida-gumjs.tar.xz" "$base/frida-gumjs-devkit-$version-linux-x86_64.tar.xz"
curl -fsSL -o "$work/frida-core.tar.xz" "$base/frida-core-devkit-$version-linux-x86_64.tar.xz"
tar xJf "$work/frida-gumjs.tar.xz" -C "$work"
tar xJf "$work/frida-core.tar.xz" -C "$work"
status=0
diff -u frida-gum-sys/include/frida-gumjs.h "$work/frida-gumjs.h" || status=1
diff -u frida-sys/include/frida-core.h "$work/frida-core.h" || status=1
if [ "$status" -ne 0 ]; then
echo "::error::The committed headers differ from the Frida $version devkits; run scripts/update-headers.sh and commit the result."
exit 1
fi
check-nostd:
name: Check no_std
runs-on: ubuntu-latest
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/docs.yml
< 8000 td class="blob-num blob-num-addition empty-cell">
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Builds the API documentation of frida and frida-sys, and publishes it to GitHub Pages
# from kkuehl/gir-bindings. Pull requests build it, so a broken intra-doc link or any
# other rustdoc warning fails them, but do not publish it.
#
# Pages has to be set to deploy from GitHub Actions (Settings > Pages > Source).

name: Docs

on:
push:
branches: [kkuehl/gir-bindings]
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: docs-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Rust nightly
# Nightly for `--cfg docsrs`, which marks the items only some platforms have.
run: rustup toolchain install nightly --profile minimal
- name: Build the docs
env:
# As docs.rs builds it: frida-sys reads its vendored frida-core.h, and nothing is
# downloaded or linked.
DOCS_RS: "1"
RUSTDOCFLAGS: --cfg docsrs -D warnings
run: cargo +nightly doc -p frida -p frida-sys --no-deps
- name: Add the root page
run: cp .github/pages/index.html target/doc/index.html
- name: Upload
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: target/doc

deploy:
name: Deploy
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/kkuehl/gir-bindings'
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}frida/
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/target
Cargo.lock
.vscode
/justfile


# Tool-local config (e.g. Claude Code workflows); not part of the crate.
.claude/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "frida-bindgen"]
path = frida-bindgen
url = https://github.com/frida/frida-bindgen.git
25 changes: 25 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,28 @@ edition = "2024"
license = "wxWindows"
repository = "https://github.com/frida/frida-rust"
description = "Rust bindings for Frida"

[workspace.lints.rust]
warnings = "deny"
unsafe_op_in_unsafe_fn = "deny"

[workspace.lints.clippy]
correctness = { level = "deny", priority = -1 }
suspicious = { level = "deny", priority = -1 }
# No panics in production code: return an error, or prove the case cannot happen in the
# types. (clippy.toml lets tests unwrap and index.)
unwrap_used = "deny"
expect_used = "deny"
panic = "deny"
todo = "deny"
unimplemented = "deny"
unreachable = "deny"
# Index and slice with get() and checked ranges; above all buffers whose length comes
# from Frida or C. (clippy.toml lets tests index.)
indexing_slicing = "deny"
# A library documents its public errors, panics and unsafe.
missing_errors_doc = "deny"
missing_panics_doc = "deny"
missing_safety_doc = "deny"
# A return value that must not be ignored, such as [`Owned`] and `Error`.
must_use_candidate = "deny"
2 changes: 1 addition & 1 deletion FRIDA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.16.4
17.30.2
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,27 @@ Rust bindings for [Frida](http://www.frida.re/).
- 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

## Documentation

The `frida` crate's API documentation, with a guide on its front page, is published from
the `kkuehl/gir-bindings` branch to <https://kkuehl.github.io/frida-rust/frida/>
(`frida-sys` beside it). To build it locally:

cargo doc -p frida --no-deps --features auto-download --open

## The generated core API

`frida` is frida-core's whole API (classes, enumerations, constructors, methods and
properties), generated from the `frida-core.gir` that ships in the core devkit by
`frida_rust/`, a standard-library Python package built, like frida-python's, frida-node's
and frida-swift's generators, on Frida's shared generator core: the `frida-bindgen`
submodule. The output is committed under `frida/src/gir/generated/`, so building needs
neither. After bumping `FRIDA_VERSION`, regenerate it and commit the result:

scripts/update-bindings.sh

It checks out the submodule if it is missing (`git submodule update --init frida-bindgen`
does the same). The generator's tests run with
`PYTHONPATH=frida-bindgen python3 -m unittest discover -s frida_rust/tests -t .` from the
repository root.
6 changes: 6 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Clippy's settings for every crate (a crate's own clippy.toml replaces this one).
# Panics are for tests: production code returns errors (see [workspace.lints.clippy]).
allow-unwrap-in-tests = true
allow-expect-in-tests = true
allow-panic-in-tests = true
allow-indexing-slicing-in-tests = true
7 changes: 5 additions & 2 deletions examples/core/compile_script/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[package]
name = "compile_script"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "wxWindows"
publish = false

[dependencies]
frida = { path = "../../../frida" }
frida = { path = "../../../frida", features = ["auto-download"] }

# An example: it unwraps to stay short, so it does not take the workspace's library lints.
[lints]
66 changes: 25 additions & 41 deletions examples/core/compile_script/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,69 +1,53 @@
use frida::{DeviceManager, Frida, Message, ScriptHandler, ScriptOption, ScriptRuntime};
use std::sync::LazyLock;

static FRIDA: LazyLock<Frida> = LazyLock::new(|| unsafe { Frida::obtain() });
use frida::{DeviceManager, ScriptOptions, ScriptRuntime};

const BYTECODE_PATH: &str = "compiled.bin";

const SCRIPT_SOURCE: &str = r#"
console.log("Hello from precompiled bytecode! pid=" + Process.id);
"#;

fn main() {
let device_manager = DeviceManager::obtain(&FRIDA);
let device = device_manager
.get_local_device()
.expect("local device unavailable");
fn main() -> Result<(), Box<dyn std::error::Error>> {
let manager = DeviceManager::new()?;
let device = manager.get_local_device()?;

println!("[*] Frida version: {}", Frida::version());
println!("[*] Device: {}", device.get_name());
println!("[*] Frida version: {}", frida::version());
println!("[*] Device: {}", device.name());

let session = device.attach(0).expect("attach to self failed");
let session = device.attach(0, None, None)?;
println!("[*] Attached to self (pid=0)");

// 1. Compile JS -> bytecode with the QJS runtime.
// Bytecode is runtime-specific: load with the same runtime.
let mut compile_opts = ScriptOption::new()
.set_name("compile_script_example")
.set_runtime(ScriptRuntime::QJS);
let bytecode = session
.compile_script(SCRIPT_SOURCE, &mut compile_opts)
.expect("compile_script failed");
let compile_opts = ScriptOptions::new()
.name("compile_script_example")
.runtime(ScriptRuntime::Qjs);
let bytecode = session.compile_script(SCRIPT_SOURCE, Some(&compile_opts), None)?;
println!("[*] Compiled {} bytes of bytecode", bytecode.len());

// 2. Demonstrate the ship-as-artifact workflow: write to disk, read back.
std::fs::write(BYTECODE_PATH, &bytecode).expect("write bytecode failed");
std::fs::write(BYTECODE_PATH, &bytecode)?;
println!("[*] Wrote bytecode to {}", BYTECODE_PATH);
let loaded = std::fs::read(BYTECODE_PATH).expect("read bytecode failed");
let loaded = std::fs::read(BYTECODE_PATH)?;
println!("[*] Read {} bytes back from disk", loaded.len());

// 3. Load the bytecode through create_script_from_bytes.
let mut load_opts = ScriptOption::new()
F9C7 .set_name("compile_script_example")
.set_runtime(ScriptRuntime::QJS);
let mut script = session
.create_script_from_bytes(&loaded, &mut load_opts)
.expect("create_script_from_bytes failed");

script
.handle_message(Handler)
.expect("handle_message failed");
script.load().expect("script load failed");
let load_opts = ScriptOptions::new()
.name("compile_script_example")
.runtime(ScriptRuntime::Qjs);
let script = session.create_script_from_bytes(&loaded, Some(&load_opts), None)?;

let _handler = script.on_message(|message, _data| {
println!("- {message:?}");
});
script.load(None)?;
println!("[*] Script loaded from bytecode");

script.unload().expect("script unload failed");
script.unload(None)?;
println!("[*] Script unloaded");

session.detach().expect("session detach failed");
session.detach(None)?;
println!("[*] Session detached");

let _ = std::fs::remove_file(BYTECODE_PATH);
}

struct Handler;

impl ScriptHandler for Handler {
fn on_message(&mut self, message: Message, _data: Option<Vec<u8>>) {
println!("- {:?}", message);
}
Ok(())
}
7 changes: 5 additions & 2 deletions examples/core/console_log/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[package]
name = "console_log"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "wxWindows"
publish = false

[dependencies]
frida = { path = "../../../frida" }
frida = { path = "../../../frida", features = ["auto-download"] }

# An example: it unwraps to stay short, so it does not take the workspace's library lints.
[lints]
Loading
Loading
0