diff --git a/README.md b/README.md index 8749377..4a87be3 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ | Standalone | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Mono.zip) | ### Known issues -* Issues with UnityEngine types in some 2020+ games - this is an issue with Unhollower, nothing I can do about it myself at the moment. * Any `MissingMethodException` or `NotSupportedException`: please report the issue and provide a copy of your mod loader log and/or Unity log. * The C# console may unexpectedly produce a GC Mark Overflow crash when calling certain outside methods. Not clear yet what is causing this, but it's being looked into. * In IL2CPP, some IEnumerable and IDictionary types may fail enumeration. Waiting for the Unhollower rewrite to address this any further. diff --git a/src/Core/Input/InputManager.cs b/src/Core/Input/InputManager.cs index 624def9..65e7071 100644 --- a/src/Core/Input/InputManager.cs +++ b/src/Core/Input/InputManager.cs @@ -61,7 +61,7 @@ namespace UnityExplorer.Core.Input // First, just try to use the legacy input, see if its working. // The InputSystem package may be present but not actually activated, so we can find out this way. - if (LegacyInput.TInput != null || (ReflectionUtility.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null)) + if (LegacyInput.TInput != null) { try { @@ -80,7 +80,7 @@ namespace UnityExplorer.Core.Input } } - if (InputSystem.TKeyboard != null || (ReflectionUtility.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null)) + if (InputSystem.TKeyboard != null) { try { diff --git a/src/Core/Reflection/Il2CppReflection.cs b/src/Core/Reflection/Il2CppReflection.cs index 267d0e4..9a6062c 100644 --- a/src/Core/Reflection/Il2CppReflection.cs +++ b/src/Core/Reflection/Il2CppReflection.cs @@ -258,17 +258,17 @@ namespace UnityExplorer } } - private static bool IsAssignableFrom(Type thisType, Type fromType) - { - if (!Il2CppTypeNotNull(fromType, out IntPtr fromTypePtr) - || !Il2CppTypeNotNull(thisType, out IntPtr thisTypePtr)) - { - // one or both of the types are not Il2Cpp types, use normal check - return thisType.IsAssignableFrom(fromType); - } - - return il2cpp_class_is_assignable_from(thisTypePtr, fromTypePtr); - } + //private static bool IsAssignableFrom(Type thisType, Type fromType) + //{ + // if (!Il2CppTypeNotNull(fromType, out IntPtr fromTypePtr) + // || !Il2CppTypeNotNull(thisType, out IntPtr thisTypePtr)) + // { + // // one or both of the types are not Il2Cpp types, use normal check + // return thisType.IsAssignableFrom(fromType); + // } + // + // return il2cpp_class_is_assignable_from(thisTypePtr, fromTypePtr); + //} #endregion @@ -450,42 +450,35 @@ namespace UnityExplorer #region Force-loading game modules + internal static string UnhollowedFolderPath => Path.GetFullPath( +#if ML + Path.Combine("MelonLoader", "Managed") +#elif BIE + Path.Combine("BepInEx", "unhollowed") +#else + Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Modules") +#endif + ); + // Helper for IL2CPP to try to make sure the Unhollowed game assemblies are actually loaded. - internal override bool Internal_LoadModule(string moduleName) - { - if (!moduleName.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase)) - moduleName += ".dll"; -#if ML - var path = Path.Combine("MelonLoader", "Managed", $"{moduleName}"); -#else - var path = Path.Combine("BepInEx", "unhollowed", $"{moduleName}"); -#endif - return DoLoadModule(path); - } + //internal override bool Internal_LoadModule(string moduleName) + //{ + // if (!moduleName.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase)) + // moduleName += ".dll"; + // + // return DoLoadModule(Path.Combine(UnhollowedFolderPath, moduleName)); + //} // Force loading all il2cpp modules internal void TryLoadGameModules() { - string dirpath = - #if ML - Path.Combine("MelonLoader", "Managed"); - #elif BIE - Path.Combine("BepInEx", "unhollowed"); - #else - Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Modules"); - #endif - ; - - if (Directory.Exists(dirpath)) + if (Directory.Exists(UnhollowedFolderPath)) { - var files = Directory.GetFiles(dirpath); + var files = Directory.GetFiles(UnhollowedFolderPath); foreach (var filePath in files) { - var name = Path.GetFileName(filePath); - if (!name.StartsWith("Unity") && !name.StartsWith("Assembly-CSharp")) - continue; try { DoLoadModule(filePath, true); @@ -496,6 +489,8 @@ namespace UnityExplorer } } } + else + ExplorerCore.LogWarning($"Expected Unhollowed folder path does not exist: '{UnhollowedFolderPath}'"); } internal bool DoLoadModule(string fullPath, bool suppressWarning = false) @@ -505,7 +500,8 @@ namespace UnityExplorer try { - Assembly.Load(File.ReadAllBytes(fullPath)); + Assembly.LoadFile(fullPath); + //Assembly.Load(File.ReadAllBytes(fullPath)); return true; } catch (Exception e) @@ -648,6 +644,9 @@ namespace UnityExplorer "UnityEngine.Scripting.GarbageCollector+CollectIncrementalDelegate.Invoke", "UnityEngine.Scripting.GarbageCollector.CollectIncremental", "UnityEngine.SpherecastCommand.ScheduleBatch", + "UnityEngine.Texture.GetPixelDataSize", + "UnityEngine.Texture.GetPixelDataOffset", + "UnityEngine.Texture.GetPixelDataOffset", "UnityEngine.Texture2D+SetPixelDataImplArrayDelegate.Invoke", "UnityEngine.Texture2D+SetPixelDataImplDelegate.Invoke", "UnityEngine.Texture2D.SetPixelDataImpl", @@ -669,6 +668,8 @@ namespace UnityExplorer #endregion + #region IL2CPP IEnumerable and IDictionary + protected override bool Internal_TryGetEntryType(Type enumerableType, out Type type) { // Check for system types (not unhollowed) @@ -713,8 +714,6 @@ namespace UnityExplorer return false; } - #region Temp il2cpp list/dictionary fixes - // Temp fix until Unhollower interface support improves internal static readonly Dictionary getEnumeratorMethods = new Dictionary(); diff --git a/src/Core/Reflection/ReflectionUtility.cs b/src/Core/Reflection/ReflectionUtility.cs index a86fb72..7709002 100644 --- a/src/Core/Reflection/ReflectionUtility.cs +++ b/src/Core/Reflection/ReflectionUtility.cs @@ -151,12 +151,14 @@ namespace UnityExplorer internal virtual string Internal_ProcessTypeInString(string theString, Type type) => theString; - // Force loading modules - public static bool LoadModule(string moduleName) - => Instance.Internal_LoadModule(moduleName); + //// Force loading modules + //public static bool LoadModule(string moduleName) + // => Instance.Internal_LoadModule(moduleName); + // + //internal virtual bool Internal_LoadModule(string moduleName) + // => false; - internal virtual bool Internal_LoadModule(string moduleName) - => false; + // Singleton finder public static void FindSingleton(string[] possibleNames, Type type, BindingFlags flags, List instances) => Instance.Internal_FindSingleton(possibleNames, type, flags, instances); @@ -441,7 +443,6 @@ namespace UnityExplorer blacklist = Instance.DefaultReflectionBlacklist; ConfigManager.Reflection_Signature_Blacklist.Value = blacklist; ConfigManager.Handler.SaveConfig(); - return; } if (string.IsNullOrEmpty(blacklist)) @@ -466,6 +467,7 @@ namespace UnityExplorer return false; var sig = $"{member.DeclaringType.FullName}.{member.Name}"; + return currentBlacklist.Contains(sig); } diff --git a/src/ExplorerCore.cs b/src/ExplorerCore.cs index b8092f4..7a0aaa7 100644 --- a/src/ExplorerCore.cs +++ b/src/ExplorerCore.cs @@ -19,7 +19,7 @@ namespace UnityExplorer public static class ExplorerCore { public const string NAME = "UnityExplorer"; - public const string VERSION = "4.0.1"; + public const string VERSION = "4.0.2"; public const string AUTHOR = "Sinai"; public const string GUID = "com.sinai.unityexplorer"; diff --git a/src/UI/CacheObject/CacheMember.cs b/src/UI/CacheObject/CacheMember.cs index c2a05d6..928582c 100644 --- a/src/UI/CacheObject/CacheMember.cs +++ b/src/UI/CacheObject/CacheMember.cs @@ -246,7 +246,6 @@ namespace UnityExplorer.UI.CacheObject var sig = GetSig(member); //ExplorerCore.Log($"Trying to cache member {sig}..."); - //ExplorerCore.Log(member.DeclaringType.FullName + "." + member.Name); CacheMember cached; Type returnType; @@ -324,7 +323,8 @@ namespace UnityExplorer.UI.CacheObject } } - internal static string GetSig(MemberInfo member) => $"{member.DeclaringType.Name}.{member.Name}"; + internal static string GetSig(MemberInfo member) + => $"{member.DeclaringType.Name}.{member.Name}"; internal static string GetArgumentString(ParameterInfo[] args) {