From 7fce43aba023e9c6ae269d671d3a3dd8006343ba Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Tue, 7 Apr 2020 01:38:44 -0700 Subject: [PATCH] Fix IDA writeUsages for metadata <19 This fixes a NullReferenceException that was being thrown for IDA script generation for metadata 16 files (e.g. as generated by Il2Cpp v5.3.0f4). --- Il2CppInspector.Common/Outputs/IDAPythonScript.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Il2CppInspector.Common/Outputs/IDAPythonScript.cs b/Il2CppInspector.Common/Outputs/IDAPythonScript.cs index 969fde0..64817b9 100644 --- a/Il2CppInspector.Common/Outputs/IDAPythonScript.cs +++ b/Il2CppInspector.Common/Outputs/IDAPythonScript.cs @@ -107,6 +107,11 @@ def MakeFunction(start, end): } private void writeUsages() { + if (model.Package.MetadataUsages == null) { + /* Version < 19 - no MetadataUsages table */ + return; + } + foreach (var usage in model.Package.MetadataUsages) { var address = usage.VirtualAddress; var name = model.GetMetadataUsageName(usage); @@ -119,8 +124,7 @@ def MakeFunction(start, end): if (usage.Type == MetadataUsageType.MethodDef || usage.Type == MetadataUsageType.MethodRef) { var method = model.GetMetadataUsageMethod(usage); writeComment(address, method); - } - else if (usage.Type != MetadataUsageType.StringLiteral) { + } else if (usage.Type != MetadataUsageType.StringLiteral) { var type = model.GetMetadataUsageType(usage); writeComment(address, type); }