mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-17 14:37:49 +08:00
Separate default reflection blacklist from user list, add try/catch
This commit is contained in:
parent
a46acba265
commit
04739d0be8
@ -113,10 +113,11 @@ namespace UnityExplorer.Core.Config
|
|||||||
"The delay on startup before the UI is created.",
|
"The delay on startup before the UI is created.",
|
||||||
1f);
|
1f);
|
||||||
|
|
||||||
Reflection_Signature_Blacklist = new ConfigElement<string>("Reflection Signature Blacklist",
|
Reflection_Signature_Blacklist = new ConfigElement<string>("Member Signature Blacklist",
|
||||||
"Use this to blacklist certain member signatures if they are known to cause a crash or other issues." +
|
"Use this to blacklist certain member signatures if they are known to cause a crash or other issues.\r\n" +
|
||||||
"\r\nSeperate signatures with a semicolon ';'.",
|
"Seperate signatures with a semicolon ';'.\r\n" +
|
||||||
"DEFAULT");
|
"For example, to blacklist Camera.main, you would add 'Camera.main;'",
|
||||||
|
"");
|
||||||
|
|
||||||
// Internal configs (panel save data)
|
// Internal configs (panel save data)
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
#region Il2cpp reflection blacklist
|
#region Il2cpp reflection blacklist
|
||||||
|
|
||||||
public override string DefaultReflectionBlacklist => string.Join(";", defaultIl2CppBlacklist);
|
public override string[] DefaultReflectionBlacklist => defaultIl2CppBlacklist.ToArray();
|
||||||
|
|
||||||
// These methods currently cause a crash in most il2cpp games,
|
// These methods currently cause a crash in most il2cpp games,
|
||||||
// even from doing "GetParameters()" on the MemberInfo.
|
// even from doing "GetParameters()" on the MemberInfo.
|
||||||
|
@ -12,7 +12,6 @@ using UnityExplorer.Core.Config;
|
|||||||
|
|
||||||
namespace UnityExplorer
|
namespace UnityExplorer
|
||||||
{
|
{
|
||||||
|
|
||||||
public class ReflectionUtility
|
public class ReflectionUtility
|
||||||
{
|
{
|
||||||
public const BF FLAGS = BF.Public | BF.Instance | BF.NonPublic | BF.Static;
|
public const BF FLAGS = BF.Public | BF.Instance | BF.NonPublic | BF.Static;
|
||||||
@ -434,20 +433,17 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
#region Reflection Blacklist
|
#region Reflection Blacklist
|
||||||
|
|
||||||
public virtual string DefaultReflectionBlacklist => string.Empty;
|
public virtual string[] DefaultReflectionBlacklist => new string[0];
|
||||||
|
|
||||||
public static void LoadBlacklistString(string blacklist)
|
public static void LoadBlacklistString(string blacklist)
|
||||||
{
|
{
|
||||||
if (string.Equals(blacklist, "DEFAULT", StringComparison.InvariantCultureIgnoreCase))
|
try
|
||||||
{
|
{
|
||||||
blacklist = Instance.DefaultReflectionBlacklist;
|
if (string.IsNullOrEmpty(blacklist) && !Instance.DefaultReflectionBlacklist.Any())
|
||||||
ConfigManager.Reflection_Signature_Blacklist.Value = blacklist;
|
|
||||||
ConfigManager.Handler.SaveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(blacklist))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
var sigs = blacklist.Split(';');
|
var sigs = blacklist.Split(';');
|
||||||
foreach (var sig in sigs)
|
foreach (var sig in sigs)
|
||||||
{
|
{
|
||||||
@ -457,9 +453,25 @@ namespace UnityExplorer
|
|||||||
if (!currentBlacklist.Contains(s))
|
if (!currentBlacklist.Contains(s))
|
||||||
currentBlacklist.Add(s);
|
currentBlacklist.Add(s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Exception parsing blacklist string: {ex.ReflectionExToString()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var sig in Instance.DefaultReflectionBlacklist)
|
||||||
|
{
|
||||||
|
if (!currentBlacklist.Contains(sig))
|
||||||
|
currentBlacklist.Add(sig);
|
||||||
|
}
|
||||||
|
|
||||||
Mono.CSharp.IL2CPP.Blacklist.SignatureBlacklist = currentBlacklist;
|
Mono.CSharp.IL2CPP.Blacklist.SignatureBlacklist = currentBlacklist;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Exception setting up reflection blacklist: {ex.ReflectionExToString()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsBlacklisted(MemberInfo member)
|
public static bool IsBlacklisted(MemberInfo member)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user