2025-05-17 14:53:51 +08:00
|
|
|
|
using dnlib.DotNet;
|
|
|
|
|
using Obfuz.Conf;
|
|
|
|
|
using Obfuz.Utils;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
|
|
namespace Obfuz.ObfusPasses.FieldEncrypt
|
|
|
|
|
{
|
|
|
|
|
public class ConfigurableEncryptPolicy : EncryptPolicyBase
|
|
|
|
|
{
|
|
|
|
|
class ObfuscationRule
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly XmlFieldRuleParser<ObfuscationRule> _configParser;
|
|
|
|
|
|
|
|
|
|
public ConfigurableEncryptPolicy(List<string> toObfuscatedAssemblyNames, List<string> configFiles)
|
|
|
|
|
{
|
|
|
|
|
_configParser = new XmlFieldRuleParser<ObfuscationRule>(toObfuscatedAssemblyNames, ParseRule, null);
|
|
|
|
|
_configParser.LoadConfigs(configFiles);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ObfuscationRule ParseRule(string configFile, XmlElement ele)
|
|
|
|
|
{
|
|
|
|
|
return new ObfuscationRule();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool NeedEncrypt(FieldDef field)
|
|
|
|
|
{
|
2025-05-20 11:08:07 +08:00
|
|
|
|
if (MetaUtil.HasEncryptFieldAttribute(field))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-05-20 16:37:38 +08:00
|
|
|
|
if (MetaUtil.HasObfuzIgnoreAttribute(field) || MetaUtil.HasObfuzIgnoreAttributeInSelfOrParent(field.DeclaringType))
|
2025-05-20 11:08:07 +08:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2025-05-17 14:53:51 +08:00
|
|
|
|
var rule = _configParser.GetFieldRule(field);
|
|
|
|
|
return rule != null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|