Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 42238)
+++ /trunk/Config.kmk	(revision 42239)
@@ -1794,4 +1794,7 @@
 # VBoxTpG (tracepoint generator)
 VBOX_VBOXTPG    ?= $(PATH_OBJ)/VBoxTpG/VBoxTpG$(HOSTSUFF_EXE)
+
+# VBoxPeSetVersion (changes the minimum OS version of an image)
+VBOX_PE_SET_VERSION ?= $(PATH_OBJ)/VBoxPeSetVersion/VBoxPeSetVersion$(HOSTSUFF_EXE)
 
 # filesplitter (splits java files)
@@ -4727,4 +4730,6 @@
  	$(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.amd64)_LIB)/libcmt$(VBOX_VCC_CRT_TYPE).lib \
  	$(PATH_TOOL_$(TEMPLATE_VBOXGUESTR3EXE_TOOL.win.amd64)_LIB)/libcpmt$(VBOX_VCC_CRT_TYPE).lib
+ TEMPLATE_VBOXGUESTR3EXE_POST_CMDS.win.x86 = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION) $(out))
+ TEMPLATE_VBOXGUESTR3EXE_LNK_DEPS.win.x86  = $(if $(eq $(tool_do),LINK_LIBRARY),,$(VBOX_PE_SET_VERSION))
 else # the gcc guys
  TEMPLATE_VBOXGUESTR3EXE_EXTENDS  = VBOXR3EXE
@@ -4745,4 +4750,14 @@
 endif
 
+#
+# Template for building normal R3 programs for the guest additions.
+#
+TEMPLATE_NewVBoxGuestR3Exe = VBox Guest Program w/ IPRT and VBGL.
+TEMPLATE_NewVBoxGuestR3Exe_EXTENDS  = VBOXGUESTR3EXE
+TEMPLATE_NewVBoxGuestR3Exe_LIBS     = \
+	$(VBOX_LIB_IPRT_GUEST_R3) \
+	$(VBOX_LIB_VBGL_R3) \
+	$(VBOX_LIB_IPRT_GUEST_R3) \
+	$(TEMPLATE_VBOXGUESTR3EXE_LIBS)
 
 #
@@ -4758,4 +4773,15 @@
  TEMPLATE_VBOXGUESTR3DLL_LDFLAGS  = $(TEMPLATE_VBOXGUESTR3EXE_LDFLAGS) -fPIC
 endif
+
+#
+# Template for building normal R3 (dynamic) libraries for the guest additions.
+#
+TEMPLATE_NewVBoxGuestR3Dll = VBox Guest User Dynamic Libraries w/ IPRT and VBGL.
+TEMPLATE_NewVBoxGuestR3Dll_EXTENDS  = VBOXGUESTR3DLL
+TEMPLATE_NewVBoxGuestR3Dll_LIBS     = \
+	$(VBOX_LIB_IPRT_GUEST_R3_SHARED) \
+	$(VBOX_LIB_VBGL_R3_SHARED) \
+	$(VBOX_LIB_IPRT_GUEST_R3_SHARED) \
+	$(TEMPLATE_VBOXGUESTR3EXE_LIBS)
 
 #
Index: /trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/WINNT/Installer/InstallHelper/Makefile.kmk	(revision 42239)
@@ -24,5 +24,5 @@
 ## @todo kBuild: This needs the WINPSDK fix to work for cross building.
 DLLS.x86 += VBoxGuestInstallHelper
-VBoxGuestInstallHelper_TEMPLATE = VBOXGUESTR3DLL
+VBoxGuestInstallHelper_TEMPLATE = NewVBoxGuestR3Dll
 ifdef VBOX_SIGN_ADDITIONS # (See the parent makefile.)
  VBoxGuestInstallHelper_INSTTYPE = none
Index: /trunk/src/VBox/Additions/WINNT/Installer/Loader/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Installer/Loader/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/WINNT/Installer/Loader/Makefile.kmk	(revision 42239)
@@ -23,5 +23,5 @@
 # This has to be 32-bit, so don't include it in the 64-bit build.
 PROGRAMS.x86 += VBoxWindowsAdditions
-VBoxWindowsAdditions_TEMPLATE= VBOXGUESTR3EXE
+VBoxWindowsAdditions_TEMPLATE= NewVBoxGuestR3Exe
 VBoxWindowsAdditions_DEFS    = _WIN32_WINNT=0x0400 _UNICODE UNICODE
 VBoxWindowsAdditions_SOURCES = \
