From 1d8fe39f599a5e5a80140a92848ee2f7d2eb01c0 Mon Sep 17 00:00:00 2001 From: de4dot Date: Thu, 24 Nov 2011 10:35:42 +0100 Subject: [PATCH] Add isEmptyObfuscated() method --- blocks/DotNetUtils.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/blocks/DotNetUtils.cs b/blocks/DotNetUtils.cs index cff9eee6..6f00f969 100644 --- a/blocks/DotNetUtils.cs +++ b/blocks/DotNetUtils.cs @@ -241,7 +241,7 @@ namespace de4dot.blocks { } public static bool isEmpty(MethodDefinition method) { - if (!method.HasBody) + if (method.Body == null) return false; foreach (var instr in method.Body.Instructions) { var code = instr.OpCode.Code; @@ -251,6 +251,17 @@ namespace de4dot.blocks { return true; } + public static bool isEmptyObfuscated(MethodDefinition method) { + if (method.Body == null) + return false; + int index = 0; + var instr = getInstruction(method.Body.Instructions, ref index); + if (instr == null || instr.OpCode.Code != Code.Ret) + return false; + + return true; + } + public static FieldDefinition findFieldType(TypeDefinition typeDefinition, string typeName, bool isStatic) { if (typeDefinition == null) return null;