Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IL2CPP V31 #6

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rust-analyzer.cargo.features": [
"unity2019",
"il2cpp_v31",
"serde"
],
"rust-analyzer.imports.granularity.group": "module"
Expand Down
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ tracing = { version = "0.1", features = [
"std",
], default-features = false, optional = true }
tracing-subscriber = { version = "0.3", default-features = false, optional = true }
tracing-error = { version = "0.1", default-features = false, optional = true }
paranoid-android = { version = "0.1.2", optional = true }
thiserror = "1"
tracing-error = { version = "0.2", default-features = false, optional = true }
paranoid-android = { version = "0.2", optional = true }
thiserror = "2"

[target.'cfg(not(target_os = "android"))'.dependencies]
tracing-subscriber = { version = "0.3", features = [
Expand All @@ -34,7 +34,9 @@ tracing-subscriber = { version = "0.3", features = [

[features]
default = ["util", "cache"]
unity2019 = ["libil2cpp/unity2019"]
il2cpp_v31 = ["libil2cpp/il2cpp_v31"]
il2cpp_v29 = ["libil2cpp/il2cpp_v29"]
il2cpp_v24 = ["libil2cpp/il2cpp_v24"]
unity2018 = ["libil2cpp/unity2018"]
util = ["tracing", "tracing-error", "tracing-subscriber", "paranoid-android"]
cache = ["libil2cpp/cache"]
Expand Down
2 changes: 1 addition & 1 deletion inline_hook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
cfg-if = "1"

[target.'cfg(not(target_os = "android"))'.dependencies]
detour = "0.8"
retour = "0.3"

[build-dependencies]
cc = "1"
8 changes: 7 additions & 1 deletion inline_hook/src/detour.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::OnceLock;

use detour::RawDetour;
use retour::RawDetour;

/// A function hook that works across most platforms
#[derive(Debug)]
Expand Down Expand Up @@ -42,3 +42,9 @@ impl Hook {
self.detour.get().map(|d| d.trampoline() as *const ())
}
}

impl Default for Hook {
fn default() -> Self {
Self::new()
}
}
1 change: 0 additions & 1 deletion inline_hook/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![cfg_attr(not(target_os = "android"), feature(once_cell))]
#![doc(html_root_url = "https://stackdoubleflow.github.io/quest-hook-rs/inline_hook")]
#![warn(
clippy::all,
Expand Down
3 changes: 3 additions & 0 deletions libil2cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extern/
*.cmake
bindings.rs
8 changes: 5 additions & 3 deletions libil2cpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ edition = "2021"

[dependencies]
quest_hook_proc_macros = { path = "../proc_macros" }
libloading = "0.7"
thiserror = "1"
libloading = "0.8"
thiserror = "2"
paste = "1"
serde = { version = "1", optional = true }

Expand All @@ -24,7 +24,9 @@ optional = true

[features]
default = []
unity2019 = []
il2cpp_v31 = []
il2cpp_v29 = []
il2cpp_v24 = []
unity2018 = []
cache = []
trace = ["tracing"]
4 changes: 4 additions & 0 deletions libil2cpp/generate_bindings.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/pwsh


bindgen wrapper.h -o bindings.rs --wrap-unsafe-ops --sort-semantically
27 changes: 27 additions & 0 deletions libil2cpp/qpm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": "0.4.0",
"sharedDir": "shared",
"dependenciesDir": "extern",
"info": {
"name": "libil2cpp-rs",
"id": "libil2cpp-rs",
"version": "0.1.0",
"url": null,
"additionalData": {
"cmake": false
}
},
"workspace": {
"scripts": {},
"qmodIncludeDirs": [],
"qmodIncludeFiles": [],
"qmodOutput": null
},
"dependencies": [
{
"id": "libil2cpp",
"versionRange": "^0.4.0",
"additionalData": {}
}
]
}
47 changes: 47 additions & 0 deletions libil2cpp/qpm.shared.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"config": {
"version": "0.4.0",
"sharedDir": "shared",
"dependenciesDir": "extern",
"info": {
"name": "libil2cpp-rs",
"id": "libil2cpp-rs",
"version": "0.1.0",
"url": null,
"additionalData": {
"cmake": false
}
},
"workspace": {
"scripts": {},
"qmodIncludeDirs": [],
"qmodIncludeFiles": [],
"qmodOutput": null
},
"dependencies": [
{
"id": "libil2cpp",
"versionRange": "^0.4.0",
"additionalData": {}
}
]
},
"restoredDependencies": [
{
"dependency": {
"id": "libil2cpp",
"versionRange": "=0.4.0",
"additionalData": {
"headersOnly": true,
"compileOptions": {
"systemIncludes": [
"il2cpp/external/baselib/Include",
"il2cpp/external/baselib/Platforms/Android/Include"
]
}
}
},
"version": "0.4.0"
}
]
}
4 changes: 3 additions & 1 deletion libil2cpp/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use crate::{
Return, Returned, ThisParameter, Type, WrapRaw,
};

#[cfg(feature = "unity2019")]
#[cfg(feature = "il2cpp_v31")]
type FieldInfoSlice<'a> = &'a [FieldInfo];
#[cfg(feature = "il2cpp_v24")]
type FieldInfoSlice<'a> = &'a [FieldInfo];
#[cfg(feature = "unity2018")]
type FieldInfoSlice<'a> = &'a [&'static FieldInfo];
Expand Down
10 changes: 9 additions & 1 deletion libil2cpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

//! Wrappers and raw bindings for Unity's libil2cpp

#[cfg(not(any(feature = "unity2019", feature = "unity2018")))]
#[cfg(not(any(feature = "il2cpp_v31", feature = "il2cpp_v29", feature = "il2cpp_v24", feature = "unity2018")))]
compile_error!("No Unity version selected");

#[cfg(feature = "trace")]
Expand All @@ -96,6 +96,12 @@ mod exception;
mod field_info;
mod method_info;
mod object;

#[cfg_attr(
any(feature = "unity2018", feature = "il2cpp_v24"),
path = "parameter_info.rs"
)]
#[cfg_attr(any(feature = "il2cpp_v31"), path = "parameter_info_stub.rs")]
mod parameter_info;
pub mod raw;
mod string;
Expand All @@ -119,3 +125,5 @@ pub use typecheck::callee::{Parameter, Parameters, Return, ThisParameter};
pub use typecheck::caller::{Argument, Arguments, Returned, ThisArgument};
pub use typecheck::generic::Generics;
pub use typecheck::ty::Type;