Index: /trunk/src/VBox/Additions/WINNT/Installer/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Installer/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/WINNT/Installer/Makefile.kmk	(revision 42239)
@@ -31,5 +31,5 @@
 
 PROGRAMS += VBoxDrvInst
-VBoxDrvInst_TEMPLATE= VBOXGUESTR3EXE
+VBoxDrvInst_TEMPLATE= NewVBoxGuestR3Exe
 VBoxDrvInst_DEFS    = _WIN32_WINNT=0x0400 _UNICODE UNICODE
 VBoxDrvInst_DEFS   += VBOX_SVN_REV=$(VBOX_SVN_REV)
@@ -47,5 +47,5 @@
 
 PROGRAMS += VBoxGuestDrvInst
-VBoxGuestDrvInst_TEMPLATE= VBOXGUESTR3EXE
+VBoxGuestDrvInst_TEMPLATE= NewVBoxGuestR3Exe
 VBoxGuestDrvInst_DEFS    =  _WIN32_WINNT=0x0400 UNICODE
 VBoxGuestDrvInst_SOURCES = \
@@ -54,5 +54,5 @@
 
 PROGRAMS += RegCleanup
-RegCleanup_TEMPLATE = VBOXGUESTR3EXE
+RegCleanup_TEMPLATE = NewVBoxGuestR3Exe
 RegCleanup_DEFS     = _WIN32_WINNT=0x0400 UNICODE
 RegCleanup_SOURCES  = \
@@ -212,5 +212,6 @@
 		$(VBOX_WINDOWS_ADDITIONS_ICON_FILE) \
 		$(VBOX_NSIS_ICON_FILE) \
-		$(VBOX_VERSION_STAMP)\
+		$(VBOX_VERSION_STAMP) \
+               $$(VBoxDrvInst_1_STAGE_TARGET) \
 		| $$(dir $$@)
 	$(call MSG_L1,Creating $@, from $<)
@@ -250,5 +251,6 @@
 		$(VBOX_NSIS_ICON_FILE) \
 		$(if $(VBOX_SIGNING_MODE),$(PATH_TARGET)/uninst.exe) \
-		$(VBOX_VERSION_STAMP)
+		$(VBOX_VERSION_STAMP) \
+               $$(VBoxDrvInst_1_STAGE_TARGET)
 	$(call MSG_L1,Creating $@, from $<)
 	$(QUIET)$(REDIRECT) -C $(VBOX_PATH_WIN_ADD_INS_SRC) \
Index: /trunk/src/VBox/Additions/WINNT/VBoxCredProv/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxCredProv/testcase/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/WINNT/VBoxCredProv/testcase/Makefile.kmk	(revision 42239)
@@ -1,5 +1,5 @@
 # $Id$
 ## @file
-# Sub-Makefile for test cases.
+# Sub-Makefile for VBoxCredProv test cases.
 #
 
@@ -20,5 +20,5 @@
 
 PROGRAMS += tstCredentialProvider
-tstCredentialProvider_TEMPLATE = VBOXGUESTR3EXE
+tstCredentialProvider_TEMPLATE = NewVBoxGuestR3Exe
 tstCredentialProvider_SOURCES  = \
 	tstCredentialProvider.cpp
Index: /trunk/src/VBox/Additions/WINNT/VBoxGINA/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxGINA/testcase/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/WINNT/VBoxGINA/testcase/Makefile.kmk	(revision 42239)
@@ -1,5 +1,5 @@
 # $Id $
 ## @file
-# Sub-Makefile for test cases.
+# Sub-Makefile for GINA test cases.
 #
 
@@ -20,5 +20,5 @@
 
 PROGRAMS += tstVBoxGINA
-tstVBoxGINA_TEMPLATE = VBOXGUESTR3EXE
+tstVBoxGINA_TEMPLATE = NewVBoxGuestR3Exe
 tstVBoxGINA_SOURCES  = \
 	tstVBoxGINA.cpp
Index: /trunk/src/VBox/Additions/WINNT/VBoxHook/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxHook/testcase/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/WINNT/VBoxHook/testcase/Makefile.kmk	(revision 42239)
@@ -26,5 +26,5 @@
 PROGRAMS += tstHook
 
-tstHook_TEMPLATE = VBOXGUESTR3EXE
+tstHook_TEMPLATE = NewVBoxGuestR3Exe
 tstHook_DEFS     = VBOX_WITH_HGCM
 tstHook_SOURCES  = tstHook.cpp
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk	(revision 42239)
@@ -20,5 +20,5 @@
 
 PROGRAMS += VBoxTray
-VBoxTray_TEMPLATE = VBOXGUESTR3EXE
+VBoxTray_TEMPLATE = NewVBoxGuestR3Exe
 ifdef VBOX_SIGN_ADDITIONS # (See the parent makefile.)
  VBoxTray_INSTTYPE = none
@@ -64,8 +64,4 @@
 endif
 
-VBoxTray_LIBS     = \
-	$(VBOX_LIB_IPRT_GUEST_R3) \
-	$(VBOX_LIB_VBGL_R3)
-
 ifdef VBOX_WITH_WDDM
  VBoxTray_DEFS   += VBOX_WITH_WDDM
Index: /trunk/src/VBox/Additions/WINNT/VBoxTray/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/VBoxTray/testcase/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/WINNT/VBoxTray/testcase/Makefile.kmk	(revision 42239)
@@ -20,5 +20,5 @@
 
 PROGRAMS += tstSessionHack
-tstSessionHack_TEMPLATE = VBOXGUESTR3EXE
+tstSessionHack_TEMPLATE = NewVBoxGuestR3Exe
 tstSessionHack_DEFS     = VBOX_WITH_HGCM
 tstSessionHack_INCS     = ../../include
@@ -26,7 +26,4 @@
 	tstSessionHack.cpp
 
-tstSessionHack_LIBS     = \
-	$(VBOX_LIB_VBGL_R3)
-
 include $(FILE_KBUILD_SUB_FOOTER)
 
Index: /trunk/src/VBox/Additions/WINNT/tools/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/tools/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/WINNT/tools/Makefile.kmk	(revision 42239)
@@ -20,9 +20,7 @@
 PROGRAMS += VBoxCertUtil
 
-VBoxCertUtil_TEMPLATE = VBOXGUESTR3EXE
+VBoxCertUtil_TEMPLATE = NewVBoxGuestR3Exe
 VBoxCertUtil_SOURCES = VBoxCertUtil.cpp
 VBoxCertUtil_LIBS = \
-    $(VBOX_LIB_IPRT_GUEST_R3) \
-    $(VBOX_LIB_VBGL_R3) \
     crypt32.lib
 
Index: /trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/common/VBoxControl/Makefile.kmk	(revision 42239)
@@ -26,5 +26,5 @@
 #
 PROGRAMS += VBoxControl
-VBoxControl_TEMPLATE = VBOXGUESTR3EXE
+VBoxControl_TEMPLATE = NewVBoxGuestR3Exe
 ifeq ($(KBUILD_TARGET),win)
  ifdef VBOX_SIGN_ADDITIONS # (See the main Windows Additions makefile.)
@@ -43,8 +43,4 @@
 VBoxControl_SOURCES.win = \
 	VBoxControl.rc
-VBoxControl_LIBS = \
-	$(VBOX_LIB_IPRT_GUEST_R3) \
-	$(VBOX_LIB_VBGL_R3) \
-	$(VBOX_LIB_IPRT_GUEST_R3)
 
 include $(FILE_KBUILD_SUB_FOOTER)
Index: /trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk	(revision 42239)
@@ -212,5 +212,5 @@
 #
 #PROGRAMS += VBoxGuestInst
-VBoxGuestInst_TEMPLATE= VBOXGUESTR3EXE
+VBoxGuestInst_TEMPLATE= NewVBoxGuestR3Exe
 VBoxGuestInst_SOURCES = win/VBoxGuestInst.cpp
 endif
Index: /trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk	(revision 42239)
@@ -33,5 +33,5 @@
 # VBoxService
 #
-VBoxService_TEMPLATE      = VBOXGUESTR3EXE
+VBoxService_TEMPLATE      = NewVBoxGuestR3Exe
 VBoxService_DEFS          = VBOX_WITH_HGCM VBOXSERVICE_TIMESYNC VBOXSERVICE_MANAGEMENT VBOXSERVICE_TOOLBOX
 VBoxService_DEFS         += \
@@ -113,8 +113,4 @@
 	VBoxServiceClipboard-os2.cpp
 
