diff --git a/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs b/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs index 7ae327e..5debfa3 100644 --- a/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs +++ b/Editor/ObfusPasses/CallObfus/ConfigurableObfuscationPolicy.cs @@ -275,26 +275,47 @@ namespace Obfuz.ObfusPasses.CallObfus } + private readonly HashSet _specialTypeFullNames = new HashSet + { + "System.Enum", + "System.Delegate", + "System.MulticastDelegate", + "Obfuz.EncryptionService`1", + }; + + private readonly HashSet _specialMethodNames = new HashSet + { + "GetEnumerator", // List.Enumerator.GetEnumerator() + ".ctor", // constructor + }; + + private readonly HashSet _specialMethodFullNames = new HashSet + { + "System.Reflection.MethodBase.GetCurrentMethod", + "System.Reflection.Assembly.GetCallingAssembly", + "System.Reflection.Assembly.GetExecutingAssembly", + "System.Reflection.Assembly.GetEntryAssembly", + }; + private bool IsSpecialNotObfuscatedMethod(TypeDef typeDef, IMethod method) { if (typeDef.IsDelegate || typeDef.IsEnum) return true; + string fullName = typeDef.FullName; + if (_specialTypeFullNames.Contains(fullName)) + { + return true; + } + string methodName = method.Name; - - // doesn't proxy call if the method is a constructor - if (methodName == ".ctor") + if (_specialMethodNames.Contains(methodName)) { return true; } - if (typeDef.Name == "EncryptionService`1") - { - return true; - } - // special handle - // don't proxy call for List.Enumerator GetEnumerator() - if (methodName == "GetEnumerator") + string methodFullName = $"{fullName}.{methodName}"; + if (_specialMethodFullNames.Contains(methodFullName)) { return true; }