SamboyCoding / Cpp2IL

Work-in-progress tool to reverse unity's IL2CPP toolchain.
MIT License
1.68k stars 197 forks source link

System.OverflowException: Arithmetic operation resulted in an overflow. #234

Closed PickleOnAString closed 1 month ago

PickleOnAString commented 1 year ago
===Cpp2IL by Samboy063===
A Tool to Reverse Unity's "il2cpp" Build Process.

[Info] [Program] Running on Win32NT
[Info] [Program] Determined game's unity version to be 2022.1.0
[Info] [Library] Initializing Metadata...
[Info] [Library]        Using actual IL2CPP Metadata version 29.1
[Info] [Library] Initialized Metadata in 491ms
[Info] [Library] Searching Binary for Required Data...
[Info] [Library] Got Binary codereg: 0x18252C310, metareg: 0x18298A470 in 176ms.
[Info] [Library] Initializing Binary...
[Fail] [Program]

Cpp2IL.Core.Exceptions.LibCpp2ILInitializationException: Fatal Exception initializing LibCpp2IL!
 ---> System.OverflowException: Arithmetic operation resulted in an overflow.
   at LibCpp2IL.ClassReadingBinaryReader.ReadClassArrayAtRawAddr[T](Int64 offset, Int64 count)
   at LibCpp2IL.Il2CppBinary.Init(UInt64 pCodeRegistration, UInt64 pMetadataRegistration)
   at LibCpp2IL.LibCpp2IlMain.Initialize(Byte[] binaryBytes, Byte[] metadataBytes, Int32[] unityVersion)
   at LibCpp2IL.LibCpp2IlMain.LoadFromFile(String pePath, String metadataPath, Int32[] unityVersion)
   at Cpp2IL.Core.Cpp2IlApi.InitializeLibCpp2Il(String assemblyPath, String metadataPath, Int32[] unityVersion, Boolean allowUserToInputAddresses)
   --- End of inner exception stack trace ---
   at Cpp2IL.Core.Cpp2IlApi.InitializeLibCpp2Il(String assemblyPath, String metadataPath, Int32[] unityVersion, Boolean allowUserToInputAddresses)
   at Cpp2IL.Program.MainWithArgs(Cpp2IlRuntimeArgs runtimeArgs)
   at Cpp2IL.Program.Main(String[] args)

Waiting for you to press enter - feel free to copy the error...

the game is slime rancher 2

SamboyCoding commented 1 year ago

This might be due to the Unity version SR2 uses. There's a couple of 2021.2 subversions that have their exe files incorrectly labelled as 2022.1, which triggers CPP2IL to try to read the metadata as V29.1 instead of V29. With that said, I believe you mentioned in discord that this doesn't happen in the development branch (the pre-releases) and I don't think the code has changed.

You can try using the --force- options (use --help to list them) and manually specify the correct unity version, and see if this helps?

Atmudia commented 1 year ago

On nightly it works

PickleOnAString commented 1 year ago

yeah it works on nightly