Several improvements were made to the Mono and IL2CPP code that should allow for easier mantainance and less spaghetti code:
Mono was already using the mono_assembly_foreach symbol to find the game assemblies. This code is now part of the crate itself so the relative call has been changed
PE module sizes are now queried using pe::read_size_of_image in order to avoid issues with Proton/Wine under linux
The function to automatically detect the IL2CPP stuct version to use was broken. It has been fixed now, although there is no guarantee this will work fine on every game, so help by experienced Unity hackers might be appreciated anyway
A CSTR const is now used instead of manually defining a capacity of 128 every time an ArrayCString is read from memory. This way, in case of need, the capacity of the ArrayCStrings can be changed as needed
A (private) Assembly struct has been added, as a MonoImage is technically loaded from the assembly. There is no need to make this struct public, but it allows to streamline some code. Also, if more functions are needed that rely on an Assembly instead of a Image, this should allow for easier future implementations
A Field struct has been added in order to use some functions specific for MonoField (get_name() and get_offset()). Class::get_field has been renamed to Class:get_field_offset for better clarity. As for Assembly, this struct is not exposed publicly
Code has been slightly modified and optimized, for example by using iterators instead of standard loops
Some functions have now a simpler syntax
Empty iterators now properly return as empty iterators, instead of returning Error
A UnityPointer struct has been added to allow for automatic pointer path resolution. It internally uses DeepPointer, wrapped into a OnceCell to allow for lazy evaluation of the pointer path with interior mutability when trying to deref() it. Example:
Several improvements were made to the Mono and IL2CPP code that should allow for easier mantainance and less spaghetti code:
mono_assembly_foreach
symbol to find the game assemblies. This code is now part of the crate itself so the relative call has been changedpe::read_size_of_image
in order to avoid issues with Proton/Wine under linuxCSTR
const is now used instead of manually defining a capacity of 128 every time anArrayCString
is read from memory. This way, in case of need, the capacity of theArrayCString
s can be changed as neededAssembly
struct has been added, as aMonoImage
is technically loaded from the assembly. There is no need to make this struct public, but it allows to streamline some code. Also, if more functions are needed that rely on anAssembly
instead of aImage
, this should allow for easier future implementationsField
struct has been added in order to use some functions specific forMonoField
(get_name()
andget_offset()
).Class::get_field
has been renamed toClass:get_field_offset
for better clarity. As forAssembly
, this struct is not exposed publiclyUnityPointer
struct has been added to allow for automatic pointer path resolution. It internally usesDeepPointer
, wrapped into aOnceCell
to allow for lazy evaluation of the pointer path with interior mutability when trying toderef()
it. Example: