Support more types of args

This commit is contained in:
de4dot 2012-04-30 08:31:09 +02:00
parent e29a8ea692
commit a1daee56f8

View File

@ -200,13 +200,16 @@ namespace de4dot.code {
} }
} }
void getLocalVariableValue(VariableDefinition variable, out object value) { bool getLocalVariableValue(VariableDefinition variable, out object value) {
if (variableValues == null) if (variableValues == null)
variableValues = new VariableValues(blocks.Locals, allBlocks); variableValues = new VariableValues(blocks.Locals, allBlocks);
var val = variableValues.getValue(variable); var val = variableValues.getValue(variable);
if (!val.isValid()) if (!val.isValid()) {
throw new ApplicationException("Could not get value of local variable"); value = null;
return false;
}
value = val.Value; value = val.Value;
return true;
} }
void findAllCallResults() { void findAllCallResults() {
@ -320,11 +323,15 @@ namespace de4dot.code {
getLocalVariableValue(Instr.getLocalVar(blocks.Locals, instr), out arg); getLocalVariableValue(Instr.getLocalVar(blocks.Locals, instr), out arg);
break; break;
case Code.Ldfld:
case Code.Ldsfld: case Code.Ldsfld:
arg = instr.Operand; arg = instr.Operand;
break; break;
default: default:
int pushes, pops;
DotNetUtils.calculateStackUsage(instr.Instruction, false, out pushes, out pops);
if (pushes != 1) {
Log.w("Could not find all arguments to method {0} ({1:X8}), instr: {2}", Log.w("Could not find all arguments to method {0} ({1:X8}), instr: {2}",
Utils.removeNewlines(method), Utils.removeNewlines(method),
method.MetadataToken.ToInt32(), method.MetadataToken.ToInt32(),
@ -332,6 +339,14 @@ namespace de4dot.code {
errors++; errors++;
return false; return false;
} }
for (int i = 0; i < pops; i++) {
if (!getArg(method, block, ref arg, ref instrIndex))
return false;
}
arg = null;
break;
}
break; break;
} }