Closed unreliablecode closed 1 year ago
Code Updated, Changed the MarshalAs attribute of the methods IL2CPP.il2cpp_class_from_name and IL2CPP.il2cpp_class_get_field_from_name to this => [MarshalAs(UnmanagedType.LPUTF8Str)].
this fix the System.AccessViolationException Error and and field not found when calling obfuscated class method or field in some games
In some games, the obfuscated class and field names appear to be using UTF8, although C# uses UTF-16. I tried using the Encoding class but had no luck, so i did altering the IL2CPP.il2cpp_class_from_name method parameter from IntPtr, String, String to IntPtr, IntPtr, IntPtr and convert the string to IntPtr by calling Marshal.StringToCoTaskMemUTF8 fixed it, i also modify the IL2CPP.il2cpp_class_get_field_from_name from IntPtr, String to IntPtr, IntPtr and convert the field name using the Marshal.The StringToCoTaskMemUTF8 function fixed it.
It fixed the field not found error and the crash when calling obfuscated class methods or fields.