From 51521cb642358770e94b8f9b4f40dd3b4c827cad Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Fri, 9 Sep 2022 17:50:28 +0200 Subject: Repository clean up, renamed ddk-template* to dpp-example*. * Improved/Added root and examples Makefile * Adapted CIs Signed-off-by: Toni Uhlig --- ddk-template-cplusplus.cpp | 126 --------------------------------------------- 1 file changed, 126 deletions(-) delete mode 100644 ddk-template-cplusplus.cpp (limited to 'ddk-template-cplusplus.cpp') 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 - -#include - -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!"); - } -} -- cgit v1.2.3