From 6c602fd542b7f97e3a23ef27c3839656906c98de Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Wed, 28 Jul 2021 16:53:41 +0200 Subject: Fixed ctor/dtor issue allowing use of static qualifiers for non primitives. * split CRT in a C and C++ part * use "fake" entry point to init CRT and set a DriverUnload routine for de-init * added -Wl,--exclude-all-symbols to DRIVER_LDFLAGS Signed-off-by: Toni Uhlig --- ddk-template-cplusplus.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'ddk-template-cplusplus.cpp') diff --git a/ddk-template-cplusplus.cpp b/ddk-template-cplusplus.cpp index 380603a..f9167ec 100644 --- a/ddk-template-cplusplus.cpp +++ b/ddk-template-cplusplus.cpp @@ -35,6 +35,29 @@ public: } }; +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; @@ -70,6 +93,8 @@ static void test_cplusplus(void) ctx.dth.WaitForTermination(); ctx.dth.WaitForTermination(); DbgPrint("MainThread EOF\n"); + + some_static.doSmth(); } extern "C" @@ -86,9 +111,6 @@ extern "C" DbgPrint("%s\n", "Hello ring0!"); cdtor_test = new TestSmth(); - /* support for service stopping */ - DriverObject->DriverUnload = DriverUnload; - test_cplusplus(); return STATUS_SUCCESS; -- cgit v1.2.3