diff --git a/Editor/ObfusPasses/WalterMark/WatermarkPass.cs b/Editor/ObfusPasses/WalterMark/WatermarkPass.cs index f86b512..c66e590 100644 --- a/Editor/ObfusPasses/WalterMark/WatermarkPass.cs +++ b/Editor/ObfusPasses/WalterMark/WatermarkPass.cs @@ -138,9 +138,12 @@ namespace Obfuz.ObfusPasses.Watermark private void AddFieldAccessToSignatureHolder(ModuleDef module, EncryptionScopeInfo encryptionScope, WatermarkInfo watermarkInfo) { + BurstCompileComputeCache burstCompileComputeCache = ObfuscationPassContext.Current.burstCompileComputeCache; var insertTargetMethods = module.Types + .Where(t => !MetaUtil.HasBurstCompileAttribute(t)) .SelectMany(t => t.Methods) - .Where(m => m.HasBody && m.Body.Instructions.Count > 10) + .Where(m => m.HasBody && m.Body.Instructions.Count > 10 && !MetaUtil.HasBurstCompileAttribute(m) + && !burstCompileComputeCache.IsBurstCompileMethodOrReferencedByBurstCompileMethod(m)) .ToList(); if (insertTargetMethods.Count == 0) @@ -149,7 +152,7 @@ namespace Obfuz.ObfusPasses.Watermark return; } - var random = encryptionScope.localRandomCreator(HashUtil.ComputeHash("AddFieldAccessToSignatureHolder")); + var random = encryptionScope.localRandomCreator(HashUtil.ComputeHash($"AddFieldAccessToSignatureHolder:{module.Name}")); DefaultMetadataImporter importer = ObfuscationPassContext.Current.moduleEntityManager.GetEntity(module); foreach (var fieldDef in watermarkInfo.signatureHoldFields) { @@ -195,7 +198,7 @@ namespace Obfuz.ObfusPasses.Watermark Debug.LogWarning($"No suitable methods found in module '{module.Name}' to insert watermark IL sequences."); return; } - var random = encryptionScope.localRandomCreator(HashUtil.ComputeHash("AddWaterMarkILSequences")); + var random = encryptionScope.localRandomCreator(HashUtil.ComputeHash($"AddWaterMarkILSequences:{module.Name}")); int[] signature = KeyGenerator.ConvertToIntKey(watermarkInfo.signature); for (int intIndex = 0; intIndex < signature.Length;) { diff --git a/Editor/ObfuscationMethodWhitelist.cs b/Editor/ObfuscationMethodWhitelist.cs index 4fe07f3..882eb8c 100644 --- a/Editor/ObfuscationMethodWhitelist.cs +++ b/Editor/ObfuscationMethodWhitelist.cs @@ -65,7 +65,7 @@ namespace Obfuz { return true; } - if (method.CustomAttributes.Find(ConstValues.BurstCompileFullName) != null || _burstCompileComputeCache.IsBurstCompileMethodOrReferencedByBurstCompileMethod(method)) + if (MetaUtil.HasBurstCompileAttribute(method) || _burstCompileComputeCache.IsBurstCompileMethodOrReferencedByBurstCompileMethod(method)) { return true; } @@ -88,7 +88,7 @@ namespace Obfuz { return true; } - if (type.CustomAttributes.Find(ConstValues.BurstCompileFullName) != null) + if (MetaUtil.HasBurstCompileAttribute(type)) { return true; } diff --git a/Editor/ObfuscationPassContext.cs b/Editor/ObfuscationPassContext.cs index ac418db..156cf88 100644 --- a/Editor/ObfuscationPassContext.cs +++ b/Editor/ObfuscationPassContext.cs @@ -62,6 +62,7 @@ namespace Obfuz public List modulesToObfuscate; public List allObfuscationRelativeModules; public ObfuzIgnoreScopeComputeCache obfuzIgnoreScopeComputeCache; + public BurstCompileComputeCache burstCompileComputeCache; public ObfuscationMethodWhitelist whiteList; public ConfigurablePassPolicy passPolicy; diff --git a/Editor/Obfuscator.cs b/Editor/Obfuscator.cs index 95a5f83..35e57d3 100644 --- a/Editor/Obfuscator.cs +++ b/Editor/Obfuscator.cs @@ -288,6 +288,7 @@ namespace Obfuz EncryptionScopeProvider = encryptionScopeProvider, }; var obfuzIgnoreScopeComputeCache = new ObfuzIgnoreScopeComputeCache(); + var burstCompileCache = new BurstCompileComputeCache(modulesToObfuscate, allObfuscationRelativeModules); _ctx = new ObfuscationPassContext { coreSettings = _coreSettings, @@ -298,8 +299,9 @@ namespace Obfuz moduleEntityManager = moduleEntityManager, obfuzIgnoreScopeComputeCache = obfuzIgnoreScopeComputeCache, + burstCompileComputeCache = burstCompileCache, - whiteList = new ObfuscationMethodWhitelist(obfuzIgnoreScopeComputeCache, new BurstCompileComputeCache(modulesToObfuscate, allObfuscationRelativeModules)), + whiteList = new ObfuscationMethodWhitelist(obfuzIgnoreScopeComputeCache, burstCompileCache), passPolicy = _passPolicy, }; ObfuscationPassContext.Current = _ctx;