BasicBlockCollection新增参数决定是否计算inLoop

dev
walon 2025-06-15 10:55:09 +08:00
parent 52fcf17161
commit d60d0e02dd
2 changed files with 11 additions and 2 deletions

View File

@ -38,13 +38,20 @@ namespace Obfuz.Emit
public IList<BasicBlock> Blocks => _blocks;
public BasicBlockCollection(MethodDef method)
public BasicBlockCollection(MethodDef method, bool computeInLoop)
{
_method = method;
HashSet<Instruction> splitPoints = BuildSplitPoint(method);
BuildBasicBlocks(method, splitPoints);
BuildInOutGraph(method);
if (computeInLoop)
{
ComputeBlocksInLoop();
}
}
public void ComputeBlocksInLoop()
{
var loopBlocks = FindLoopBlocks(_blocks);
foreach (var block in loopBlocks)
{

View File

@ -10,6 +10,8 @@ namespace Obfuz.ObfusPasses
{
protected abstract bool NeedObfuscateMethod(MethodDef method);
protected virtual bool ComputeBlockInLoop => true;
public override void Process()
{
var ctx = ObfuscationPassContext.Current;
@ -48,7 +50,7 @@ namespace Obfuz.ObfusPasses
private void ObfuscateData(MethodDef method)
{
BasicBlockCollection bbc = new BasicBlockCollection(method);
BasicBlockCollection bbc = new BasicBlockCollection(method, ComputeBlockInLoop);
IList<Instruction> instructions = method.Body.Instructions;