Index: /trunk/include/iprt/asn1.h
===================================================================
--- /trunk/include/iprt/asn1.h	(revision 51998)
+++ /trunk/include/iprt/asn1.h	(revision 51999)
@@ -26,9 +26,4 @@
 #ifndef ___iprt_asn1_h
 #define ___iprt_asn1_h
-
-#if defined(DEBUG_bird) && !defined(IN_SUP_HARDENED_R3) && defined(IN_RING3) /* TEMPORARY! */
-# define RTMEM_WRAP_TO_EF_APIS                                               /* TEMPORARY! */
-# include <iprt/mem.h>                                                       /* TEMPORARY! */
-#endif                                                                       /* TEMPORARY! */
 
 #include <iprt/time.h>
Index: /trunk/src/VBox/HostDrivers/Support/Makefile.kmk
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/Makefile.kmk	(revision 51998)
+++ /trunk/src/VBox/HostDrivers/Support/Makefile.kmk	(revision 51999)
@@ -182,5 +182,6 @@
 	$(if $(VBOX_WITH_MAIN),VBOX_WITH_MAIN,) \
 	$(if $(VBOX_WITH_RAW_MODE),VBOX_WITH_RAW_MODE,) \
-	$(if $(VBOX_WITHOUT_DEBUGGER_CHECKS),VBOX_WITHOUT_DEBUGGER_CHECKS,)
+	$(if $(VBOX_WITHOUT_DEBUGGER_CHECKS),VBOX_WITHOUT_DEBUGGER_CHECKS,) \
+	$(if $(VBOX_PERMIT_VISUAL_STUDIO_PROFILING),VBOX_PERMIT_VISUAL_STUDIO_PROFILING,)
 ifdef VBOX_WITH_VISTA_NO_SP
  SUPR3HardenedStatic_DEFS.win += VBOX_WITH_VISTA_NO_SP
@@ -531,4 +532,7 @@
   VBoxDrv_DEFS           += VBOX_WITHOUT_DEBUGGER_CHECKS
  endif
+ ifdef VBOX_PERMIT_VISUAL_STUDIO_PROFILING
+  VBoxDrv_DEFS           += VBOX_PERMIT_VISUAL_STUDIO_PROFILING
+ endif
  #VBoxDrv_DEFS.debug      += DEBUG_DARWIN_GIP
  VBoxDrv_DEFS.darwin     := VBOX_WITH_HOST_VMX
Index: /trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp	(revision 51998)
+++ /trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyProcess-win.cpp	(revision 51999)
@@ -122,5 +122,9 @@
      * The array is large enough to hold the executable, all allowed DLLs, and one
      * more so we can get the image name of the first unwanted DLL. */
-    SUPHNTVPIMAGE           aImages[1+6+1];
+    SUPHNTVPIMAGE           aImages[1 + 6 + 1
+#ifdef VBOX_PERMIT_VISUAL_STUDIO_PROFILING
+                                    + 16
+#endif
+                                   ];
     /** Memory compare scratch buffer.*/
     uint8_t                 abMemory[_4K];
@@ -150,5 +154,13 @@
     "apphelp.dll",
     "apisetschema.dll",
-    "sfc.dll"
+    "sfc.dll",
+#ifdef VBOX_PERMIT_VISUAL_STUDIO_PROFILING
+    "psapi.dll",
+    "msvcrt.dll",
+    "advapi32.dll",
+    "sechost.dll",
+    "rpcrt4.dll",
+    "SamplingRuntime.dll",
+#endif
 };
 
@@ -817,4 +829,5 @@
             pImage->fDll    = true;
 
+#ifndef VBOX_PERMIT_VISUAL_STUDIO_PROFILING
             /* The directory name must match the one we've got for System32. */
             if (   cwcDirName * sizeof(WCHAR) != g_System32NtPath.UniStr.Length
@@ -825,5 +838,5 @@
                                            "Expected %ls to be loaded from %ls.",
                                            pImage->Name.UniStr.Buffer, g_System32NtPath.UniStr.Buffer);
-
+#endif
             break;
         }
@@ -1038,4 +1051,5 @@
          * Executable memory?
          */
+#ifndef VBOX_PERMIT_VISUAL_STUDIO_PROFILING
         else if (MemInfo.Protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY))
         {
@@ -1050,10 +1064,11 @@
                                 MemInfo.AllocationBase,
                                 MemInfo.AllocationProtect);
-#ifdef IN_RING3
+# ifdef IN_RING3
             /* Continue add more information about the problematic process. */
-#else
+# else
             return pThis->rcResult;
-#endif
+# endif
         }
+#endif
 
         /*
Index: /trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp	(revision 51998)
+++ /trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp	(revision 51999)
@@ -624,4 +624,15 @@
                                g_offSupLibHardenedExeNtName * sizeof(WCHAR)) == 0)
                 fFlags |= SUPHNTVI_F_REQUIRE_KERNEL_CODE_SIGNING | SUPHNTVI_F_REQUIRE_SIGNATURE_ENFORCEMENT;
+#ifdef VBOX_PERMIT_VISUAL_STUDIO_PROFILING
+            /* Hack to allow profiling our code with Visual Studio. */
+            else if (   uBuf.UniStr.Length > sizeof(L"\\SamplingRuntime.dll")
+                     && memcmp(uBuf.UniStr.Buffer + (uBuf.UniStr.Length - sizeof(L"\\SamplingRuntime.dll") + sizeof(WCHAR)) / sizeof(WCHAR),
+                               L"\\SamplingRuntime.dll", sizeof(L"\\SamplingRuntime.dll") - sizeof(WCHAR)) == 0 )
+            {
+                if (hMyFile != hFile)
+                    NtClose(hMyFile);
+                return g_pfnNtCreateSectionReal(phSection, fAccess, pObjAttribs, pcbSection, fProtect, fAttribs, hFile);
+            }
+#endif
             else
             {
