对MonoPInvokeCallbackAttribute、Zlua.LuaInvokeAttribute、Zlua.LuaCallbackAttribute、ZluaLuaMarshalAsAttribute禁用所有符号混淆

1.x
walon 2025-06-06 20:28:08 +08:00
parent 1508cdc31d
commit b38becf84a
2 changed files with 18 additions and 2 deletions

View File

@ -13,5 +13,11 @@
public const string EncryptFieldAttributeFullName = "Obfuz.EncryptFieldAttribute"; public const string EncryptFieldAttributeFullName = "Obfuz.EncryptFieldAttribute";
public const string EmbeddedAttributeFullName = "Microsoft.CodeAnalysis.EmbeddedAttribute"; public const string EmbeddedAttributeFullName = "Microsoft.CodeAnalysis.EmbeddedAttribute";
public const string MonoPInvokeCallbackAttributeName = "MonoPInvokeCallbackAttribute";
public const string ZluaLuaInvokeAttributeFullName = "Zlua.LuaInvokeAttribute";
public const string ZluaLuaCallbackAttributeFullName = "Zlua.LuaCallbackAttribute";
public const string ZluaLuaMarshalAsAttributeFullName = "Zlua.LuaMarshalAsAttribute";
} }
} }

View File

@ -2,6 +2,7 @@
using Obfuz.Editor; using Obfuz.Editor;
using Obfuz.Utils; using Obfuz.Utils;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace Obfuz.ObfusPasses.SymbolObfus.Policies namespace Obfuz.ObfusPasses.SymbolObfus.Policies
{ {
@ -14,17 +15,26 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
_obfuzIgnoreScopeComputeCache = obfuzIgnoreScopeComputeCache; _obfuzIgnoreScopeComputeCache = obfuzIgnoreScopeComputeCache;
} }
private readonly HashSet<string> _fullIgnoreTypeNames = new HashSet<string> private readonly HashSet<string> _fullIgnoreTypeFullNames = new HashSet<string>
{ {
ConstValues.ObfuzIgnoreAttributeFullName, ConstValues.ObfuzIgnoreAttributeFullName,
ConstValues.ObfuzScopeFullName, ConstValues.ObfuzScopeFullName,
ConstValues.EncryptFieldAttributeFullName, ConstValues.EncryptFieldAttributeFullName,
ConstValues.EmbeddedAttributeFullName, ConstValues.EmbeddedAttributeFullName,
ConstValues.ZluaLuaInvokeAttributeFullName,
ConstValues.ZluaLuaCallbackAttributeFullName,
ConstValues.ZluaLuaMarshalAsAttributeFullName,
};
private readonly HashSet<string> _fullIgnoreTypeNames = new HashSet<string>
{
ConstValues.MonoPInvokeCallbackAttributeName,
}; };
private bool IsFullIgnoreObfuscatedType(TypeDef typeDef) private bool IsFullIgnoreObfuscatedType(TypeDef typeDef)
{ {
return _fullIgnoreTypeNames.Contains(typeDef.FullName) || MetaUtil.HasMicrosoftCodeAnalysisEmbeddedAttribute(typeDef); return _fullIgnoreTypeFullNames.Contains(typeDef.FullName) || _fullIgnoreTypeNames.Contains(typeDef.Name) || MetaUtil.HasMicrosoftCodeAnalysisEmbeddedAttribute(typeDef);
} }
public override bool NeedRename(TypeDef typeDef) public override bool NeedRename(TypeDef typeDef)