From 7e7bfe4f3a365664e307c0aa55eeb17a996debc7 Mon Sep 17 00:00:00 2001 From: FernTheDev <15272073+Fernthedev@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:51:34 -0400 Subject: [PATCH] Feature switching for brocollib version --- Cargo.lock | 248 +++++++++++++++++++++-------- Cargo.toml | 19 ++- src/generate/cpp/cpp_type.rs | 2 +- src/generate/cs_members.rs | 4 +- src/generate/offsets/mod.rs | 7 +- src/generate/offsets/offsets_29.rs | 48 +++--- src/main.rs | 6 + 7 files changed, 230 insertions(+), 104 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9c96ff28..38ae9dab1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,9 +34,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -49,36 +49,36 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -108,9 +108,22 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdfe7137c8817d4649b0f05e559c759efa8fb376cd25a33c4d069288332f1202" dependencies = [ - "bad64-sys", + "bad64-sys 0.5.0", "cstr_core", - "num-derive", + "num-derive 0.3.3", + "num-traits", + "static_assertions", +] + +[[package]] +name = "bad64" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba05edc6ff60c0cacfb48eab9d0f9f8a51663071b47c9673c2340c87ebf12c3" +dependencies = [ + "bad64-sys 0.7.0", + "cstr_core", + "num-derive 0.4.2", "num-traits", "static_assertions", ] @@ -121,7 +134,18 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95ee29370ca1576779cbf37adc0bebd518ef7956bb457f64fe499817a7774aea" dependencies = [ - "bindgen", + "bindgen 0.59.2", + "cc", + "glob", +] + +[[package]] +name = "bad64-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "565d858ca3f61068d61bf37020549bbd0692b11ff072352183a9f21226fe78c7" +dependencies = [ + "bindgen 0.69.5", "cc", "glob", ] @@ -163,6 +187,26 @@ dependencies = [ "shlex", ] +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.6.0", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.89", +] + [[package]] name = "binread" version = "2.2.0" @@ -200,9 +244,9 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "brocolib" version = "0.1.0" -source = "git+https://github.com/Fernthedev/brocolib.git?branch=il2cpp_v31_fix/codegen-modules#bd89c14b653b5967bf0b07841e5b4b71b222acb6" +source = "git+https://github.com/Stackdoubleflow/brocolib.git?branch=il2cpp_v29#d3bc9f2bd9f0c42b71d5a8e0549a1a34cb1e943e" dependencies = [ - "bad64", + "bad64 0.6.0", "binde", "binread", "byteorder", @@ -210,6 +254,19 @@ dependencies = [ "thiserror", ] +[[package]] +name = "brocolib" +version = "0.1.0" +source = "git+https://github.com/Stackdoubleflow/brocolib.git?branch=il2cpp_v31#da52205092fbce29d9e0b36246ffeb06ae17a76f" +dependencies = [ + "bad64 0.9.0", + "binde", + "binread", + "byteorder", + "object 0.36.5", + "thiserror", +] + [[package]] name = "byteorder" version = "1.5.0" @@ -218,15 +275,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cc" -version = "1.1.28" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -261,9 +318,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -271,9 +328,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -290,14 +347,14 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.89", ] [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "color-eyre" @@ -328,16 +385,17 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "cordl" version = "0.1.0" dependencies = [ "bitflags 2.6.0", - "brocolib", + "brocolib 0.1.0 (git+https://github.com/Stackdoubleflow/brocolib.git?branch=il2cpp_v29)", + "brocolib 0.1.0 (git+https://github.com/Stackdoubleflow/brocolib.git?branch=il2cpp_v31)", "byteorder", "bytes", "clap", @@ -346,7 +404,7 @@ dependencies = [ "fs_extra", "include_dir", "indent_write", - "itertools", + "itertools 0.13.0", "log", "pathdiff", "pretty_env_logger", @@ -447,9 +505,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide 0.8.0", @@ -539,6 +597,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.13.0" @@ -550,9 +617,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jobserver" @@ -577,9 +644,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" [[package]] name = "libloading" @@ -648,6 +715,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -676,6 +754,17 @@ dependencies = [ "memchr", ] +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "flate2", + "memchr", + "ruzstd", +] + [[package]] name = "once_cell" version = "1.20.2" @@ -690,9 +779,9 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" [[package]] name = "peeking_take_while" @@ -702,9 +791,9 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pretty_env_logger" @@ -718,9 +807,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -756,9 +845,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -768,9 +857,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -797,9 +886,18 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + +[[package]] +name = "ruzstd" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "99c3938e133aac070997ddc684d4b393777d293ba170f2988c8fd5ea2ad4ce21" +dependencies = [ + "twox-hash", +] [[package]] name = "ryu" @@ -818,29 +916,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.89", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -888,9 +986,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", @@ -908,22 +1006,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.89", ] [[package]] @@ -944,9 +1042,9 @@ checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-core", @@ -954,9 +1052,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -983,11 +1081,21 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "static_assertions", +] + [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "utf8parse" diff --git a/Cargo.toml b/Cargo.toml index 9281969ef..8371dbfe5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,12 +7,23 @@ edition = "2021" [features] default = ["il2cpp_v31"] -il2cpp_v31 = [] -il2cpp_v29 = [] +il2cpp_v31 = ["brocolib_il2cpp_v31"] +il2cpp_v29 = ["brocolib_il2cpp_v29"] + +# Alias a second version of the dependency with a different package name +[dependencies.brocolib_il2cpp_v31] +git = "https://github.com/Stackdoubleflow/brocolib.git" +branch = "il2cpp_v31" +optional = true +package = "brocolib" + +[dependencies.brocolib_il2cpp_v29] +git = "https://github.com/Stackdoubleflow/brocolib.git" +branch = "il2cpp_v29" +optional = true +package = "brocolib" [dependencies] -brocolib = { git = "https://github.com/Fernthedev/brocolib.git", branch = "il2cpp_v31_fix/codegen-modules" } -# brocolib = { git = "https://github.com/Stackdoubleflow/brocolib.git", branch = "il2cpp_v31" } clap = { version = "4", features = ["derive"] } indent_write = { version = "*" } color-eyre = "0.6" diff --git a/src/generate/cpp/cpp_type.rs b/src/generate/cpp/cpp_type.rs index d33f8e01a..84aa7d32d 100644 --- a/src/generate/cpp/cpp_type.rs +++ b/src/generate/cpp/cpp_type.rs @@ -611,7 +611,7 @@ impl CppType { continue; } - let prop_ty = prop.prop_ty.get_type(name_resolver.cordl_metadata); + let _prop_ty = prop.prop_ty.get_type(name_resolver.cordl_metadata); let prop_resolved_ty = name_resolver.resolve_name(self, &prop.prop_ty, TypeUsage::Property, false); diff --git a/src/generate/cs_members.rs b/src/generate/cs_members.rs index b8cd53b70..09f4f9a5b 100644 --- a/src/generate/cs_members.rs +++ b/src/generate/cs_members.rs @@ -5,9 +5,9 @@ use itertools::Itertools; use crate::data::type_resolver::ResolvedType; -use super::writer::Writable; -use std::{hash::Hash, sync::Arc}; + +use std::{hash::Hash}; #[derive(Debug, Eq, Hash, PartialEq, Clone, Default, PartialOrd, Ord)] pub struct CsGenericTemplate { diff --git a/src/generate/offsets/mod.rs b/src/generate/offsets/mod.rs index 605487006..28d2b09de 100644 --- a/src/generate/offsets/mod.rs +++ b/src/generate/offsets/mod.rs @@ -1,11 +1,12 @@ #[cfg(feature = "il2cpp_v29")] mod offsets_29; -#[cfg(feature = "il2cpp_v31")] -mod offsets_31; - #[cfg(feature = "il2cpp_v29")] pub use offsets_29::*; + +#[cfg(feature = "il2cpp_v31")] +mod offsets_31; + #[cfg(feature = "il2cpp_v31")] pub use offsets_31::*; diff --git a/src/generate/offsets/offsets_29.rs b/src/generate/offsets/offsets_29.rs index 6c4fa4ebf..8f9e5a958 100644 --- a/src/generate/offsets/offsets_29.rs +++ b/src/generate/offsets/offsets_29.rs @@ -1,6 +1,6 @@ use core::mem; -use crate::generate::metadata::Metadata; +use crate::generate::metadata::CordlMetadata; use crate::generate::metadata::PointerSize; use crate::generate::type_extensions::TypeDefinitionExtensions; use crate::TypeDefinitionIndex; @@ -33,8 +33,8 @@ pub struct SizeInfo { pub fn get_size_info<'a>( t: &'a Il2CppTypeDefinition, tdi: TypeDefinitionIndex, - generic_inst_types: Option<&Vec>, - metadata: &'a Metadata, + generic_inst_types: Option<&[usize]>, + metadata: &'a CordlMetadata, ) -> SizeInfo { let size_metadata = get_size_of_type_table(metadata, tdi).unwrap(); let mut instance_size = size_metadata.instance_size; @@ -79,8 +79,8 @@ pub fn get_size_info<'a>( pub fn get_size_and_packing<'a>( t: &'a Il2CppTypeDefinition, tdi: TypeDefinitionIndex, - generic_inst_types: Option<&Vec>, - metadata: &'a Metadata, + generic_inst_types: Option<&[usize]>, + metadata: &'a CordlMetadata, ) -> (u32, Option) { let size_metadata = get_size_of_type_table(metadata, tdi).unwrap(); let mut metadata_size = size_metadata.instance_size; @@ -102,9 +102,9 @@ pub fn get_size_and_packing<'a>( } pub fn get_il2cpptype_sa( - metadata: &Metadata<'_>, + metadata: &CordlMetadata<'_>, ty: &Il2CppType, - generic_inst_types: Option<&Vec>, + generic_inst_types: Option<&[usize]>, ) -> SizeAndAlignment { get_type_size_and_alignment(ty, generic_inst_types, metadata) } @@ -112,8 +112,8 @@ pub fn get_il2cpptype_sa( pub fn get_sizeof_type<'a>( t: &'a Il2CppTypeDefinition, tdi: TypeDefinitionIndex, - generic_inst_types: Option<&Vec>, - metadata: &'a Metadata, + generic_inst_types: Option<&[usize]>, + metadata: &'a CordlMetadata, ) -> u32 { let size_metadata = get_size_of_type_table(metadata, tdi).unwrap(); let mut metadata_size = size_metadata.instance_size; @@ -185,7 +185,7 @@ fn packing_is_default(bitfield: u32, packing_is_default_offset: u8) -> bool { } /// RuntimeType::GetPacking -fn get_packing(metadata: &Metadata<'_>, ty_def: &Il2CppTypeDefinition) -> Option { +fn get_packing(metadata: &CordlMetadata<'_>, ty_def: &Il2CppTypeDefinition) -> Option { // according to this, packing is by default n = 8 // https://learn.microsoft.com/en-us/cpp/preprocessor/pack?view=msvc-170 if packing_is_default(ty_def.bitfield, metadata.packing_is_default_offset) { @@ -197,7 +197,7 @@ fn get_packing(metadata: &Metadata<'_>, ty_def: &Il2CppTypeDefinition) -> Option } /// GlobalMetadata::FromTypeDefinition -fn get_type_def_packing(metadata: &Metadata, ty_def: &Il2CppTypeDefinition) -> Option { +fn get_type_def_packing(metadata: &CordlMetadata, ty_def: &Il2CppTypeDefinition) -> Option { let packing = packing_value(ty_def.bitfield, metadata.packing_field_offset); // packing 8 is default @@ -215,7 +215,7 @@ fn size_is_default(bitfield: u32, size_is_default_offset: u8) -> bool { } fn get_size( - metadata: &Metadata<'_>, + metadata: &CordlMetadata<'_>, tdi: TypeDefinitionIndex, ty_def: &Il2CppTypeDefinition, ) -> Option { @@ -228,10 +228,10 @@ fn get_size( /// Inspired by libil2cpp Class::LayoutFieldsLocked pub fn layout_fields( - metadata: &Metadata<'_>, + metadata: &CordlMetadata<'_>, declaring_ty_def: &Il2CppTypeDefinition, declaring_tdi: TypeDefinitionIndex, - generic_inst_types: Option<&Vec>, + generic_inst_types: Option<&[usize]>, offsets: Option<&mut Vec>, strictly_calculated: bool, ) -> SizeAndAlignment { @@ -340,10 +340,10 @@ pub fn layout_fields( /// equivalent to libil2cpp FieldLayout::LayoutFields with the instance field filter fn layout_instance_fields( - metadata: &Metadata<'_>, + metadata: &CordlMetadata<'_>, declaring_ty_def: &Il2CppTypeDefinition, declaring_tdi: TypeDefinitionIndex, - generic_inst_types: Option<&Vec>, + generic_inst_types: Option<&[usize]>, offsets: Option<&mut Vec>, parent_sa: SizeAndAlignment, ) -> SizeAndAlignment { @@ -422,7 +422,7 @@ fn layout_instance_fields( } fn get_offset_of_type_table( - metadata: &Metadata<'_>, + metadata: &CordlMetadata<'_>, tdi: TypeDefinitionIndex, field: usize, ) -> Option { @@ -440,9 +440,9 @@ fn get_offset_of_type_table( } fn get_parent_sa( - metadata: &Metadata<'_>, + metadata: &CordlMetadata<'_>, parent_index: u32, - generic_inst_types: Option<&Vec>, + generic_inst_types: Option<&[usize]>, ) -> SizeAndAlignment { let parent_ty = &metadata.metadata_registration.types[parent_index as usize]; let (parent_tdi, parent_generics) = match parent_ty.data { @@ -499,7 +499,7 @@ fn get_parent_sa( metadata, &metadata.metadata.global_metadata.type_definitions[parent_tdi], parent_tdi, - parent_generics.as_ref(), + parent_generics.as_deref(), None, false, ) @@ -509,7 +509,7 @@ fn update_instance_size_for_generic_class( ty_def: &Il2CppTypeDefinition, tdi: TypeDefinitionIndex, instance_size: usize, - metadata: &Metadata<'_>, + metadata: &CordlMetadata<'_>, ) -> usize { // need to set this in case there are no fields in a generic instance type if !ty_def.generic_container_index.is_valid() { @@ -532,7 +532,7 @@ fn update_instance_size_for_generic_class( } pub fn get_size_of_type_table<'a>( - metadata: &'a Metadata<'a>, + metadata: &'a CordlMetadata<'a>, tdi: TypeDefinitionIndex, ) -> Option<&'a Il2CppTypeDefinitionSizes> { if let Some(size_table) = &metadata @@ -576,8 +576,8 @@ fn get_alignment_of_type(ty: OffsetType, pointer_size: PointerSize) -> u8 { fn get_type_size_and_alignment( ty: &Il2CppType, - generic_inst_types: Option<&Vec>, - metadata: &Metadata, + generic_inst_types: Option<&[usize]>, + metadata: &CordlMetadata, ) -> SizeAndAlignment { let mut sa = SizeAndAlignment { alignment: 0, diff --git a/src/main.rs b/src/main.rs index be6548e1d..49fc225db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,12 @@ #![feature(exit_status_error)] #![feature(iterator_try_collect)] +#[cfg(feature="il2cpp_v31")] +extern crate brocolib_il2cpp_v31 as brocolib; + +#[cfg(feature="il2cpp_v29")] +extern crate brocolib_il2cpp_v29 as brocolib; + use brocolib::{global_metadata::TypeDefinitionIndex, runtime_metadata::TypeData}; use byteorder::LittleEndian; use color_eyre::eyre::Context;