diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2021-04-20 17:04:24 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2021-04-20 17:06:22 +0200 |
commit | abc7a2f0b862f192c562d62053fc210b778cedb1 (patch) | |
tree | 352840c79f95b1c2dd01a5017222614975cc33e8 /ddk-template-cplusplus.cpp | |
parent | 3d51ea5b54a55c5417236ed00212d1e3d5134dd2 (diff) |
Added MT support for ring0 drivers.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'ddk-template-cplusplus.cpp')
-rw-r--r-- | ddk-template-cplusplus.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/ddk-template-cplusplus.cpp b/ddk-template-cplusplus.cpp index aafe492..b540a22 100644 --- a/ddk-template-cplusplus.cpp +++ b/ddk-template-cplusplus.cpp @@ -14,17 +14,25 @@ public: } }; -static void threadRoutine(PVOID threadContext) +struct threadContext +{ + DriverThread::Semaphore sem; + DriverThread::Thread dth; +}; + +static NTSTATUS threadRoutine(PVOID threadContext) { DbgPrint("ThreadRoutine %p, ThreadContext: %p\n", threadRoutine, threadContext); for (size_t i = 3; i > 0; --i) { DbgPrint("ThreadLoop: %zu\n", i); } - DbgPrint("Fin.\n"); - DriverThread::Semaphore * const sem = (DriverThread::Semaphore *)threadContext; - sem->Release(); - TERMINATE_MYSELF(STATUS_SUCCESS); + struct threadContext * const ctx = (struct threadContext *)threadContext; + DbgPrint("Fin. ThreadId: %p\n", ctx->dth.GetThreadId()); + ctx->sem.Release(); + DbgPrint("Thread WaitForTermination: 0x%X\n", ctx->dth.WaitForTermination()); // must return STATUS_UNSUCCESSFUL; + + return STATUS_SUCCESS; } static void test_cplusplus(void) @@ -32,12 +40,13 @@ static void test_cplusplus(void) TestSmth t; t.doSmth(); - DriverThread::Semaphore sem; - DriverThread::Thread dt; - dt.Start(threadRoutine, (PVOID)&sem); - sem.Wait(); - DbgPrint("Thread signaled semaphore.\n"); - dt.WaitForTermination(); + struct threadContext ctx; + ctx.dth.Start(threadRoutine, (PVOID)&ctx); + ctx.sem.Wait(); + DbgPrint("MainThread semaphore signaled.\n"); + ctx.dth.WaitForTermination(); + ctx.dth.WaitForTermination(); + DbgPrint("MainThread EOF\n"); } extern "C" |