diff --git a/lib/winapi/processthreadsapi.h b/lib/winapi/processthreadsapi.h index 51b646cdd..c76b0d6fb 100644 --- a/lib/winapi/processthreadsapi.h +++ b/lib/winapi/processthreadsapi.h @@ -23,6 +23,8 @@ DWORD GetThreadId (HANDLE Thread); BOOL SwitchToThread (VOID); BOOL SetThreadPriority (HANDLE hThread, int nPriority); +DWORD SuspendThread (HANDLE hThread); +DWORD ResumeThread (HANDLE hThread); DWORD TlsAlloc (void); BOOL TlsFree (DWORD dwTlsIndex); diff --git a/lib/winapi/thread.c b/lib/winapi/thread.c index 378881444..9a10d519f 100644 --- a/lib/winapi/thread.c +++ b/lib/winapi/thread.c @@ -172,3 +172,31 @@ BOOL SetThreadPriority (HANDLE hThread, int nPriority) ObfDereferenceObject(thread); return TRUE; } + +DWORD SuspendThread (HANDLE hThread) +{ + ULONG PreviousSuspendCount; + NTSTATUS status; + + status = NtSuspendThread(hThread, &PreviousSuspendCount); + if (!NT_SUCCESS(status)) { + SetLastError(RtlNtStatusToDosError(status)); + return -1; + } + + return PreviousSuspendCount; +} + +DWORD ResumeThread (HANDLE hThread) +{ + ULONG PreviousResumeCount; + NTSTATUS status; + + status = NtResumeThread(hThread, &PreviousResumeCount); + if (!NT_SUCCESS(status)) { + SetLastError(RtlNtStatusToDosError(status)); + return -1; + } + + return PreviousResumeCount; +}