Update field type
This commit is contained in:
parent
929d943112
commit
d35e92b53c
|
@ -19,9 +19,9 @@
|
|||
|
||||
namespace de4dot.blocks {
|
||||
public abstract class BaseBlock {
|
||||
BaseBlock parent = null;
|
||||
ScopeBlock parent = null;
|
||||
|
||||
public BaseBlock Parent {
|
||||
public ScopeBlock Parent {
|
||||
get { return parent; }
|
||||
set { parent = value; }
|
||||
}
|
||||
|
|
|
@ -235,16 +235,14 @@ namespace de4dot.blocks {
|
|||
break;
|
||||
}
|
||||
|
||||
foreach (var nopBlock in nopBlocks.Keys) {
|
||||
var scopeBlock = (ScopeBlock)nopBlock.Parent;
|
||||
scopeBlock.removeDeadBlock(nopBlock);
|
||||
}
|
||||
foreach (var nopBlock in nopBlocks.Keys)
|
||||
nopBlock.Parent.removeDeadBlock(nopBlock);
|
||||
}
|
||||
|
||||
static Block getNopBlockTarget(Dictionary<Block, bool> nopBlocks, Block source, Block nopBlock) {
|
||||
if (nopBlock == null || !nopBlocks.ContainsKey(nopBlock) || source == nopBlock.FallThrough)
|
||||
return null;
|
||||
if (((ScopeBlock)nopBlock.Parent).BaseBlocks[0] == nopBlock)
|
||||
if (nopBlock.Parent.BaseBlocks[0] == nopBlock)
|
||||
return null;
|
||||
var target = nopBlock.FallThrough;
|
||||
if (nopBlock.Parent != target.Parent)
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace de4dot.blocks {
|
|||
var deadBlocksDict = new Dictionary<BaseBlock, bool>();
|
||||
foreach (var baseBlock in findDeadBlocks()) {
|
||||
deadBlocksDict[baseBlock] = true;
|
||||
ScopeBlock parent = (ScopeBlock)baseBlock.Parent;
|
||||
ScopeBlock parent = baseBlock.Parent;
|
||||
ScopeBlockInfo info;
|
||||
if (!infos.TryGetValue(parent, out info))
|
||||
infos[parent] = info = new ScopeBlockInfo(parent);
|
||||
|
|
|
@ -282,7 +282,7 @@ namespace de4dot.blocks {
|
|||
}
|
||||
|
||||
// Replace the BaseBlocks with a new BaseBlock, returning the old ones.
|
||||
public List<BaseBlock> replace(int startInstr, int endInstr, BaseBlock bb) {
|
||||
public List<BaseBlock> replace(int startInstr, int endInstr, ScopeBlock bb) {
|
||||
int startIndex, endIndex;
|
||||
var rv = getBlocks(startInstr, endInstr, out startIndex, out endIndex);
|
||||
updateParent(rv, bb);
|
||||
|
@ -294,7 +294,7 @@ namespace de4dot.blocks {
|
|||
return rv;
|
||||
}
|
||||
|
||||
public List<BaseBlock> getBlocks(BaseBlock parent) {
|
||||
public List<BaseBlock> getBlocks(ScopeBlock parent) {
|
||||
if (blocksLeft.Count == 0)
|
||||
return new List<BaseBlock>();
|
||||
int startIndex, endIndex;
|
||||
|
@ -302,7 +302,7 @@ namespace de4dot.blocks {
|
|||
return updateParent(lb, parent);
|
||||
}
|
||||
|
||||
List<BaseBlock> updateParent(List<BaseBlock> lb, BaseBlock parent) {
|
||||
List<BaseBlock> updateParent(List<BaseBlock> lb, ScopeBlock parent) {
|
||||
foreach (var bb in lb)
|
||||
bb.Parent = parent;
|
||||
return lb;
|
||||
|
|
|
@ -174,10 +174,7 @@ namespace de4dot.blocks {
|
|||
if (isOurBaseBlock(bb))
|
||||
return bb;
|
||||
|
||||
for (bb = bb.Parent; bb != null; bb = bb.Parent) {
|
||||
var sb = bb as ScopeBlock;
|
||||
if (sb == null)
|
||||
throw new ApplicationException("Parent is not a ScopeBlock");
|
||||
for (var sb = bb.Parent; sb != null; sb = sb.Parent) {
|
||||
if (isOurBaseBlock(sb))
|
||||
return sb;
|
||||
}
|
||||
|
|
|
@ -348,7 +348,7 @@ namespace de4dot.code.deobfuscators.SmartAssembly {
|
|||
}
|
||||
|
||||
void removeDeadBlock(Block block) {
|
||||
var parent = (ScopeBlock)block.Parent;
|
||||
var parent = block.Parent;
|
||||
if (parent != null) // null if already dead
|
||||
parent.removeDeadBlock(block);
|
||||
}
|
||||
|
|
|
@ -99,15 +99,15 @@ namespace de4dot.code.deobfuscators.dotNET_Reactor {
|
|||
antiSnBlock.replaceLastInstrsWithBranch(numInstructions, goodBlock);
|
||||
|
||||
if (badBlock.FallThrough == badBlock && badBlock.Sources.Count == 1 && badBlock.Targets == null) {
|
||||
((ScopeBlock)badBlock.Parent).removeGuaranteedDeadBlock(badBlock);
|
||||
badBlock.Parent.removeGuaranteedDeadBlock(badBlock);
|
||||
return true;
|
||||
}
|
||||
if (badBlock.Instructions.Count <= 1 && badBlock.LastInstr.OpCode.Code == Code.Nop) {
|
||||
if (badBlock.FallThrough != null && badBlock.Targets == null && badBlock.Sources.Count == 0) {
|
||||
var badBlock2 = badBlock.FallThrough;
|
||||
if (badBlock2.FallThrough == badBlock2 && badBlock2.Sources.Count == 2 && badBlock2.Targets == null) {
|
||||
((ScopeBlock)badBlock.Parent).removeGuaranteedDeadBlock(badBlock);
|
||||
((ScopeBlock)badBlock2.Parent).removeGuaranteedDeadBlock(badBlock2);
|
||||
badBlock.Parent.removeGuaranteedDeadBlock(badBlock);
|
||||
badBlock2.Parent.removeGuaranteedDeadBlock(badBlock2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user