Bug fix. Some methods have a body but 0 instrs

This commit is contained in:
de4dot 2011-09-24 18:48:15 +02:00
parent f1ff27fd10
commit 5dd6567fc9
2 changed files with 8 additions and 3 deletions

View File

@ -411,7 +411,7 @@ namespace de4dot {
Log.v("Deobfuscating {0} ({1:X8})", method, method.MetadataToken.ToUInt32());
Log.indent();
if (method.HasBody) {
if (hasNonEmptyBody(method)) {
var blocks = new Blocks(method);
deob.deobfuscateMethodBegin(blocks);
@ -434,6 +434,10 @@ namespace de4dot {
}
}
bool hasNonEmptyBody(MethodDefinition method) {
return method.HasBody && method.Body.Instructions.Count > 0;
}
void deobfuscateStrings(Blocks blocks) {
switch (options.StringDecrypterType) {
case DecrypterType.None:
@ -481,7 +485,7 @@ namespace de4dot {
Log.v("{0}: {1} ({2:X8})", msg, method, method.MetadataToken.ToUInt32());
Log.indent();
if (method.HasBody) {
if (hasNonEmptyBody(method)) {
var blocks = new Blocks(method);
handler(blocks);

View File

@ -41,7 +41,8 @@ namespace de4dot.blocks {
visited = new Dictionary<BaseBlock, bool>();
sorted = new List<BaseBlock>(scopeBlock.BaseBlocks.Count);
search(scopeBlock.BaseBlocks[0]);
if (scopeBlock.BaseBlocks.Count > 0)
search(scopeBlock.BaseBlocks[0]);
sorted.Reverse(); // It's in reverse order
// Just in case there's dead code or unreferenced exception blocks