fix: 修复符号混淆规则文件中modifier条件对property和event没有生效的bug。由于property和event本身并不存在Access Attributes,实际上是由它们所包含的method的Access属性`或`计算而来。

main
walon 2025-09-10 18:20:29 +08:00
parent e12a0e26dc
commit 403764e7af
1 changed files with 24 additions and 2 deletions

View File

@ -395,12 +395,34 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
private bool MatchModifier(ModifierType? modifierType, PropertyDef propertyDef)
{
return modifierType == null || (modifierType & ComputeModifierType((FieldAttributes)propertyDef.Attributes)) != 0;
FieldAttributes access = default;
if (propertyDef.GetMethod != null)
{
access |= (FieldAttributes)propertyDef.GetMethod.Access;
}
if (propertyDef.SetMethod != null)
{
access |= (FieldAttributes)propertyDef.SetMethod.Access;
}
return modifierType == null || (modifierType & ComputeModifierType(access)) != 0;
}
private bool MatchModifier(ModifierType? modifierType, EventDef eventDef)
{
return modifierType == null || (modifierType & ComputeModifierType((FieldAttributes)eventDef.Attributes)) != 0;
FieldAttributes access = default;
if (eventDef.AddMethod != null)
{
access |= (FieldAttributes)eventDef.AddMethod.Access;
}
if (eventDef.RemoveMethod != null)
{
access |= (FieldAttributes)eventDef.RemoveMethod.Access;
}
if (eventDef.InvokeMethod != null)
{
access |= (FieldAttributes)eventDef.InvokeMethod.Access;
}
return modifierType == null || (modifierType & ComputeModifierType(access)) != 0;
}
private class MethodComputeCache