Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 04739d0

Browse files
committed
Separate default reflection blacklist from user list, add try/catch
1 parent a46acba commit 04739d0

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

src/Core/Config/ConfigManager.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,11 @@ private static void CreateConfigElements()
113113
"The delay on startup before the UI is created.",
114114
1f);
115115

116-
Reflection_Signature_Blacklist = new ConfigElement<string>("Reflection Signature Blacklist",
117-
"Use this to blacklist certain member signatures if they are known to cause a crash or other issues." +
118-
"\r\nSeperate signatures with a semicolon ';'.",
119-
"DEFAULT");
116+
Reflection_Signature_Blacklist = new ConfigElement<string>("Member Signature Blacklist",
117+
"Use this to blacklist certain member signatures if they are known to cause a crash or other issues.\r\n" +
118+
"Seperate signatures with a semicolon ';'.\r\n" +
119+
"For example, to blacklist Camera.main, you would add 'Camera.main;'",
120+
"");
120121

121122
// Internal configs (panel save data)
122123

src/Core/Reflection/Il2CppReflection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,12 @@ internal bool DoLoadModule(string fullPath, bool suppressWarning = false)
515515
return false;
516516
}
517517

518-
#endregion
518+
#endregion
519519

520520

521521
#region Il2cpp reflection blacklist
522522

523-
public override string DefaultReflectionBlacklist => string.Join(";", defaultIl2CppBlacklist);
523+
public override string[] DefaultReflectionBlacklist => defaultIl2CppBlacklist.ToArray();
524524

525525
// These methods currently cause a crash in most il2cpp games,
526526
// even from doing "GetParameters()" on the MemberInfo.

src/Core/Reflection/ReflectionUtility.cs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
namespace UnityExplorer
1414
{
15-
1615
public class ReflectionUtility
1716
{
1817
public const BF FLAGS = BF.Public | BF.Instance | BF.NonPublic | BF.Static;
@@ -434,31 +433,44 @@ public static MethodInfo GetMethodInfo(Type type, string methodName, Type[] argu
434433

435434
#region Reflection Blacklist
436435

437-
public virtual string DefaultReflectionBlacklist => string.Empty;
436+
public virtual string[] DefaultReflectionBlacklist => new string[0];
438437

439438
public static void LoadBlacklistString(string blacklist)
440439
{
441-
if (string.Equals(blacklist, "DEFAULT", StringComparison.InvariantCultureIgnoreCase))
440+
try
442441
{
443-
blacklist = Instance.DefaultReflectionBlacklist;
444-
ConfigManager.Reflection_Signature_Blacklist.Value = blacklist;
445-
ConfigManager.Handler.SaveConfig();
446-
}
442+
if (string.IsNullOrEmpty(blacklist) && !Instance.DefaultReflectionBlacklist.Any())
443+
return;
447444

448-
if (string.IsNullOrEmpty(blacklist))
449-
return;
445+
try
446+
{
447+
var sigs = blacklist.Split(';');
448+
foreach (var sig in sigs)
449+
{
450+
var s = sig.Trim();
451+
if (string.IsNullOrEmpty(s))
452+
continue;
453+
if (!currentBlacklist.Contains(s))
454+
currentBlacklist.Add(s);
455+
}
456+
}
457+
catch (Exception ex)
458+
{
459+
ExplorerCore.LogWarning($"Exception parsing blacklist string: {ex.ReflectionExToString()}");
460+
}
461+
462+
foreach (var sig in Instance.DefaultReflectionBlacklist)
463+
{
464+
if (!currentBlacklist.Contains(sig))
465+
currentBlacklist.Add(sig);
466+
}
450467

451-
var sigs = blacklist.Split(';');
452-
foreach (var sig in sigs)
468+
Mono.CSharp.IL2CPP.Blacklist.SignatureBlacklist = currentBlacklist;
469+
}
470+
catch (Exception ex)
453471
{
454-
var s = sig.Trim();
455-
if (string.IsNullOrEmpty(s))
456-
continue;
457-
if (!currentBlacklist.Contains(s))
458-
currentBlacklist.Add(s);
472+
ExplorerCore.LogWarning($"Exception setting up reflection blacklist: {ex.ReflectionExToString()}");
459473
}
460-
461-
Mono.CSharp.IL2CPP.Blacklist.SignatureBlacklist = currentBlacklist;
462474
}
463475

464476
public static bool IsBlacklisted(MemberInfo member)

0 commit comments

Comments
 (0)