From 3ddf04eafccfb3340c89728c77313515fe3231c8 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Mon, 7 Dec 2020 22:46:25 +0100 Subject: [PATCH] Model: Don't crash on obfuscated assembly or namespace strings --- Il2CppInspector.Common/Reflection/Assembly.cs | 3 ++- Il2CppInspector.Common/Reflection/TypeInfo.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Il2CppInspector.Common/Reflection/Assembly.cs b/Il2CppInspector.Common/Reflection/Assembly.cs index 20f31cb..312e8d6 100644 --- a/Il2CppInspector.Common/Reflection/Assembly.cs +++ b/Il2CppInspector.Common/Reflection/Assembly.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.RegularExpressions; namespace Il2CppInspector.Reflection { public class Assembly @@ -49,7 +50,7 @@ namespace Il2CppInspector.Reflection { // Get full assembly name var nameDef = AssemblyDefinition.aname; - var name = Model.Package.Strings[nameDef.nameIndex]; + var name = Regex.Replace(Model.Package.Strings[nameDef.nameIndex], @"[^A-Za-z0-9_\-\.()]", ""); var culture = Model.Package.Strings[nameDef.cultureIndex]; if (string.IsNullOrEmpty(culture)) culture = "neutral"; diff --git a/Il2CppInspector.Common/Reflection/TypeInfo.cs b/Il2CppInspector.Common/Reflection/TypeInfo.cs index 8b40580..eb131b8 100644 --- a/Il2CppInspector.Common/Reflection/TypeInfo.cs +++ b/Il2CppInspector.Common/Reflection/TypeInfo.cs @@ -12,6 +12,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Reflection; using System.Text; +using System.Text.RegularExpressions; namespace Il2CppInspector.Reflection { @@ -739,7 +740,7 @@ namespace Il2CppInspector.Reflection Definition = pkg.TypeDefinitions[typeIndex]; Index = typeIndex; - Namespace = pkg.Strings[Definition.namespaceIndex]; + Namespace = Regex.Replace(pkg.Strings[Definition.namespaceIndex], @"[^A-Za-z0-9_\-\.<>{}]", ""); Name = pkg.Strings[Definition.nameIndex]; // Nested type?