hao-il2cpp-runtime 0.0.7

Hook and call into Unity Il2Cpp games from inside the game process
Documentation
use thiserror::Error;

/// A result whose error is [`Error`](enum@Error).
pub type Result<T> = std::result::Result<T, Error>;

#[derive(Error, Debug)]
/// What went wrong loading the game binary, finding things in it, or calling
/// and hooking its methods.
pub enum Error {
    /// The game binary couldn't be opened, or isn't loaded in this process.
    #[error("could not load the game binary: {0}")]
    Load(libloading::Error),
    /// An `il2cpp_*` function this crate needs isn't exported by the game
    /// binary, e.g. the binary isn't an Il2Cpp `GameAssembly`.
    #[error("the game binary does not export {0}: {1}")]
    MissingExport(&'static str, libloading::Error),
    /// The game binary is for another platform, e.g. a Windows build running
    /// under Wine/Proton seen from a Linux mod.
    #[error("{0}")]
    UnsupportedBinary(String),
    /// A hook's or call's Rust types don't match the method's real signature.
    #[error("signature mismatch, {0}")]
    Signature(String),
    /// `il2cpp_init` returned failure in [`Il2Cpp::init_standalone`](crate::Il2Cpp::init_standalone).
    #[error("il2cpp_init failed")]
    Init,
    /// An assembly, class, method, field or object wasn't found, or couldn't be allocated.
    #[error("could not find {0}")]
    NotFound(String),
    /// A name passed to the runtime contains a nul byte, so it can't be a C string.
    #[error("{0} contains a nul byte")]
    Nul(String),
    /// Installing or removing a hook failed.
    #[error("hooking failed: {0:?}")]
    Hook(hooking::error::HookingError),
    /// The called method threw a managed exception; holds its `ToString()`.
    #[error("{0}")]
    Exception(String),
}