aboutsummaryrefslogtreecommitdiff
path: root/ddk-template-cplusplus.cpp
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2021-04-20 14:41:49 +0200
committerToni Uhlig <matzeton@googlemail.com>2021-04-20 14:41:49 +0200
commit3d51ea5b54a55c5417236ed00212d1e3d5134dd2 (patch)
tree6b1f14b42dc6bf4d6f06bfdc1b64d018acb77c77 /ddk-template-cplusplus.cpp
parentfb6917305fe5e09da02d887f7cfde916006e9c13 (diff)
Added kernel threading support.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'ddk-template-cplusplus.cpp')
-rw-r--r--ddk-template-cplusplus.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/ddk-template-cplusplus.cpp b/ddk-template-cplusplus.cpp
index f4e3ce4..aafe492 100644
--- a/ddk-template-cplusplus.cpp
+++ b/ddk-template-cplusplus.cpp
@@ -1,5 +1,7 @@
#include <ntddk.h>
+#include <DriverThread.hpp>
+
class TestSmth
{
public:
@@ -12,10 +14,30 @@ public:
}
};
+static void 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);
+}
+
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();
}
extern "C"