Last active
December 8, 2017 00:12
-
-
Save Cyberboss/0c94ee177d624fbfb019ecc798100be2 to your computer and use it in GitHub Desktop.
Resume all thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
namespace ResumeAllThreads | |
{ | |
static class Program | |
{ | |
enum ThreadAccess : int | |
{ | |
SUSPEND_RESUME = (0x0002), | |
} | |
[DllImport("kernel32.dll")] | |
static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId); | |
[DllImport("kernel32.dll")] | |
static extern bool CloseHandle(IntPtr hObject); | |
[DllImport("kernel32.dll")] | |
static extern int ResumeThread(IntPtr hThread); | |
static void Main() | |
{ | |
Console.WriteLine("Enter process ID to resume: "); | |
var pidtext = Console.ReadLine(); | |
int pid; | |
try | |
{ | |
pid = Convert.ToInt32(pidtext); | |
} | |
catch | |
{ | |
Console.WriteLine("Invalid PID!"); | |
return; | |
} | |
var proc = Process.GetProcessById(pid); | |
foreach (ProcessThread thread in proc.Threads) | |
{ | |
var pOpenThread = OpenThread(ThreadAccess.SUSPEND_RESUME, false, (uint)thread.Id); | |
if (pOpenThread == IntPtr.Zero) | |
continue; | |
ResumeThread(pOpenThread); | |
CloseHandle(pOpenThread); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment