禁止混淆带`[BurstCompile]`的函数

main
walon 2025-07-11 18:03:25 +08:00
parent c3238c54a9
commit 2887231df7
3 changed files with 14 additions and 1 deletions

View File

@ -1,4 +1,6 @@
namespace Obfuz.Editor using System.Text;
namespace Obfuz.Editor
{ {
public static class ConstValues public static class ConstValues
{ {
@ -19,5 +21,7 @@
public const string ZluaLuaInvokeAttributeFullName = "Zlua.LuaInvokeAttribute"; public const string ZluaLuaInvokeAttributeFullName = "Zlua.LuaInvokeAttribute";
public const string ZluaLuaCallbackAttributeFullName = "Zlua.LuaCallbackAttribute"; public const string ZluaLuaCallbackAttributeFullName = "Zlua.LuaCallbackAttribute";
public const string ZluaLuaMarshalAsAttributeFullName = "Zlua.LuaMarshalAsAttribute"; public const string ZluaLuaMarshalAsAttributeFullName = "Zlua.LuaMarshalAsAttribute";
public const string BurstCompileFullName = "Unity.Burst.BurstCompileAttribute";
} }
} }

View File

@ -23,6 +23,7 @@ namespace Obfuz.ObfusPasses.SymbolObfus.Policies
ConstValues.ZluaLuaInvokeAttributeFullName, ConstValues.ZluaLuaInvokeAttributeFullName,
ConstValues.ZluaLuaCallbackAttributeFullName, ConstValues.ZluaLuaCallbackAttributeFullName,
ConstValues.ZluaLuaMarshalAsAttributeFullName, ConstValues.ZluaLuaMarshalAsAttributeFullName,
ConstValues.BurstCompileFullName,
}; };

View File

@ -63,6 +63,10 @@ namespace Obfuz
{ {
return true; return true;
} }
if (method.CustomAttributes.Find(ConstValues.BurstCompileFullName) != null)
{
return true;
}
// don't obfuscate cctor when it has RuntimeInitializeOnLoadMethodAttribute with load type AfterAssembliesLoaded // don't obfuscate cctor when it has RuntimeInitializeOnLoadMethodAttribute with load type AfterAssembliesLoaded
if (method.IsStatic && method.Name == ".cctor" && typeDef.Methods.Any(m => DoesMethodContainsRuntimeInitializeOnLoadMethodAttributeAndLoadTypeGreaterEqualAfterAssembliesLoaded(m))) if (method.IsStatic && method.Name == ".cctor" && typeDef.Methods.Any(m => DoesMethodContainsRuntimeInitializeOnLoadMethodAttributeAndLoadTypeGreaterEqualAfterAssembliesLoaded(m)))
@ -82,6 +86,10 @@ namespace Obfuz
{ {
return true; return true;
} }
if (type.CustomAttributes.Find(ConstValues.BurstCompileFullName) != null)
{
return true;
}
if (_obfuzComputeCache.HasSelfOrDeclaringOrEnclosingOrInheritObfuzIgnoreScope(type, type.DeclaringType, ObfuzScope.TypeName)) if (_obfuzComputeCache.HasSelfOrDeclaringOrEnclosingOrInheritObfuzIgnoreScope(type, type.DeclaringType, ObfuzScope.TypeName))
{ {
return true; return true;