-VBoxService_LIBS          = \
-	$(VBOX_LIB_IPRT_GUEST_R3) \
-	$(VBOX_LIB_VBGL_R3) \
-	$(VBOX_LIB_IPRT_GUEST_R3)
 if1of ($(KBUILD_TARGET), linux)
  VBoxService_LIBS        += \
@@ -133,5 +129,5 @@
 # VBoxServiceNT - NT4 version of VBoxService.
 #
-VBoxServiceNT_TEMPLATE = VBOXGUESTR3EXE
+VBoxServiceNT_TEMPLATE = NewVBoxGuestR3Exe
 VBoxServiceNT_EXTENDS  = VBoxService
 VBoxServiceNT_DEFS.win = _WIN32_WINNT=0x0400 TARGET_NT4 VBOXSERVICE_MANAGEMENT
Index: /trunk/src/VBox/Additions/common/VBoxService/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/testcase/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/common/VBoxService/testcase/Makefile.kmk	(revision 42239)
@@ -27,11 +27,7 @@
 # tstUserInfo
 #
-tstUserInfo_TEMPLATE    = VBOXGUESTR3EXE
+tstUserInfo_TEMPLATE    = NewVBoxGuestR3Exe
 tstUserInfo_SOURCES     = \
 	tstUserInfo.cpp
-tstUserInfo_LIBS        = \
-	$(VBOX_LIB_IPRT_GUEST_R3) \
-	$(VBOX_LIB_VBGL_R3) \
-	$(VBOX_LIB_IPRT_GUEST_R3)
 
 include $(FILE_KBUILD_SUB_FOOTER)
Index: /trunk/src/VBox/Additions/common/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/testcase/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/common/testcase/Makefile.kmk	(revision 42239)
@@ -27,15 +27,9 @@
 # tstPageFusion
 #
-tstPageFusion_TEMPLATE      = VBOXGUESTR3EXE
+tstPageFusion_TEMPLATE      = NewVBoxGuestR3Exe
 tstPageFusion_DEFS.win     += _WIN32_WINNT=0x0501
-
 tstPageFusion_SOURCES       = \
 	tstPageFusion.cpp
 
-tstPageFusion_LIBS          = \
-	$(VBOX_LIB_IPRT_GUEST_R3) \
-	$(VBOX_LIB_VBGL_R3) \
-	$(VBOX_LIB_IPRT_GUEST_R3)
-
 include $(FILE_KBUILD_SUB_FOOTER)
 
Index: /trunk/src/VBox/Additions/linux/sharedfolders/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/linux/sharedfolders/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/linux/sharedfolders/Makefile.kmk	(revision 42239)
@@ -76,5 +76,5 @@
 #
 PROGRAMS += mount.vboxsf
-mount.vboxsf_TEMPLATE    = VBOXGUESTR3EXE
+mount.vboxsf_TEMPLATE    = NewVBoxGuestR3Exe
 mount.vboxsf_DEFS        = _GNU_SOURCE
 mount.vboxsf_SOURCES     = \
Index: /trunk/src/VBox/Additions/solaris/SharedFolders/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/solaris/SharedFolders/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/solaris/SharedFolders/Makefile.kmk	(revision 42239)
@@ -91,5 +91,5 @@
 #
 PROGRAMS                += vboxfsmount
-vboxfsmount_TEMPLATE    = VBOXGUESTR3EXE
+vboxfsmount_TEMPLATE    = NewVBoxGuestR3Exe
 vboxfsmount_SOURCES     = vboxfs_mount.c
 
Index: /trunk/src/VBox/Additions/x11/VBoxClient/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/Makefile.kmk	(revision 42239)
@@ -24,5 +24,5 @@
 PROGRAMS += VBoxClient
 
-VBoxClient_TEMPLATE = VBOXGUESTR3EXE
+VBoxClient_TEMPLATE = NewVBoxGuestR3Exe
 VBoxClient_DEFS += VBOX_X11_CLIPBOARD VBOX_WITH_HGCM
 ifdef VBOX_WITH_DBUS
@@ -45,7 +45,4 @@
 	dl
 VBoxClient_LIBS = \
-	$(VBOX_LIB_IPRT_GUEST_R3) \
-	$(VBOX_LIB_VBGL_R3) \
-	$(VBOX_LIB_IPRT_GUEST_R3) \
 	X11 \
 	Xrandr \
