From c4fa0d6bcd29bc9abd3b9979a6785b239dca5aa2 Mon Sep 17 00:00:00 2001 From: Sinai Date: Tue, 1 Jun 2021 16:00:18 +1000 Subject: [PATCH] Add better time logging to reflection init --- src/Core/Reflection/Il2CppReflection.cs | 14 ++++++-------- src/Core/Reflection/ReflectionUtility.cs | 4 ++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Core/Reflection/Il2CppReflection.cs b/src/Core/Reflection/Il2CppReflection.cs index e5796a4..e3c6aa1 100644 --- a/src/Core/Reflection/Il2CppReflection.cs +++ b/src/Core/Reflection/Il2CppReflection.cs @@ -16,6 +16,7 @@ using CppType = Il2CppSystem.Type; using BF = System.Reflection.BindingFlags; using UnityExplorer.Core.Config; using UnhollowerBaseLib.Attributes; +using UnityEngine; namespace UnityExplorer { @@ -25,10 +26,15 @@ namespace UnityExplorer { base.Initialize(); + float start = Time.realtimeSinceStartup; TryLoadGameModules(); + ExplorerCore.Log($"Loaded Unhollowed modules in {Time.realtimeSinceStartup - start} seconds"); + start = Time.realtimeSinceStartup; BuildDeobfuscationCache(); OnTypeLoaded += TryCacheDeobfuscatedType; + ExplorerCore.Log($"Setup IL2CPP reflection in {Time.realtimeSinceStartup - start} seconds, " + + $"deobfuscated types count: {DeobfuscatedTypes.Count}"); } #region IL2CPP Extern and pointers @@ -67,19 +73,11 @@ namespace UnityExplorer private static void BuildDeobfuscationCache() { - float start = UnityEngine.Time.realtimeSinceStartup; - foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var type in asm.TryGetTypes()) TryCacheDeobfuscatedType(type); } - - if (DeobfuscatedTypes.Count > 0) - { - ExplorerCore.Log($"Built deobfuscation cache in {UnityEngine.Time.realtimeSinceStartup - start} seconds, " + - $"initial count: {DeobfuscatedTypes.Count} "); - } } private static void TryCacheDeobfuscatedType(Type type) diff --git a/src/Core/Reflection/ReflectionUtility.cs b/src/Core/Reflection/ReflectionUtility.cs index f9ded05..0549236 100644 --- a/src/Core/Reflection/ReflectionUtility.cs +++ b/src/Core/Reflection/ReflectionUtility.cs @@ -65,10 +65,14 @@ namespace UnityExplorer private static void SetupTypeCache() { + float start = Time.realtimeSinceStartup; + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) CacheTypes(asm); AppDomain.CurrentDomain.AssemblyLoad += AssemblyLoaded; + + ExplorerCore.Log($"Cached AppDomain assemblies in {Time.realtimeSinceStartup - start} seconds"); } private static void AssemblyLoaded(object sender, AssemblyLoadEventArgs args)