Skip to content
Draft
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6c56fed
Separate the concept of Transform and GameObject; separate the concep…
mitchell-merry May 11, 2026
958fbd8
Add isSelf function, add / update more comments
mitchell-merry May 11, 2026
f575ae4
Create get_class_mono/il2cpp which should fix the klass_name discrepa…
mitchell-merry May 11, 2026
0152784
come on now
mitchell-merry May 11, 2026
25d397b
remove todo comments
mitchell-merry May 11, 2026
d078723
tweak
mitchell-merry May 11, 2026
c974ef2
Revert changes for scene name and path as string
mitchell-merry May 13, 2026
e964365
tmp
mitchell-merry May 14, 2026
5ab8c87
add new sig, add offsets
mitchell-merry May 15, 2026
135f371
update project settings
mitchell-merry May 15, 2026
305c1c5
add cheat table
mitchell-merry May 15, 2026
440ec35
add to todo
mitchell-merry May 15, 2026
25f596a
latest unity version etc
mitchell-merry May 16, 2026
5df5ac0
create mono::Object and clarify everything
mitchell-merry May 16, 2026
822dac3
comments
mitchell-merry May 16, 2026
1b3ed11
update todo
mitchell-merry May 16, 2026
50be285
Start cleaning
mitchell-merry Jun 27, 2026
1cb0786
remove more
mitchell-merry Jun 27, 2026
03646e0
more cleaning + formatting
mitchell-merry Jun 27, 2026
b54ef8e
Allow manually overriding the scene manager offsets
mitchell-merry Jun 27, 2026
8679e33
Merge branch 'master' into transform-refactor-tweaks
mitchell-merry Jun 27, 2026
a24f19e
Add another fixme
mitchell-merry Jun 27, 2026
63776b0
Revert changes to offsets, leave note
mitchell-merry Jun 27, 2026
972bb5e
Add get_component_mono_object to streamline
mitchell-merry Jun 27, 2026
1a29b00
Support older Unity versions by splitting on Mono version when readin…
mitchell-merry Jun 27, 2026
6657b25
Couple doc improvements
mitchell-merry Jun 27, 2026
f323316
Some more documentation
mitchell-merry Jun 28, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
/Cargo.lock
.idea
**/.DS_Store
15 changes: 14 additions & 1 deletion src/game_engine/unity/il2cpp/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@
}

impl Class {
pub(super) fn get_name<const N: usize>(
pub fn get_from_component(

Check warning on line 16 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / Test (Host)

missing documentation for an associated function

Check warning on line 16 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, stable)

missing documentation for an associated function

Check warning on line 16 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, stable)

missing documentation for an associated function

Check warning on line 16 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, nightly)

missing documentation for an associated function

Check warning on line 16 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, nightly)

missing documentation for an associated function

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"component" isn't accurate here, but there's something in between the component and the class. not exactly sure what it is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ ] TODO: figure out what it is

process: &Process,
module: &Module,
component: Address,
) -> Result<Self, Error> {
process
.read_pointer(component, module.pointer_size)
.ok()
.filter(|val| !val.is_null())
.map(|class| Class { class })
.ok_or(Error {})
}

pub fn get_name<const N: usize>(

Check warning on line 29 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / Test (Host)

missing documentation for a method

Check warning on line 29 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, stable)

missing documentation for a method

Check warning on line 29 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, stable)

missing documentation for a method

Check warning on line 29 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, nightly)

missing documentation for a method

Check warning on line 29 in src/game_engine/unity/il2cpp/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, nightly)

missing documentation for a method
&self,
process: &Process,
module: &Module,
Expand Down
33 changes: 30 additions & 3 deletions src/game_engine/unity/mono/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
pub use asr_derive::MonoClass as Class;

/// A .NET class that is part of an [`Image`](Image).
#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
pub struct Class {
pub(super) class: Address,
pub class: Address,

Check warning on line 12 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / Test (Host)

missing documentation for a struct field

Check warning on line 12 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, stable)

missing documentation for a struct field

Check warning on line 12 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, stable)

missing documentation for a struct field

Check warning on line 12 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, nightly)

missing documentation for a struct field

Check warning on line 12 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, nightly)

missing documentation for a struct field
}

impl Class {
pub(super) fn get_name<const N: usize>(
pub fn get_name<const N: usize>(

Check warning on line 16 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / Test (Host)

missing documentation for a method

Check warning on line 16 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, stable)

missing documentation for a method

Check warning on line 16 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, stable)

missing documentation for a method

Check warning on line 16 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, nightly)

missing documentation for a method

Check warning on line 16 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, nightly)

missing documentation for a method
&self,
process: &Process,
module: &Module,
Expand Down Expand Up @@ -215,3 +215,30 @@
retry(|| self.get_parent(process, module)).await
}
}

