From 2cb8427f3ad6793b54349954bc31da1b54778993 Mon Sep 17 00:00:00 2001 From: yck1509 Date: Tue, 13 Oct 2015 15:35:05 +0800 Subject: [PATCH] Minor updates --- Confuser.Core/ConfuserContext.cs | 5 +++++ .../Constants/ReferenceReplacer.cs | 18 +----------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Confuser.Core/ConfuserContext.cs b/Confuser.Core/ConfuserContext.cs index c0e527b26..56b7c806a 100644 --- a/Confuser.Core/ConfuserContext.cs +++ b/Confuser.Core/ConfuserContext.cs @@ -142,6 +142,11 @@ public ModuleDefMD CurrentModule { /// The output byte[] debug symbol. public byte[] CurrentModuleSymbol { get; internal set; } + /// + /// Gets the token used to indicate cancellation + /// + public CancellationToken CancellationToken { get { return token; } } + /// /// Throws a System.OperationCanceledException if protection process has been canceled. /// diff --git a/Confuser.Protections/Constants/ReferenceReplacer.cs b/Confuser.Protections/Constants/ReferenceReplacer.cs index 54ee2491a..ed37dd9b8 100644 --- a/Confuser.Protections/Constants/ReferenceReplacer.cs +++ b/Confuser.Protections/Constants/ReferenceReplacer.cs @@ -373,25 +373,9 @@ static void ReplaceCFG(MethodDef method, List> } // Update state for blocks not in use - var done = new HashSet(); - var q = new Stack(graph.Where(b => (b.Type & ControlFlowBlockType.Entry) != 0).Reverse()); - while (q.Count > 0) { - var block = q.Pop(); - if (done.Contains(block)) - continue; - done.Add(block); - - foreach (var succ in block.Targets) - q.Push(succ); - - if (blockReferences.ContainsKey(block.Id)) - continue; - InsertEmptyStateUpdate(cfgCtx, block); - } - for (int i = 0; i < graph.Count; i++) { var block = graph[i]; - if (done.Contains(block) || blockReferences.ContainsKey(block.Id)) + if (blockReferences.ContainsKey(block.Id)) continue; InsertEmptyStateUpdate(cfgCtx, block); }