Index: /trunk/src/VBox/Runtime/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Runtime/Makefile.kmk	(revision 42238)
+++ /trunk/src/VBox/Runtime/Makefile.kmk	(revision 42239)
@@ -1066,5 +1066,9 @@
 RuntimeGuestR3_SOURCES.$(KBUILD_TARGET).amd64:= $(RuntimeR3_SOURCES.$(KBUILD_TARGET).amd64)
 RuntimeGuestR3_SOURCES.$(KBUILD_HOST).$(KBUILD_TARGET_ARCH)   := $(RuntimeR3_SOURCES.$(KBUILD_HOST).$(KBUILD_TARGET_ARCH))
-
+ifdef VBOX_USE_VCC100
+ RuntimeGuestR3_SOURCES.win.x86              += \
+ 	r3/win/vcc100-kernel32-fakes.cpp \
+ 	r3/win/vcc100-kernel32-fakesA.asm
+endif
 
 #
Index: /trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp	(revision 42239)
+++ /trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakes.cpp	(revision 42239)
@@ -0,0 +1,141 @@
+/* $Id$ */
+/** @file
+ * IPRT - Tricks to make the Visual C++ 2010 CRT work on NT4, W2K and XP.
+ */
+
+/*
+ * Copyright (C) 2012 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.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <iprt/cdefs.h>
+
+#ifndef RT_ARCH_X86
+# error "This code is X86 only"
+#endif
+
+#define DecodePointer                           Ignore_DecodePointer
+#define EncodePointer                           Ignore_EncodePointer
+#define InitializeCriticalSectionAndSpinCount   Ignore_InitializeCriticalSectionAndSpinCount
+#define HeapSetInformation                      Ignore_HeapSetInformation
+#define HeapQueryInformation                    Ignore_HeapQueryInformation
+#include <Windows.h>
+#undef DecodePointer
+#undef EncodePointer
+#undef InitializeCriticalSectionAndSpinCount
+#undef HeapSetInformation
+#undef HeapQueryInformation
+
+
+#ifndef HEAP_STANDARD
+# define HEAP_STANDARD 0
+#endif
+
+
+/** @todo Try dynamically resolve the functions the first time one of them is
+ *        called. */
+
+extern "C"
+__declspec(dllexport) PVOID WINAPI
+DecodePointer(PVOID pvEncoded)
+{
+    /*
+     * Fallback code.
+     */
+    return pvEncoded;
+}
+
+
+extern "C"
+__declspec(dllexport) PVOID WINAPI
+EncodePointer(PVOID pvNative)
+{
+    /*
+     * Fallback code.
+     */
+    return pvNative;
+}
+
+
+extern "C"
+__declspec(dllexport) BOOL WINAPI
+InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION pCritSect, DWORD cSpin)
+{
+
+    /*
+     * Fallback code.
+     */
+    InitializeCriticalSection(pCritSect);
+    return TRUE;
+}
+
+
+extern "C"
+__declspec(dllexport) BOOL WINAPI
+HeapSetInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf)
+{
+    /*
+     * Fallback code.
+     */
+    if (enmInfoClass == HeapCompatibilityInformation)
+    {
+        if (   cbBuf != sizeof(ULONG)
+            || !pvBuf
+            || *(PULONG)pvBuf == HEAP_STANDARD
+           )
+        {
+            SetLastError(ERROR_INVALID_PARAMETER);
+            return FALSE;
+        }
+        return TRUE;
+    }
+
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return FALSE;
+}
+
+
+extern "C"
+__declspec(dllexport) BOOL WINAPI
+HeapQueryInformation(HANDLE hHeap, HEAP_INFORMATION_CLASS enmInfoClass, PVOID pvBuf, SIZE_T cbBuf, PSIZE_T pcbRet)
+{
+
+    /*
+     * Fallback code.
+     */
+    if (enmInfoClass == HeapCompatibilityInformation)
+    {
+        *pcbRet = sizeof(ULONG);
+        if (cbBuf < sizeof(ULONG) || !pvBuf)
+        {
+            SetLastError(ERROR_INSUFFICIENT_BUFFER);
+            return FALSE;
+        }
+        *(PULONG)pvBuf = HEAP_STANDARD;
+        return TRUE;
+    }
+
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return FALSE;
+}
+
Index: /trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakesA.asm
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakesA.asm	(revision 42239)
+++ /trunk/src/VBox/Runtime/r3/win/vcc100-kernel32-fakesA.asm	(revision 42239)
@@ -0,0 +1,27 @@
+
+
+%include "iprt/asmdefs.mac"
+
+%ifndef RT_ARCH_X86
+ %error "This is x86 only code.
+%endif
+
+
+%macro MAKE_IMPORT_ENTRY 2
+extern _ %+ %1 %+ @ %+ %2
+global __imp__ %+ %1 %+ @ %+ %2
+__imp__ %+ %1 %+ @ %+ %2:
+    dd _ %+ %1 %+ @ %+ %2
+
+%endmacro
+
+
+BEGINDATA
+
+MAKE_IMPORT_ENTRY DecodePointer, 4
+MAKE_IMPORT_ENTRY EncodePointer, 4
+MAKE_IMPORT_ENTRY InitializeCriticalSectionAndSpinCount, 8
+MAKE_IMPORT_ENTRY HeapSetInformation, 16
+MAKE_IMPORT_ENTRY HeapQueryInformation, 20
+
+
Index: /trunk/src/bldprogs/Makefile.kmk
===================================================================
--- /trunk/src/bldprogs/Makefile.kmk	(revision 42238)
+++ /trunk/src/bldprogs/Makefile.kmk	(revision 42239)
@@ -61,4 +61,8 @@
 endif
 
