SamboyCoding / Cpp2IL

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

Attribute Primitive error #207

Closed Inovator closed 1 year ago

Inovator commented 1 year ago

Game: Broken Arrow on Steam (you can download the demo for free) Code: most recent build from develop [b676382] and older releases

It appears that there is a issue in [CustomAttributePrimitiveParameter] (https://github.com/SamboyCoding/Cpp2IL/blob/b6763820bd99b48c765dc5df6fdf8ef769871ef3/Cpp2IL.Core/Model/CustomAttributes/CustomAttributePrimitiveParameter.cs#L91) I'm not sure what IL2CPP_TYPE_END signifies, default enum value?

===Cpp2IL by Samboy063===
A Tool to Reverse Unity's "il2cpp" Build Process.
Version 2022.1.0-pre-release.11

[Info] [Program] Running on Win32NT
[Info] [Plugins] Loading plugins from C:\Users\Ino\Downloads\Cpp2IL-2022.1.0-pre-release.11-Windows-Netframework472\Plugins...
[Info] [Plugins] Using Plugin: Cpp2IL Built-In
[Info] [Program] Determined game's unity version to be 2021.3.15a0
[Info] [Library] Initializing Metadata...
[Info] [Library]        Using actual IL2CPP Metadata version 29
[Info] [Library] Initialized Metadata in 227ms
[Info] [Library] Using binary type Portable Executable (from LibCpp2IL)
[Info] [Library] Searching Binary for Required Data...
[Info] [Library] Got Binary codereg: 0x184C83F70, metareg: 0x1858F10A0 in 397ms.
[Info] [Library] Initializing Binary...
[Info] [Library] Initialized Binary in 199ms
[Info] [Library] Mapping pointers to Il2CppMethodDefinitions...Processed 140640 OK (111ms)
[Info] [Program] Creating application model...
[Info] [Program] Application model created in 1312.297ms
[Info] [Program] Pre-processing processing layers...
[Info] [Program]     Attribute Injector...
[Info] [Program]     Attribute Injector finished in 0ms
[Info] [Program] Invoking processing layers...
[Info] [Program]     Attribute Injector...
[Fail] [CA Restore] Failed to read attribute data for Il2CppMethodDefinition[Name='.ctor', ReturnType=System.Void, DeclaringType=Il2CppTypeDefinition[namespace='BrokenArrow.MissionEditor.Runtime.Core.Nodes', name='NodeName', parentType=System.Attribute, assembly=Il2CppImageDefinition[Name=BrokenArrow.MissionEditor.Runtime.dll]]], which has parameters System.String
[Fail] [CA Restore] This member (Type: BrokenArrow.MissionEditor.Runtime.Nodes.StartNode) has 101 bytes of data starting at 0x12198B8
[Fail] [CA Restore] The post-constructor data started at 0x11 bytes into our blob
[Fail] [CA Restore] Data for this constructor started at 0x19 bytes into our blob, we are now 0x1D bytes into the blob
[Fail] [CA Restore] The exception message was CustomAttributePrimitiveParameter constructed with a non-primitive type: IL2CPP_TYPE_END
[Fail] [Program] Processing layer attributeinjector threw an exception: System.Exception: CustomAttributePrimitiveParameter constructed with a non-primitive type: IL2CPP_TYPE_END
   at Cpp2IL.Core.Model.CustomAttributes.CustomAttributePrimitiveParameter.ReadFromV29Blob(BinaryReader reader, ApplicationAnalysisContext context) in /_/Cpp2IL.Core/Model/CustomAttributes/CustomAttributePrimitiveParameter.cs:line 92
   at Cpp2IL.Core.Utils.V29AttributeUtils.ReadAttribute(Stream stream, MethodAnalysisContext constructor, ApplicationAnalysisContext context) in /_/Cpp2IL.Core/Utils/V29AttributeUtils.cs:line 48
   at Cpp2IL.Core.Model.Contexts.HasCustomAttributes.AnalyzeCustomAttributeDataV29() in /_/Cpp2IL.Core/Model/Contexts/HasCustomAttributes.cs:line 259
   at Cpp2IL.Core.Model.Contexts.HasCustomAttributes.AnalyzeCustomAttributeData(Boolean allowAnalysis) in /_/Cpp2IL.Core/Model/Contexts/HasCustomAttributes.cs:line 221
   at Cpp2IL.Core.ProcessingLayers.AttributeInjectorProcessingLayer.InjectAttributeAttribute(ApplicationAnalysisContext appContext) in /_/Cpp2IL.Core/ProcessingLayers/AttributeInjectorProcessingLayer.cs:line 148
   at Cpp2IL.Core.ProcessingLayers.AttributeInjectorProcessingLayer.Process(ApplicationAnalysisContext appContext, Action`2 progressCallback) in /_/Cpp2IL.Core/ProcessingLayers/AttributeInjectorProcessingLayer.cs:line 28
   at Cpp2IL.Program.RunProcessingLayers(Cpp2IlRuntimeArgs runtimeArgs, Action`1 run) in C:\Users\Sam\RiderProjects\Cpp2IL\Cpp2IL\Program.cs:line 539
SamboyCoding commented 1 year ago

Interesting, IL2CPP_TYPE_END should never be used, so this implies there's an error in the read logic - but this is the first I've heard of it. Will try to check it out tomorrow.

Inovator commented 1 year ago

No rush really, might be a new version unity with a new il2cpp or something... the game is fairly new this and KSP coming out later this month should be the newest unity games on the block

SamboyCoding commented 1 year ago

Nah, I know this version works under normal circumstances - there's no new IL2CPP metadata version.

SamboyCoding commented 1 year ago

Fixed as per above on latest commit/nightly. Thanks for the report!