Remember to add this as first arg if HasThis is set
This commit is contained in:
parent
8c2f26bfcb
commit
a594b11254
|
@ -26,9 +26,9 @@ namespace de4dot.blocks.cflow {
|
||||||
Block block;
|
Block block;
|
||||||
InstructionEmulator instructionEmulator = new InstructionEmulator();
|
InstructionEmulator instructionEmulator = new InstructionEmulator();
|
||||||
|
|
||||||
public void init(Block block, IList<ParameterDefinition> args, IList<VariableDefinition> locals) {
|
public void init(Blocks blocks, Block block) {
|
||||||
this.block = block;
|
this.block = block;
|
||||||
instructionEmulator.init(false, args, locals);
|
instructionEmulator.init(blocks.Method.HasThis, false, blocks.Method.Parameters, blocks.Locals);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if code was updated, false otherwise
|
// Returns true if code was updated, false otherwise
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace de4dot.blocks.cflow {
|
||||||
var lastInstr = block.LastInstr;
|
var lastInstr = block.LastInstr;
|
||||||
if (!DotNetUtils.isConditionalBranch(lastInstr.OpCode.Code) && lastInstr.OpCode.Code != Code.Switch)
|
if (!DotNetUtils.isConditionalBranch(lastInstr.OpCode.Code) && lastInstr.OpCode.Code != Code.Switch)
|
||||||
continue;
|
continue;
|
||||||
blockCflowDeobfuscator.init(block, blocks.Method.Parameters, blocks.Locals);
|
blockCflowDeobfuscator.init(blocks, block);
|
||||||
changed |= blockCflowDeobfuscator.deobfuscate();
|
changed |= blockCflowDeobfuscator.deobfuscate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,14 @@ namespace de4dot.blocks.cflow {
|
||||||
List<Value> args = new List<Value>();
|
List<Value> args = new List<Value>();
|
||||||
List<Value> locals = new List<Value>();
|
List<Value> locals = new List<Value>();
|
||||||
|
|
||||||
public void init(bool initLocals, IList<ParameterDefinition> parameterDefinitions, IList<VariableDefinition> variableDefinitions) {
|
public void init(bool hasThis, bool initLocals, IList<ParameterDefinition> parameterDefinitions, IList<VariableDefinition> variableDefinitions) {
|
||||||
this.parameterDefinitions = parameterDefinitions;
|
this.parameterDefinitions = parameterDefinitions;
|
||||||
this.variableDefinitions = variableDefinitions;
|
this.variableDefinitions = variableDefinitions;
|
||||||
valueStack.init();
|
valueStack.init();
|
||||||
|
|
||||||
args.Clear();
|
args.Clear();
|
||||||
|
if (hasThis)
|
||||||
|
args.Add(new UnknownValue());
|
||||||
foreach (var arg in parameterDefinitions)
|
foreach (var arg in parameterDefinitions)
|
||||||
args.Add(getUnknownValue(arg.ParameterType));
|
args.Add(getUnknownValue(arg.ParameterType));
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ namespace de4dot.blocks.cflow {
|
||||||
foreach (var source in new List<Block>(block.Sources)) {
|
foreach (var source in new List<Block>(block.Sources)) {
|
||||||
if (!isBranchBlock(source))
|
if (!isBranchBlock(source))
|
||||||
continue;
|
continue;
|
||||||
instructionEmulator.init(false, blocks.Method.Parameters, blocks.Locals);
|
instructionEmulator.init(blocks.Method.HasThis, false, blocks.Method.Parameters, blocks.Locals);
|
||||||
instructionEmulator.emulate(source.Instructions);
|
instructionEmulator.emulate(source.Instructions);
|
||||||
|
|
||||||
var target = getSwitchTarget(switchTargets, switchFallThrough, source, instructionEmulator.pop());
|
var target = getSwitchTarget(switchTargets, switchFallThrough, source, instructionEmulator.pop());
|
||||||
|
@ -145,7 +145,7 @@ namespace de4dot.blocks.cflow {
|
||||||
foreach (var source in new List<Block>(block.Sources)) {
|
foreach (var source in new List<Block>(block.Sources)) {
|
||||||
if (!isBranchBlock(source))
|
if (!isBranchBlock(source))
|
||||||
continue;
|
continue;
|
||||||
instructionEmulator.init(false, blocks.Method.Parameters, blocks.Locals);
|
instructionEmulator.init(blocks.Method.HasThis, false, blocks.Method.Parameters, blocks.Locals);
|
||||||
instructionEmulator.emulate(source.Instructions);
|
instructionEmulator.emulate(source.Instructions);
|
||||||
|
|
||||||
var target = getSwitchTarget(switchTargets, switchFallThrough, source, instructionEmulator.getLocal(switchVariable));
|
var target = getSwitchTarget(switchTargets, switchFallThrough, source, instructionEmulator.getLocal(switchVariable));
|
||||||
|
@ -168,7 +168,7 @@ namespace de4dot.blocks.cflow {
|
||||||
foreach (var source in new List<Block>(block.Sources)) {
|
foreach (var source in new List<Block>(block.Sources)) {
|
||||||
if (!isBranchBlock(source))
|
if (!isBranchBlock(source))
|
||||||
continue;
|
continue;
|
||||||
instructionEmulator.init(false, blocks.Method.Parameters, blocks.Locals);
|
instructionEmulator.init(blocks.Method.HasThis, false, blocks.Method.Parameters, blocks.Locals);
|
||||||
instructionEmulator.emulate(source.Instructions);
|
instructionEmulator.emulate(source.Instructions);
|
||||||
|
|
||||||
var target = getSwitchTarget(switchTargets, switchFallThrough, source, instructionEmulator.pop());
|
var target = getSwitchTarget(switchTargets, switchFallThrough, source, instructionEmulator.pop());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user