From c173efe6893d9d7ab51296727216fc5b70c91020 Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 29 May 2025 11:39:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=A6=E5=8F=B7=E6=B7=B7=E6=B7=86=E5=BC=80?= =?UTF-8?q?=E5=90=AFdebug=E6=83=85=E5=86=B5=E4=B8=8B=E4=B8=8D=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E4=BD=86=E5=86=99=E5=85=A5symbol-mapping-debug.xml?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E8=BF=99=E6=A0=B7LinkXmlProcess?= =?UTF-8?q?=E4=B8=AD=E4=B9=9F=E8=83=BD=E6=AD=A3=E7=A1=AE=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E5=88=B0=E6=B7=B7=E6=B7=86=E5=90=8E=E7=9A=84=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs | 9 ++++++++- .../Editor/ObfusPasses/SymbolObfus/SymbolRename.cs | 2 +- .../Editor/Settings/SymbolObfuscationSettings.cs | 10 +++++++++- .../Editor/Unity/LinkXmlProcess.cs | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs b/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs index 256a245..9e2aaa4 100644 --- a/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs +++ b/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/RenameRecordMap.cs @@ -87,6 +87,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus } private readonly string _mappingFile; + private readonly bool _debug; private readonly Dictionary _assemblies = new Dictionary(); @@ -99,9 +100,10 @@ namespace Obfuz.ObfusPasses.SymbolObfus private readonly Dictionary _virtualMethodGroups = new Dictionary(); - public RenameRecordMap(string mappingFile) + public RenameRecordMap(string mappingFile, bool debug) { _mappingFile = mappingFile; + _debug = debug; } public void Init(List assemblies, INameMaker nameMaker) @@ -227,6 +229,11 @@ namespace Obfuz.ObfusPasses.SymbolObfus { return; } + if (_debug) + { + Debug.Log($"skip loading debug mapping file: {Path.GetFullPath(mappingFile)}"); + return; + } var doc = new XmlDocument(); doc.Load(mappingFile); var root = doc.DocumentElement; diff --git a/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs b/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs index 045a2ea..e09ac7a 100644 --- a/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs +++ b/com.code-philosophy.obfuz/Editor/ObfusPasses/SymbolObfus/SymbolRename.cs @@ -48,7 +48,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus _useConsistentNamespaceObfuscation = settings.useConsistentNamespaceObfuscation; _mappingXmlPath = settings.symbolMappingFile; _obfuscationRuleFiles = settings.ruleFiles.ToList(); - _renameRecordMap = new RenameRecordMap(settings.debug ? null : settings.symbolMappingFile); + _renameRecordMap = new RenameRecordMap(settings.symbolMappingFile, settings.debug); _virtualMethodGroupCalculator = new VirtualMethodGroupCalculator(); _nameMaker = settings.debug ? NameMakerFactory.CreateDebugNameMaker() : NameMakerFactory.CreateNameMakerBaseASCIICharSet(settings.obfuscatedNamePrefix); diff --git a/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs b/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs index ae7f274..f53df82 100644 --- a/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs +++ b/com.code-philosophy.obfuz/Editor/Settings/SymbolObfuscationSettings.cs @@ -33,12 +33,20 @@ namespace Obfuz.Settings [Tooltip("symbol mapping file path")] public string symbolMappingFile = "Assets/Obfuz/SymbolObfus/symbol-mapping.xml"; + [Tooltip("debug symbol mapping file path, used for debugging purposes")] + public string debugSymbolMappingFile = "Assets/Obfuz/SymbolObfus/symbol-mapping-debug.xml"; + [Tooltip("rule files")] public string[] ruleFiles; [Tooltip("custom rename policy types")] public string[] customRenamePolicyTypes; + public string GetSymbolMappingFile() + { + return debug ? debugSymbolMappingFile : symbolMappingFile; + } + public SymbolObfuscationSettingsFacade ToFacade() { return new SymbolObfuscationSettingsFacade @@ -46,7 +54,7 @@ namespace Obfuz.Settings debug = debug, obfuscatedNamePrefix = obfuscatedNamePrefix, useConsistentNamespaceObfuscation = useConsistentNamespaceObfuscation, - symbolMappingFile = symbolMappingFile, + symbolMappingFile = GetSymbolMappingFile(), ruleFiles = ruleFiles?.ToList() ?? new List(), customRenamePolicyTypes = customRenamePolicyTypes?.Select(typeName => ReflectionUtil.FindUniqueTypeInCurrentAppDomain(typeName)).ToList() ?? new List(), }; diff --git a/com.code-philosophy.obfuz/Editor/Unity/LinkXmlProcess.cs b/com.code-philosophy.obfuz/Editor/Unity/LinkXmlProcess.cs index ad02820..14358d5 100644 --- a/com.code-philosophy.obfuz/Editor/Unity/LinkXmlProcess.cs +++ b/com.code-philosophy.obfuz/Editor/Unity/LinkXmlProcess.cs @@ -42,7 +42,7 @@ namespace Obfuz.Unity public static string GenerateAdditionalLinkXmlFile(BuildTarget target) { ObfuzSettings settings = ObfuzSettings.Instance; - string symbolMappingFile = settings.symbolObfusSettings.symbolMappingFile; + string symbolMappingFile = settings.symbolObfusSettings.GetSymbolMappingFile(); if (!File.Exists(symbolMappingFile)) { Debug.LogWarning($"Symbol mapping file not found: {symbolMappingFile}. Skipping link.xml generation.");