From bffbe419d571a7ea0b3bf5d035872131ec4c5ea9 Mon Sep 17 00:00:00 2001 From: de4dot Date: Sat, 11 Feb 2012 23:11:41 +0100 Subject: [PATCH] Add hasInteger() method --- de4dot.code/deobfuscators/DeobUtils.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/de4dot.code/deobfuscators/DeobUtils.cs b/de4dot.code/deobfuscators/DeobUtils.cs index 6335934a..4332f8a7 100644 --- a/de4dot.code/deobfuscators/DeobUtils.cs +++ b/de4dot.code/deobfuscators/DeobUtils.cs @@ -162,5 +162,19 @@ namespace de4dot.code.deobfuscators { ((int)reader.ReadByte() << 8) + reader.ReadByte(); } + + public static bool hasInteger(MethodDefinition method, uint value) { + return hasInteger(method, (int)value); + } + + public static bool hasInteger(MethodDefinition method, int value) { + foreach (var instr in method.Body.Instructions) { + if (!DotNetUtils.isLdcI4(instr)) + continue; + if (DotNetUtils.getLdcI4Value(instr) == value) + return true; + } + return false; + } } }