IL2CPP: Fix binary validation bug (typeDefinitionsSizes)

This commit is contained in:
Katy Coe
2021-01-15 16:33:27 +01:00
parent 3e4910a0fa
commit f555ce40ff

View File

@@ -283,14 +283,13 @@ namespace Il2CppInspector
* typeRefPointers must be a series of pointers in __const * typeRefPointers must be a series of pointers in __const
* MethodInvokePointers must be a series of pointers in __text or .text, and in sequential order * MethodInvokePointers must be a series of pointers in __text or .text, and in sequential order
*/ */
if (MetadataRegistration.typesCount < MetadataRegistration.typeDefinitionsSizesCount if ((Metadata != null && Metadata.Types.Length != MetadataRegistration.typeDefinitionsSizesCount)
|| MetadataRegistration.genericMethodTableCount < MetadataRegistration.genericInstsCount || CodeRegistration.reversePInvokeWrapperCount > 0x10000
|| CodeRegistration.reversePInvokeWrapperCount > 0x4000
|| CodeRegistration.unresolvedVirtualCallCount > 0x4000 // >= 22 || CodeRegistration.unresolvedVirtualCallCount > 0x4000 // >= 22
|| CodeRegistration.interopDataCount > 0x1000 // >= 23 || CodeRegistration.interopDataCount > 0x1000 // >= 23
|| (Image.Version <= 24.1 && CodeRegistration.invokerPointersCount > CodeRegistration.methodPointersCount)) || (Image.Version <= 24.1 && CodeRegistration.invokerPointersCount > CodeRegistration.methodPointersCount))
throw new NotSupportedException("The detected Il2CppCodeRegistration / Il2CppMetadataRegistration structs do not pass validation. This may mean that their fields have been re-ordered as a form of obfuscation and Il2CppInspector has not been able to restore the original order automatically. Consider re-ordering the fields in Il2CppBinaryClasses.cs and try again."); throw new NotSupportedException("The detected Il2CppCodeRegistration / Il2CppMetadataRegistration structs do not pass validation. This may mean that their fields have been re-ordered as a form of obfuscation and Il2CppInspector has not been able to restore the original order automatically. Consider re-ordering the fields in Il2CppBinaryClasses.cs and try again.");
// The global method pointer list was deprecated in v24.2 in favour of Il2CppCodeGenModule // The global method pointer list was deprecated in v24.2 in favour of Il2CppCodeGenModule
if (Image.Version <= 24.1) if (Image.Version <= 24.1)
GlobalMethodPointers = Image.ReadMappedArray<ulong>(CodeRegistration.pmethodPointers, (int) CodeRegistration.methodPointersCount); GlobalMethodPointers = Image.ReadMappedArray<ulong>(CodeRegistration.pmethodPointers, (int) CodeRegistration.methodPointersCount);