From ac171e3f29af8a740d0969778dc3a75797de0f01 Mon Sep 17 00:00:00 2001 From: de4dot Date: Tue, 6 Nov 2012 15:58:55 +0100 Subject: [PATCH] Fix code since CilBody/HasCilBody were renamed --- AssemblyData/methodsrewriter/CodeGenerator.cs | 2 +- AssemblyData/methodsrewriter/MMethod.cs | 2 +- blocks/Blocks.cs | 2 +- blocks/DotNetUtils.cs | 32 ++++++++--------- blocks/cflow/CachedCflowDeobfuscator.cs | 2 +- blocks/cflow/CflowDeobfuscator.cs | 2 +- blocks/cflow/InstructionEmulator.cs | 2 +- blocks/cflow/MethodCallInliner.cs | 2 +- blocks/cflow/MethodCallInlinerBase.cs | 4 +-- de4dot.code/MethodReturnValueInliner.cs | 4 +-- de4dot.code/ObfuscatedFile.cs | 10 +++--- de4dot.code/deobfuscators/ArrayFinder.cs | 6 ++-- de4dot.code/deobfuscators/ConstantsReader.cs | 4 +-- de4dot.code/deobfuscators/DeobUtils.cs | 8 ++--- de4dot.code/deobfuscators/DeobfuscatorBase.cs | 18 +++++----- .../deobfuscators/InlinedMethodsFinder.cs | 6 ++-- de4dot.code/deobfuscators/MethodStack.cs | 2 +- .../deobfuscators/ProxyCallFixerBase.cs | 8 ++--- de4dot.code/deobfuscators/StringCounts.cs | 4 +-- de4dot.code/deobfuscators/TypesRestorer.cs | 10 +++--- .../deobfuscators/UnusedMethodsFinder.cs | 4 +-- .../deobfuscators/Xenocode/StringDecrypter.cs | 4 +-- de4dot.code/renamer/ResourceKeysRenamer.cs | 8 ++--- de4dot.code/renamer/ResourceRenamer.cs | 4 +-- de4dot.code/renamer/TypeInfo.cs | 36 +++++++++---------- dot10 | 2 +- 26 files changed, 94 insertions(+), 94 deletions(-) diff --git a/AssemblyData/methodsrewriter/CodeGenerator.cs b/AssemblyData/methodsrewriter/CodeGenerator.cs index ad3c5000..2d3dcdeb 100644 --- a/AssemblyData/methodsrewriter/CodeGenerator.cs +++ b/AssemblyData/methodsrewriter/CodeGenerator.cs @@ -178,7 +178,7 @@ namespace AssemblyData.methodsrewriter { void initLocals() { locals = new List(); - foreach (var local in methodInfo.methodDef.CilBody.LocalList) + foreach (var local in methodInfo.methodDef.Body.LocalList) locals.Add(ilg.DeclareLocal(Resolver.getRtType(local.Type), local.Type.IsPinned)); tempObjLocal = ilg.DeclareLocal(typeof(object)); tempObjArrayLocal = ilg.DeclareLocal(typeof(object[])); diff --git a/AssemblyData/methodsrewriter/MMethod.cs b/AssemblyData/methodsrewriter/MMethod.cs index 0efccbf8..dfd3be0e 100644 --- a/AssemblyData/methodsrewriter/MMethod.cs +++ b/AssemblyData/methodsrewriter/MMethod.cs @@ -30,7 +30,7 @@ namespace AssemblyData.methodsrewriter { } public bool hasInstructions() { - return methodDef.CilBody != null && methodDef.CilBody.Instructions.Count != 0; + return methodDef.Body != null && methodDef.Body.Instructions.Count != 0; } public override string ToString() { diff --git a/blocks/Blocks.cs b/blocks/Blocks.cs index 25800f79..d7fc893a 100644 --- a/blocks/Blocks.cs +++ b/blocks/Blocks.cs @@ -46,7 +46,7 @@ namespace de4dot.blocks { } public void updateBlocks() { - var body = method.CilBody; + var body = method.Body; locals = body.LocalList; methodBlocks = new InstructionListParser(body.Instructions, body.ExceptionHandlers).parse(); } diff --git a/blocks/DotNetUtils.cs b/blocks/DotNetUtils.cs index 65d9333d..7bc86720 100644 --- a/blocks/DotNetUtils.cs +++ b/blocks/DotNetUtils.cs @@ -160,9 +160,9 @@ namespace de4dot.blocks { } public static bool isEmpty(MethodDef method) { - if (method.CilBody == null) + if (method.Body == null) return false; - foreach (var instr in method.CilBody.Instructions) { + foreach (var instr in method.Body.Instructions) { var code = instr.OpCode.Code; if (code != Code.Nop && code != Code.Ret) return false; @@ -171,10 +171,10 @@ namespace de4dot.blocks { } public static bool isEmptyObfuscated(MethodDef method) { - if (method.CilBody == null) + if (method.Body == null) return false; int index = 0; - var instr = getInstruction(method.CilBody.Instructions, ref index); + var instr = getInstruction(method.Body.Instructions, ref index); if (instr == null || instr.OpCode.Code != Code.Ret) return false; @@ -467,8 +467,8 @@ namespace de4dot.blocks { public static IList getCodeStrings(MethodDef method) { var strings = new List(); - if (method != null && method.CilBody != null) { - foreach (var instr in method.CilBody.Instructions) { + if (method != null && method.Body != null) { + foreach (var instr in method.Body.Instructions) { if (instr.OpCode.Code == Code.Ldstr) strings.Add((string)instr.Operand); } @@ -604,14 +604,14 @@ namespace de4dot.blocks { #endif public static void copyBody(MethodDef method, out IList instructions, out IList exceptionHandlers) { - if (method == null || !method.HasCilBody) { + if (method == null || !method.HasBody) { instructions = new List(); exceptionHandlers = new List(); return; } - var oldInstrs = method.CilBody.Instructions; - var oldExHandlers = method.CilBody.ExceptionHandlers; + var oldInstrs = method.Body.Instructions; + var oldExHandlers = method.Body.ExceptionHandlers; instructions = new List(oldInstrs.Count); exceptionHandlers = new List(oldExHandlers.Count); var oldToIndex = Utils.createObjectToIndexDictionary(oldInstrs); @@ -669,15 +669,15 @@ namespace de4dot.blocks { #endif public static void restoreBody(MethodDef method, IEnumerable instructions, IEnumerable exceptionHandlers) { - if (method == null || method.CilBody == null) + if (method == null || method.Body == null) return; - var bodyInstrs = method.CilBody.Instructions; + var bodyInstrs = method.Body.Instructions; bodyInstrs.Clear(); foreach (var instr in instructions) bodyInstrs.Add(instr); - var bodyExceptionHandlers = method.CilBody.ExceptionHandlers; + var bodyExceptionHandlers = method.Body.ExceptionHandlers; bodyExceptionHandlers.Clear(); foreach (var eh in exceptionHandlers) bodyExceptionHandlers.Add(eh); @@ -696,8 +696,8 @@ namespace de4dot.blocks { } static void copyLocalsFromTo(MethodDef fromMethod, MethodDef toMethod) { - var fromBody = fromMethod.CilBody; - var toBody = toMethod.CilBody; + var fromBody = fromMethod.Body; + var toBody = toMethod.Body; toBody.LocalList.Clear(); foreach (var local in fromBody.LocalList) @@ -705,8 +705,8 @@ namespace de4dot.blocks { } static void updateInstructionOperands(MethodDef fromMethod, MethodDef toMethod) { - var fromBody = fromMethod.CilBody; - var toBody = toMethod.CilBody; + var fromBody = fromMethod.Body; + var toBody = toMethod.Body; toBody.InitLocals = fromBody.InitLocals; toBody.MaxStack = fromBody.MaxStack; diff --git a/blocks/cflow/CachedCflowDeobfuscator.cs b/blocks/cflow/CachedCflowDeobfuscator.cs index f19b03b6..273951b6 100644 --- a/blocks/cflow/CachedCflowDeobfuscator.cs +++ b/blocks/cflow/CachedCflowDeobfuscator.cs @@ -48,7 +48,7 @@ namespace de4dot.blocks.cflow { if (deobfuscated.TryGetValue(method, out deobfuscatedMethod)) return deobfuscatedMethod; - if (method.CilBody == null || method.CilBody.Instructions.Count == 0) { + if (method.Body == null || method.Body.Instructions.Count == 0) { deobfuscated[method] = method; return method; } diff --git a/blocks/cflow/CflowDeobfuscator.cs b/blocks/cflow/CflowDeobfuscator.cs index 2ca7454c..9452094d 100644 --- a/blocks/cflow/CflowDeobfuscator.cs +++ b/blocks/cflow/CflowDeobfuscator.cs @@ -40,7 +40,7 @@ namespace de4dot.blocks.cflow { } static bool hasNonEmptyBody(MethodDef method) { - return method.CilBody != null && method.CilBody.Instructions.Count > 0; + return method.Body != null && method.Body.Instructions.Count > 0; } void deobfuscate(MethodDef method, Action handler) { diff --git a/blocks/cflow/InstructionEmulator.cs b/blocks/cflow/InstructionEmulator.cs index e2ed4bc6..e110f374 100644 --- a/blocks/cflow/InstructionEmulator.cs +++ b/blocks/cflow/InstructionEmulator.cs @@ -48,7 +48,7 @@ namespace de4dot.blocks.cflow { public void init(MethodDef method) { this.parameterDefs = method.Parameters; - this.localDefs = method.CilBody.LocalList; + this.localDefs = method.Body.LocalList; valueStack.init(); protectedStackValues.Clear(); diff --git a/blocks/cflow/MethodCallInliner.cs b/blocks/cflow/MethodCallInliner.cs index 3bb4d91e..e0b270fb 100644 --- a/blocks/cflow/MethodCallInliner.cs +++ b/blocks/cflow/MethodCallInliner.cs @@ -62,7 +62,7 @@ namespace de4dot.blocks.cflow { if (!canInline(methodToInline)) return false; - var body = methodToInline.CilBody; + var body = methodToInline.Body; if (body == null) return false; diff --git a/blocks/cflow/MethodCallInlinerBase.cs b/blocks/cflow/MethodCallInlinerBase.cs index 3905fed3..e647890b 100644 --- a/blocks/cflow/MethodCallInlinerBase.cs +++ b/blocks/cflow/MethodCallInlinerBase.cs @@ -131,7 +131,7 @@ namespace de4dot.blocks.cflow { if (instr.GetParameterIndex() != loadIndex) return null; loadIndex++; - instr = DotNetUtils.getInstruction(methodToInline.CilBody.Instructions, ref instrIndex); + instr = DotNetUtils.getInstruction(methodToInline.Body.Instructions, ref instrIndex); } if (instr == null || loadIndex != methodArgsCount - popLastArgs) return null; @@ -187,7 +187,7 @@ namespace de4dot.blocks.cflow { } protected virtual bool isReturn(MethodDef methodToInline, int instrIndex) { - var instr = DotNetUtils.getInstruction(methodToInline.CilBody.Instructions, ref instrIndex); + var instr = DotNetUtils.getInstruction(methodToInline.Body.Instructions, ref instrIndex); return instr != null && instr.OpCode.Code == Code.Ret; } diff --git a/de4dot.code/MethodReturnValueInliner.cs b/de4dot.code/MethodReturnValueInliner.cs index a13d7ca6..c8b41792 100644 --- a/de4dot.code/MethodReturnValueInliner.cs +++ b/de4dot.code/MethodReturnValueInliner.cs @@ -218,7 +218,7 @@ namespace de4dot.code { bool getLocalVariableValue(Local variable, out object value) { if (variableValues == null) - variableValues = new VariableValues(theMethod.CilBody.LocalList, allBlocks); + variableValues = new VariableValues(theMethod.Body.LocalList, allBlocks); var val = variableValues.getValue(variable); if (!val.isValid()) { value = null; @@ -342,7 +342,7 @@ namespace de4dot.code { case Code.Ldloc_1: case Code.Ldloc_2: case Code.Ldloc_3: - getLocalVariableValue(instr.Instruction.GetLocal(theMethod.CilBody.LocalList), out arg); + getLocalVariableValue(instr.Instruction.GetLocal(theMethod.Body.LocalList), out arg); break; case Code.Ldfld: diff --git a/de4dot.code/ObfuscatedFile.cs b/de4dot.code/ObfuscatedFile.cs index 9debb82b..cd2a4f95 100644 --- a/de4dot.code/ObfuscatedFile.cs +++ b/de4dot.code/ObfuscatedFile.cs @@ -549,7 +549,7 @@ namespace de4dot.code { catch (Exception ex) { if (!canLoadMethodBody(method)) { Log.v("Invalid method body. {0:X8}", method.MDToken.ToInt32()); - method.CilBody = new CilBody(); + method.Body = new CilBody(); } else { Log.w("Could not deobfuscate method {0:X8}. Hello, E.T.: {1}", // E.T. = exception type @@ -568,7 +568,7 @@ namespace de4dot.code { static bool canLoadMethodBody(MethodDef method) { try { - var body = method.CilBody; + var body = method.Body; return true; } catch { @@ -582,7 +582,7 @@ namespace de4dot.code { var blocks = new Blocks(method); int numRemovedLocals = 0; - int oldNumInstructions = method.CilBody.Instructions.Count; + int oldNumInstructions = method.Body.Instructions.Count; deob.deobfuscateMethodBegin(blocks); if (options.ControlFlowDeobfuscation) { @@ -611,7 +611,7 @@ namespace de4dot.code { if (numRemovedLocals > 0) Log.v("Removed {0} unused local(s)", numRemovedLocals); - int numRemovedInstructions = oldNumInstructions - method.CilBody.Instructions.Count; + int numRemovedInstructions = oldNumInstructions - method.Body.Instructions.Count; if (numRemovedInstructions > 0) Log.v("Removed {0} dead instruction(s)", numRemovedInstructions); @@ -625,7 +625,7 @@ namespace de4dot.code { } bool hasNonEmptyBody(MethodDef method) { - return method.HasCilBody && method.CilBody.Instructions.Count > 0; + return method.HasBody && method.Body.Instructions.Count > 0; } void deobfuscateStrings(Blocks blocks) { diff --git a/de4dot.code/deobfuscators/ArrayFinder.cs b/de4dot.code/deobfuscators/ArrayFinder.cs index 458afe8f..dc1c1ae4 100644 --- a/de4dot.code/deobfuscators/ArrayFinder.cs +++ b/de4dot.code/deobfuscators/ArrayFinder.cs @@ -31,7 +31,7 @@ namespace de4dot.code.deobfuscators { public static List getArrays(MethodDef method, IType arrayElementType) { var arrays = new List(); - var instrs = method.CilBody.Instructions; + var instrs = method.Body.Instructions; for (int i = 0; i < instrs.Count; i++) { IType type; var ary = getArray(instrs, ref i, out type); @@ -135,7 +135,7 @@ namespace de4dot.code.deobfuscators { var theArray = new UnknownValue(); emulator.push(theArray); - var instructions = method.CilBody.Instructions; + var instructions = method.Body.Instructions; int i; for (i = newarrIndex + 1; i < instructions.Count; i++) { var instr = instructions[i]; @@ -194,7 +194,7 @@ done: } public static bool findNewarr(MethodDef method, ref int i, out int size) { - var instructions = method.CilBody.Instructions; + var instructions = method.Body.Instructions; for (; i < instructions.Count; i++) { var instr = instructions[i]; if (instr.OpCode.Code != Code.Newarr || i < 1) diff --git a/de4dot.code/deobfuscators/ConstantsReader.cs b/de4dot.code/deobfuscators/ConstantsReader.cs index 5ffe6e9f..85ab4c45 100644 --- a/de4dot.code/deobfuscators/ConstantsReader.cs +++ b/de4dot.code/deobfuscators/ConstantsReader.cs @@ -99,8 +99,8 @@ namespace de4dot.code.deobfuscators { } public ConstantsReader(MethodDef method) - : this(method.CilBody.Instructions) { - this.locals = method.CilBody.LocalList; + : this(method.Body.Instructions) { + this.locals = method.Body.LocalList; } public ConstantsReader(IList instrs, IList locals) diff --git a/de4dot.code/deobfuscators/DeobUtils.cs b/de4dot.code/deobfuscators/DeobUtils.cs index ee54420b..5df4037a 100644 --- a/de4dot.code/deobfuscators/DeobUtils.cs +++ b/de4dot.code/deobfuscators/DeobUtils.cs @@ -210,9 +210,9 @@ namespace de4dot.code.deobfuscators { } public static int indexOfLdci4Instruction(MethodDef method, int value) { - if (method == null || method.CilBody == null) + if (method == null || method.Body == null) return -1; - var instrs = method.CilBody.Instructions; + var instrs = method.Body.Instructions; for (int i = 0; i < instrs.Count; i++) { var instr = instrs[i]; if (!instr.IsLdcI4()) @@ -249,9 +249,9 @@ namespace de4dot.code.deobfuscators { public static List getAllResolveHandlers(MethodDef method) { var list = new List(); - if (method == null || method.CilBody == null) + if (method == null || method.Body == null) return list; - foreach (var instr in method.CilBody.Instructions) { + foreach (var instr in method.Body.Instructions) { if (instr.OpCode.Code != Code.Ldftn && instr.OpCode.Code != Code.Ldvirtftn) continue; var handler = instr.Operand as MethodDef; diff --git a/de4dot.code/deobfuscators/DeobfuscatorBase.cs b/de4dot.code/deobfuscators/DeobfuscatorBase.cs index 53697525..2ae4a4b6 100644 --- a/de4dot.code/deobfuscators/DeobfuscatorBase.cs +++ b/de4dot.code/deobfuscators/DeobfuscatorBase.cs @@ -540,15 +540,15 @@ namespace de4dot.code.deobfuscators { foreach (var type in module.GetTypes()) { foreach (var method in type.Methods) { if (isFatHeader(method)) - method.CilBody.InitLocals = true; + method.Body.InitLocals = true; } } } static bool isFatHeader(MethodDef method) { - if (method == null || method.CilBody == null) + if (method == null || method.Body == null) return false; - var body = method.CilBody; + var body = method.Body; if (body.InitLocals || body.MaxStack > 8) return true; if (body.LocalList.Count > 0) @@ -562,10 +562,10 @@ namespace de4dot.code.deobfuscators { } static int getCodeSize(MethodDef method) { - if (method == null || method.CilBody == null) + if (method == null || method.Body == null) return 0; int size = 0; - foreach (var instr in method.CilBody.Instructions) + foreach (var instr in method.Body.Instructions) size += instr.GetSize(); return size; } @@ -575,10 +575,10 @@ namespace de4dot.code.deobfuscators { } protected void findPossibleNamesToRemove(MethodDef method) { - if (method == null || !method.HasCilBody) + if (method == null || !method.HasBody) return; - foreach (var instr in method.CilBody.Instructions) { + foreach (var instr in method.Body.Instructions) { if (instr.OpCode == OpCodes.Ldstr) namesToPossiblyRemove.Add((string)instr.Operand); } @@ -730,14 +730,14 @@ namespace de4dot.code.deobfuscators { foreach (var type in module.GetTypes()) { foreach (var method in type.Methods) { - if (method.CilBody == null) + if (method.Body == null) continue; if (decrypterMethods.exists(method)) break; // decrypter type / nested type method if (removedMethods.exists(method)) continue; - foreach (var instr in method.CilBody.Instructions) { + foreach (var instr in method.Body.Instructions) { switch (instr.OpCode.Code) { case Code.Call: case Code.Callvirt: diff --git a/de4dot.code/deobfuscators/InlinedMethodsFinder.cs b/de4dot.code/deobfuscators/InlinedMethodsFinder.cs index 1c732d9e..50d79c81 100644 --- a/de4dot.code/deobfuscators/InlinedMethodsFinder.cs +++ b/de4dot.code/deobfuscators/InlinedMethodsFinder.cs @@ -40,9 +40,9 @@ namespace de4dot.code.deobfuscators { continue; if (method.Name == ".cctor") continue; - if (method.CilBody == null) + if (method.Body == null) continue; - var instrs = method.CilBody.Instructions; + var instrs = method.Body.Instructions; if (instrs.Count < 2) continue; @@ -100,7 +100,7 @@ namespace de4dot.code.deobfuscators { static bool isCallMethod(MethodDef method) { int loadIndex = 0; int methodArgsCount = DotNetUtils.getArgsCount(method); - var instrs = method.CilBody.Instructions; + var instrs = method.Body.Instructions; int i = 0; for (; i < instrs.Count && i < methodArgsCount; i++) { var instr = instrs[i]; diff --git a/de4dot.code/deobfuscators/MethodStack.cs b/de4dot.code/deobfuscators/MethodStack.cs index 525b19f0..1e80262b 100644 --- a/de4dot.code/deobfuscators/MethodStack.cs +++ b/de4dot.code/deobfuscators/MethodStack.cs @@ -246,7 +246,7 @@ namespace de4dot.code.deobfuscators { case Code.Ldloc_1: case Code.Ldloc_2: case Code.Ldloc_3: - local = pushInstr.GetLocal(method.CilBody.LocalList); + local = pushInstr.GetLocal(method.Body.LocalList); if (local == null) return null; type = local.Type.RemovePinned(); diff --git a/de4dot.code/deobfuscators/ProxyCallFixerBase.cs b/de4dot.code/deobfuscators/ProxyCallFixerBase.cs index 34379e50..98c0fba6 100644 --- a/de4dot.code/deobfuscators/ProxyCallFixerBase.cs +++ b/de4dot.code/deobfuscators/ProxyCallFixerBase.cs @@ -210,7 +210,7 @@ namespace de4dot.code.deobfuscators { foreach (var tmp in getDelegateTypes()) { var type = tmp; var cctor = type.FindClassConstructor(); - if (cctor == null || !cctor.HasCilBody) + if (cctor == null || !cctor.HasBody) continue; if (!type.HasFields) continue; @@ -394,7 +394,7 @@ namespace de4dot.code.deobfuscators { protected void find2() { foreach (var type in getDelegateTypes()) { var cctor = type.FindClassConstructor(); - if (cctor == null || !cctor.HasCilBody) + if (cctor == null || !cctor.HasBody) continue; if (!type.HasFields) continue; @@ -441,10 +441,10 @@ namespace de4dot.code.deobfuscators { Dictionary getFieldToMethodDictionary(TypeDef type) { var dict = new Dictionary(); foreach (var method in type.Methods) { - if (!method.IsStatic || !method.HasCilBody || method.Name == ".cctor") + if (!method.IsStatic || !method.HasBody || method.Name == ".cctor") continue; - var instructions = method.CilBody.Instructions; + var instructions = method.Body.Instructions; for (int i = 0; i < instructions.Count; i++) { var instr = instructions[i]; if (instr.OpCode.Code != Code.Ldsfld) diff --git a/de4dot.code/deobfuscators/StringCounts.cs b/de4dot.code/deobfuscators/StringCounts.cs index 7e2e251e..d22b0121 100644 --- a/de4dot.code/deobfuscators/StringCounts.cs +++ b/de4dot.code/deobfuscators/StringCounts.cs @@ -87,8 +87,8 @@ namespace de4dot.code.deobfuscators { class LocalTypes : StringCounts { public LocalTypes(MethodDef method) { - if (method != null && method.CilBody != null) - init(method.CilBody.LocalList); + if (method != null && method.Body != null) + init(method.Body.LocalList); } public LocalTypes(IEnumerable locals) { diff --git a/de4dot.code/deobfuscators/TypesRestorer.cs b/de4dot.code/deobfuscators/TypesRestorer.cs index 311eb0e0..54404498 100644 --- a/de4dot.code/deobfuscators/TypesRestorer.cs +++ b/de4dot.code/deobfuscators/TypesRestorer.cs @@ -253,7 +253,7 @@ namespace de4dot.code.deobfuscators { } void deobfuscateMethod(MethodDef method) { - if (!method.IsStatic || method.CilBody == null) + if (!method.IsStatic || method.Body == null) return; bool fixReturnType = isUnknownType(method.MethodSig.GetRetType()); @@ -271,7 +271,7 @@ namespace de4dot.code.deobfuscators { var methodParams = method.Parameters; PushedArgs pushedArgs; - var instructions = method.CilBody.Instructions; + var instructions = method.Body.Instructions; for (int i = 0; i < instructions.Count; i++) { var instr = instructions[i]; switch (instr.OpCode.Code) { @@ -329,7 +329,7 @@ namespace de4dot.code.deobfuscators { pushedArgs = MethodStack.getPushedArgInstructions(instructions, i); if (pushedArgs.NumValidArgs < 1) break; - addMethodArgType(method, getParameter(methodParams, pushedArgs.getEnd(0)), instr.GetLocal(method.CilBody.LocalList)); + addMethodArgType(method, getParameter(methodParams, pushedArgs.getEnd(0)), instr.GetLocal(method.Body.LocalList)); break; case Code.Stsfld: @@ -474,9 +474,9 @@ namespace de4dot.code.deobfuscators { info.clear(); foreach (var method in allMethods) { - if (method.CilBody == null) + if (method.Body == null) continue; - var instructions = method.CilBody.Instructions; + var instructions = method.Body.Instructions; for (int i = 0; i < instructions.Count; i++) { var instr = instructions[i]; TypeSig fieldType = null; diff --git a/de4dot.code/deobfuscators/UnusedMethodsFinder.cs b/de4dot.code/deobfuscators/UnusedMethodsFinder.cs index 83cb535e..0cc92da6 100644 --- a/de4dot.code/deobfuscators/UnusedMethodsFinder.cs +++ b/de4dot.code/deobfuscators/UnusedMethodsFinder.cs @@ -58,14 +58,14 @@ namespace de4dot.code.deobfuscators { } void check(MethodDef method) { - if (method.CilBody == null) + if (method.Body == null) return; if (possiblyUnusedMethods.ContainsKey(method)) return; if (removedMethods.exists(method)) return; - foreach (var instr in method.CilBody.Instructions) { + foreach (var instr in method.Body.Instructions) { switch (instr.OpCode.Code) { case Code.Call: case Code.Calli: diff --git a/de4dot.code/deobfuscators/Xenocode/StringDecrypter.cs b/de4dot.code/deobfuscators/Xenocode/StringDecrypter.cs index a2a64a5a..4c7e4437 100644 --- a/de4dot.code/deobfuscators/Xenocode/StringDecrypter.cs +++ b/de4dot.code/deobfuscators/Xenocode/StringDecrypter.cs @@ -64,11 +64,11 @@ namespace de4dot.code.deobfuscators.Xenocode { method = null; break; } - if (method == null || method.CilBody == null) + if (method == null || method.Body == null) continue; bool foundConstant = false; - foreach (var instr in method.CilBody.Instructions) { + foreach (var instr in method.Body.Instructions) { if (instr.IsLdcI4() && instr.GetLdcI4Value() == STRING_DECRYPTER_KEY_CONST) { foundConstant = true; break; diff --git a/de4dot.code/renamer/ResourceKeysRenamer.cs b/de4dot.code/renamer/ResourceKeysRenamer.cs index 69526cf8..ff5854a2 100644 --- a/de4dot.code/renamer/ResourceKeysRenamer.cs +++ b/de4dot.code/renamer/ResourceKeysRenamer.cs @@ -81,9 +81,9 @@ namespace de4dot.code.renamer { static string getResourceName(TypeDef type) { foreach (var method in type.Methods) { - if (method.CilBody == null) + if (method.Body == null) continue; - var instrs = method.CilBody.Instructions; + var instrs = method.Body.Instructions; string resourceName = null; for (int i = 0; i < instrs.Count; i++) { var instr = instrs[i]; @@ -155,10 +155,10 @@ namespace de4dot.code.renamer { nameToInfo[info.element.Name] = info; foreach (var method in type.Methods) { - if (method.CilBody == null) + if (method.Body == null) continue; - var instrs = method.CilBody.Instructions; + var instrs = method.Body.Instructions; for (int i = 0; i < instrs.Count; i++) { var call = instrs[i]; if (call.OpCode.Code != Code.Call && call.OpCode.Code != Code.Callvirt) diff --git a/de4dot.code/renamer/ResourceRenamer.cs b/de4dot.code/renamer/ResourceRenamer.cs index ab2a509a..854c5edd 100644 --- a/de4dot.code/renamer/ResourceRenamer.cs +++ b/de4dot.code/renamer/ResourceRenamer.cs @@ -60,9 +60,9 @@ namespace de4dot.code.renamer { oldNameToTypeInfo[info.oldFullName] = info; foreach (var method in module.getAllMethods()) { - if (!method.HasCilBody) + if (!method.HasBody) continue; - var instrs = method.CilBody.Instructions; + var instrs = method.Body.Instructions; for (int i = 0; i < instrs.Count; i++) { var instr = instrs[i]; if (instr.OpCode != OpCodes.Ldstr) diff --git a/de4dot.code/renamer/TypeInfo.cs b/de4dot.code/renamer/TypeInfo.cs index 3a8e7dce..cbc97310 100644 --- a/de4dot.code/renamer/TypeInfo.cs +++ b/de4dot.code/renamer/TypeInfo.cs @@ -456,11 +456,11 @@ namespace de4dot.code.renamer { ourMethods.add(methodDef.MethodDef, methodDef); foreach (var methodDef in type.AllMethods) { - if (methodDef.MethodDef.CilBody == null) + if (methodDef.MethodDef.Body == null) continue; if (methodDef.MethodDef.IsStatic || methodDef.MethodDef.IsVirtual) continue; - var instructions = methodDef.MethodDef.CilBody.Instructions; + var instructions = methodDef.MethodDef.Body.Instructions; for (int i = 2; i < instructions.Count; i++) { var call = instructions[i]; if (call.OpCode.Code != Code.Call && call.OpCode.Code != Code.Callvirt) @@ -513,9 +513,9 @@ namespace de4dot.code.renamer { } static IField getFieldReference(MethodDef method) { - if (method == null || method.CilBody == null) + if (method == null || method.Body == null) return null; - var instructions = method.CilBody.Instructions; + var instructions = method.Body.Instructions; int index = 0; var ldarg0 = DotNetUtils.getInstruction(instructions, ref index); if (ldarg0 == null || ldarg0.GetParameterIndex() != 0) @@ -527,11 +527,11 @@ namespace de4dot.code.renamer { if (ret == null) return null; if (ret.IsStloc()) { - var local = ret.GetLocal(method.CilBody.LocalList); + var local = ret.GetLocal(method.Body.LocalList); ret = DotNetUtils.getInstruction(instructions, ref index); if (ret == null || !ret.IsLdloc()) return null; - if (ret.GetLocal(method.CilBody.LocalList) != local) + if (ret.GetLocal(method.Body.LocalList) != local) return null; ret = DotNetUtils.getInstruction(instructions, ref index); } @@ -580,7 +580,7 @@ namespace de4dot.code.renamer { static IMethod getVbHandler(MethodDef method, out string eventName) { eventName = null; - if (method.CilBody == null) + if (method.Body == null) return null; var sig = method.MethodSig; if (sig == null) @@ -589,12 +589,12 @@ namespace de4dot.code.renamer { return null; if (sig.Params.Count != 1) return null; - if (method.CilBody.LocalList.Count != 1) + if (method.Body.LocalList.Count != 1) return null; - if (!isEventHandlerType(method.CilBody.LocalList[0].Type)) + if (!isEventHandlerType(method.Body.LocalList[0].Type)) return null; - var instructions = method.CilBody.Instructions; + var instructions = method.Body.Instructions; int index = 0; int newobjIndex = findInstruction(instructions, index, Code.Newobj); @@ -676,11 +676,11 @@ namespace de4dot.code.renamer { var checker = NameChecker; foreach (var methodDef in type.AllMethods) { - if (methodDef.MethodDef.CilBody == null) + if (methodDef.MethodDef.Body == null) continue; if (methodDef.MethodDef.IsStatic) continue; - var instructions = methodDef.MethodDef.CilBody.Instructions; + var instructions = methodDef.MethodDef.Body.Instructions; for (int i = 0; i < instructions.Count - 6; i++) { // We're looking for this code pattern: // ldarg.0 @@ -755,12 +755,12 @@ namespace de4dot.code.renamer { var checker = NameChecker; foreach (var methodDef in type.AllMethods) { - if (methodDef.MethodDef.CilBody == null) + if (methodDef.MethodDef.Body == null) continue; if (methodDef.MethodDef.IsStatic) continue; var method = methodDef.MethodDef; - var instructions = method.CilBody.Instructions; + var instructions = method.Body.Instructions; for (int i = 0; i < instructions.Count - 5; i++) { // ldarg.0 // ldarg.0 / dup @@ -839,11 +839,11 @@ namespace de4dot.code.renamer { string findWindowsFormsClassName(MTypeDef type) { foreach (var methodDef in type.AllMethods) { - if (methodDef.MethodDef.CilBody == null) + if (methodDef.MethodDef.Body == null) continue; if (methodDef.MethodDef.IsStatic || methodDef.MethodDef.IsVirtual) continue; - var instructions = methodDef.MethodDef.CilBody.Instructions; + var instructions = methodDef.MethodDef.Body.Instructions; for (int i = 2; i < instructions.Count; i++) { var call = instructions[i]; if (call.OpCode.Code != Code.Call && call.OpCode.Code != Code.Callvirt) @@ -872,9 +872,9 @@ namespace de4dot.code.renamer { foreach (var methodDef in type.AllMethods) { if (methodDef.MethodDef.Name != ".ctor") continue; - if (methodDef.MethodDef.CilBody == null) + if (methodDef.MethodDef.Body == null) continue; - foreach (var instr in methodDef.MethodDef.CilBody.Instructions) { + foreach (var instr in methodDef.MethodDef.Body.Instructions) { if (instr.OpCode.Code != Code.Call && instr.OpCode.Code != Code.Callvirt) continue; if (!MethodEqualityComparer.CompareDeclaringTypes.Equals(possibleInitMethod.MethodDef, instr.Operand as IMethod)) diff --git a/dot10 b/dot10 index 8acaf8b4..12295508 160000 --- a/dot10 +++ b/dot10 @@ -1 +1 @@ -Subproject commit 8acaf8b483a7ddd6b31f618b205d7ac6c28593b2 +Subproject commit 12295508eddc4cc7c35cd10e23fbffcb87fb7afb