From 7962de961c36bf8ee4affe95d4ec130498e5fd8d Mon Sep 17 00:00:00 2001 From: de4dot Date: Sun, 22 Jan 2012 11:15:14 +0100 Subject: [PATCH] Add getModuleTypeCctor() method --- blocks/DotNetUtils.cs | 4 ++++ de4dot.code/deobfuscators/CryptoObfuscator/AntiDebugger.cs | 2 +- de4dot.code/deobfuscators/CryptoObfuscator/TamperDetection.cs | 2 +- de4dot.code/deobfuscators/SmartAssembly/MemoryManagerInfo.cs | 2 +- de4dot.code/deobfuscators/SmartAssembly/ResolverInfoBase.cs | 2 +- de4dot.code/deobfuscators/dotNET_Reactor/v3/NativeLibSaver.cs | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/blocks/DotNetUtils.cs b/blocks/DotNetUtils.cs index 4cdfcc01..f562fee1 100644 --- a/blocks/DotNetUtils.cs +++ b/blocks/DotNetUtils.cs @@ -294,6 +294,10 @@ namespace de4dot.blocks { return module.Types[0]; } + public static MethodDefinition getModuleTypeCctor(ModuleDefinition module) { + return getMethod(getModuleType(module), ".cctor"); + } + public static bool isEmpty(MethodDefinition method) { if (method.Body == null) return false; diff --git a/de4dot.code/deobfuscators/CryptoObfuscator/AntiDebugger.cs b/de4dot.code/deobfuscators/CryptoObfuscator/AntiDebugger.cs index 58cad126..91cb694a 100644 --- a/de4dot.code/deobfuscators/CryptoObfuscator/AntiDebugger.cs +++ b/de4dot.code/deobfuscators/CryptoObfuscator/AntiDebugger.cs @@ -45,7 +45,7 @@ namespace de4dot.code.deobfuscators.CryptoObfuscator { public void find() { if (find(module.EntryPoint)) return; - if (find(DotNetUtils.getMethod(DotNetUtils.getModuleType(module), ".cctor"))) + if (find(DotNetUtils.getModuleTypeCctor(module))) return; } diff --git a/de4dot.code/deobfuscators/CryptoObfuscator/TamperDetection.cs b/de4dot.code/deobfuscators/CryptoObfuscator/TamperDetection.cs index f20b5ea1..8d9202e7 100644 --- a/de4dot.code/deobfuscators/CryptoObfuscator/TamperDetection.cs +++ b/de4dot.code/deobfuscators/CryptoObfuscator/TamperDetection.cs @@ -45,7 +45,7 @@ namespace de4dot.code.deobfuscators.CryptoObfuscator { public void find() { if (find(module.EntryPoint)) return; - if (find(DotNetUtils.getMethod(DotNetUtils.getModuleType(module), ".cctor"))) + if (find(DotNetUtils.getModuleTypeCctor(module))) return; } diff --git a/de4dot.code/deobfuscators/SmartAssembly/MemoryManagerInfo.cs b/de4dot.code/deobfuscators/SmartAssembly/MemoryManagerInfo.cs index 91ca79c9..6b292ea9 100644 --- a/de4dot.code/deobfuscators/SmartAssembly/MemoryManagerInfo.cs +++ b/de4dot.code/deobfuscators/SmartAssembly/MemoryManagerInfo.cs @@ -43,7 +43,7 @@ namespace de4dot.code.deobfuscators.SmartAssembly { } public bool find() { - if (checkCalledMethods(DotNetUtils.getMethod(DotNetUtils.getModuleType(module), ".cctor"))) + if (checkCalledMethods(DotNetUtils.getModuleTypeCctor(module))) return true; if (checkCalledMethods(module.EntryPoint)) return true; diff --git a/de4dot.code/deobfuscators/SmartAssembly/ResolverInfoBase.cs b/de4dot.code/deobfuscators/SmartAssembly/ResolverInfoBase.cs index 92827cba..902b3215 100644 --- a/de4dot.code/deobfuscators/SmartAssembly/ResolverInfoBase.cs +++ b/de4dot.code/deobfuscators/SmartAssembly/ResolverInfoBase.cs @@ -58,7 +58,7 @@ namespace de4dot.code.deobfuscators.SmartAssembly { if (resolverType != null) return true; - if (findTypes(DotNetUtils.getMethod(DotNetUtils.getModuleType(module), ".cctor"))) + if (findTypes(DotNetUtils.getModuleTypeCctor(module))) return true; if (findTypes(module.EntryPoint)) return true; diff --git a/de4dot.code/deobfuscators/dotNET_Reactor/v3/NativeLibSaver.cs b/de4dot.code/deobfuscators/dotNET_Reactor/v3/NativeLibSaver.cs index f604e09c..dcbe87f2 100644 --- a/de4dot.code/deobfuscators/dotNET_Reactor/v3/NativeLibSaver.cs +++ b/de4dot.code/deobfuscators/dotNET_Reactor/v3/NativeLibSaver.cs @@ -65,7 +65,7 @@ namespace de4dot.code.deobfuscators.dotNET_Reactor.v3 { } public void find() { - foreach (var info in DotNetUtils.getCalledMethods(module, DotNetUtils.getMethod(DotNetUtils.getModuleType(module), ".cctor"))) { + foreach (var info in DotNetUtils.getCalledMethods(module, DotNetUtils.getModuleTypeCctor(module))) { if (!DotNetUtils.isMethod(info.Item2, "System.Void", "()")) continue; if (info.Item1.FullName != "{F1C5056B-0AFC-4423-9B83-D13A26B48869}")