From 5d827fe881db94abb2693414ec79eb178f5e37ab Mon Sep 17 00:00:00 2001 From: LukeFZ <17146677+LukeFZ@users.noreply.github.com> Date: Sun, 18 Aug 2024 22:40:29 +0200 Subject: [PATCH] fix metadata usage validity checks --- Il2CppInspector.Common/IL2CPP/MetadataUsage.cs | 2 ++ Il2CppInspector.Common/Reflection/TypeInfo.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector.Common/IL2CPP/MetadataUsage.cs b/Il2CppInspector.Common/IL2CPP/MetadataUsage.cs index d05d1b8..5123ab4 100644 --- a/Il2CppInspector.Common/IL2CPP/MetadataUsage.cs +++ b/Il2CppInspector.Common/IL2CPP/MetadataUsage.cs @@ -27,6 +27,8 @@ namespace Il2CppInspector public int SourceIndex { get; } public ulong VirtualAddress { get; private set; } + public readonly bool IsValid => Type != 0; + public MetadataUsage(MetadataUsageType type, int sourceIndex, ulong virtualAddress = 0) { Type = type; SourceIndex = sourceIndex; diff --git a/Il2CppInspector.Common/Reflection/TypeInfo.cs b/Il2CppInspector.Common/Reflection/TypeInfo.cs index 305ba43..3067c40 100644 --- a/Il2CppInspector.Common/Reflection/TypeInfo.cs +++ b/Il2CppInspector.Common/Reflection/TypeInfo.cs @@ -259,7 +259,7 @@ namespace Il2CppInspector.Reflection MetadataUsage[] vt = Assembly.Model.Package.GetVTable(Definition); MethodBase[] res = new MethodBase[vt.Length]; for (int i = 0; i < vt.Length; i++) { - if (vt[i] != null) + if (vt[i].IsValid) res[i] = Assembly.Model.GetMetadataUsageMethod(vt[i]); } return res;