Skip to main content

Crate cleat

Crate cleat 

Source
Expand description

§cleat — Android IL2CPP game modding toolkit

Safe Rust bindings over IL2CPP. Read fields, call methods, install inline hooks — the unsafe stays inside the library.

§Quick example

use cleat::prelude::*;

#[cleat::main]
fn my_mod() -> cleat::Result<()> {
    cleat::set_app_data("/data/data/com.example.game/files");

    let player = Il2CppClass::find("Player")?;
    let max_hp: i32 = player.static_field_value("maxHealth")?;

    Ok(())
}

#[cleat::hook("Assembly-CSharp", "Player", "TakeDamage")]
fn god_mode(this: &Il2CppObject, damage: i32) -> cleat::Result<()> {
    // Nullify incoming damage.
    god_mode::original(this, 0);
    Ok(())
}

§Features

  • Field access — read and write static/instance fields.
  • Method calls — parameterised and generic methods supported.
  • Inline hooks — #[cleat::hook] wraps ShadowHook, no manual trampoline code.
  • Custom value types — #[cleat::value_type] derives FFI-safe read/write for your #[repr(C)] structs.

§Setup

[lib]
crate-type = ["cdylib"]

[dependencies]
cleat = "0.1"
cargo ndk -t arm64-v8a -o ./target/jniLibs build --release

§Requirements

  • Rust nightly (edition 2024)
  • Android NDK r26+
  • cargo-ndk ≥ 3.0
  • libshadowhook.so (runtime, bundled in the APK)

Modules§

prelude
cleat prelude — imports all commonly used types in one line.

Structs§

HookGuard
Desktop stub — allows cargo check on non-Android platforms. Hooks are no-ops and will fail gracefully at runtime.
Il2CppArray
Wrapper around a managed T[] array.
Il2CppClass
A handle to an IL2CPP class (type metadata, not an instance).
Il2CppList
Direct memory mapping of .NET’s List<T>.
Il2CppObject
A handle to a live managed object on the IL2CPP heap.
Il2CppString
A managed System.String — cheap to copy (it’s just a pointer).
MethodInfo
Handle to an IL2CPP method.

Enums§

Error
All the ways a cleat operation can fail.

Traits§

Args
Converts a tuple of arguments into an array of FFI raw pointers.
Il2CppValueType
Marks a type that can be shuttled across the IL2CPP FFI boundary.

Functions§

app_data
Get the app data directory that was set with set_app_data.
init
Desktop stub — init is a no-op outside Android.
invoke_icall_0
Safety
invoke_icall_1
Safety
invoke_icall_2
Safety
invoke_icall_3
Safety
resolve_icall
Resolve an IL2CPP internal call (iCall) by its fully qualified name.
set_app_data
Tell cleat where your app’s private files live.

Type Aliases§

Quaternion
Result
The standard result alias used everywhere in cleat.
Vector2
Vector3
Vector4

Attribute Macros§

hook
Injects an inline hook for the given method.
main
Wraps your function in the Android entry point.
value_type
Derives Il2CppValueType for a #[repr(C)] struct.