SymbolObfuscationSettings新增配置项keepUnknownSymbolInSymbolMappingFile
parent
432eb83c41
commit
f1c423ed02
|
@ -87,6 +87,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus
|
||||||
|
|
||||||
private readonly string _mappingFile;
|
private readonly string _mappingFile;
|
||||||
private readonly bool _debug;
|
private readonly bool _debug;
|
||||||
|
private readonly bool _keepUnknownSymbolInSymbolMappingFile;
|
||||||
private readonly Dictionary<string, RenameMappingAssembly> _assemblies = new Dictionary<string, RenameMappingAssembly>();
|
private readonly Dictionary<string, RenameMappingAssembly> _assemblies = new Dictionary<string, RenameMappingAssembly>();
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,10 +100,11 @@ namespace Obfuz.ObfusPasses.SymbolObfus
|
||||||
private readonly Dictionary<VirtualMethodGroup, RenameRecord> _virtualMethodGroups = new Dictionary<VirtualMethodGroup, RenameRecord>();
|
private readonly Dictionary<VirtualMethodGroup, RenameRecord> _virtualMethodGroups = new Dictionary<VirtualMethodGroup, RenameRecord>();
|
||||||
|
|
||||||
|
|
||||||
public RenameRecordMap(string mappingFile, bool debug)
|
public RenameRecordMap(string mappingFile, bool debug, bool keepUnknownSymbolInSymbolMappingFile)
|
||||||
{
|
{
|
||||||
_mappingFile = mappingFile;
|
_mappingFile = mappingFile;
|
||||||
_debug = debug;
|
_debug = debug;
|
||||||
|
_keepUnknownSymbolInSymbolMappingFile = keepUnknownSymbolInSymbolMappingFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(List<ModuleDef> assemblies, INameMaker nameMaker)
|
public void Init(List<ModuleDef> assemblies, INameMaker nameMaker)
|
||||||
|
@ -395,7 +397,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus
|
||||||
{
|
{
|
||||||
WriteTypeMapping(assemblyNode, typeDef);
|
WriteTypeMapping(assemblyNode, typeDef);
|
||||||
}
|
}
|
||||||
else
|
else if (_keepUnknownSymbolInSymbolMappingFile)
|
||||||
{
|
{
|
||||||
WriteTypeMapping(assemblyNode, typeName, ass.types[typeName]);
|
WriteTypeMapping(assemblyNode, typeName, ass.types[typeName]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus
|
||||||
_useConsistentNamespaceObfuscation = settings.useConsistentNamespaceObfuscation;
|
_useConsistentNamespaceObfuscation = settings.useConsistentNamespaceObfuscation;
|
||||||
_mappingXmlPath = settings.symbolMappingFile;
|
_mappingXmlPath = settings.symbolMappingFile;
|
||||||
_obfuscationRuleFiles = settings.ruleFiles.ToList();
|
_obfuscationRuleFiles = settings.ruleFiles.ToList();
|
||||||
_renameRecordMap = new RenameRecordMap(settings.symbolMappingFile, settings.debug);
|
_renameRecordMap = new RenameRecordMap(settings.symbolMappingFile, settings.debug, settings.keepUnknownSymbolInSymbolMappingFile);
|
||||||
_virtualMethodGroupCalculator = new VirtualMethodGroupCalculator();
|
_virtualMethodGroupCalculator = new VirtualMethodGroupCalculator();
|
||||||
_nameMaker = settings.debug ? NameMakerFactory.CreateDebugNameMaker() : NameMakerFactory.CreateNameMakerBaseASCIICharSet(settings.obfuscatedNamePrefix);
|
_nameMaker = settings.debug ? NameMakerFactory.CreateDebugNameMaker() : NameMakerFactory.CreateNameMakerBaseASCIICharSet(settings.obfuscatedNamePrefix);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Obfuz.Settings
|
||||||
public bool debug;
|
public bool debug;
|
||||||
public string obfuscatedNamePrefix;
|
public string obfuscatedNamePrefix;
|
||||||
public bool useConsistentNamespaceObfuscation;
|
public bool useConsistentNamespaceObfuscation;
|
||||||
|
public bool keepUnknownSymbolInSymbolMappingFile;
|
||||||
public string symbolMappingFile;
|
public string symbolMappingFile;
|
||||||
public List<string> ruleFiles;
|
public List<string> ruleFiles;
|
||||||
public List<Type> customRenamePolicyTypes;
|
public List<Type> customRenamePolicyTypes;
|
||||||
|
@ -27,6 +28,9 @@ namespace Obfuz.Settings
|
||||||
[Tooltip("obfuscate same namespace to one name")]
|
[Tooltip("obfuscate same namespace to one name")]
|
||||||
public bool useConsistentNamespaceObfuscation = true;
|
public bool useConsistentNamespaceObfuscation = true;
|
||||||
|
|
||||||
|
[Tooltip("keep unknown symbol in symbol mapping file, if false, unknown symbol will be removed from mapping file")]
|
||||||
|
public bool keepUnknownSymbolInSymbolMappingFile = true;
|
||||||
|
|
||||||
[Tooltip("symbol mapping file path")]
|
[Tooltip("symbol mapping file path")]
|
||||||
public string symbolMappingFile = "Assets/Obfuz/SymbolObfus/symbol-mapping.xml";
|
public string symbolMappingFile = "Assets/Obfuz/SymbolObfus/symbol-mapping.xml";
|
||||||
|
|
||||||
|
@ -51,6 +55,7 @@ namespace Obfuz.Settings
|
||||||
debug = debug,
|
debug = debug,
|
||||||
obfuscatedNamePrefix = obfuscatedNamePrefix,
|
obfuscatedNamePrefix = obfuscatedNamePrefix,
|
||||||
useConsistentNamespaceObfuscation = useConsistentNamespaceObfuscation,
|
useConsistentNamespaceObfuscation = useConsistentNamespaceObfuscation,
|
||||||
|
keepUnknownSymbolInSymbolMappingFile = keepUnknownSymbolInSymbolMappingFile,
|
||||||
symbolMappingFile = GetSymbolMappingFile(),
|
symbolMappingFile = GetSymbolMappingFile(),
|
||||||
ruleFiles = ruleFiles?.ToList() ?? new List<string>(),
|
ruleFiles = ruleFiles?.ToList() ?? new List<string>(),
|
||||||
customRenamePolicyTypes = customRenamePolicyTypes?.Select(typeName => ReflectionUtil.FindUniqueTypeInCurrentAppDomain(typeName)).ToList() ?? new List<Type>(),
|
customRenamePolicyTypes = customRenamePolicyTypes?.Select(typeName => ReflectionUtil.FindUniqueTypeInCurrentAppDomain(typeName)).ToList() ?? new List<Type>(),
|
||||||
|
|
Loading…
Reference in New Issue