aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2021-04-20 19:51:31 +0200
committerToni Uhlig <matzeton@googlemail.com>2021-04-20 19:52:39 +0200
commitf1f9af3057e4088d8bb7f23d16a42c080ff7d036 (patch)
tree75748d4a7e2c756b0f5c577c05c74d95cf8ae6d4
parent22c2101b7f4085a77299469740df666f98e70985 (diff)
Fixed possible deadlock.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--DriverThread.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/DriverThread.cpp b/DriverThread.cpp
index 93eda51..c048c04 100644
--- a/DriverThread.cpp
+++ b/DriverThread.cpp
@@ -19,7 +19,7 @@ extern "C" void InterceptorThreadRoutine(PVOID threadContext)
PsTerminateSystemThread(self->m_routine(self->m_threadContext));
}
-NTSTATUS DriverThread::Thread::Start(threadRoutine routine, PVOID threadContext)
+NTSTATUS DriverThread::Thread::Start(threadRoutine_t routine, PVOID threadContext)
{
HANDLE threadHandle;
NTSTATUS status;
@@ -40,8 +40,12 @@ NTSTATUS DriverThread::Thread::Start(threadRoutine routine, PVOID threadContext)
NTSTATUS DriverThread::Thread::WaitForTermination(LONGLONG timeout)
{
+ if (PsGetCurrentThreadId() == m_threadId)
+ {
+ return STATUS_UNSUCCESSFUL;
+ }
LockGuard lock(m_mutex);
- if (m_threadObject == nullptr || PsGetCurrentThreadId() == m_threadId)
+ if (m_threadObject == nullptr)
{
return STATUS_UNSUCCESSFUL;
}