From 62deffa10def7cf1661aa36e103aef1992544f1b Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 26 Jun 2025 10:09:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8DCallObfus=E6=B7=B7?= =?UTF-8?q?=E6=B7=86=E4=BA=86Enum.HasFlag=E5=92=8CGetHashCode=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=90=8E=EF=BC=8CUnity=202021=E7=9A=84il2cpp=E7=94=9F?= =?UTF-8?q?=E6=88=90cpp=E4=BB=A3=E7=A0=81=E6=97=B6=E5=8F=91=E7=94=9F?= =?UTF-8?q?=E5=86=85=E9=83=A8=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=202.=20=E4=BF=AE=E5=A4=8DCallObfus=E6=B7=B7=E6=B7=86=E4=BA=86M?= =?UTF-8?q?ethodBase.GetCurrentMethod=E5=AF=BC=E8=87=B4=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E4=BA=86=E9=94=99=E8=AF=AF=E5=87=BD=E6=95=B0=E7=9A=84=E4=B8=A5?= =?UTF-8?q?=E9=87=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfigurableObfuscationPolicy.cs | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) 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; }