diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2022-09-09 17:50:28 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2022-09-09 18:24:21 +0200 |
commit | 51521cb642358770e94b8f9b4f40dd3b4c827cad (patch) | |
tree | 4795b8bffcdf2b628d9c9be15a4ebb1150f9f760 /ddk-template-cplusplus.cpp | |
parent | 3be8cccbdbb548a4538d23470aa20e65b33e7815 (diff) |
Repository clean up, renamed ddk-template* to dpp-example*.
* Improved/Added root and examples Makefile
* Adapted CIs
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'ddk-template-cplusplus.cpp')
-rw-r--r-- | ddk-template-cplusplus.cpp | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/ddk-template-cplusplus.cpp b/ddk-template-cplusplus.cpp deleted file mode 100644 index c1d9b29..0000000 --- a/ddk-template-cplusplus.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include <ntddk.h> - -#include <DriverThread.hpp> - -class TestSmth -{ -public: - TestSmth() - { - DbgPrint("%s\n", "ctor"); - } - ~TestSmth() - { - DbgPrint("%s\n", "dtor"); - } - void doSmth(void) - { - DbgPrint("%s\n", "Hello Class!"); - } -}; -static TestSmth * cdtor_test; - -class Derived : public TestSmth -{ -public: - Derived() - { - } - ~Derived() - { - } - void doSmth(void) - { - DbgPrint("%s\n", "Hello Derived!"); - } -}; - -class DerivedWithCDtor : public Derived -{ -public: - explicit DerivedWithCDtor(unsigned int value) - { - some_value = value; - DbgPrint("%s\n", "DerivedWithCDtor-Ctor."); - } - ~DerivedWithCDtor() - { - DbgPrint("%s\n", "DerivedWithCDtor-Dtor."); - } - void doSmth(void) - { - DbgPrint("SomeValue: %X\n", some_value); - } - -private: - unsigned int some_value = 0; -}; - -static DerivedWithCDtor some_static(0xDEADC0DE); - -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); - } - 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) -{ - TestSmth t; - t.doSmth(); - Derived d; - d.doSmth(); - - 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"); - - some_static.doSmth(); -} - -extern "C" -{ - - DRIVER_INITIALIZE DriverEntry; - DRIVER_UNLOAD DriverUnload; - - NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) - { - (void)DriverObject; - (void)RegistryPath; - - DbgPrint("%s\n", "Hello ring0!"); - cdtor_test = new TestSmth(); - - test_cplusplus(); - - return STATUS_SUCCESS; - } - - VOID DriverUnload(PDRIVER_OBJECT DriverObject) - { - (void)DriverObject; - - delete cdtor_test; - DbgPrint("%s\n", "Bye ring0!"); - } -} |