Index: trunk/src/VBox/Runtime/testcase/Makefile.kmk
===================================================================
--- trunk/src/VBox/Runtime/testcase/Makefile.kmk	(revision 51878)
+++ trunk/src/VBox/Runtime/testcase/Makefile.kmk	(revision 51906)
@@ -171,9 +171,23 @@
  	tstLdr-4 \
  	tstNoCrt-1 \
-	tstRTR0MemUserKernelDriver \
-	tstRTR0SemMutexDriver \
-	tstRTR0TimerDriver \
-	tstR0ThreadPreemptionDriver \
 	tstTSC
+ if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+  PROGRAMS += \
+  	tstRTR0MemUserKernelDriverHardened \
+  	tstRTR0SemMutexDriverHardened \
+  	tstRTR0TimerDriverHardened \
+  	tstR0ThreadPreemptionDriverHardened
+  DLLS     += \
+    	tstRTR0MemUserKernelDriver \
+  	tstRTR0SemMutexDriver \
+  	tstRTR0TimerDriver \
+  	tstR0ThreadPreemptionDriver
+ else
+  PROGRAMS += \
+    	tstRTR0MemUserKernelDriver \
+  	tstRTR0SemMutexDriver \
+  	tstRTR0TimerDriver \
+  	tstR0ThreadPreemptionDriver
+ endif
  SYSMODS += \
  	tstLdrObjR0 \
@@ -644,4 +658,13 @@
  tstRTR0DbgKrnlInfo_LIBS += $(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
 endif
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstRTR0DbgKrnlInfoDriverHardened_TEMPLATE = VBoxR3HardenedTstExe
+ tstRTR0DbgKrnlInfoDriverHardened_NAME = tstRTR0DbgKrnlInfoDriver
+ tstRTR0DbgKrnlInfoDriverHardened_DEFS = PROGRAM_NAME_STR=\"tstRTR0DbgKrnlInfoDriver\"
+ tstRTR0DbgKrnlInfoDriverHardened_SOURCES = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstRTR0DbgKrnlInfoDriver_TEMPLATE = VBoxR3TstDll
+else
+ tstRTR0DbgKrnlInfoDriver_TEMPLATE = VBOXR3TSTEXE
+endif
 tstRTR0DbgKrnlInfoDriver_TEMPLATE = VBOXR3TSTEXE
 tstRTR0DbgKrnlInfoDriver_SOURCES = tstRTR0DbgKrnlInfoDriver.cpp
@@ -657,5 +680,13 @@
  tstRTR0MemUserKernel_LIBS += $(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
 endif
-tstRTR0MemUserKernelDriver_TEMPLATE = VBOXR3TSTEXE
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstRTR0MemUserKernelDriverHardened_TEMPLATE = VBoxR3HardenedTstExe
+ tstRTR0MemUserKernelDriverHardened_NAME = tstRTR0MemUserKernelDriver
+ tstRTR0MemUserKernelDriverHardened_DEFS = PROGRAM_NAME_STR=\"tstRTR0MemUserKernelDriver\"
+ tstRTR0MemUserKernelDriverHardened_SOURCES = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstRTR0MemUserKernelDriver_TEMPLATE = VBoxR3TstDll
+else
+ tstRTR0MemUserKernelDriver_TEMPLATE = VBOXR3TSTEXE
+endif
 tstRTR0MemUserKernelDriver_SOURCES = tstRTR0MemUserKernelDriver.cpp
 
@@ -670,5 +701,13 @@
  tstRTR0SemMutex_LIBS += $(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
 endif
-tstRTR0SemMutexDriver_TEMPLATE = VBOXR3TSTEXE
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstRTR0SemMutexDriverHardened_TEMPLATE = VBoxR3HardenedTstExe
+ tstRTR0SemMutexDriverHardened_NAME = tstRTR0SemMutexDriver
+ tstRTR0SemMutexDriverHardened_DEFS = PROGRAM_NAME_STR=\"tstRTR0SemMutexDriver\"
+ tstRTR0SemMutexDriverHardened_SOURCES = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstRTR0SemMutexDriver_TEMPLATE = VBoxR3TstDll
+else
+ tstRTR0SemMutexDriver_TEMPLATE = VBOXR3TSTEXE
+endif
 tstRTR0SemMutexDriver_SOURCES = tstRTR0SemMutexDriver.cpp
 
@@ -683,5 +722,13 @@
  tstRTR0Timer_LIBS += $(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
 endif
-tstRTR0TimerDriver_TEMPLATE = VBOXR3TSTEXE
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstRTR0TimerDriverHardened_TEMPLATE = VBoxR3HardenedTstExe
+ tstRTR0TimerDriverHardened_NAME = tstRTR0TimerDriver
+ tstRTR0TimerDriverHardened_DEFS = PROGRAM_NAME_STR=\"tstRTR0TimerDriver\"
+ tstRTR0TimerDriverHardened_SOURCES = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstRTR0TimerDriver_TEMPLATE = VBoxR3TstDll
+else
+ tstRTR0TimerDriver_TEMPLATE = VBOXR3TSTEXE
+endif
 tstRTR0TimerDriver_SOURCES = tstRTR0TimerDriver.cpp
 
@@ -696,5 +743,13 @@
  tstR0ThreadPreemption_LIBS += $(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
 endif
-tstR0ThreadPreemptionDriver_TEMPLATE = VBOXR3TSTEXE
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstR0ThreadPreemptionDriverHardened_TEMPLATE = VBoxR3HardenedTstExe
+ tstR0ThreadPreemptionDriverHardened_NAME = tstR0ThreadPreemptionDriver
+ tstR0ThreadPreemptionDriverHardened_DEFS = PROGRAM_NAME_STR=\"tstR0ThreadPreemptionDriver\"
+ tstR0ThreadPreemptionDriverHardened_SOURCES = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstR0ThreadPreemptionDriver_TEMPLATE = VBoxR3TstDll
+else
+ tstR0ThreadPreemptionDriver_TEMPLATE = VBOXR3TSTEXE
+endif
 tstR0ThreadPreemptionDriver_SOURCES = tstR0ThreadPreemptionDriver.cpp
 
Index: trunk/src/VBox/Runtime/testcase/tstR0ThreadPreemptionDriver.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstR0ThreadPreemptionDriver.cpp	(revision 51878)
+++ trunk/src/VBox/Runtime/testcase/tstR0ThreadPreemptionDriver.cpp	(revision 51906)
@@ -75,5 +75,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
 #ifndef VBOX
@@ -286,2 +289,13 @@
 }
 
+
+#if !defined(VBOX_WITH_HARDENING) || !defined(RT_OS_WINDOWS)
+/**
+ * Main entry point.
+ */
+int main(int argc, char **argv, char **envp)
+{
+    return TrustedMain(argc, argv, envp);
+}
+#endif
+
Index: trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfoDriver.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfoDriver.cpp	(revision 51878)
+++ trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfoDriver.cpp	(revision 51906)
@@ -42,5 +42,8 @@
 
 
-int main (int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
 #ifndef VBOX
@@ -151,2 +154,13 @@
 }
 
+
+#if !defined(VBOX_WITH_HARDENING) || !defined(RT_OS_WINDOWS)
+/**
+ * Main entry point.
+ */
+int main(int argc, char **argv, char **envp)
+{
+    return TrustedMain(argc, argv, envp);
+}
+#endif
+
Index: trunk/src/VBox/Runtime/testcase/tstRTR0MemUserKernelDriver.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTR0MemUserKernelDriver.cpp	(revision 51878)
+++ trunk/src/VBox/Runtime/testcase/tstRTR0MemUserKernelDriver.cpp	(revision 51906)
@@ -43,5 +43,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ * Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
 #ifndef VBOX
@@ -209,2 +212,13 @@
 }
 
+
+#if !defined(VBOX_WITH_HARDENING) || !defined(RT_OS_WINDOWS)
+/**
+ * Main entry point.
+ */
+int main(int argc, char **argv, char **envp)
+{
+    return TrustedMain(argc, argv, envp);
+}
+#endif
+
Index: trunk/src/VBox/Runtime/testcase/tstRTR0SemMutexDriver.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTR0SemMutexDriver.cpp	(revision 51878)
+++ trunk/src/VBox/Runtime/testcase/tstRTR0SemMutexDriver.cpp	(revision 51906)
@@ -169,5 +169,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
 #ifndef VBOX
@@ -289,2 +292,13 @@
 }
 
+
+#if !defined(VBOX_WITH_HARDENING) || !defined(RT_OS_WINDOWS)
+/**
+ * Main entry point.
+ */
+int main(int argc, char **argv, char **envp)
+{
+    return TrustedMain(argc, argv, envp);
+}
+#endif
+
Index: trunk/src/VBox/Runtime/testcase/tstRTR0TimerDriver.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTR0TimerDriver.cpp	(revision 51878)
+++ trunk/src/VBox/Runtime/testcase/tstRTR0TimerDriver.cpp	(revision 51906)
@@ -44,5 +44,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
 #ifndef VBOX
@@ -118,2 +121,13 @@
 }
 
+
+#if !defined(VBOX_WITH_HARDENING) || !defined(RT_OS_WINDOWS)
+/**
+ * Main entry point.
+ */
+int main(int argc, char **argv, char **envp)
+{
+    return TrustedMain(argc, argv, envp);
+}
+#endif
+
