WatermarkPass不对DOTS函数注入水印指令
parent
246a49f8ba
commit
739fcb24c5
|
@ -138,9 +138,12 @@ namespace Obfuz.ObfusPasses.Watermark
|
||||||
|
|
||||||
private void AddFieldAccessToSignatureHolder(ModuleDef module, EncryptionScopeInfo encryptionScope, WatermarkInfo watermarkInfo)
|
private void AddFieldAccessToSignatureHolder(ModuleDef module, EncryptionScopeInfo encryptionScope, WatermarkInfo watermarkInfo)
|
||||||
{
|
{
|
||||||
|
BurstCompileComputeCache burstCompileComputeCache = ObfuscationPassContext.Current.burstCompileComputeCache;
|
||||||
var insertTargetMethods = module.Types
|
var insertTargetMethods = module.Types
|
||||||
|
.Where(t => !MetaUtil.HasBurstCompileAttribute(t))
|
||||||
.SelectMany(t => t.Methods)
|
.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();
|
.ToList();
|
||||||
|
|
||||||
if (insertTargetMethods.Count == 0)
|
if (insertTargetMethods.Count == 0)
|
||||||
|
@ -149,7 +152,7 @@ namespace Obfuz.ObfusPasses.Watermark
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var random = encryptionScope.localRandomCreator(HashUtil.ComputeHash("AddFieldAccessToSignatureHolder"));
|
var random = encryptionScope.localRandomCreator(HashUtil.ComputeHash($"AddFieldAccessToSignatureHolder:{module.Name}"));
|
||||||
DefaultMetadataImporter importer = ObfuscationPassContext.Current.moduleEntityManager.GetEntity<DefaultMetadataImporter>(module);
|
DefaultMetadataImporter importer = ObfuscationPassContext.Current.moduleEntityManager.GetEntity<DefaultMetadataImporter>(module);
|
||||||
foreach (var fieldDef in watermarkInfo.signatureHoldFields)
|
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.");
|
Debug.LogWarning($"No suitable methods found in module '{module.Name}' to insert watermark IL sequences.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var random = encryptionScope.localRandomCreator(HashUtil.ComputeHash("AddWaterMarkILSequences"));
|
var random = encryptionScope.localRandomCreator(HashUtil.ComputeHash($"AddWaterMarkILSequences:{module.Name}"));
|
||||||
int[] signature = KeyGenerator.ConvertToIntKey(watermarkInfo.signature);
|
int[] signature = KeyGenerator.ConvertToIntKey(watermarkInfo.signature);
|
||||||
for (int intIndex = 0; intIndex < signature.Length;)
|
for (int intIndex = 0; intIndex < signature.Length;)
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Obfuz
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (method.CustomAttributes.Find(ConstValues.BurstCompileFullName) != null || _burstCompileComputeCache.IsBurstCompileMethodOrReferencedByBurstCompileMethod(method))
|
if (MetaUtil.HasBurstCompileAttribute(method) || _burstCompileComputeCache.IsBurstCompileMethodOrReferencedByBurstCompileMethod(method))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ namespace Obfuz
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (type.CustomAttributes.Find(ConstValues.BurstCompileFullName) != null)
|
if (MetaUtil.HasBurstCompileAttribute(type))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ namespace Obfuz
|
||||||
public List<ModuleDef> modulesToObfuscate;
|
public List<ModuleDef> modulesToObfuscate;
|
||||||
public List<ModuleDef> allObfuscationRelativeModules;
|
public List<ModuleDef> allObfuscationRelativeModules;
|
||||||
public ObfuzIgnoreScopeComputeCache obfuzIgnoreScopeComputeCache;
|
public ObfuzIgnoreScopeComputeCache obfuzIgnoreScopeComputeCache;
|
||||||
|
public BurstCompileComputeCache burstCompileComputeCache;
|
||||||
|
|
||||||
public ObfuscationMethodWhitelist whiteList;
|
public ObfuscationMethodWhitelist whiteList;
|
||||||
public ConfigurablePassPolicy passPolicy;
|
public ConfigurablePassPolicy passPolicy;
|
||||||
|
|
|
@ -288,6 +288,7 @@ namespace Obfuz
|
||||||
EncryptionScopeProvider = encryptionScopeProvider,
|
EncryptionScopeProvider = encryptionScopeProvider,
|
||||||
};
|
};
|
||||||
var obfuzIgnoreScopeComputeCache = new ObfuzIgnoreScopeComputeCache();
|
var obfuzIgnoreScopeComputeCache = new ObfuzIgnoreScopeComputeCache();
|
||||||
|
var burstCompileCache = new BurstCompileComputeCache(modulesToObfuscate, allObfuscationRelativeModules);
|
||||||
_ctx = new ObfuscationPassContext
|
_ctx = new ObfuscationPassContext
|
||||||
{
|
{
|
||||||
coreSettings = _coreSettings,
|
coreSettings = _coreSettings,
|
||||||
|
@ -298,8 +299,9 @@ namespace Obfuz
|
||||||
moduleEntityManager = moduleEntityManager,
|
moduleEntityManager = moduleEntityManager,
|
||||||
|
|
||||||
obfuzIgnoreScopeComputeCache = obfuzIgnoreScopeComputeCache,
|
obfuzIgnoreScopeComputeCache = obfuzIgnoreScopeComputeCache,
|
||||||
|
burstCompileComputeCache = burstCompileCache,
|
||||||
|
|
||||||
whiteList = new ObfuscationMethodWhitelist(obfuzIgnoreScopeComputeCache, new BurstCompileComputeCache(modulesToObfuscate, allObfuscationRelativeModules)),
|
whiteList = new ObfuscationMethodWhitelist(obfuzIgnoreScopeComputeCache, burstCompileCache),
|
||||||
passPolicy = _passPolicy,
|
passPolicy = _passPolicy,
|
||||||
};
|
};
|
||||||
ObfuscationPassContext.Current = _ctx;
|
ObfuscationPassContext.Current = _ctx;
|
||||||
|
|
Loading…
Reference in New Issue