Use UTF8 in Il2Cpp PInvoke calls#220
Conversation
Il2CppInterop.Runtime/IL2CPP.cs
Outdated
|
|
||
| while ((nestedTypePtr = il2cpp_class_get_nested_types(enclosingType, ref iter)) != IntPtr.Zero) | ||
| if (Marshal.PtrToStringAnsi(il2cpp_class_get_name(nestedTypePtr)) == nestedTypeName) | ||
| if (Marshal.PtrToStringUTF8(il2cpp_class_get_name(nestedTypePtr)) == nestedTypeName) |
There was a problem hiding this comment.
I find it difficult to believe this is the only place. Strings should be either all Ansi or all UTF8.
There was a problem hiding this comment.
My old PR loaded System.String everywhere.
abdebd5
There was a problem hiding this comment.
That commit is more attractive to me. A couple small tweaks:
- All
DllImportinIL2CPP.csshould be changed toLibraryImport. - Delete
Il2CppApi.cs.
There was a problem hiding this comment.
LibraryImport is only supported on .NET 7+
Are there plans for moving the entire project to 8 or 9? 10 is still 4 months away but would be LTS.
There was a problem hiding this comment.
I forgot about that limitation. DllImport is fine for now. That'll let modding communities make immediate use of your work.
v2 is coming soon. It will probably be .NET 9 for a beta period and switch to .NET 10 in November.
There was a problem hiding this comment.
thanks
I've now had time to test the patch and I've not found any issue so far.
04a4c61 to
38e9b33
Compare
|
Has this even been tested? Like at all? It literally causes heap corruption no matter the game or platform |
Fixes BepInEx#220 which completely broke most of the Il2Cpp imports. Reverts BepInEx#227. The fallback method for GetIl2CppNestedType is no longer needed as the root cause of the issue has been solved.
|
I've been running it for a bit with unity explorer on some unity 2021 game. Didn't use it heavily. |
This reverts commit f749ff6
In a previous pull request I had already worked around this by loading all FFI strings as System.String.
I've run into this issue again and reimplemented this part from the PR: 6a7afa1
This seems to be the only critical part it seems. If this resolve fails, the NativeClassPtr is null and other parts of the code will dereference it without checking.