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

Commit d0e5087

Browse files
committed
Prevent deobfuscation crash from using Il2CppType.From, and use faster method anyway
1 parent a9a53ba commit d0e5087

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/Core/Reflection/Il2CppReflection.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using CppType = Il2CppSystem.Type;
1616
using BF = System.Reflection.BindingFlags;
1717
using UnityExplorer.Core.Config;
18+
using UnhollowerBaseLib.Attributes;
1819

1920
namespace UnityExplorer
2021
{
@@ -80,15 +81,19 @@ private static void TryCacheDeobfuscatedType(Type type)
8081
{
8182
try
8283
{
83-
// Thanks to Slaynash for this
84-
if (type.CustomAttributes.Any(it => it.AttributeType.Name == "ObfuscatedNameAttribute"))
84+
if (!type.CustomAttributes.Any())
85+
return;
86+
87+
foreach (var att in type.CustomAttributes)
8588
{
86-
var cppType = Il2CppType.From(type);
89+
// Thanks to Slaynash for this
8790

88-
if (!DeobfuscatedTypes.ContainsKey(cppType.FullName))
91+
if (att.AttributeType == typeof(ObfuscatedNameAttribute))
8992
{
90-
DeobfuscatedTypes.Add(cppType.FullName, type);
91-
reverseDeobCache.Add(type.FullName, cppType.FullName);
93+
string obfuscatedName = att.ConstructorArguments[0].Value.ToString();
94+
95+
DeobfuscatedTypes.Add(obfuscatedName, type);
96+
reverseDeobCache.Add(type.FullName, obfuscatedName);
9297
}
9398
}
9499
}
@@ -462,14 +467,6 @@ internal override void Internal_FindSingleton(string[] possibleNames, Type type,
462467

463468
// Helper for IL2CPP to try to make sure the Unhollowed game assemblies are actually loaded.
464469

465-
//internal override bool Internal_LoadModule(string moduleName)
466-
//{
467-
// if (!moduleName.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase))
468-
// moduleName += ".dll";
469-
//
470-
// return DoLoadModule(Path.Combine(UnhollowedFolderPath, moduleName));
471-
//}
472-
473470
// Force loading all il2cpp modules
474471

475472
internal void TryLoadGameModules()

0 commit comments

Comments
 (0)