From 1ff3b5c3249fa600af49a6328a4b7e531ea56243 Mon Sep 17 00:00:00 2001 From: walon Date: Mon, 24 Nov 2025 18:40:22 +0800 Subject: [PATCH 1/5] =?UTF-8?q?new:=20=E6=96=B0=E5=A2=9EPS5=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/ObfuscatorBuilder.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Editor/ObfuscatorBuilder.cs b/Editor/ObfuscatorBuilder.cs index 07f0491..547c16c 100644 --- a/Editor/ObfuscatorBuilder.cs +++ b/Editor/ObfuscatorBuilder.cs @@ -135,6 +135,8 @@ namespace Obfuz "PlaybackEngines/WSASupport/Variations/il2cpp/Managed", #elif UNITY_LUMIN "PlaybackEngines/LuminSupport/Variations/il2cpp/Managed", +#elif UNITY_PS5 + "PlaybackEngines/PS5Player/Variations/il2cpp/Managed", #else #error "Unsupported platform, please report to us" #endif From 3615bbcce922c2131161d356eddc708a3106477c Mon Sep 17 00:00:00 2001 From: walon Date: Fri, 26 Dec 2025 21:25:08 +0800 Subject: [PATCH 2/5] fix: fix resolving type in Obfuz.Runtime failed when no to-obfuscated dll references to Obfuz.Runtime --- Editor/Obfuscator.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Editor/Obfuscator.cs b/Editor/Obfuscator.cs index 71e6019..6b2008f 100644 --- a/Editor/Obfuscator.cs +++ b/Editor/Obfuscator.cs @@ -330,6 +330,7 @@ namespace Obfuz private void LoadAssemblies(AssemblyCache assemblyCache, List modulesToObfuscate, List allObfuscationRelativeModules) { + assemblyCache.LoadModule("Obfuz.Runtime"); foreach (string assName in _allObfuscationRelativeAssemblyNames) { ModuleDefMD mod = assemblyCache.TryLoadModule(assName); From 7b06f0fed8675c31cbae9760a93e7deec0c0a05c Mon Sep 17 00:00:00 2001 From: EP-Toushirou <45257277+EP-Toushirou@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:42:19 +0800 Subject: [PATCH 3/5] new: add support for 6000.3.x; fix: fix deprecated warning of PlayerSettings.GetScriptingBackend(BuildTargetGroup) in Unity 6000 --- Editor/ObfuscatorBuilder.cs | 29 +++++++++++++++++------------ Editor/Utils/PlatformUtil.cs | 9 +++++++-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Editor/ObfuscatorBuilder.cs b/Editor/ObfuscatorBuilder.cs index 547c16c..3f923d9 100644 --- a/Editor/ObfuscatorBuilder.cs +++ b/Editor/ObfuscatorBuilder.cs @@ -90,23 +90,28 @@ namespace Obfuz public static List BuildUnityAssemblySearchPaths(bool searchPathIncludeUnityEditorDll = false) { +#if UNITY_6000_3_OR_NEWER && UNITY_EDITOR_OSX + string monoBleedingEdgePath = "Resources/Scripting/MonoBleedingEdge"; +#else + string monoBleedingEdgePath = "MonoBleedingEdge"; +#endif string applicationContentsPath = EditorApplication.applicationContentsPath; var searchPaths = new List { #if UNITY_2021_1_OR_NEWER -#if UNITY_STANDALONE_WIN || (UNITY_EDITOR_WIN && UNITY_SERVER) || UNITY_WSA || UNITY_LUMIN - "MonoBleedingEdge/lib/mono/unityaot-win32", - "MonoBleedingEdge/lib/mono/unityaot-win32/Facades", -#elif UNITY_STANDALONE_OSX || (UNITY_EDITOR_OSX && UNITY_SERVER) || UNITY_IOS || UNITY_TVOS - "MonoBleedingEdge/lib/mono/unityaot-macos", - "MonoBleedingEdge/lib/mono/unityaot-macos/Facades", + #if UNITY_STANDALONE_WIN || (UNITY_EDITOR_WIN && UNITY_SERVER) || UNITY_WSA || UNITY_LUMIN + $"{monoBleedingEdgePath}/lib/mono/unityaot-win32", + $"{monoBleedingEdgePath}/lib/mono/unityaot-win32/Facades", + #elif UNITY_STANDALONE_OSX || (UNITY_EDITOR_OSX && UNITY_SERVER) || UNITY_IOS || UNITY_TVOS || UNITY_VISIONOS + $"{monoBleedingEdgePath}/lib/mono/unityaot-macos", + $"{monoBleedingEdgePath}/lib/mono/unityaot-macos/Facades", + #else + $"{monoBleedingEdgePath}/lib/mono/unityaot-linux", + $"{monoBleedingEdgePath}/lib/mono/unityaot-linux/Facades", + #endif #else - "MonoBleedingEdge/lib/mono/unityaot-linux", - "MonoBleedingEdge/lib/mono/unityaot-linux/Facades", -#endif -#else - "MonoBleedingEdge/lib/mono/unityaot", - "MonoBleedingEdge/lib/mono/unityaot/Facades", + $"{monoBleedingEdgePath}/lib/mono/unityaot", + $"{monoBleedingEdgePath}/lib/mono/unityaot/Facades", #endif #if UNITY_STANDALONE_WIN || (UNITY_EDITOR_WIN && UNITY_SERVER) diff --git a/Editor/Utils/PlatformUtil.cs b/Editor/Utils/PlatformUtil.cs index 37125e4..e0449a4 100644 --- a/Editor/Utils/PlatformUtil.cs +++ b/Editor/Utils/PlatformUtil.cs @@ -26,8 +26,13 @@ namespace Obfuz.Utils { public static bool IsMonoBackend() { - return PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup) - == ScriptingImplementation.Mono2x; + BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; +#if UNITY_6000_0_OR_NEWER + var namedBuildTarget = UnityEditor.Build.NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup); + return PlayerSettings.GetScriptingBackend(namedBuildTarget) == ScriptingImplementation.Mono2x; +#else + return PlayerSettings.GetScriptingBackend(buildTargetGroup) == ScriptingImplementation.Mono2x; +#endif } } } From 977779c8b7ca9e4367aa19eab505f8392a92fbbe Mon Sep 17 00:00:00 2001 From: walon Date: Fri, 3 Jul 2026 10:02:55 +0800 Subject: [PATCH 4/5] fix(SymbolObfus): still rename parameter names of .ctor and ..ctor even they aren't renamed --- Editor/ObfusPasses/SymbolObfus/SymbolRename.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs b/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs index 3f1ecb4..efa00d1 100644 --- a/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs +++ b/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs @@ -538,6 +538,8 @@ namespace Obfuz.ObfusPasses.SymbolObfus { foreach (MethodDef method in type.Methods) { + // always rename method params, even if the method is not renamed + RenameMethodParams(method); if (method.IsVirtual) { continue; @@ -805,7 +807,6 @@ namespace Obfuz.ObfusPasses.SymbolObfus private void Rename(MethodDef method, RefMethodMetas refMethodMetas, string newName) { ModuleDefMD mod = (ModuleDefMD)method.DeclaringType.Module; - RenameMethodParams(method); RenameMethodBody(method); if (refMethodMetas != null) { From fa2345017a22c74d13d9dd84b21bfc158d13b80d Mon Sep 17 00:00:00 2001 From: walon Date: Sun, 19 Jul 2026 13:02:21 +0800 Subject: [PATCH 5/5] fix: fix VirtualMethodGroupCalculator.TypeFlatMethods::IsLooseTypeSigMatch treats type and forward type as different type by type.AssemblyQualifiedName which leads same-virtual-slot virtual methods are grouped to different virtual method group. see [issue-32](https://github.com/focus-creative-games/obfuz/issues/32) --- .../ObfusPasses/SymbolObfus/SymbolRename.cs | 41 +++++++++++-------- .../VirtualMethodGroupCalculator.cs | 10 ++++- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs b/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs index efa00d1..fbb904d 100644 --- a/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs +++ b/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs @@ -49,6 +49,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus private readonly Dictionary> _customAttributeArgumentsWithTypeByMods = new Dictionary>(); private readonly RenameRecordMap _renameRecordMap; private readonly VirtualMethodGroupCalculator _virtualMethodGroupCalculator; + private readonly List _virtualMethods = new List(); private readonly List _customPolicyTypes; class CustomAttributeInfo @@ -205,6 +206,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus public void Process() { _renameRecordMap.Init(_toObfuscatedModules, _nameMaker); + BuildVirtualMethodGroup(); RenameTypes(); RenameFields(); RenameMethods(); @@ -525,11 +527,28 @@ namespace Obfuz.ObfusPasses.SymbolObfus } } + private void BuildVirtualMethodGroup() + { + foreach (ModuleDef mod in _obfuscatedAndNotObfuscatedModules) + { + foreach (TypeDef type in mod.GetTypes()) + { + _virtualMethodGroupCalculator.CalculateType(type); + foreach (MethodDef method in type.Methods) + { + if (method.IsVirtual) + { + _virtualMethods.Add(method); + } + } + } + } + } + private void RenameMethods() { //Debug.Log("Rename methods begin"); //Debug.Log("Rename not virtual methods begin"); - var virtualMethods = new List(); var refMethodMetasMap = new Dictionary(); BuildRefMethodMetasMap(refMethodMetasMap); foreach (ModuleDef mod in _toObfuscatedModules) @@ -552,28 +571,13 @@ namespace Obfuz.ObfusPasses.SymbolObfus } } - foreach (ModuleDef mod in _obfuscatedAndNotObfuscatedModules) - { - foreach (TypeDef type in mod.GetTypes()) - { - _virtualMethodGroupCalculator.CalculateType(type); - foreach (MethodDef method in type.Methods) - { - if (method.IsVirtual) - { - virtualMethods.Add(method); - } - } - } - } - //Debug.Log("Rename not virtual methods end"); //Debug.Log("Rename virtual methods begin"); var visitedVirtualMethods = new HashSet(); var groupNeedRenames = new Dictionary(); - foreach (var method in virtualMethods) + foreach (var method in _virtualMethods) { if (!visitedVirtualMethods.Add(method)) { @@ -753,7 +757,8 @@ namespace Obfuz.ObfusPasses.SymbolObfus foreach (TypeRef typeRef in refTypeDefMeta.typeRefs) { Assert.AreEqual(typeRef.FullName, oldFullName); - Assert.IsTrue(typeRef.DefinitionAssembly.Name == moduleName); + // Assert fail when typeRef to a fowarded type + // Assert.IsTrue(typeRef.DefinitionAssembly.Name == moduleName); if (!string.IsNullOrEmpty(oldNamespace)) { typeRef.Namespace = newNamespace; diff --git a/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs b/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs index 997de92..b8d2041 100644 --- a/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs +++ b/Editor/ObfusPasses/SymbolObfus/VirtualMethodGroupCalculator.cs @@ -160,7 +160,15 @@ namespace Obfuz.ObfusPasses.SymbolObfus case ElementType.Class: case ElementType.ValueType: { - return t1.AssemblyQualifiedName == t2.AssemblyQualifiedName; + if (t1.AssemblyQualifiedName == t2.AssemblyQualifiedName) + { + return true; + } + if (t1.FullName == t2.FullName) + { + return t1.ToTypeDefOrRef().ResolveTypeDefThrow() == t2.ToTypeDefOrRef().ResolveTypeDefThrow(); + } + return false; } case ElementType.Ptr: case ElementType.ByRef: