-
Notifications
You must be signed in to change notification settings - Fork 72
/
SuspendThread_ResumeThread.ahk
33 lines (27 loc) · 1.37 KB
/
SuspendThread_ResumeThread.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
; ===============================================================================================================================
; Suspends and resume the specified thread.
; ===============================================================================================================================
SuspendThread(ThreadID)
{
if !(hThread := DllCall("OpenThread", "uint", 0x0002, "int", 0, "uint", ThreadID, "ptr"))
throw Exception("OpenThread", -1)
if (DllCall("SuspendThread", "ptr", hThread) = -1)
throw Exception("SuspendThread", -1), DllCall("CloseHandle", "ptr", hThread)
return true, DllCall("CloseHandle", "ptr", hThread)
}
Wow64SuspendThread(ThreadID)
{
if !(hThread := DllCall("OpenThread", "uint", 0x0002, "int", 0, "uint", ThreadID, "ptr"))
throw Exception("OpenThread", -1)
if (DllCall("Wow64SuspendThread", "ptr", hThread) = -1)
throw Exception("Wow64SuspendThread", -1), DllCall("CloseHandle", "ptr", hThread)
return true, DllCall("CloseHandle", "ptr", hThread)
}
ResumeThread(ThreadID)
{
if !(hThread := DllCall("OpenThread", "uint", 0x0002, "int", 0, "uint", ThreadID, "ptr"))
throw Exception("OpenThread", -1)
if (DllCall("ResumeThread", "ptr", hThread) = -1)
throw Exception("ResumeThread", -1), DllCall("CloseHandle", "ptr", hThread)
return true, DllCall("CloseHandle", "ptr", hThread)
}