bool deobfuscate2(Block block, int i) { var instrs = block.Instructions; if (i >= instrs.Count - 2) return false; var ldsfld = instrs[i]; if (ldsfld.OpCode.Code != Code.Ldsfld) return false; var info = fieldToInfo.find(ldsfld.Operand as FieldReference); if (info == null) return false; var ldci4 = instrs[i + 1]; if (!ldci4.isLdcI4()) return false; var ldelem = instrs[i + 2]; if (ldelem.OpCode.Code != Code.Ldelem_U1) return false; block.remove(i, 3 - 1); instrs[i] = new Instr(DotNetUtils.createLdci4(info.array[ldci4.getLdcI4Value()])); return true; }
bool deobfuscate3(Block block, int i) { var instrs = block.Instructions; if (i + 1 >= instrs.Count) return false; int start = i; var ldsfld = instrs[i]; if (ldsfld.OpCode.Code != Code.Ldsfld) return false; var info = fieldToInfo.find(ldsfld.Operand as FieldReference); if (info == null) return false; if (!instrs[i + 1].isLdcI4()) return false; var constants = getConstantsReader(block); int value; i += 2; if (!constants.getInt32(ref i, out value)) return false; if (i >= instrs.Count) return false; var stelem = instrs[i]; if (stelem.OpCode.Code != Code.Stelem_I1) return false; block.remove(start, i - start + 1); return true; }
bool deobfuscate1(Block block, int i) { var instrs = block.Instructions; if (i >= instrs.Count - 2) return false; var ldloc = instrs[i]; if (!ldloc.isLdloc()) return false; var local = DotNetUtils.getLocalVar(blocks.Locals, ldloc.Instruction); if (local == null) return false; FieldInfo info; if (!localToInfo.TryGetValue(local, out info)) return false; var ldci4 = instrs[i + 1]; if (!ldci4.isLdcI4()) return false; var ldelem = instrs[i + 2]; if (ldelem.OpCode.Code != Code.Ldelem_U1) return false; block.remove(i, 3 - 1); instrs[i] = new Instr(DotNetUtils.createLdci4(info.array[ldci4.getLdcI4Value()])); return true; }