1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Runtime-first IL2CPP integration for Rust.
//!
//! `il2cpp-bridge-rs` is designed for code already running inside a process that
//! has Unity's IL2CPP runtime loaded. It resolves IL2CPP exports at runtime,
//! builds a metadata cache, and exposes higher-level wrappers for common tasks
//! such as:
//!
//! - locating assemblies and classes
//! - selecting and invoking methods
//! - reading fields and properties
//! - finding Unity objects in the scene
//! - dumping metadata into C#-like pseudo-code
//!
//! The crate does not hide the fact that IL2CPP integration is pointer-heavy and
//! runtime-sensitive. It aims to make the common paths easier and harder to
//! misuse, not to turn IL2CPP into a purely safe abstraction.
//!
//! # Recommended Flow
//!
//! 1. Call [`init`] once the target process has loaded IL2CPP.
//! 2. Use [`api::cache`] helpers to reach assemblies.
//! 3. Resolve [`structs::Class`] and [`structs::Method`] values from the cache.
//! 4. Prefer instance-bound lookups such as [`structs::Object::method`] for
//! instance calls.
//! 5. Attach additional threads with [`api::Thread`] before doing runtime work
//! outside the initialization callback.
//!
//! # Example
//!
//! ```no_run
//! use il2cpp_bridge_rs::{api, init};
//! use std::ffi::c_void;
//!
//! init("GameAssembly", || {
//! let asm = api::cache::csharp();
//! let player = asm
//! .class("PlayerController")
//! .expect("PlayerController should exist");
//!
//! let method = player
//! .method(("TakeDamage", ["System.Single"]))
//! .expect("TakeDamage(float) should exist");
//!
//! println!("Resolved {}::{} @ RVA 0x{:X}", player.name, method.name, method.rva);
//!
//! if let Some(obj) = player.find_objects_of_type(false).into_iter().next() {
//! let bound = obj
//! .method(("TakeDamage", ["System.Single"]))
//! .expect("instance method should exist");
//!
//! let amount: f32 = 25.0;
//! unsafe {
//! let _: Result<(), _> =
//! bound.call(&[&amount as *const f32 as *mut c_void]);
//! }
//! }
//! });
//! ```
//!
//! This example is `no_run` because it depends on a live Unity IL2CPP runtime.
//! In normal usage, generated rustdoc should be treated as the canonical
//! signature-level reference, while the repository markdown guides explain
//! workflows and platform/runtime caveats.
pub use init;
pub use promote_library_to_global;