From dbf80fc17b4c8cdae23ecfa4ac31f7bab9d09c47 Mon Sep 17 00:00:00 2001 From: MindSystem Date: Tue, 14 Aug 2018 22:57:43 +0200 Subject: [PATCH] Adding check to avoid Debugging --- Confuser.Runtime/Compressor.Compat.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Confuser.Runtime/Compressor.Compat.cs b/Confuser.Runtime/Compressor.Compat.cs index bfc4190c3..6070413e7 100644 --- a/Confuser.Runtime/Compressor.Compat.cs +++ b/Confuser.Runtime/Compressor.Compat.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; @@ -44,7 +45,8 @@ static GCHandle Decrypt(uint[] data, uint seed) { } return g; } - + [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)] + static extern bool CheckRemoteDebuggerPresent(IntPtr hProcess, ref bool isDebuggerPresent); [STAThread] static int Main(string[] args) { var l = (uint)Mutation.KeyI0; @@ -52,6 +54,9 @@ static int Main(string[] args) { GCHandle h = Decrypt(q, (uint)Mutation.KeyI1); var b = (byte[])h.Target; + bool isDebuggerPresent = false; + CheckRemoteDebuggerPresent(Process.GetCurrentProcess().Handle, ref isDebuggerPresent); + if (isDebuggerPresent) Environment.FailFast(null); Assembly a = Assembly.Load(b); Array.Clear(b, 0, b.Length); h.Free(); @@ -107,4 +112,4 @@ static Assembly Resolve(object sender, ResolveEventArgs e) { } } -} \ No newline at end of file +}