Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 51905)
+++ /trunk/Config.kmk	(revision 51906)
@@ -4019,4 +4019,12 @@
 
 #
+# Template for building hardened Ring-3 executables.
+# These shall have no extra runpaths, esp. not origin ones.
+#
+TEMPLATE_VBoxR3HardenedTstExe = VBox Ring-3 Hardened Testcase Exe (currently windows only!)
+TEMPLATE_VBoxR3HardenedTstExe_EXTENDS = VBOXR3HARDENEDEXE
+TEMPLATE_VBoxR3HardenedTstExe_INST = $(INST_TESTCASE)
+
+#
 # Template for building set-uid-to-root helper programs.
 # In hardened builds, these may only contain absolute runpaths!
@@ -4123,4 +4131,17 @@
  TEMPLATE_VBOXR3TSTNPEXE_CXXFLAGS         = $(filter-out -pedantic -Wshadow,$(TEMPLATE_VBOXR3TSTEXE_CXXFLAGS)) -Wno-sign-compare
  TEMPLATE_VBOXR3TSTNPEXE_CFLAGS           = $(filter-out -pedantic -Wshadow -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations,$(TEMPLATE_VBOXR3TSTEXE_CFLAGS)) -Wno-sign-compare
+endif
+
+
+#
+# Ring-3 testcase DLL.
+#
+TEMPLATE_VBoxR3TstDll = VBox Ring-3 Testcase Dll
+TEMPLATE_VBoxR3TstDll_EXTENDS = VBOXR3TSTEXE
+ifn1of ($(KBUILD_TARGET), darwin win os2)
+ TEMPLATE_VBoxR3TstDll_DEFS     = $(TEMPLATE_VBOXR3TSTEXE_DEFS) PIC
+ TEMPLATE_VBoxR3TstDll_CFLAGS   = $(TEMPLATE_VBOXR3TSTEXE_CFLAGS) -fPIC
+ TEMPLATE_VBoxR3TstDll_CXXFLAGS = $(TEMPLATE_VBOXR3TSTEXE_CXXFLAGS) -fPIC
+ TEMPLATE_VBoxR3TstDll_LDFLAGS  = $(TEMPLATE_VBOXR3TSTEXE_LDFLAGS) -fPIC
 endif
 
Index: /trunk/src/VBox/Devices/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Devices/Makefile.kmk	(revision 51905)
+++ /trunk/src/VBox/Devices/Makefile.kmk	(revision 51906)
@@ -1216,6 +1216,17 @@
  #
  ifdef VBOX_WITH_TESTCASES
-  PROGRAMS += tstIntNet-1
-  tstIntNet-1_TEMPLATE    = VBOXR3TSTEXE
+  if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+   PROGRAMS += tstIntNetHardened-1
+   tstIntNetHardened-1_TEMPLATE = VBoxR3HardenedTstExe
+   tstIntNetHardened-1_NAME     = tstIntNet-1
+   tstIntNetHardened-1_DEFS     = PROGRAM_NAME_STR=\"tstIntNet-1\"
+   tstIntNetHardened-1_SOURCES  = ../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+
+   DLLS += tstIntNet-1
+   tstIntNet-1_TEMPLATE   = VBoxR3TstDll
+  else
+   PROGRAMS += tstIntNet-1
+   tstIntNet-1_TEMPLATE   = VBOXR3TSTEXE
+  endif
   tstIntNet-1_SOURCES     = \
  	Network/testcase/tstIntNet-1.cpp \
