Print warning if we failed to restore an instr op
This commit is contained in:
parent
c39e421010
commit
2949862614
|
@ -30,13 +30,12 @@ namespace de4dot.code.deobfuscators.CliSecure.vm {
|
||||||
class CilOperandInstructionRestorer {
|
class CilOperandInstructionRestorer {
|
||||||
MethodDefinition method;
|
MethodDefinition method;
|
||||||
|
|
||||||
// Returns true if something was restored
|
|
||||||
public bool restore(MethodDefinition method) {
|
public bool restore(MethodDefinition method) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
bool changed = false;
|
bool atLeastOneFailed = false;
|
||||||
|
|
||||||
if (method == null || method.Body == null)
|
if (method == null || method.Body == null)
|
||||||
return changed;
|
return atLeastOneFailed;
|
||||||
|
|
||||||
var instrs = method.Body.Instructions;
|
var instrs = method.Body.Instructions;
|
||||||
for (int i = 0; i < instrs.Count; i++) {
|
for (int i = 0; i < instrs.Count; i++) {
|
||||||
|
@ -66,14 +65,15 @@ namespace de4dot.code.deobfuscators.CliSecure.vm {
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!isValidType(operandType))
|
if (!isValidType(operandType)) {
|
||||||
|
atLeastOneFailed = true;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
instr.Operand = operandType;
|
instr.Operand = operandType;
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return atLeastOneFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValidType(TypeReference type) {
|
bool isValidType(TypeReference type) {
|
||||||
|
|
|
@ -49,7 +49,8 @@ namespace de4dot.code.deobfuscators.CliSecure.vm {
|
||||||
|
|
||||||
DotNetUtils.restoreBody(cilMethod, newInstructions, newExceptions);
|
DotNetUtils.restoreBody(cilMethod, newInstructions, newExceptions);
|
||||||
|
|
||||||
operandRestorer.restore(cilMethod);
|
if (operandRestorer.restore(cilMethod))
|
||||||
|
Log.w("Failed to restore one or more instruction operands in CSVM method {0:X8}", cilMethod.MetadataToken.ToInt32());
|
||||||
}
|
}
|
||||||
|
|
||||||
void fixLocals(IList<Instruction> instrs, IList<VariableDefinition> locals) {
|
void fixLocals(IList<Instruction> instrs, IList<VariableDefinition> locals) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user