| Crates.io | kittymemory-rs |
| lib.rs | kittymemory-rs |
| version | 0.3.4 |
| created_at | 2025-11-23 15:08:07.926751+00 |
| updated_at | 2026-01-25 19:37:42.441292+00 |
| description | Rust bindings for KittyMemory - A memory manipulation library for Android and iOS |
| homepage | |
| repository | https://github.com/rodroidmods/kittymemory-rs |
| max_upload_size | |
| id | 1946656 |
| size | 212,277 |
Production-ready Rust bindings for KittyMemory — a comprehensive memory manipulation library for Android and iOS.
⚠️ Important: Use version 0.3.0 or higher. Version 0.3.0 includes complete feature parity with the original KittyMemory library with 100+ new functions and advanced capabilities.
Note: The
keystonefeature for assembly patching is currently experimental and may have build issues. Use hex/bytes patching for production. Windows currentely is not supported, you might get errors if you try to build it in a windows pc, its recomanded to use WSL2 to compile it for android.
sys: Raw FFI bindings (auto-generated with bindgen)safe: Safe Rust wrappers with RAII and error handlingprelude: Convenient imports for common use casesAdd to your Cargo.toml:
[dependencies]
kittymemory-rs = "0.3" # Recommended: auto-updates to latest stable 0.3.x
With Keystone assembler support:
[dependencies]
kittymemory-rs = { version = "0.3", features = ["keystone"] }
Or from GitHub:
[dependencies]
kittymemory = { git = "https://github.com/rodroidmods/kittymemory-rs", branch = "main" }
libclang (for bindgen)use kittymemory_rs::prelude::*;
let addr = 0x12345678;
let value: i32 = mem_read(addr)?;
mem_write(addr, &42i32)?;
use kittymemory_rs::prelude::*;
// Basic patching with absolute address
let mut patch = Patch::with_hex(0x1000, "90 90 90 90")?;
patch.modify()?;
patch.restore()?;
Create patches using library name + offset - just like the C++ API:
#[cfg(target_os = "android")]
use kittymemory::prelude::*;
// Helper to convert hex string to offset
fn string2offset(hex_str: &str) -> usize {
let clean = hex_str.trim().trim_start_matches("0x").trim_start_matches("0X");
usize::from_str_radix(clean, 16).unwrap_or(0)
}
// Create patch using library name + offset (like C++ MemoryPatch::createWithHex)
let mut money_patch = Patch::with_hex_lib(
"libil2cpp.so",
string2offset("0xD6D93C"),
"62 01 0C 00 1E FF 2F E1"
)?;
money_patch.modify()?;
// Or with raw bytes
let mut bytes_patch = Patch::with_bytes_lib(
"libil2cpp.so",
0xD6D93C,
&[0x62, 0x01, 0x0C, 0x00, 0x1E, 0xFF, 0x2F, 0xE1]
)?;
bytes_patch.modify()?;
keystone feature)// With absolute address
let mut patch = Patch::with_asm(
0x1000,
AsmArch::ARM64,
"mov x0, #42\nret",
0x1000
)?;
patch.modify()?;
// With library name + offset (Android only)
#[cfg(target_os = "android")]
let mut asm_patch = Patch::with_asm_lib(
"libil2cpp.so",
0xD6D93C,
AsmArch::ARM32,
"mov r0, #1; bx lr"
)?;
use kittymemory_rs::prelude::*;
if let Some(addr) = find_pattern_first(0x10000000, 0x20000000, "48 8B ? ? 48 89") {
println!("Found at {:#x}", addr);
}
let all_matches = find_hex_all(0x10000000, 0x20000000, "DEADBEEF", "xxxxxxxx");
for addr in all_matches {
println!("Match at {:#x}", addr);
}
#[cfg(target_os = "android")]
use kittymemory::prelude::*;
let elf = ElfScanner::find("libil2cpp.so").expect("Library not found");
if let Some(addr) = elf.find_symbol("il2cpp_init") {
println!("il2cpp_init at {:#x}", addr);
}
println!("Base: {:#x}", elf.base());
println!("Size: {:#x}", elf.load_size());
println!("Native: {}", elf.is_native());
#[cfg(target_os = "android")]
use kittymemory::prelude::*;
let linker = LinkerScanner::get();
for lib in linker.all_soinfo() {
println!("{}: base={:#x} size={:#x}", lib.path, lib.base, lib.size);
}
if let Some(info) = linker.find_soinfo("libc.so") {
println!("libc base: {:#x}", info.base);
}
#[cfg(target_os = "android")]
use kittymemory::prelude::*;
let maps = get_all_maps();
for map in maps {
println!("{:#x}-{:#x} {} {}",
map.start_address, map.end_address, map.protection, map.pathname);
}
let lib_maps = get_maps_filtered("libunity.so", ProcMapFilter::Contains);
#[cfg(target_os = "ios")]
use kittymemory::prelude::*;
let base = MemoryFileInfo::get_base_info();
println!("Base executable: {}", base.name());
if let Some(lib) = MemoryFileInfo::get_file_info("libSystem.dylib") {
let text = lib.get_segment("__TEXT");
println!("__TEXT: {:#x}-{:#x}", text.start, text.end);
if let Some(addr) = lib.find_symbol("_malloc") {
println!("malloc at {:#x}", addr);
}
}
use kittymemory_rs::prelude::*;
let data = vec![0xDE, 0xAD, 0xBE, 0xEF];
let hex = data_to_hex(&data);
println!("Hex: {}", hex);
let bytes = hex_to_data("DEADBEEF")?;
let dump = hex_dump(0x1000, 64);
println!("{}", dump);
cargo build
cargo install cargo-ndk
cargo ndk -t arm64-v8a build --release
rustup target add aarch64-apple-ios
cargo build --target aarch64-apple-ios --release
Run the basic example:
cargo run --example usage
Run the advanced features example (showcasing new v0.3.0 features):
cargo run --example advanced_features
The advanced example demonstrates:
Generate and open the documentation:
cargo doc --open
keystone: Enable assembly patching with Keystone assemblerandroid: Android-specific features (auto-detected)ios: iOS-specific features (auto-detected)safe module: RAII wrappers with automatic cleanup and error handlingsys module: Raw FFI - requires manual memory management and unsafe blocks| Feature | Android | iOS | Cross-Platform |
|---|---|---|---|
| Memory R/W | ✅ | ✅ | ✅ |
| Patching | ✅ | ✅ | ✅ |
| Pattern Scanning | ✅ | ✅ | ✅ |
| ELF Analysis | ✅ | N/A | - |
| Mach-O Analysis | N/A | ✅ | - |
| LinkerScanner | ✅ | N/A | - |
| Process Maps | ✅ | N/A | - |
| JNI Support | ✅ | N/A | - |
| Pointer Validation | ✅ | ✅ | ✅ |
MIT
Contributions welcome! Open issues or submit pull requests.
Patch::with_hex_lib() - Create hex patch with library name + offsetPatch::with_bytes_lib() - Create bytes patch with library name + offsetPatch::with_asm_lib() - Create assembly patch with library name + offset (requires keystone)Intended for education, research, and legitimate reverse engineering only. Users are responsible for compliance with applicable laws and platform terms.