Index: /trunk/src/VBox/Devices/Network/testcase/tstIntNet-1.cpp
===================================================================
--- /trunk/src/VBox/Devices/Network/testcase/tstIntNet-1.cpp	(revision 51905)
+++ /trunk/src/VBox/Devices/Network/testcase/tstIntNet-1.cpp	(revision 51906)
@@ -645,5 +645,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     /*
@@ -1003,2 +1006,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/HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMainTemplate.cpp	(revision 51906)
+++ /trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMainTemplate.cpp	(revision 51906)
@@ -0,0 +1,25 @@
+/* $Id$ */
+/** @file
+ * Hardened main() template.
+ */
+
+/*
+ * Copyright (C) 2008-2014 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include <VBox/sup.h>
+
+
+int main(int argc, char **argv, char **envp)
+{
+    return SUPR3HardenedMain(PROGRAM_NAME_STR, 0, argc, argv, envp);
+}
+
Index: /trunk/src/VBox/HostDrivers/Support/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/testcase/Makefile.kmk	(revision 51905)
+++ /trunk/src/VBox/HostDrivers/Support/testcase/Makefile.kmk	(revision 51906)
@@ -33,4 +33,5 @@
 	SUPLoggerCtl
 ifdef VBOX_WITH_TESTCASES
+ if !defined(VBOX_WITH_HARDENING) || "$(KBUILD_TARGET)" != "win"
 PROGRAMS += \
 	tstPage \
@@ -45,4 +46,5 @@
 	tstSupSem \
 	tstSupSem-Zombie
+ endif
 PROGRAMS.win += \
 	tstNtQueryStuff
Index: /trunk/src/VBox/Runtime/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Runtime/testcase/Makefile.kmk	(revision 51905)
+++ /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 51905)
+++ /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 51905)
+++ /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 51905)
+++ /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 51905)
+++ /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 51905)
+++ /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
+
Index: /trunk/src/VBox/VMM/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/VMM/testcase/Makefile.kmk	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/Makefile.kmk	(revision 51906)
@@ -41,7 +41,19 @@
 endif
 ifndef VBOX_ONLY_EXTPACKS_USE_IMPLIBS
- PROGRAMS  += tstGlobalConfig tstInstrEmul
+ PROGRAMS  += tstInstrEmul
+ if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+  PROGRAMS += tstGlobalConfigHardened
+  DLL      += tstGlobalConfig
+ else
+  PROGRAMS += tstGlobalConfig
+ endif
+
  ifdef VBOX_WITH_RAW_MODE
-  PROGRAMS  += tstVMM tstVMM-HM
+  if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+   PROGRAMS += tstVMMHardened
+   DLLS     += tstVMM
+  else
+   PROGRAMS += tstVMM tstVMM-HM
+  endif
   ifneq ($(KBUILD_TARGET),win)
    PROGRAMS += tstVMMFork
@@ -49,27 +61,35 @@
  endif
  ifdef VBOX_WITH_TESTCASES
-  PROGRAMS  += \
-  	tstCFGM \
+  if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+   PROGRAMS += tstCFGMHardened tstSSMHardened tstVMREQHardened tstMMHyperHeapHardened tstAnimateHardened
+   DLLS     += tstCFGM tstSSM tstVMREQ tstMMHyperHeap tstAnimate
+  else
+   PROGRAMS += tstCFGM tstSSM tstVMREQ tstMMHyperHeap tstAnimate
+  endif
+  PROGRAMS += \
   	tstCompressionBenchmark \
 	tstIEMCheckMc \
-  	tstMMHyperHeap \
-  	tstSSM \
   	tstVMMR0CallHost-1 \
   	tstVMMR0CallHost-2 \
-  	tstVMREQ \
 	tstX86-FpuSaveRestore
   ifn1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), solaris.x86 solaris.amd64 win.amd64 ) ## TODO: Fix the code.
    PROGRAMS += tstX86-1
   endif
-  ifneq ($(KBUILD_TARGET),l4)
-   PROGRAMS += tstAnimate
-  endif
   ifdef VBOX_WITH_RAW_MODE
-   PROGRAMS += tstMicro
-   SYSMODS  += tstMicroRC
+   if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+    PROGRAMS += tstMicroHardened
+    DLLS     += tstMicro
+   else
+    PROGRAMS += tstMicro
+   endif
+   SYSMODS   += tstMicroRC
   endif
   ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
-   PROGRAMS  += tstPDMAsyncCompletion
-   PROGRAMS  += tstPDMAsyncCompletionStress
+   if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+    PROGRAMS += tstPDMAsyncCompletionHardened tstPDMAsyncCompletionStressHardened
+    DLLS     += tstPDMAsyncCompletion tstPDMAsyncCompletionStress
+   else
+    PROGRAMS += tstPDMAsyncCompletion tstPDMAsyncCompletionStress
+   endif
   endif
  endif # VBOX_WITH_TESTCASES
@@ -202,8 +222,22 @@
 
 
-tstGlobalConfig_TEMPLATE= VBOXR3TSTEXE
+#
+# Glboal config tool.
+#
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstGlobalConfigHardened_TEMPLATE = VBoxR3HardenedTstExe
+ tstGlobalConfigHardened_NAME     = tstGlobalConfig
+ tstGlobalConfigHardened_DEFS     = PROGRAM_NAME_STR=\"tstGlobalConfig\"
+ tstGlobalConfigHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstGlobalConfig_TEMPLATE = VBoxR3TstDll
+else
+ tstGlobalConfig_TEMPLATE = VBOXR3TSTEXE
+endif
 tstGlobalConfig_SOURCES = tstGlobalConfig.cpp
 tstGlobalConfig_LIBS    = $(LIB_RUNTIME)
 
+#
+# Testcase for checking the repurposing of the IEM instruction code.
+#
 tstIEMCheckMc_TEMPLATE  = VBOXR3TSTEXE
 tstIEMCheckMc_SOURCES   = tstIEMCheckMc.cpp
@@ -213,24 +247,66 @@
 endif
 
-tstMMHyperHeap_TEMPLATE = VBOXR3TSTEXE
+#
+# VMM heap testcase.
+#
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstMMHyperHeapHardened_TEMPLATE = VBoxR3HardenedTstExe
+ tstMMHyperHeapHardened_NAME     = tstMMHyperHeap
+ tstMMHyperHeapHardened_DEFS     = PROGRAM_NAME_STR=\"tstMMHyperHeap\"
+ tstMMHyperHeapHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstMMHyperHeap_TEMPLATE = VBoxR3TstDll
+else
+ tstMMHyperHeap_TEMPLATE = VBOXR3TSTEXE
+endif
 tstMMHyperHeap_SOURCES  = tstMMHyperHeap.cpp
 tstMMHyperHeap_LIBS     = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
-tstSSM_TEMPLATE         = VBOXR3TSTEXE
+#
+# Saved state manager testcase.
+#
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstSSMHardened_TEMPLATE = VBoxR3HardenedTstExe
+ tstSSMHardened_NAME     = tstSSM
+ tstSSMHardened_DEFS     = PROGRAM_NAME_STR=\"tstSSM\"
+ tstSSMHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstSSM_TEMPLATE        = VBoxR3TstDll
+else
+ tstSSM_TEMPLATE        = VBOXR3TSTEXE
+endif
 tstSSM_INCS             = $(VBOX_PATH_VMM_SRC)/include
 tstSSM_SOURCES          = tstSSM.cpp
 tstSSM_LIBS             = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+#
+# Test some EM assembly routines used in instruction emulation.
+#
 tstInstrEmul_TEMPLATE   = VBOXR3EXE
 tstInstrEmul_SOURCES    = tstInstrEmul.cpp ../VMMAll/EMAllA.asm
 tstInstrEmul_LIBS       = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
-tstCFGM_TEMPLATE        = VBOXR3TSTEXE
+#
+# VMM configuration manager tests.
+#
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstCFGMHardened_TEMPLATE = VBoxR3HardenedTstExe
+ tstCFGMHardened_NAME     = tstCFGM
+ tstCFGMHardened_DEFS     = PROGRAM_NAME_STR=\"tstCFGM\"
+ tstCFGMHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstCFGM_TEMPLATE       = VBoxR3TstDll
+else
+ tstCFGM_TEMPLATE       = VBOXR3TSTEXE
+endif
 tstCFGM_SOURCES         = tstCFGM.cpp
 tstCFGM_LIBS            = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+#
+# Comparing some compression algorithms considered for SSM usage.
+#
 tstCompressionBenchmark_TEMPLATE = VBOXR3TSTEXE
 tstCompressionBenchmark_SOURCES  = tstCompressionBenchmark.cpp
 
+#
+# Two testcases for checking the ring-3 "long jump" code.
+#
 tstVMMR0CallHost-1_TEMPLATE = VBOXR3TSTEXE
 tstVMMR0CallHost-1_DEFS = VMM_R0_NO_SWITCH_STACK
@@ -246,9 +322,31 @@
 tstVMMR0CallHost-2_DEFS = VMM_R0_SWITCH_STACK
 
-tstVMREQ_TEMPLATE       = VBOXR3EXE
+#
+# For testing the VM request queue code.
+#
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstVMREQHardened_TEMPLATE = VBOXR3HARDENEDEXE
+ tstVMREQHardened_NAME     = tstVMREQ
+ tstVMREQHardened_DEFS     = PROGRAM_NAME_STR=\"tstVMREQ\"
+ tstVMREQHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstVMREQ_TEMPLATE      = VBOXR3
+else
+ tstVMREQ_TEMPLATE      = VBOXR3EXE
+endif
 tstVMREQ_SOURCES        = tstVMREQ.cpp
 tstVMREQ_LIBS           = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
-tstAnimate_TEMPLATE     = VBOXR3EXE
+#
+# Tool for reanimate things like OS/2 dumps.
+#
+if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+ tstAnimateHardened_TEMPLATE = VBOXR3HARDENEDEXE
+ tstAnimateHardened_NAME     = tstAnimate
+ tstAnimateHardened_DEFS     = PROGRAM_NAME_STR=\"tstAnimate\"
+ tstAnimateHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+ tstAnimate_TEMPLATE    = VBOXR3
+else
+ tstAnimate_TEMPLATE    = VBOXR3EXE
+endif
 tstAnimate_SOURCES      = tstAnimate.cpp
 tstAnimate_LIBS         = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
@@ -264,17 +362,45 @@
 ifdef VBOX_WITH_RAW_MODE
 
- tstVMM_TEMPLATE        = VBOXR3EXE
+ #
+ # Raw-mode VMM testcase.
+ #
+ if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+  tstVMMHardened_TEMPLATE = VBOXR3HARDENEDEXE
+  tstVMMHardened_NAME     = tstVMM
+  tstVMMHardened_DEFS     = PROGRAM_NAME_STR=\"tstVMM\"
+  tstVMMHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+  tstVMM_TEMPLATE       = VBOXR3
+ else
+  tstVMM_TEMPLATE       = VBOXR3EXE
+ endif
  tstVMM_SOURCES         = tstVMM.cpp
  tstVMM_LIBS            = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+ #
+ # HM VMM testcase.
+ #
  tstVMM-HM_TEMPLATE     = VBOXR3EXE
  tstVMM-HM_SOURCES      = tstVMM-HM.cpp
  tstVMM-HM_LIBS         = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
+ #
+ # VMM host process fork test case (memory ++).
+ #
  tstVMMFork_TEMPLATE    = VBOXR3EXE
  tstVMMFork_SOURCES     = tstVMMFork.cpp
  tstVMMFork_LIBS        = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
- tstMicro_TEMPLATE       = VBOXR3EXE
+ #
+ # Raw-mode micro benchmark.
+ #
+ if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+  tstMicroHardened_TEMPLATE = VBOXR3HARDENEDEXE
+  tstMicroHardened_NAME     = tstMicro
+  tstMicroHardened_DEFS     = PROGRAM_NAME_STR=\"tstMicro\"
+  tstMicroHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+  tstMicro_TEMPLATE      = VBOXR3
+ else
+  tstMicro_TEMPLATE      = VBOXR3EXE
+ endif
  tstMicro_SOURCES        = tstMicro.cpp
  tstMicro_LIBS           = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
@@ -302,10 +428,32 @@
 
 ifdef VBOX_WITH_PDM_ASYNC_COMPLETION
- tstPDMAsyncCompletion_TEMPLATE         = VBOXR3EXE
+ #
+ # PDM asynchronous completation test.
+ #
+ if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+  tstPDMAsyncCompletionHardened_TEMPLATE = VBOXR3HARDENEDEXE
+  tstPDMAsyncCompletionHardened_NAME     = tstPDMAsyncCompletion
+  tstPDMAsyncCompletionHardened_DEFS     = PROGRAM_NAME_STR=\"tstPDMAsyncCompletion\"
+  tstPDMAsyncCompletionHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+  tstPDMAsyncCompletion_TEMPLATE        = VBOXR3
+ else
+  tstPDMAsyncCompletion_TEMPLATE        = VBOXR3EXE
+ endif
  tstPDMAsyncCompletion_INCS             = $(VBOX_PATH_VMM_SRC)/include
  tstPDMAsyncCompletion_SOURCES          = tstPDMAsyncCompletion.cpp
  tstPDMAsyncCompletion_LIBS             = $(LIB_VMM) $(LIB_REM) $(LIB_RUNTIME)
 
- tstPDMAsyncCompletionStress_TEMPLATE   = VBOXR3EXE
+ #
+ # PDM asynchronous completation stress test.
+ #
+ if defined(VBOX_WITH_HARDENING) && "$(KBUILD_TARGET)" == "win"
+  tstPDMAsyncCompletionStressHardened_TEMPLATE = VBOXR3HARDENEDEXE
+  tstPDMAsyncCompletionStressHardened_NAME     = tstPDMAsyncCompletionStress
+  tstPDMAsyncCompletionStressHardened_DEFS     = PROGRAM_NAME_STR=\"tstPDMAsyncCompletionStress\"
+  tstPDMAsyncCompletionStressHardened_SOURCES  = ../../HostDrivers/Support/SUPR3HardenedMainTemplate.cpp
+  tstPDMAsyncCompletionStress_TEMPLATE  = VBOXR3
+ else
+  tstPDMAsyncCompletionStress_TEMPLATE  = VBOXR3EXE
+ endif
  tstPDMAsyncCompletionStress_INCS       = $(VBOX_PATH_VMM_SRC)/include
  tstPDMAsyncCompletionStress_SOURCES    = tstPDMAsyncCompletionStress.cpp
Index: /trunk/src/VBox/VMM/testcase/tstAnimate.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstAnimate.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstAnimate.cpp	(revision 51906)
@@ -619,5 +619,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     int rcRet = 1;
@@ -937,2 +940,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/VMM/testcase/tstCFGM.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstCFGM.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstCFGM.cpp	(revision 51906)
@@ -136,5 +136,9 @@
 }
 
-int main()
+
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     /*
@@ -153,2 +157,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/VMM/testcase/tstGlobalConfig.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstGlobalConfig.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstGlobalConfig.cpp	(revision 51906)
@@ -39,5 +39,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     RTR3InitExe(argc, &argv, 0);
@@ -121,2 +124,14 @@
     return RT_FAILURE(rc) ? 1 : 0;
 }
+
+
+#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/VMM/testcase/tstMMHyperHeap.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstMMHyperHeap.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstMMHyperHeap.cpp	(revision 51906)
@@ -38,5 +38,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
 
@@ -241,2 +244,14 @@
     return 0;
 }
+
+
+#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/VMM/testcase/tstMicro.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstMicro.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstMicro.cpp	(revision 51906)
@@ -340,5 +340,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     int     rcRet = 0;                  /* error count. */
@@ -386,2 +389,14 @@
     return rcRet;
 }