/** Represents a MonoObject, which is an instantiation of a MonoVTable (and therefore MonoClass). It
* is where the actual fields of the class live.
*
* See https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/metadata/object.h#L31.
*/
pub struct Object {
pub address: Address,

Check warning on line 225 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / Test (Host)

missing documentation for a struct field

Check warning on line 225 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, stable)

missing documentation for a struct field

Check warning on line 225 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, stable)

missing documentation for a struct field

Check warning on line 225 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-wasip1, nightly)

missing documentation for a struct field

Check warning on line 225 in src/game_engine/unity/mono/class.rs

View workflow job for this annotation

GitHub Actions / build (wasm32-unknown-unknown, nightly)

missing documentation for a struct field
}

impl Object {
/** Get the class of this object */
pub fn get_class(&self, process: &Process, module: &Module) -> Result<Class, Error> {
process
// MonoVTable *vtable
// See https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/metadata/object.h#L32
.read_pointer(self.address, module.pointer_size)
.ok()
.filter(|val| !val.is_null())
// MonoClass *klass
// See https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/metadata/class-internals.h#L360
.and_then(|addr| process.read_pointer(addr, module.pointer_size).ok())
.filter(|val| !val.is_null())
.map(|class| Class { class })
.ok_or(Error {})
}
}
2 changes: 1 addition & 1 deletion src/game_engine/unity/mono/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use assembly::Assembly;
mod image;
pub use image::Image;
mod class;
pub use class::Class;
pub use class::{Class, Object};
mod field;
use field::Field;
mod version;
Expand Down
232 changes: 120 additions & 112 deletions src/game_engine/unity/mono/offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,118 +241,126 @@ impl MonoOffsets {
},
v_table: MonoVTableOffsets { vtable: 0x28 },
}),
(BinaryFormat::ELF | BinaryFormat::MachO, Version::V3, PointerSize::Bit64) => Some(&Self {
assembly: AssemblyOffsets {
aname: 0x10,
image: 0x60,
},
image: ImageOffsets { class_cache: 0x4D0 },
hash_table: HashTableOffsets {
size: 0x18,
table: 0x20,
},
class: ClassOffsets {
parent: 0x28,
image: 0x38,
name: 0x40,
namespace: 0x48,
vtable_size: 0x54,
fields: 0x90,
runtime_info: 0xC8,
field_count: 0xF8,
next_class_cache: 0x100,
},
field: FieldInfoOffsets {
name: 0x8,
offset: 0x18,
alignment: 0x20,
},
v_table: MonoVTableOffsets { vtable: 0x48 },
}),
(BinaryFormat::ELF | BinaryFormat::MachO, Version::V2, PointerSize::Bit64) => Some(&Self {
assembly: AssemblyOffsets {
aname: 0x10,
image: 0x60,
},
image: ImageOffsets { class_cache: 0x4C0 },
hash_table: HashTableOffsets {
size: 0x18,
table: 0x20,
},
class: ClassOffsets {
parent: 0x28,
image: 0x38,
name: 0x40,
namespace: 0x48,
vtable_size: 0x54,
fields: 0x90,
runtime_info: 0xC8,
field_count: 0xF8,
next_class_cache: 0x100,
},
field: FieldInfoOffsets {
name: 0x8,
offset: 0x18,
alignment: 0x20,
},
v_table: MonoVTableOffsets { vtable: 0x40 },
}),
(BinaryFormat::ELF | BinaryFormat::MachO, Version::V1Cattrs, PointerSize::Bit64) => Some(&Self {
assembly: AssemblyOffsets {
aname: 0x10,
image: 0x58,
},
image: ImageOffsets { class_cache: 0x3D0 },
hash_table: HashTableOffsets {
size: 0x18,
table: 0x20,
},
class: ClassOffsets {
parent: 0x28,
image: 0x40,
name: 0x48,
namespace: 0x50,
vtable_size: 0x18,
fields: 0xA8,
runtime_info: 0xF8,
field_count: 0x94,
next_class_cache: 0x100,
},
field: FieldInfoOffsets {
name: 0x8,
offset: 0x18,
alignment: 0x20,
},
v_table: MonoVTableOffsets { vtable: 0x48 },
}),
(BinaryFormat::ELF | BinaryFormat::MachO, Version::V1, PointerSize::Bit64) => Some(&Self {
assembly: AssemblyOffsets {
aname: 0x10,
image: 0x58,
},
image: ImageOffsets { class_cache: 0x3D0 },
hash_table: HashTableOffsets {
size: 0x18,
table: 0x20,
},
class: ClassOffsets {
parent: 0x28,
image: 0x38,
name: 0x40,
namespace: 0x48,
vtable_size: 0x18,
fields: 0xA0,
runtime_info: 0xF0,
field_count: 0x8C,
next_class_cache: 0xF8,
},
field: FieldInfoOffsets {
name: 0x8,
offset: 0x18,
alignment: 0x20,
},
v_table: MonoVTableOffsets { vtable: 0x48 },
}),
(BinaryFormat::ELF | BinaryFormat::MachO, Version::V3, PointerSize::Bit64) => {
Some(&Self {

@mitchell-merry mitchell-merry Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this indented a level... I didn't change any offsets here.

assembly: AssemblyOffsets {
aname: 0x10,
image: 0x60,
},
image: ImageOffsets { class_cache: 0x4D0 },
hash_table: HashTableOffsets {
size: 0x18,
table: 0x20,
},
class: ClassOffsets {
parent: 0x28,
image: 0x38,
name: 0x40,
namespace: 0x48,
vtable_size: 0x54,
fields: 0x90,
runtime_info: 0xC8,
field_count: 0xF8,
next_class_cache: 0x100,
},
field: FieldInfoOffsets {
name: 0x8,
offset: 0x18,
alignment: 0x20,
},
v_table: MonoVTableOffsets { vtable: 0x48 },
})
}
(BinaryFormat::ELF | BinaryFormat::MachO, Version::V2, PointerSize::Bit64) => {
Some(&Self {
assembly: AssemblyOffsets {
aname: 0x10,
image: 0x60,
},
image: ImageOffsets { class_cache: 0x4C0 },
hash_table: HashTableOffsets {
size: 0x18,
table: 0x20,
},
class: ClassOffsets {
parent: 0x28,
image: 0x38,
name: 0x40,
namespace: 0x48,
vtable_size: 0x54,
fields: 0x90,
runtime_info: 0xC8,
field_count: 0xF8,
next_class_cache: 0x100,
},
field: FieldInfoOffsets {
name: 0x8,
offset: 0x18,
alignment: 0x20,
},
v_table: MonoVTableOffsets { vtable: 0x40 },
})
}
(BinaryFormat::ELF | BinaryFormat::MachO, Version::V1Cattrs, PointerSize::Bit64) => {
Some(&Self {
assembly: AssemblyOffsets {
aname: 0x10,
image: 0x58,
},
image: ImageOffsets { class_cache: 0x3D0 },
hash_table: HashTableOffsets {
size: 0x18,
table: 0x20,
},
class: ClassOffsets {
parent: 0x28,
image: 0x40,
name: 0x48,
namespace: 0x50,
vtable_size: 0x18,
fields: 0xA8,
runtime_info: 0xF8,
field_count: 0x94,
next_class_cache: 0x100,
},
field: FieldInfoOffsets {
name: 0x8,
offset: 0x18,
alignment: 0x20,
},
v_table: MonoVTableOffsets { vtable: 0x48 },
})
}
(BinaryFormat::ELF | BinaryFormat::MachO, Version::V1, PointerSize::Bit64) => {
Some(&Self {
assembly: AssemblyOffsets {
aname: 0x10,
image: 0x58,
},
image: ImageOffsets { class_cache: 0x3D0 },
hash_table: HashTableOffsets {
size: 0x18,
table: 0x20,
},
class: ClassOffsets {
parent: 0x28,
image: 0x38,
name: 0x40,
namespace: 0x48,
vtable_size: 0x18,
fields: 0xA0,
runtime_info: 0xF0,
field_count: 0x8C,
next_class_cache: 0xF8,
},
field: FieldInfoOffsets {
name: 0x8,
offset: 0x18,
alignment: 0x20,
},
v_table: MonoVTableOffsets { vtable: 0x48 },
})
}
_ => None,
}
}
Expand Down
40 changes: 40 additions & 0 deletions src/game_engine/unity/scene_manager/component.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use crate::game_engine::unity::mono;
use crate::game_engine::unity::scene_manager::SceneManager;
use crate::{Address, Error, Process};

/// Representing a Unity Component, usually attached to a GameObject
#[derive(Debug)]
pub struct Component {
/// the base address of the component
pub address: Address,
}

impl Component {
/** Retrieves the MonoObject this Component holds */
pub fn get_mono_object(
&self,
process: &Process,
scene_manager: &SceneManager,
) -> Result<mono::Object, Error> {
// TODO is this only true on 6000?
// other versions, according to how ASR currently is, do not dereference twice here
// NOTE: I'm like 80% sure the following is true
process
// class ScriptingGCHandle m_MonoReference
// See https://gist.github.com/just-ero/92457b51baf85bd1e5b8c87de8c9835e#file-object-hpp-L18
// In Mono this is a MonoObjectHandle, which is a MonoObject**
// MonoObject **__raw
// See https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/metadata/handle-decl.h#L72
.read_pointer(
self.address + scene_manager.offsets.scripting_object_handle,
scene_manager.pointer_size,
)
.ok()
.filter(|val| !val.is_null())
// MonoObject *__raw
.and_then(|addr| process.read_pointer(addr, scene_manager.pointer_size).ok())
.filter(|val| !val.is_null())
.map(|address| mono::Object { address })
.ok_or(Error {})
}
}
Loading
Loading