From df0abbc847815176db748699628b19f8d450a9eb Mon Sep 17 00:00:00 2001 From: Sinai <49360850+sinai-dev@users.noreply.github.com> Date: Tue, 3 Aug 2021 16:11:16 +1000 Subject: [PATCH] Small optimizations/cleanup --- src/Core/Reflection/Il2CppReflection.cs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Core/Reflection/Il2CppReflection.cs b/src/Core/Reflection/Il2CppReflection.cs index d7676d6..7f38390 100644 --- a/src/Core/Reflection/Il2CppReflection.cs +++ b/src/Core/Reflection/Il2CppReflection.cs @@ -134,6 +134,9 @@ namespace UnityExplorer var type = obj.GetType(); try { + if (type.IsGenericType) + return type; + if (IsString(obj)) return typeof(string); @@ -178,7 +181,8 @@ namespace UnityExplorer if (fullname.StartsWith("System.")) fullname = $"Il2Cpp{fullname}"; - AllTypes.TryGetValue(fullname, out Type monoType); + if (!AllTypes.TryGetValue(fullname, out Type monoType)) + ExplorerCore.LogWarning($"Failed to get type by name '{fullname}'!"); return monoType; } @@ -497,16 +501,7 @@ namespace UnityExplorer { var files = Directory.GetFiles(UnhollowedFolderPath); foreach (var filePath in files) - { - try - { - DoLoadModule(filePath, true); - } - catch //(Exception ex) - { - //ExplorerCore.LogWarning($"Failed to force-load module '{name}': {ex.ReflectionExToString()}"); - } - } + DoLoadModule(filePath, false); } else ExplorerCore.LogWarning($"Expected Unhollowed folder path does not exist: '{UnhollowedFolderPath}'"); @@ -514,7 +509,7 @@ namespace UnityExplorer internal bool DoLoadModule(string fullPath, bool suppressWarning = false) { - if (!File.Exists(fullPath)) + if (string.IsNullOrEmpty(fullPath) || !File.Exists(fullPath)) return false; try @@ -525,11 +520,9 @@ namespace UnityExplorer } catch (Exception e) { - if (!suppressWarning) - Console.WriteLine($"Failed loading module '{Path.GetFileName(fullPath)}'! {e.ReflectionExToString()}"); + //ExplorerCore.LogWarning($"Failed loading module '{Path.GetFileName(fullPath)}'! {e.ReflectionExToString()}"); + return false; } - - return false; } #endregion