Actually use index of the not opcode

Signed-off-by: angelsl <hidingfromhidden@gmail.com>
This commit is contained in:
angelsl 2015-08-28 00:01:40 +08:00
parent ffeb7c9472
commit 133814073c

View File

@ -183,6 +183,7 @@ namespace de4dot.code.deobfuscators.CryptoObfuscator {
static bool CheckFlipBits(MethodDef method, out int index) { static bool CheckFlipBits(MethodDef method, out int index) {
int nots = 0, i; int nots = 0, i;
var instrs = method.Body.Instructions; var instrs = method.Body.Instructions;
index = -1;
for (i = 0; i < instrs.Count - 1; i++) { for (i = 0; i < instrs.Count - 1; i++) {
var ldloc = instrs[i]; var ldloc = instrs[i];
if (!ldloc.IsLdloc()) if (!ldloc.IsLdloc())
@ -190,11 +191,11 @@ namespace de4dot.code.deobfuscators.CryptoObfuscator {
var local = ldloc.GetLocal(method.Body.Variables); var local = ldloc.GetLocal(method.Body.Variables);
if (local == null || local.Type.GetElementType().GetPrimitiveSize() < 0) if (local == null || local.Type.GetElementType().GetPrimitiveSize() < 0)
continue; continue;
if (instrs[i + 1].OpCode.Code == Code.Not) {
if (instrs[i + 1].OpCode.Code == Code.Not)
nots++; nots++;
index = i + 1;
}
} }
index = i;
return (nots & 1) == 1; return (nots & 1) == 1;
} }