+BLDPROGS.win += VBoxPeSetVersion
+VBoxPeSetVersion_TEMPLATE = VBOXBLDPROG
+VBoxPeSetVersion_SOURCES  = VBoxPeSetVersion.cpp
+
 include $(FILE_KBUILD_SUB_FOOTER)
 
Index: /trunk/src/bldprogs/VBoxPeSetVersion.cpp
===================================================================
--- /trunk/src/bldprogs/VBoxPeSetVersion.cpp	(revision 42239)
+++ /trunk/src/bldprogs/VBoxPeSetVersion.cpp	(revision 42239)
@@ -0,0 +1,89 @@
+/* $Id$ */
+/** @file
+ * IPRT - Change the OS and SubSystem version to 4.0 (VS2010 trick).
+ */
+
+/*
+ * Copyright (C) 2012 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.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <Windows.h>
+#include <stdio.h>
+#include <string.h>
+
+
+/** @todo Rewrite this so it can take options and print out error messages. */
+int main(int argc, char **argv)
+{
+    FILE *pFile = fopen(argv[1], "r+b");
+    if (!pFile)
+        return 1;
+    IMAGE_DOS_HEADER MzHdr;
+    if (fread(&MzHdr, sizeof(MzHdr), 1, pFile) != 1)
+        return 2;
+
+    if (fseek(pFile, MzHdr.e_lfanew, SEEK_SET) != 0)
+        return 3;
+
+    IMAGE_NT_HEADERS32 NtHdrs;
+    if (fread(&NtHdrs, sizeof(NtHdrs), 1, pFile) != 1)
+        return 4;
+    if (NtHdrs.Signature != IMAGE_NT_SIGNATURE)
+        return 5;
+    if (NtHdrs.FileHeader.Machine != IMAGE_FILE_MACHINE_I386)
+        return 6;
+    if (NtHdrs.OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC)
+        return 7;
+
+    if (NtHdrs.OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC)
+        return 7;
+
+    IMAGE_NT_HEADERS32 NtHdrsNew = NtHdrs;
+    if (NtHdrsNew.OptionalHeader.MajorOperatingSystemVersion > 4)
+    {
+        NtHdrsNew.OptionalHeader.MajorOperatingSystemVersion = 4;
+        NtHdrsNew.OptionalHeader.MinorOperatingSystemVersion = 0;
+    }
+    if (NtHdrsNew.OptionalHeader.MajorSubsystemVersion > 4)
+    {
+        NtHdrsNew.OptionalHeader.MajorSubsystemVersion = 4;
+        NtHdrsNew.OptionalHeader.MinorSubsystemVersion = 0;
+    }
+
+    if (memcmp(&NtHdrsNew, &NtHdrs, sizeof(NtHdrs)))
+    {
+        /** @todo calc checksum. */
+        NtHdrsNew.OptionalHeader.CheckSum = 0;
+
+        if (fseek(pFile, MzHdr.e_lfanew, SEEK_SET) != 0)
+            return 10;
+        if (fwrite(&NtHdrsNew, sizeof(NtHdrsNew), 1, pFile) != 1)
+            return 11;
+    }
+
+    if (fclose(pFile) != 0)
+        return 29;
+    return 0;
+}
+
