Preserve tokens if VM code couldn't be restored

This commit is contained in:
de4dot 2012-12-14 16:51:21 +01:00
parent e8a9c0675a
commit 6ce3b44de6
2 changed files with 12 additions and 4 deletions

View File

@ -271,8 +271,12 @@ namespace de4dot.code.deobfuscators.Agile_NET {
}
if (options.RestoreVmCode) {
csvm.restore();
addResourceToBeRemoved(csvm.Resource, "CSVM data resource");
if (csvm.restore())
addResourceToBeRemoved(csvm.Resource, "CSVM data resource");
else {
Logger.e("Couldn't restore VM methods");
preserveTokensAndTypes();
}
}
}

View File

@ -78,13 +78,17 @@ namespace de4dot.code.deobfuscators.Agile_NET.vm {
return DotNetUtils.getResource(module, "_CSVM") as EmbeddedResource;
}
public void restore() {
public bool restore() {
if (!Detected)
return;
return true;
int oldIndent = Logger.Instance.IndentLevel;
try {
restore2();
return true;
}
catch {
return false;
}
finally {
Logger.Instance.IndentLevel = oldIndent;