From d4dac58fc8637c08bb6aae6d8e18fe2a625b6222 Mon Sep 17 00:00:00 2001 From: Sinai Date: Sat, 20 Feb 2021 19:39:19 +1100 Subject: [PATCH] Fix for deobfuscated unhollowed types not being properly resolved --- src/ExplorerCore.cs | 2 +- src/Helpers/ReflectionHelpers.cs | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index d40e945..3507bae 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -17,7 +17,7 @@ namespace UnityExplorer public class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "3.1.7"; + public const string VERSION = "3.1.8"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer"; diff --git a/src/Helpers/ReflectionHelpers.cs b/src/Helpers/ReflectionHelpers.cs index 5400c5e..f136af6 100644 --- a/src/Helpers/ReflectionHelpers.cs +++ b/src/Helpers/ReflectionHelpers.cs @@ -101,8 +101,24 @@ namespace UnityExplorer.Helpers return Il2CppToMonoType[cppType]; var getType = Type.GetType(cppType.AssemblyQualifiedName); - Il2CppToMonoType.Add(cppType, getType); - return getType; + + if (getType != null) + { + Il2CppToMonoType.Add(cppType, getType); + return getType; + } + else + { + string baseName = cppType.FullName; + string baseAssembly = cppType.Assembly.GetName().name; + + Type unhollowedType = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name == baseAssembly)?.GetTypes().FirstOrDefault(t => + t.CustomAttributes.Any(ca => + ca.AttributeType.Name == "ObfuscatedNameAttribute" && (string)ca.ConstructorArguments[0].Value == baseName)); + + Il2CppToMonoType.Add(cppType, unhollowedType); + return unhollowedType; + } } private static readonly Dictionary CppClassPointers = new Dictionary();