pub type Result<'a, T> = std::result::Result<T, &'a mut Il2CppException>;
4 changes: 3 additions & 1 deletion libil2cpp/src/method_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use crate::{
Returned, ThisArgument, WrapRaw,
};

#[cfg(feature = "unity2019")]
#[cfg(feature = "il2cpp_v31")]
type ParameterInfoSlice<'a> = &'a [ParameterInfo];
#[cfg(feature = "il2cpp_v24")]
type ParameterInfoSlice<'a> = &'a [ParameterInfo];
#[cfg(feature = "unity2018")]
type ParameterInfoSlice<'a> = &'a [&'static ParameterInfo];
Expand Down
35 changes: 35 additions & 0 deletions libil2cpp/src/parameter_info_stub.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::fmt;

use crate::{raw, Il2CppType, WrapRaw};

/// Information about a C# parameter
#[repr(transparent)]
pub struct ParameterInfo(&'static Il2CppType);

unsafe impl Send for ParameterInfo {}
unsafe impl Sync for ParameterInfo {}

impl ParameterInfo {
/// Type of the parameter
pub fn ty(&self) -> &Il2CppType {
self.0
}
}

impl fmt::Debug for ParameterInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ParameterInfo")
.field("ty", &self.ty())
.finish()
}
}

impl fmt::Display for ParameterInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.ty())
}
}

unsafe impl WrapRaw for ParameterInfo {
type Raw = raw::Il2CppType;
}
2 changes: 1 addition & 1 deletion libil2cpp/src/raw/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use libloading::{Library, Symbol};
use quest_hook_proc_macros::il2cpp_functions;
use std::ffi::c_void;
use std::sync::{LazyLock, OnceLock};
use std::os::raw::c_char;
use std::sync::{LazyLock, OnceLock};

use super::{
FieldInfo, Il2CppArray, Il2CppAssembly, Il2CppClass, Il2CppDomain, Il2CppException,
Expand Down
4 changes: 3 additions & 1 deletion libil2cpp/src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

mod functions;

#[cfg_attr(feature = "unity2019", path = "types_2019.rs")]
#[cfg_attr(feature = "il2cpp_v31", path = "types_v31.rs")]
#[cfg_attr(feature = "il2cpp_v29", path = "types_v29.rs")]
#[cfg_attr(feature = "il2cpp_v24", path = "types_v24.rs")]
#[cfg_attr(feature = "unity2018", path = "types_2018.rs")]
mod types;

Expand Down
File renamed without changes.
Loading