+
+
+#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/VMM/testcase/tstPDMAsyncCompletion.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletion.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletion.cpp	(revision 51906)
@@ -73,5 +73,8 @@
 }
 
-int main(int argc, char *argv[])
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     int rcRet = 0; /* error count */
@@ -257,2 +260,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/VMM/testcase/tstPDMAsyncCompletionStress.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletionStress.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstPDMAsyncCompletionStress.cpp	(revision 51906)
@@ -568,5 +568,8 @@
 }
 
-int main(int argc, char *argv[])
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     int rcRet = 0; /* error count */
@@ -630,2 +633,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/VMM/testcase/tstSSM.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstSSM.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstSSM.cpp	(revision 51906)
@@ -684,5 +684,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     /*
@@ -917,2 +920,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/VMM/testcase/tstVMM.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstVMM.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstVMM.cpp	(revision 51906)
@@ -193,5 +193,8 @@
 
 
-int main(int argc, char **argv)
+/**
+ * Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     /*
@@ -364,2 +367,14 @@
     return RTTestSummaryAndDestroy(hTest);
 }
+
+
+#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/VMM/testcase/tstVMREQ.cpp
===================================================================
--- /trunk/src/VBox/VMM/testcase/tstVMREQ.cpp	(revision 51905)
+++ /trunk/src/VBox/VMM/testcase/tstVMREQ.cpp	(revision 51906)
@@ -225,5 +225,8 @@
 }
 
-int main(int argc, char **argv)
+/**
+ *  Entry point.
+ */
+extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
 {
     RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_SUPLIB);
@@ -331,2 +334,14 @@
     return !!g_cErrors;
 }
+
+
+#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
+
