Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 48281)
+++ /trunk/Config.kmk	(revision 48282)
@@ -509,4 +509,8 @@
 # The main api.
 VBOX_WITH_MAIN = 1
+# Whether to also ship 32-bit main API on 64-bit systems.
+if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), solaris.amd64)
+ VBOX_WITH_32_ON_64_MAIN_API = 1
+endif
 # The recompiler.
 VBOX_WITH_REM = 1
@@ -1605,4 +1609,5 @@
  LIB_RUNTIME     = $(PATH_STAGE_BIN)/VBoxRT.dylib
  LIB_RUNTIME_EF  = #$(PATH_STAGE_LIB)/RuntimeEFCPP.a
+ VBOX_LIB_RUNTIME_X86   = $(PATH_STAGE_BIN)/VBoxRT-x86.dylib
  LIB_KPROFILE    = $(PATH_STAGE_BIN)/kPrf2.dylib
  LIB_VMM         = $(PATH_STAGE_BIN)/VBoxVMM.dylib
@@ -1610,4 +1615,5 @@
  LIB_REM         = $(PATH_STAGE_LIB)/VBoxREM.dylib
  LIB_XPCOM       = $(PATH_STAGE_BIN)/VBoxXPCOM.dylib
+ VBOX_LIB_XPCOM_X86     = $(PATH_STAGE_BIN)/VBoxXPCOM-x86.dylib
  LIB_DDU         = $(PATH_STAGE_BIN)/VBoxDDU.dylib
 endif
@@ -1615,4 +1621,5 @@
  LIB_RUNTIME     = $(PATH_STAGE_BIN)/VBoxRT.so
  LIB_RUNTIME_EF  = $(PATH_STAGE_LIB)/RuntimeEFCPP.a
+ VBOX_LIB_RUNTIME_X86   = $(PATH_STAGE_BIN)/VBoxRT-x86.so
  LIB_KPROFILE    = $(PATH_STAGE_BIN)/kPrf2.so
  LIB_VMM         = $(PATH_STAGE_BIN)/VBoxVMM.so
@@ -1620,4 +1627,5 @@
  LIB_REM         = $(PATH_STAGE_LIB)/VBoxREM.so
  LIB_XPCOM       = $(PATH_STAGE_BIN)/VBoxXPCOM.so
+ VBOX_LIB_XPCOM_X86   = $(PATH_STAGE_BIN)/VBoxXPCOM-x86.so
  LIB_DDU         = $(PATH_STAGE_BIN)/VBoxDDU.so
 endif
@@ -1625,4 +1633,5 @@
  LIB_RUNTIME     = $(PATH_STAGE_BIN)/VBoxRT.dll
  LIB_RUNTIME_EF  = #$(PATH_STAGE_LIB)/RuntimeEFCPP.a
+ VBOX_LIB_RUNTIME_X86   = $(PATH_STAGE_BIN)/VBoxRT-x86.dll
  LIB_KPROFILE    = $(PATH_STAGE_BIN)/kPrf2.dll
  LIB_VMM         = $(PATH_STAGE_BIN)/VBoxVMM.dll
@@ -1630,4 +1639,5 @@
  LIB_REM         = $(PATH_STAGE_LIB)/VBoxREMImp.lib
  LIB_XPCOM       = $(PATH_STAGE_BIN)/VBoxXCOM.dll
+ VBOX_LIB_XPCOM_X86     = $(PATH_STAGE_BIN)/VBoxXPCOM-x86.dll
  LIB_DDU         = $(PATH_STAGE_BIN)/VBoxDDU.dll
  VBOX_OBJ_SYS0   = $(PATH_OBJ)/RuntimeR0/os2/sys0.obj
@@ -1636,9 +1646,11 @@
  LIB_RUNTIME     = $(PATH_STAGE_LIB)/VBoxRT.lib
  LIB_RUNTIME_EF  = #$(PATH_STAGE_LIB)/RuntimeEFCPP.lib
+ VBOX_LIB_RUNTIME_X86   = $(PATH_STAGE_LIB)/VBoxRT-x86.lib
  LIB_KPROFILE    = $(PATH_STAGE_LIB)/kPrf2.lib
  LIB_VMM         = $(PATH_STAGE_LIB)/VBoxVMM.lib
  LIB_VMMGC       = $(PATH_OBJ)/VMMRC/VMMGC.lib
  LIB_REM         = $(PATH_STAGE_LIB)/VBoxREMImp.lib
- LIB_XPCOM       = $(PATH_STAGE_BIN)/VBoxXPCOM.dll
+ LIB_XPCOM       = $(PATH_STAGE_BIN)/VBoxXPCOM.lib
+ VBOX_LIB_XPCOM_X86     = $(PATH_STAGE_BIN)/VBoxXPCOM-x86.lib
  LIB_DDU         = $(PATH_STAGE_LIB)/VBoxDDU.lib
 endif
@@ -2692,7 +2704,9 @@
  SDK_VBOX_ZLIB_INCS  ?= $(PATH_ROOT)/src/libs/zlib-1.2.6
  SDK_VBOX_ZLIB_LIBS  ?= $(PATH_STAGE_LIB)/VBox-zlib$(VBOX_SUFF_LIB)
+ SDK_VBOX_ZLIB_LIBS.x86 ?= $(PATH_STAGE_LIB)/VBox-zlib-x86$(VBOX_SUFF_LIB)
 else
  SDK_VBOX_ZLIB_INCS  ?=
  SDK_VBOX_ZLIB_LIBS  ?= z
+ SDK_VBOX_ZLIB_LIBS.x86 ?= z
  SDK_VBOX_ZLIB_DEFS.linux ?= _LARGEFILE64_SOURCE
 endif
@@ -2712,4 +2726,12 @@
 	$(PATH_STAGE_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB)
 
+SDK_VBOX_OPENSSL-x86      = Only for VBoxRT and/or statically linked programs.
+SDK_VBOX_OPENSSL-x86_VBOX_DEFAULT_INCS := $(PATH_OUT)/obj/crypto-headers/include
+SDK_VBOX_OPENSSL-x86_INCS ?= $(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)
+SDK_VBOX_OPENSSL-x86_ORDERDEPS ?= $(crypto-headers_1_TARGET)
+SDK_VBOX_OPENSSL-x86_LIBS ?= \
+	$(PATH_STAGE_LIB)/VBox-libssl-x86$(VBOX_SUFF_LIB) \
+	$(PATH_STAGE_LIB)/VBox-libcrypto-x86$(VBOX_SUFF_LIB)
+
 SDK_VBOX_OPENSSL2      = What you should be using.
 SDK_VBOX_OPENSSL2_EXTENDS = VBOX_OPENSSL
@@ -2738,4 +2760,9 @@
 SDK_VBOX_LIBCURL_LIBS ?= $(PATH_STAGE_LIB)/VBox-libcurl$(VBOX_SUFF_LIB)
 SDK_VBOX_LIBCURL_DEFS ?= BUILDING_LIBCURL
+
+SDK_VBOX_LIBCURL-x86           = .
+SDK_VBOX_LIBCURL-x86_INCS     ?= $(PATH_ROOT)/src/libs/curl-7.27.0/include
+SDK_VBOX_LIBCURL-x86_LIBS.x86 ?= $(PATH_STAGE_LIB)/VBox-libcurl-x86$(VBOX_SUFF_LIB)
+SDK_VBOX_LIBCURL-x86_DEFS     ?= BUILDING_LIBCURL
 endif
 
@@ -3603,4 +3630,12 @@
 endif
 
+# x86 edition of the above template for use on AMD64 targets.
+TEMPLATE_VBoxR3Dll-x86                = 32-bit VBox ring-3 SO/DLLs, no warnings
+TEMPLATE_VBoxR3Dll-x86_EXTENDS        = VBoxR3Dll
+TEMPLATE_VBoxR3Dll-x86_BLD_TRG_ARCH   = x86
+TEMPLATE_VBoxR3Dll-x86_DEFS           = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBoxR3Dll_DEFS)) \
+	HC_ARCH_BITS=32 ARCH_BITS=32
+
+
 #
 # Template for building performance critical stuff with warnings-as-errors.
@@ -3626,4 +3661,12 @@
 endif
 
+# x86 edition of the above template for use on AMD64 targets.
+TEMPLATE_VBoxR3DllNoPic-x86                = 32-bit VBox ring-3 SO/DLLs without PIC, without warnings.
+TEMPLATE_VBoxR3DllNoPic-x86_EXTENDS        = VBoxR3DllNoPic
+TEMPLATE_VBoxR3DllNoPic-x86_BLD_TRG_ARCH   = x86
+TEMPLATE_VBoxR3DllNoPic-x86_DEFS           = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBoxR3DllNoPic_DEFS)) \
+	HC_ARCH_BITS=32 ARCH_BITS=32
+
+
 #
 # Template for building performance critical stuff without warnings-as-errors.
@@ -3637,6 +3680,6 @@
  TEMPLATE_VBoxR3DllWarnNoPic_LDFLAGS       = $(TEMPLATE_VBOXR3EXE_LDFLAGS)
 else ifeq ($(KBUILD_TARGET),win)
- TEMPLATE_VBoxR3DllNoPic_CFLAGS.release    = $(TEMPLATE_VBOXR3_CFLAGS.release) -GS-
- TEMPLATE_VBoxR3DllNoPic_CXXFLAGS.release  = $(TEMPLATE_VBOXR3_CXXFLAGS.release) -GS-
+ TEMPLATE_VBoxR3DllWarnNoPic_CFLAGS.release   = $(TEMPLATE_VBOXR3_CFLAGS.release) -GS-
+ TEMPLATE_VBoxR3DllWarnNoPic_CXXFLAGS.release = $(TEMPLATE_VBOXR3_CXXFLAGS.release) -GS-
 endif
 
@@ -3849,5 +3892,7 @@
 # (Same transformation as for VBOXR3NPEXE.)
 #
-TEMPLATE_VBOXR3NP= VBox Ring 3 Non-pedantic
+# @deprecated Use VBoxR3DllNonPedantic!
+#
+TEMPLATE_VBOXR3NP = VBox Ring 3 Non-pedantic
 TEMPLATE_VBOXR3NP_EXTENDS = VBOXR3
 ifneq ($(KBUILD_TARGET),win) # (only gcc)
@@ -3857,4 +3902,26 @@
 	-Wno-sign-compare -Werror-implicit-function-declaration
 endif
+
+
+#
+# Template for building bad C/C++ style R3 shared libraries / Dlls (no -pedantic).
+# (Same transformation as for VBoxR3ExeNonPedantic.)
+#
+TEMPLATE_VBoxR3DllNonPedantic               = VBox ring-3 Non-pedantic, with warnings.
+TEMPLATE_VBoxR3DllNonPedantic_EXTENDS       = VBOXR3
+ifneq ($(KBUILD_TARGET),win) # (only gcc)
+ TEMPLATE_VBoxR3DllNonPedantic_TOOL         = $(VBOX_GCC_TOOL)
+ TEMPLATE_VBoxR3DllNonPedantic_CXXFLAGS     = $(filter-out -pedantic -Wshadow,$(TEMPLATE_VBOXR3_CXXFLAGS)) -Wno-sign-compare
+ TEMPLATE_VBoxR3DllNonPedantic_CFLAGS       = $(filter-out -pedantic -Wshadow -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations,$(TEMPLATE_VBOXR3_CFLAGS)) \
+	-Wno-sign-compare -Werror-implicit-function-declaration
+endif
+
+# x86 edition of the above template for use on AMD64 targets.
+TEMPLATE_VBoxR3DllNonPedantic-x86           = 32-bit VBox ring-3 SO/DLLs, no warnings
+TEMPLATE_VBoxR3DllNonPedantic-x86_EXTENDS   = VBoxR3DllNonPedantic
+TEMPLATE_VBoxR3DllNonPedantic-x86_BLD_TRG_ARCH = x86
+TEMPLATE_VBoxR3DllNonPedantic-x86_DEFS      = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBoxR3Dll_DEFS)) \
+	HC_ARCH_BITS=32 ARCH_BITS=32
+
 
 
@@ -4134,4 +4201,16 @@
 	-compatibility_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
 
+TEMPLATE_VBoxMainComp-x86  = 32-bit VBox Main Component (shared library)
+TEMPLATE_VBoxMainComp-x86_EXTENDS = VBOXMAINCOMP
+TEMPLATE_VBoxMainComp-x86_BLD_TRG_ARCH = x86
+TEMPLATE_VBoxMainComp-x86_DEFS = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBOXMAINCOMP_DEFS)) HC_ARCH_BIT=32 ARCH_BITS=32 \
+	VBOX_IN_32_ON_64_MAIN_API
+TEMPLATE_VBoxMainComp-x86_LIBS = \
+	$(subst $(PATH_STAGE_LIB)/VBoxCOM$(VBOX_SUFF_LIB),$(PATH_STAGE_LIB)/VBoxCOM-x86$(VBOX_SUFF_LIB),\
+	$(subst $(LIB_RUNTIME),$(VBOX_LIB_RUNTIME_X86),\
+	$(subst $(LIB_XPCOM),$(VBOX_LIB_XPCOM_X86),\
+	$(TEMPLATE_VBOXMAINCOMP_LIBS))))
+
+
 #
 # Template for building the Main static libraries.
@@ -4139,7 +4218,13 @@
 # This differs from VBOXMAINDLL only that it zeroes out the _LIBS definition.
 #
-TEMPLATE_VBOXMAINLIB  = VBox Main Component (static library)
-TEMPLATE_VBOXMAINLIB_EXTENDS = VBOXMAINDLL
-TEMPLATE_VBOXMAINLIB_LIBS =
+TEMPLATE_VBoxMainLib  = VBox Main Component (static library)
+TEMPLATE_VBoxMainLib_EXTENDS = VBOXMAINDLL
+TEMPLATE_VBoxMainLib_LIBS =
+
+TEMPLATE_VBoxMainLib-x86  = 32-bit VBox Main Component (static library)
+TEMPLATE_VBoxMainLib-x86_EXTENDS = VBoxMainLib
+TEMPLATE_VBoxMainLib-x86_BLD_TRG_ARCH = x86
+TEMPLATE_VBoxMainLib-x86_DEFS = $(filter-out HC_ARCH_BITS%,$(TEMPLATE_VBoxMainLib_DEFS)) HC_ARCH_BIT=32 ARCH_BITS=32 \
+	VBOX_IN_32_ON_64_MAIN_API
 
 #
Index: /trunk/src/VBox/HostDrivers/Support/Makefile.kmk
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/Makefile.kmk	(revision 48281)
+++ /trunk/src/VBox/HostDrivers/Support/Makefile.kmk	(revision 48282)
@@ -32,4 +32,7 @@
 #
 LIBRARIES += SUPR3 SUPR3Static SUPR3HardenedStatic
+ifdef VBOX_WITH_32_ON_64_MAIN_API
+ LIBRARIES += SUPR3-x86
+endif
 ifndef VBOX_ONLY_DOCS
  if1of ($(VBOX_LDR_FMT), pe lx)
@@ -85,4 +88,8 @@
 	SUPR3HardenedVerify.cpp \
 	$(KBUILD_TARGET)/SUPLib-$(KBUILD_TARGET).cpp
+
+SUPR3-x86_TEMPLATE = VBoxR3Dll-x86
+SUPR3-x86_EXTENDS  = SUPR3
+
 
 #
Index: /trunk/src/VBox/Installer/solaris/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Installer/solaris/Makefile.kmk	(revision 48281)
+++ /trunk/src/VBox/Installer/solaris/Makefile.kmk	(revision 48282)
@@ -267,6 +267,14 @@
 	components/VBoxSVCM.so \
 	components/VBoxXPCOMIPCC.so
+ifdef VBOX_WITH_32_ON_64_MAIN_API
+ SOLARIS_STRIP_BINS += \
+	VBoxRT-x86.so \
+	VBoxXPCOM-x86.so \
+	components/VBoxClient-x86.so \
+	components/VBoxSVCM-x86.so \
+	components/VBoxXPCOMIPCC-x86.so
+endif
 ifdef VBOX_WITH_HARDENING
-SOLARIS_STRIP_BINS += \
+ SOLARIS_STRIP_BINS += \
 	VBoxNetDHCP.so \
 	VBoxNetNAT.so \
@@ -530,4 +538,8 @@
 #
 # -=-=-=-=-=-=-=- Main package -=-=-=-=-=-=-=-
+#
+# !!WARNING!!  The current packing may NOT produce the expected rules in
+# !!WARNING!!  incremental build!  Removed and renamed components may
+# !!WARNING!!  appear in the package!  Always do clean builds for customers.
 #
 
@@ -615,5 +627,10 @@
  ifdef VBOX_WITH_PYTHON
 	$(QUIET)$(if $(SOL64_PKG),$(MKDIR) -p $(SOLARIS_VBOXINST_DIR)/$(VBOX_SOL_PYTHON_DIR_64),)
+  ifdef VBOX_WITH_32_ON_64_MAIN_API
+	$(QUIET)$(INSTALL) -m 0644 $(if $(VBOX_DO_STRIP),-s) $(filter     %_x86.so,$(wildcard $(SOLARIS_OUT_BIN)/VBoxPython*.so)) $(SOLARIS_VBOXINST_DIR)/
+	$(QUIET)$(INSTALL) -m 0644 $(if $(VBOX_DO_STRIP),-s) $(filter-out %_x86.so,$(wildcard $(SOLARIS_OUT_BIN)/VBoxPython*.so)) $(SOLARIS_VBOXINST_DIR)/$(VBOX_SOL_PYTHON_DIR_64)/
+  else
 	$(QUIET)$(INSTALL) -m 0644 $(if $(VBOX_DO_STRIP),-s) $(wildcard $(SOLARIS_OUT_BIN)/VBoxPython*.so)                   $(SOLARIS_VBOXINST_DIR)/$(if $(SOL64_PKG),$(VBOX_SOL_PYTHON_DIR_64)/,)
+  endif
  endif
 	$(QUIET)$(if $(VBOX_WITH_QTGUI),$(if $(VBOX_WITH_QT4_SUN),$(INSTALL) -m 0755 $(VBOX_PATH_QT4)/bin/qtconfig           $(SOLARIS_VBOXINST_DIR_ISA)/VBoxQtconfig,),)
Index: /trunk/src/VBox/Main/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Main/Makefile.kmk	(revision 48281)
+++ /trunk/src/VBox/Main/Makefile.kmk	(revision 48282)
@@ -168,5 +168,5 @@
 #
 LIBRARIES += VBoxAPIWrap
-VBoxAPIWrap_TEMPLATE        = VBOXMAINLIB
+VBoxAPIWrap_TEMPLATE        = VBoxMainLib
 VBoxAPIWrap_SOURCES         = $(VBoxAPIWrap_GENERATEDCPP)
 VBoxAPIWrap_GENERATEDCPP    = $(filter %.cpp,$(VBoxAPIWrap_GENERATEDSOURCES))
@@ -187,4 +187,9 @@
 include $(VBoxAPIWrap_KMK)
 
+ifdef VBOX_WITH_32_ON_64_MAIN_API
+LIBRARIES += VBoxAPIWrap-x86
+VBoxAPIWrap-x86_TEMPLATE = VBoxMainLib-x86
+VBoxAPIWrap-x86_EXTENDS  = VBoxAPIWrap
+endif
 
 #
@@ -542,4 +547,12 @@
  endif
 VBoxSVCM_INTERMEDIATES += $(VBOX_IDL_HEADER.XPCOM)
+
+ # 32-bit version of the module.
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxSVCM-x86
+VBoxSVCM-x86_TEMPLATE = VBoxMainComp-x86
+VBoxSVCM-x86_EXTENDS  = VBoxSVCM
+ endif
+
 endif # VBOX_WITH_XPCOM
 
@@ -574,6 +587,10 @@
 	$(if $(VBOX_WITH_PCI_PASSTHROUGH),VBOX_WITH_PCI_PASSTHROUGH,) \
 	$(if $(VBOX_WITH_VPX),VBOX_WITH_VPX,)
-
-
+ifdef VBOX_WITH_CRHGSMI
+ VBoxC_DEFS += VBOX_WITH_CRHGSMI
+endif
+ifdef VBOX_WITH_NETSHAPER
+ VBoxC_DEFS += VBOX_WITH_NETSHAPER
+endif
 VBoxC_DEFS.darwin.x86 = VBOX_WITH_2X_4GB_ADDR_SPACE
 VBoxC_DEFS.win.x86 += _WIN32_WINNT=0x0500
@@ -605,5 +622,4 @@
 	$(if-expr "$(LIB_VMM)" == "$(VBOX_LIB_VMM_LAZY)",$(LIB_REM),) \
 	$(VBOX_LIB_VMM_LAZY)
-
 ifdef VBOX_WITH_NETFLT
  VBoxC_LIBS.win += \
@@ -621,7 +637,6 @@
 endif
 
-
-VBoxC_INTERMEDIATES =            \
-	$(VBOX_MAIN_PREREQS)     \
+VBoxC_INTERMEDIATES = \
+	$(VBOX_MAIN_PREREQS) \
 	$(VBOX_XML_SCHEMADEFS_H) \
 	$(VBOX_AUTOGEN_EVENT_H)
@@ -676,45 +691,31 @@
 	src-client/win/VBoxC.def \
 	src-client/win/VBoxC.rc
-
 ifdef VBOX_WITH_GUEST_CONTROL
-VBoxC_SOURCES += \
+ VBoxC_SOURCES += \
 	src-client/GuestSessionImplTasks.cpp \
 	src-client/GuestCtrlPrivate.cpp
 endif
-
 ifdef VBOX_WITH_DRAG_AND_DROP
-VBoxC_SOURCES += \
+ VBoxC_SOURCES += \
 	src-client/GuestDnDImpl.cpp
 endif
-
 ifdef VBOX_WITH_XPCOM
-VBoxC_SOURCES += \
+ VBoxC_SOURCES += \
 	src-client/xpcom/module.cpp
 endif
-
 ifdef VBOX_WITH_HGCM
-VBoxC_SOURCES += \
+ VBoxC_SOURCES += \
 	src-client/HGCMObjects.cpp \
 	src-client/HGCMThread.cpp \
 	src-client/HGCM.cpp
 endif
-
-ifdef VBOX_WITH_CRHGSMI
-VBoxC_DEFS += VBOX_WITH_CRHGSMI
-endif
-
 ifdef VBOX_WITH_USB
-VBoxC_SOURCES += \
+ VBoxC_SOURCES += \
 	src-client/RemoteUSBBackend.cpp
 endif
-
 ifdef VBOX_WITH_VPX
-VBoxC_SOURCES += \
+ VBoxC_SOURCES += \
 	src-client/EbmlWriter.cpp \
 	src-client/VideoRec.cpp
-endif
-
-ifdef VBOX_WITH_NETSHAPER
-VBoxC_DEFS += VBOX_WITH_NETSHAPER
 endif
 
@@ -738,4 +739,33 @@
 	$(VBOX_XSLTPROC) --stringparam Module VBoxC -o $@ $< $(VBOX_XIDL_FILE)
 
+ifdef VBOX_WITH_32_ON_64_MAIN_API
+ #
+ # 32-bit VBox API Client In-Process module.
+ #
+ DLLS += VBoxClient-x86
+ VBoxClient-x86_TEMPLATE = VBoxMainComp-x86
+ VBoxClient-x86_EXTENDS  = VBoxC
+ VBoxClient-x86_DEFS = VBOX_COM_INPROC_API_CLIENT $(VBoxC_DEFS)
+ VBoxClient-x86_SOURCES = \
+ 	src-all/EventImpl.cpp \
+ 	src-all/Global.cpp \
+ 	src-all/VirtualBoxBase.cpp \
+ 	src-all/VirtualBoxErrorInfoImpl.cpp \
+ 	src-client/ClientTokenHolder.cpp \
+ 	src-client/SessionImpl.cpp \
+ 	src-client/VirtualBoxClientImpl.cpp \
+ 	$(VBOX_AUTOGEN_EVENT_CPP) \
+ 	$(VBOX_XML_SCHEMADEFS_CPP)
+ VBoxClient-x86_SOURCES.win = \
+ 	src-client/win/dllmain.cpp \
+ 	src-client/win/VBoxC.def \
+ 	src-client/win/VBoxC.rc
+ ifdef VBOX_WITH_XPCOM
+  VBoxClient-x86_SOURCES += \
+  	src-client/xpcom/module.cpp
+ endif
+ VBoxClient-x86_LIBS = $(NO_SUCH_VARIABLE)
+endif
+
 
 #
@@ -743,5 +773,5 @@
 #
 LIBRARIES += VBoxCOM
-VBoxCOM_TEMPLATE        = VBOXMAINLIB
+VBoxCOM_TEMPLATE        = VBoxMainLib
 VBoxCOM_INTERMEDIATES   = $(VBOX_MAIN_PREREQS)
 VBoxCOM_SOURCES         = \
@@ -769,4 +799,12 @@
 	$(if $(VBOX_BLEEDING_EDGE),VBOX_BLEEDING_EDGE=\"$(VBOX_BLEEDING_EDGE)\",)
 
+# 32-bit version of VBoxCOM.
+ifdef VBOX_WITH_32_ON_64_MAIN_API
+ LIBRARIES += VBoxCOM-x86
+ VBoxCOM-x86_TEMPLATE = VBoxMainLib-x86
+ VBoxCOM-x86_EXTENDS  = VBoxCOM
+endif
+
+
 
 #
Index: /trunk/src/VBox/Main/glue/initterm.cpp
===================================================================
--- /trunk/src/VBox/Main/glue/initterm.cpp	(revision 48281)
+++ /trunk/src/VBox/Main/glue/initterm.cpp	(revision 48282)
@@ -338,8 +338,15 @@
     vrc = RTStrCopy(szXptiDat, sizeof(szXptiDat), szCompReg);
     AssertRCReturn(vrc, NS_ERROR_FAILURE);
+#ifdef VBOX_IN_32_ON_64_MAIN_API
+    vrc = RTPathAppend(szCompReg, sizeof(szCompReg), "compreg-x86.dat");
+    AssertRCReturn(vrc, NS_ERROR_FAILURE);
+    vrc = RTPathAppend(szXptiDat, sizeof(szXptiDat), "xpti-x86.dat");
+    AssertRCReturn(vrc, NS_ERROR_FAILURE);
+#else
     vrc = RTPathAppend(szCompReg, sizeof(szCompReg), "compreg.dat");
     AssertRCReturn(vrc, NS_ERROR_FAILURE);
     vrc = RTPathAppend(szXptiDat, sizeof(szXptiDat), "xpti.dat");
     AssertRCReturn(vrc, NS_ERROR_FAILURE);
+#endif
 
     LogFlowFunc(("component registry  : \"%s\"\n", szCompReg));
Index: /trunk/src/VBox/Main/glue/vboxapi.py
===================================================================
--- /trunk/src/VBox/Main/glue/vboxapi.py	(revision 48281)
+++ /trunk/src/VBox/Main/glue/vboxapi.py	(revision 48282)
@@ -37,8 +37,12 @@
     # Will be set by the installer
     VBoxBinDir = "%VBOX_INSTALL_PATH%"
+else:
+    VBoxBinDir = os.path.abspath(VBoxBinDir);
 
 if VBoxSdkDir is None:
     # Will be set by the installer
     VBoxSdkDir = "%VBOX_SDK_PATH%"
+else:
+    VBoxBinDir = os.path.abspath(VBoxSdkDir);
 
 os.environ["VBOX_PROGRAM_PATH"] = VBoxBinDir
Index: /trunk/src/VBox/Main/include/SessionImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/SessionImpl.h	(revision 48281)
+++ /trunk/src/VBox/Main/include/SessionImpl.h	(revision 48282)
@@ -1,4 +1,3 @@
 /** @file
- *
  * VBox Client Session COM Class definition
  */
@@ -122,5 +121,7 @@
     ComPtr<IInternalMachineControl> mControl;
 
+#ifndef VBOX_COM_INPROC_API_CLIENT
     ComObjPtr<Console> mConsole;
+#endif
 
     ComPtr<IMachine> mRemoteMachine;
@@ -134,4 +135,4 @@
 };
 
-#endif // ____H_SESSIONIMPL
+#endif // !____H_SESSIONIMPL
 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
Index: /trunk/src/VBox/Main/src-client/SessionImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/SessionImpl.cpp	(revision 48281)
+++ /trunk/src/VBox/Main/src-client/SessionImpl.cpp	(revision 48282)
@@ -165,14 +165,19 @@
 
     HRESULT rc;
+#ifndef VBOX_COM_INPROC_API_CLIENT
     if (mConsole)
        rc = mConsole->machine().queryInterfaceTo(aMachine);
     else
+#endif
        rc = mRemoteMachine.queryInterfaceTo(aMachine);
     if (FAILED(rc))
     {
         /** @todo VBox 3.3: replace E_FAIL with rc here. */
+#ifndef VBOX_COM_INPROC_API_CLIENT
         if (mConsole)
             setError(E_FAIL, tr("Failed to query the session machine (%Rhrc)"), rc);
-        else if (FAILED_DEAD_INTERFACE(rc))
+        else
+#endif
+        if (FAILED_DEAD_INTERFACE(rc))
             setError(E_FAIL, tr("Peer process crashed"));
         else
@@ -195,7 +200,9 @@
 
     HRESULT rc;
+#ifndef VBOX_COM_INPROC_API_CLIENT
     if (mConsole)
         rc = mConsole.queryInterfaceTo(aConsole);
     else
+#endif
         rc = mRemoteConsole.queryInterfaceTo(aConsole);
 
@@ -203,7 +210,10 @@
     {
         /** @todo VBox 3.3: replace E_FAIL with rc here. */
+#ifndef VBOX_COM_INPROC_API_CLIENT
         if (mConsole)
             setError(E_FAIL, tr("Failed to query the console (%Rhrc)"), rc);
-        else if (FAILED_DEAD_INTERFACE(rc))
+        else
+#endif
+        if (FAILED_DEAD_INTERFACE(rc))
             setError(E_FAIL, tr("Peer process crashed"));
         else
@@ -262,4 +272,5 @@
     AssertReturn(mState != SessionState_Unlocked, VBOX_E_INVALID_VM_STATE);
 
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertMsgReturn(mType == SessionType_WriteLock && !!mConsole,
                     ("This is not a direct session!\n"),
@@ -276,4 +287,8 @@
 
     return S_OK;
+
+#else  /* VBOX_COM_INPROC_API_CLIENT */
+    return VBOX_E_INVALID_OBJECT_STATE;
+#endif /* VBOX_COM_INPROC_API_CLIENT */
 }
 
@@ -313,4 +328,5 @@
     AssertReturn(!!mControl, E_FAIL);
 
+#ifndef VBOX_COM_INPROC_API_CLIENT
     rc = mConsole.createObject();
     AssertComRCReturn(rc, rc);
@@ -318,4 +334,5 @@
     rc = mConsole->init(aMachine, mControl, aLockType);
     AssertComRCReturn(rc, rc);
+#endif
 
     Utf8Str strTokenId(aTokenId);
@@ -353,4 +370,5 @@
         /* some cleanup */
         mControl.setNull();
+#ifndef VBOX_COM_INPROC_API_CLIENT
         if (!mConsole.isNull())
         {
@@ -358,4 +376,5 @@
             mConsole.setNull();
         }
+#endif
     }
 
@@ -465,7 +484,11 @@
 
     AssertReturn(!mControl.isNull(), E_FAIL);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(!mConsole.isNull(), E_FAIL);
 
     return mConsole->updateMachineState(aMachineState);
+#else
+    return S_OK;
+#endif
 }
 
@@ -529,7 +552,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onNetworkAdapterChange(networkAdapter, changeAdapter);
+#else
+    return S_OK;
+#endif
 }
 
@@ -544,7 +571,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onSerialPortChange(serialPort);
+#else
+    return S_OK;
+#endif
 }
 
@@ -559,7 +590,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onParallelPortChange(parallelPort);
+#else
+    return S_OK;
+#endif
 }
 
@@ -574,7 +609,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onStorageControllerChange();
+#else
+    return S_OK;
+#endif
 }
 
@@ -589,7 +628,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onMediumChange(aMediumAttachment, aForce);
+#else
+    return S_OK;
+#endif
 }
 
@@ -604,7 +647,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onCPUChange(aCPU, aRemove);
+#else
+    return S_OK;
+#endif
 }
 
@@ -619,7 +666,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onCPUExecutionCapChange(aExecutionCap);
+#else
+    return S_OK;
+#endif
 }
 
@@ -634,7 +685,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onVRDEServerChange(aRestart);
+#else
+    return S_OK;
+#endif
 }
 
@@ -649,7 +704,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onVideoCaptureChange();
+#else
+    return S_OK;
+#endif
 }
 
@@ -664,7 +723,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onUSBControllerChange();
+#else
+    return S_OK;
+#endif
 }
 
@@ -679,7 +742,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onSharedFolderChange(aGlobal);
+#else
+    return S_OK;
+#endif
 }
 
@@ -694,7 +761,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onClipboardModeChange(aClipboardMode);
+#else
+    return S_OK;
+#endif
 }
 
@@ -708,7 +779,11 @@
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onDragAndDropModeChange(aDragAndDropMode);
+#else
+    return S_OK;
+#endif
 }
 
@@ -725,7 +800,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onUSBDeviceAttach(aDevice, aError, aMaskedIfs);
+#else
+    return S_OK;
+#endif
 }
 
@@ -741,7 +820,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onUSBDeviceDetach(aId, aError);
+#else
+    return S_OK;
+#endif
 }
 
@@ -754,5 +837,7 @@
 
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
-    AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
+    AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
+#endif
 
     if (mState != SessionState_Locked)
@@ -767,5 +852,9 @@
     }
 
+#ifndef VBOX_COM_INPROC_API_CLIENT
     return mConsole->onShowWindow(aCheck, aCanShow, aWinId);
+#else
+    return S_OK;
+#endif
 }
 
@@ -780,7 +869,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onBandwidthGroupChange(aBandwidthGroup);
+#else
+    return S_OK;
+#endif
 }
 
@@ -795,7 +888,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->onStorageDeviceChange(aMediumAttachment, aRemove, aSilent);
+#else
+    return S_OK;
+#endif
 }
 
@@ -803,5 +900,5 @@
                                           BOOL aIsSetter, BSTR *aRetValue, LONG64 *aRetTimestamp, BSTR *aRetFlags)
 {
-#ifdef VBOX_WITH_GUEST_PROPS
+#if defined(VBOX_WITH_GUEST_PROPS) && !defined(VBOX_COM_INPROC_API_CLIENT)
     AutoCaller autoCaller(this);
     AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
@@ -846,5 +943,5 @@
                                                ComSafeArrayOut(BSTR, aFlags))
 {
-#ifdef VBOX_WITH_GUEST_PROPS
+#if defined(VBOX_WITH_GUEST_PROPS) && !defined(VBOX_COM_INPROC_API_CLIENT)
     AutoCaller autoCaller(this);
     AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
@@ -896,4 +993,5 @@
                         tr("Machine is not locked by session (session state: %s)."),
                         Global::stringifySessionState(mState));
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
@@ -906,4 +1004,7 @@
                                        ComSafeArrayInArg(aChildrenToReparent),
                                        aProgress);
+#else
+    return E_NOTIMPL;
+#endif
 }
 
@@ -916,4 +1017,5 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
@@ -921,4 +1023,7 @@
 
     return S_OK;
+#else
+    return E_NOTIMPL;
+#endif
 }
 
@@ -931,7 +1036,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->pause(aReason);
+#else
+    return E_NOTIMPL;
+#endif
 }
 
@@ -944,7 +1053,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->resume(aReason);
+#else
+    return E_NOTIMPL;
+#endif
 }
 
@@ -957,7 +1070,11 @@
     AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
     AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
     AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
 
     return mConsole->saveState(aReason, aProgress);
+#else
+    return E_NOTIMPL;
+#endif
 }
 
@@ -1015,4 +1132,5 @@
     if (mType == SessionType_WriteLock)
     {
+#ifndef VBOX_COM_INPROC_API_CLIENT
         if (!mConsole.isNull())
         {
@@ -1020,9 +1138,12 @@
             mConsole.setNull();
         }
+#endif
     }
     else
     {
         mRemoteMachine.setNull();
+#ifndef VBOX_COM_INPROC_API_CLIENT
         mRemoteConsole.setNull();
+#endif
     }
 
Index: /trunk/src/VBox/Main/src-client/xpcom/module.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/xpcom/module.cpp	(revision 48281)
+++ /trunk/src/VBox/Main/src-client/xpcom/module.cpp	(revision 48282)
@@ -60,7 +60,13 @@
 // XPCOM glue code unfolding
 
+NS_DECL_CLASSINFO(VirtualBoxClient)
+NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VirtualBoxClient, IVirtualBoxClient)
+NS_DECL_CLASSINFO(Session)
+NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Session, ISession, IInternalSessionControl)
+
+#ifndef VBOX_COM_INPROC_API_CLIENT
 NS_DECL_CLASSINFO(Guest)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Guest, IGuest)
-#ifdef VBOX_WITH_GUEST_CONTROL
+ #ifdef VBOX_WITH_GUEST_CONTROL
 NS_DECL_CLASSINFO(GuestDirectory)
 NS_IMPL_THREADSAFE_ISUPPORTS2_CI(GuestDirectory, IGuestDirectory, IDirectory)
@@ -73,5 +79,5 @@
 NS_DECL_CLASSINFO(GuestSession)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(GuestSession, IGuestSession)
-#endif
+ #endif
 NS_DECL_CLASSINFO(Keyboard)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard)
@@ -92,5 +98,5 @@
 NS_DECL_CLASSINFO(VRDEServerInfo)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VRDEServerInfo, IVRDEServerInfo)
-#ifdef VBOX_WITH_EXTPACK
+ #ifdef VBOX_WITH_EXTPACK
 // deliberately omit ExtPackFile as it's unusable in the client context
 // NS_DECL_CLASSINFO(ExtPackFile)
@@ -100,15 +106,12 @@
 NS_DECL_CLASSINFO(ExtPackManager)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ExtPackManager, IExtPackManager)
-#endif
+ #endif
 NS_DECL_CLASSINFO(AdditionsFacility)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(AdditionsFacility, IAdditionsFacility)
 
-NS_DECL_CLASSINFO(Session)
-NS_IMPL_THREADSAFE_ISUPPORTS2_CI(Session, ISession, IInternalSessionControl)
 NS_DECL_CLASSINFO(Console)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Console, IConsole)
 
-NS_DECL_CLASSINFO(VirtualBoxClient)
-NS_IMPL_THREADSAFE_ISUPPORTS1_CI(VirtualBoxClient, IVirtualBoxClient)
+#endif /* VBOX_COM_INPROC_API_CLIENT */
 
 /**
Index: /trunk/src/VBox/Runtime/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Runtime/Makefile.kmk	(revision 48281)
+++ /trunk/src/VBox/Runtime/Makefile.kmk	(revision 48282)
@@ -108,4 +108,7 @@
  LIBRARIES.win.x86 += RuntimeR3VccTricks
  DLLS += VBoxRT
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+  DLLS += VBoxRT-x86
+ endif
 endif
 
@@ -1307,5 +1310,9 @@
 VBoxRT_SOURCES.$(KBUILD_TARGET) = $(RuntimeR3_SOURCES.$(KBUILD_TARGET))
 VBoxRT_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH) := $(RuntimeR3_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
+VBoxRT_SOURCES.$(KBUILD_TARGET).x86   := $(RuntimeR3_SOURCES.$(KBUILD_TARGET).x86)
+VBoxRT_SOURCES.$(KBUILD_TARGET).amd64 := $(RuntimeR3_SOURCES.$(KBUILD_TARGET).amd64)
 VBoxRT_SOURCES.$(KBUILD_TARGET_ARCH) := $(RuntimeR3_SOURCES.$(KBUILD_TARGET_ARCH))
+VBoxRT_SOURCES.x86   := $(RuntimeR3_SOURCES.x86)
+VBoxRT_SOURCES.amd64 := $(RuntimeR3_SOURCES.amd64)
 VBoxRT_SOURCES.win            += \
 	r3/win/dllmain-win.cpp \
@@ -1405,4 +1412,68 @@
 endif # linux
 
+
+#
+# VBoxRT-x86 - 32-bit version of VBoxRT
+#
+VBoxRT-x86_EXTENDS = VBoxRT
+VBoxRT-x86_TEMPLATE = VBoxR3Dll-x86
+VBoxRT-x86_SDKS  = VBOX_LIBXML2 VBOX_BOOST
+ifdef VBOX_WITH_LIBCURL
+ VBoxRT-x86_SDKS += VBOX_LIBCURL-x86
+endif
+VBoxRT-x86_SDKS  += VBOX_OPENSSL-x86
+
+VBoxRT-x86_LIBS = \
+	$(PATH_STAGE_LIB)/VBox-liblzf-x86$(VBOX_SUFF_LIB)
+if1of ($(KBUILD_TARGET_ARCH), amd64 x86)
+VBoxRT-x86_LIBS += \
+	$(PATH_STAGE_LIB)/SUPR3-x86$(VBOX_SUFF_LIB)
+endif
+ifdef IPRT_WITH_KSTUFF
+ VBoxRT-x86_LIBS                  += \
+	$(PATH_STAGE_LIB)/VBox-kStuff-x86$(VBOX_SUFF_LIB)
+endif
+ifndef SDK_VBOX_LIBXML2_LIBS
+ VBoxRT-x86_LIBS                 += \
+	$(PATH_STAGE_LIB)/VBox-libxml2-x86$(VBOX_SUFF_LIB)
+endif
+VBoxRT-x86_LIBS                  += \
+	$(SDK_VBOX_ZLIB_LIBS.x86)
+ifndef SDK_VBOX_OPENSSL_LIBS
+ VBoxRT-x86_LIBS                 += \
+	$(PATH_STAGE_LIB)/VBox-libcrypto-x86$(VBOX_SUFF_LIB) \
+	$(PATH_STAGE_LIB)/VBox-libssl-x86$(VBOX_SUFF_LIB)
+endif
+ifdef IPRT_WITH_LZO
+ VBoxRT-x86_LIBS                  += lzo2
+endif
+VBoxRT-x86_LIBS.linux              = \
+	crypt
+VBoxRT-x86_LIBS.darwin             = \
+	iconv
+VBoxRT-x86_LIBS.freebsd            = \
+	iconv \
+	rt
+VBoxRT-x86_LIBS.haiku              = \
+	iconv
+VBoxRT-x86_LIBS.solaris            = \
+	kstat \
+	contract
+ifn1of ($(KBUILD_TARGET_ARCH), sparc32 sparc64)
+ # SMBIOS not available on Solaris SPARC.
+ VBoxRT-x86_LIBS.solaris += smbios
+endif
+VBoxRT-x86_LIBS.win                = \
+	$(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/vccomsup.lib \
+	$(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/wbemuuid.lib
+
+VBoxRT-x86_SOURCES.win = $(filter-out %.def,$(VBoxRT_SOURCES.win),) $(VBoxRT-x86_0_OUTDIR)/VBoxRT.def
+if1of ($(DLLS), VBoxRT-x86)
+$$(VBoxRT-x86_0_OUTDIR)/VBoxRT.def: \
+		$(PATH_SUB_CURRENT)/r3/win/VBoxRT-win32.def \
+		$(PATH_SUB_CURRENT)/r3/win/$(if $(VBOX_OSE),VBoxRT-openssl-ose.def,VBoxRT-openssl.def)
+	$(RM) -f -- $@
+	$(REDIRECT) -wto $@ -- $(CAT_EXT) $^
+endif
 
 #
@@ -2183,5 +2254,5 @@
  $(lib)_common/err/errmsgxpcom.cpp_DEPS = $(IPRT_OUT_DIR)/errmsgvboxcomdata.h
 endef
-$(foreach lib,RuntimeR3 RuntimeBldProg VBoxRT,$(eval $(def_errmsgwin_deps)))
+$(foreach lib,RuntimeR3 RuntimeBldProg VBoxRT VBoxRT-x86,$(eval $(def_errmsgwin_deps)))
 
 
Index: /trunk/src/libs/kStuff/Makefile.kmk
===================================================================
--- /trunk/src/libs/kStuff/Makefile.kmk	(revision 48281)
+++ /trunk/src/libs/kStuff/Makefile.kmk	(revision 48282)
@@ -71,4 +71,9 @@
 	iprt/kRdrFile-iprt.cpp
 
+ifdef VBOX_WITH_32_ON_64_MAIN_API # 32-bit edition.
+ LIBRARIES += VBox-kStuff-x86
+ VBox-kStuff-x86_TEMPLATE = VBoxR3Dll-x86
+ VBox-kStuff-x86_EXTENDS = VBox-kStuff
+endif
 
 #
Index: /trunk/src/libs/liblzf-3.4/Makefile.kmk
===================================================================
--- /trunk/src/libs/liblzf-3.4/Makefile.kmk	(revision 48281)
+++ /trunk/src/libs/liblzf-3.4/Makefile.kmk	(revision 48282)
@@ -41,4 +41,11 @@
 VBox-liblzf-static_SOURCES    = $(VBox-liblzf_SOURCES)
 
+ifdef VBOX_WITH_32_ON_64_MAIN_API # 32-bit edition.
+ LIBRARIES += VBox-liblzf-x86
+ VBox-liblzf-x86_TEMPLATE = VBoxR3Dll-x86
+ VBox-liblzf-x86_EXTENDS = VBox-liblzf
+endif
+
+
 include $(FILE_KBUILD_SUB_FOOTER)
 
Index: /trunk/src/libs/libxml2-2.6.31/Makefile.kmk
===================================================================
--- /trunk/src/libs/libxml2-2.6.31/Makefile.kmk	(revision 48281)
+++ /trunk/src/libs/libxml2-2.6.31/Makefile.kmk	(revision 48282)
@@ -80,4 +80,11 @@
 # VBox-libxml2_SDKS.win      += WINPSDK
 
+ifdef VBOX_WITH_32_ON_64_MAIN_API # 32-bit edition.
+ LIBRARIES += VBox-libxml2-x86
+ VBox-libxml2-x86_TEMPLATE = VBoxR3DllNonPedantic-x86
+ VBox-libxml2-x86_EXTENDS = VBox-libxml2
+endif
+
+
 include $(FILE_KBUILD_SUB_FOOTER)
 
Index: /trunk/src/libs/xpcom18a4/Config.kmk
===================================================================
--- /trunk/src/libs/xpcom18a4/Config.kmk	(revision 48281)
+++ /trunk/src/libs/xpcom18a4/Config.kmk	(revision 48282)
@@ -25,4 +25,5 @@
 #
 VBOX_PATH_XPCOM_SRC := $(PATH_ROOT)/src/libs/xpcom18a4
+
 
 #
@@ -259,4 +260,26 @@
 TEMPLATE_XPCOMOSX107_DEFS.darwin        = $(filter-out $(VBOX_DARWIN_DEF_SDK_DEFS),$(TEMPLATE_XPCOM_DEFS.darwin)) $(VBOX_DARWIN_DEF_SDK_10_7_DEFS)
 TEMPLATE_XPCOMOSX107_INCS.darwin        = $(VBOX_PATH_MACOSX_SDK_10_7)/Developer/Headers/FlatCarbon
+
+
+#
+# Creates a x86 target for an XPCOM target if so desired.
+# The target is specified as the first argument: $(evalcall VBOX_XPCOM_X86,target).
+#
+ifdef VBOX_WITH_32_ON_64_MAIN_API
+ define VBOX_XPCOM_X86
+  $(1)-x86_TEMPLATE := $(strip $($(1)_TEMPLATE))-x86
+  $(1)-x86_EXTENDS  := $(1)
+ endef
+else
+ define VBOX_XPCOM_X86
+ endef
+endif
+
+# Corresponding 32-bit template(s).
+TEMPLATE_XPCOM-x86                  = 32-bit XPCOM libraries (shared)
+TEMPLATE_XPCOM-x86_EXTENDS          = XPCOM
+TEMPLATE_XPCOM-x86_BLD_TRG_ARCH     = x86
+TEMPLATE_XPCOM-x86_DEFS             = $(TEMPLATE_XPCOM_DEFS) VBOX_IN_32_ON_64_MAIN_API
+TEMPLATE_XPCOM-x86_LIBS             = $(subst $(LIB_RUNTIME),$(VBOX_LIB_RUNTIME_X86),$(TEMPLATE_XPCOM_LIBS))
 
 
Index: /trunk/src/libs/xpcom18a4/Makefile.kmk
===================================================================
--- /trunk/src/libs/xpcom18a4/Makefile.kmk	(revision 48281)
+++ /trunk/src/libs/xpcom18a4/Makefile.kmk	(revision 48282)
@@ -75,5 +75,5 @@
 ifndef VBOX_ONLY_SDK
 
-LIBRARIES += \
+VBOX_XPCOM_LIBRARIES := \
 	VBox-xpcom-nspr \
 	VBox-xpcom-typelib \
@@ -87,15 +87,19 @@
 	VBox-xpcom-xptcall \
 	VBox-xpcom-proxy \
+	VBox-xpcom-ipcshared \
 	VBoxXPCOMGlue_s \
-	$(if $(VBOX_WITH_XPCOM_GLUE_WHICH_IS_UNUSED),VBoxXPCOMGlue,) \
-	VBox-xpcom-ipcutils \
-	VBox-xpcom-ipcshared \
-	VBox-xpcom-ipcdlock \
-	VBox-xpcom-ipctransmgr \
-	VBox-xpcom-ipctmgrcom
-
-DLLS += \
-	VBoxXPCOM \
+	$(if $(VBOX_WITH_XPCOM_GLUE_WHICH_IS_UNUSED),VBoxXPCOMGlue,)
+LIBRARIES += $(VBOX_XPCOM_LIBRARIES)
+
+VBOX_XPCOM_DLLS := \
+    VBoxXPCOM \
 	VBoxXPCOMIPCC
+DLLS += $(VBOX_XPCOM_DLLS)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+LIBRARIES += $(addsuffix -x86,$(VBOX_XPCOM_LIBRARIES))
+DLLS      += $(addsuffix -x86,$(VBOX_XPCOM_DLLS))
+ endif
+
 
  ifdef VBOX_WITH_TESTCASES
@@ -676,4 +680,6 @@
 	$(QUIET)$(APPEND) -t $@ '#define _BUILD_STRING "$(date +%Y-%m-%d %T)"'
 
+$(evalcall2 VBOX_XPCOM_X86,VBox-xpcom-nspr)
+
 
 VBox-xpcom-typelib_TEMPLATE = XPCOM
@@ -683,4 +689,5 @@
 	xpcom/typelib/xpt/src/xpt_struct.c \
 	xpcom/typelib/xpt/src/xpt_xdr.c
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-typelib)
 
 VBox-xpcom-string_TEMPLATE = XPCOM
@@ -698,4 +705,5 @@
 	xpcom/string/src/nsStringComparator.cpp \
 	xpcom/string/src/nsStringObsolete.cpp
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-string)
 
 VBox-xpcom-base_TEMPLATE = XPCOM
@@ -713,4 +721,5 @@
 	xpcom/base/nsTraceRefcntImpl.cpp \
 	xpcom/base/nsStackFrameUnix.cpp
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-base)
 
 VBox-xpcom-ds_TEMPLATE = XPCOM
@@ -752,4 +761,5 @@
 	xpcom/ds/nsArrayEnumerator.cpp
 #   xpcom/ds/nsHashPropertyBag.cpp
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-ds)
 
 # @todo what about MOZ_USER_DIR?
@@ -793,4 +803,5 @@
 VBox-xpcom-io_SOURCES.os2 = \
 	xpcom/io/nsLocalFileOS2.cpp
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-io)
 
 VBox-xpcom-components_TEMPLATE = XPCOM
@@ -805,4 +816,5 @@
 	xpcom/components/xcDll.cpp \
 	xpcom/components/nsStaticComponentLoader.cpp
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-components)
 
 VBox-xpcom-threads_TEMPLATE = XPCOM
@@ -819,4 +831,5 @@
 	xpcom/threads/nsProcessCommon.cpp \
 	xpcom/threads/TimerThread.cpp
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-threads)
 
 VBox-xpcom-xptinfo_TEMPLATE = XPCOM
@@ -833,4 +846,5 @@
 	xpcom/reflect/xptinfo/src/xptiZipItem.cpp \
 	xpcom/reflect/xptinfo/src/xptiZipLoader.cpp
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-xptinfo)
 
 
@@ -867,5 +881,4 @@
     xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp
 endif
-
 xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_solaris.cpp_CXXFLAGS = -O0
 # -O0 works fine, while -O1 doesn't. The gcc man page can't be listing all the -f*
@@ -874,13 +887,17 @@
 # bug and it's not worth investigating as I'm not the maintainger of the solaris gcc port. [bird, 2007-09-17]
 
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-xptcall)
+
 
 VBox-xpcom-proxy_TEMPLATE = XPCOM
 VBox-xpcom-proxy_INSTTYPE = none
 VBox-xpcom-proxy_DEFS     = _IMPL_NS_COM EXPORT_XPTC_API EXPORT_XPTI_API
-VBox-xpcom-proxy_SOURCES  = xpcom/proxy/src/nsProxyEvent.cpp \
-                            xpcom/proxy/src/nsProxyEventClass.cpp \
-                            xpcom/proxy/src/nsProxyEventObject.cpp \
-                            xpcom/proxy/src/nsProxyObjectManager.cpp \
-                            xpcom/proxy/src/nsProxyRelease.cpp
+VBox-xpcom-proxy_SOURCES  = \
+    xpcom/proxy/src/nsProxyEvent.cpp \
+    xpcom/proxy/src/nsProxyEventClass.cpp \
+    xpcom/proxy/src/nsProxyEventObject.cpp \
+    xpcom/proxy/src/nsProxyObjectManager.cpp \
+    xpcom/proxy/src/nsProxyRelease.cpp
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-proxy)
 
 
@@ -918,4 +935,5 @@
 VBoxXPCOMGlue_s_DEFS     = _IMPL_NS_COM
 VBoxXPCOMGlue_s_SOURCES  = $(VBoxXPCOMGlue_COMMON_SOURCES)
+$(evalcall VBOX_XPCOM_X86,VBoxXPCOMGlue_s)
 
 # standalone glue library which all third-party client apps (if any) will
@@ -924,4 +942,5 @@
 VBoxXPCOMGlue_SOURCES  = $(VBoxXPCOMGlue_COMMON_SOURCES)
 #VBoxXPCOMGlue_INST     = lib/ $(INST_SDK)lib/
+$(evalcall VBOX_XPCOM_X86,VBoxXPCOMGlue)
 
 
@@ -1000,4 +1019,60 @@
 VBoxXPCOM_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxXPCOM.dylib
 
+#
+# The 32-bit VBoxXPCOM Shared Object, assembling all lib files.
+#
+VBoxXPCOM-x86_TEMPLATE = XPCOM-x86
+VBoxXPCOM-x86_EXTENDS = VBoxXPCOM
+VBoxXPCOM-x86_NAME = VBoxXPCOM-x86
+VBoxXPCOM-x86_LIBS = \
+	$(VBox-xpcom-typelib-x86_1_TARGET) \
+	$(VBox-xpcom-string-x86_1_TARGET) \
+	$(VBox-xpcom-base-x86_1_TARGET) \
+	$(VBox-xpcom-ds-x86_1_TARGET) \
+	$(VBox-xpcom-io-x86_1_TARGET) \
+	$(VBox-xpcom-components-x86_1_TARGET) \
+	$(VBox-xpcom-threads-x86_1_TARGET) \
+	$(VBox-xpcom-xptinfo-x86_1_TARGET) \
+	$(VBox-xpcom-xptcall-x86_1_TARGET) \
+	$(VBox-xpcom-proxy-x86_1_TARGET) \
+	$(VBox-xpcom-nspr-x86_1_TARGET) \
+	$(VBoxXPCOMGlue_s-x86_1_TARGET)
+
+ifeq ($(filter-out freebsd linux netbsd openbsd,$(KBUILD_TARGET)),) # gnu ld.
+VBoxXPCOM-x86_LDFLAGS = -Wl,--whole-archive \
+	$(VBox-xpcom-typelib-x86_1_TARGET) \
+	$(VBox-xpcom-string-x86_1_TARGET) \
+	$(VBox-xpcom-base-x86_1_TARGET) \
+	$(VBox-xpcom-ds-x86_1_TARGET) \
+	$(VBox-xpcom-io-x86_1_TARGET) \
+	$(VBox-xpcom-components-x86_1_TARGET) \
+	$(VBox-xpcom-threads-x86_1_TARGET) \
+	$(VBox-xpcom-xptinfo-x86_1_TARGET) \
+	$(VBox-xpcom-xptcall-x86_1_TARGET) \
+	$(VBox-xpcom-proxy-x86_1_TARGET) \
+	$(VBox-xpcom-nspr-x86_1_TARGET) \
+	$(VBoxXPCOMGlue_s-x86_1_TARGET) \
+	-Wl,--no-whole-archive
+endif
+
+VBoxXPCOM-x86_LDFLAGS.solaris += -Wl,-z,allextract \
+	$(VBox-xpcom-typelib-x86_1_TARGET) \
+	$(VBox-xpcom-string-x86_1_TARGET) \
+	$(VBox-xpcom-base-x86_1_TARGET) \
+	$(VBox-xpcom-ds-x86_1_TARGET) \
+	$(VBox-xpcom-io-x86_1_TARGET) \
+	$(VBox-xpcom-components-x86_1_TARGET) \
+	$(VBox-xpcom-threads-x86_1_TARGET) \
+	$(VBox-xpcom-xptinfo-x86_1_TARGET) \
+	$(VBox-xpcom-xptcall-x86_1_TARGET) \
+	$(VBox-xpcom-proxy-x86_1_TARGET) \
+	$(VBox-xpcom-nspr-x86_1_TARGET) \
+	$(VBoxXPCOMGlue_s-x86_1_TARGET) \
+	-Wl,-z,defaultextract
+
+
+#
+# IPC templates.
+#
 ifdef VBOX_IPC_RELEASE_LOG
 IPC_LOGGING = 1
@@ -1014,6 +1089,22 @@
  TEMPLATE_XPCOMIPC_DEFS           += IPC_LOGGING
 endif
-
 TEMPLATE_XPCOMIPC_LIBS             = $(VBoxXPCOM_1_TARGET) $(TEMPLATE_XPCOM_LIBS)
+ifneq ($(KBUILD_TARGET),win)
+ ifeq ($(filter-out solaris.x86 %.amd64 %.sparc32 %.sparc64,$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)),) ## TODO: cleanup!
+  if defined(VBOX_WITH_RELATIVE_RUNPATH) && !defined(VBOX_WITH_HARDENING)
+   TEMPLATE_XPCOMIPC_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)%',$(TEMPLATE_XPCOM_LDFLAGS)) '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/..'
+  endif
+ else ifndef VBOX_WITH_HARDENING
+  ifdef VBOX_WITH_RELATIVE_RUNPATH
+   TEMPLATE_XPCOMIPC_LDFLAGS = $(filter-out '$(VBOX_GCC_RPATH_OPT)%',$(TEMPLATE_XPCOM_LDFLAGS)) '$(VBOX_GCC_RPATH_OPT)$(VBOX_WITH_RELATIVE_RUNPATH)/..'
+  endif
+ endif
+endif
+
+TEMPLATE_XPCOMIPC-x86              = 32-bit XPCOM IPC libraries
+TEMPLATE_XPCOMIPC-x86_EXTENDS      = XPCOMIPC
+TEMPLATE_XPCOMIPC-x86_BLD_TRG_ARCH = x86
+TEMPLATE_XPCOMIPC-x86_LIBS         = $(VBoxXPCOM-x86_1_TARGET) $(TEMPLATE_XPCOM-x86_LIBS)
+
 
 TEMPLATE_XPCOMIPCEXE               = XPCOM IPC executables
@@ -1024,10 +1115,7 @@
 endif
 
-VBox-xpcom-ipcutils_TEMPLATE = XPCOMIPC
-VBox-xpcom-ipcutils_INSTTYPE = none
-VBox-xpcom-ipcutils_SOURCES = \
-	ipc/ipcd/util/src/ipcMessageReader.cpp \
-	ipc/ipcd/util/src/ipcMessageWriter.cpp
-
+#
+# Shared IPC code. Used by the IPC component as well as the executables.
+#
 VBox-xpcom-ipcshared_TEMPLATE = XPCOMIPC
 VBox-xpcom-ipcshared_INSTTYPE = none
@@ -1040,21 +1128,5 @@
 	ipc/ipcd/shared/src/ipcIDList.cpp \
 	ipc/ipcd/shared/src/ipcm.cpp
-
-VBox-xpcom-ipcdlock_TEMPLATE = XPCOMIPC
-VBox-xpcom-ipcdlock_INSTTYPE = none
-VBox-xpcom-ipcdlock_SOURCES = \
-	ipc/ipcd/extensions/lock/src/ipcLockProtocol.cpp \
-	ipc/ipcd/extensions/lock/src/ipcLockService.cpp
-
-VBox-xpcom-ipctransmgr_TEMPLATE = XPCOMIPC
-VBox-xpcom-ipctransmgr_INSTTYPE = none
-VBox-xpcom-ipctransmgr_SOURCES = \
-	ipc/ipcd/extensions/transmngr/src/tmTransactionService.cpp
-
-VBox-xpcom-ipctmgrcom_TEMPLATE = XPCOMIPC
-VBox-xpcom-ipctmgrcom_INSTTYPE = none
-VBox-xpcom-ipctmgrcom_SOURCES = \
-	ipc/ipcd/extensions/transmngr/common/tmTransaction.cpp \
-	ipc/ipcd/extensions/transmngr/common/tmVector.cpp
+$(evalcall VBOX_XPCOM_X86,VBox-xpcom-ipcshared)
 
 
@@ -1070,5 +1142,17 @@
 	ipc/ipcd/client/src/ipcService.cpp \
 	ipc/ipcd/client/src/ipcModuleFactory.cpp \
-	ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
+	ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp\
+    \
+	ipc/ipcd/util/src/ipcMessageReader.cpp \
+	ipc/ipcd/util/src/ipcMessageWriter.cpp \
+    \
+	ipc/ipcd/extensions/lock/src/ipcLockProtocol.cpp \
+	ipc/ipcd/extensions/lock/src/ipcLockService.cpp \
+    \
+	ipc/ipcd/extensions/transmngr/src/tmTransactionService.cpp \
+    \
+	ipc/ipcd/extensions/transmngr/common/tmTransaction.cpp \
+	ipc/ipcd/extensions/transmngr/common/tmVector.cpp
+
 ifeq ($(KBUILD_TARGET),win)
 VBoxXPCOMIPCC_SOURCES += \
@@ -1080,11 +1164,10 @@
 VBoxXPCOMIPCC_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/components/VBoxXPCOMIPCC.dylib
 VBoxXPCOMIPCC_LIBS = \
-	$(VBox-xpcom-ipcutils_1_TARGET) \
-	$(VBox-xpcom-ipcshared_1_TARGET) \
-	$(VBox-xpcom-ipcdlock_1_TARGET) \
-	$(VBox-xpcom-ipctransmgr_1_TARGET) \
-	$(VBox-xpcom-ipctmgrcom_1_TARGET)
-# EF
-#VBoxXPCOMIPCC_LIBS += $(LIB_RUNTIME)
+	$(VBox-xpcom-ipcshared_1_TARGET)
+
+# 32-bit version of the component.
+$(evalcall VBOX_XPCOM_X86,VBoxXPCOMIPCC)
+VBoxXPCOMIPCC-x86_LIBS = \
+	$(VBox-xpcom-ipcshared-x86_1_TARGET)
 
 
Index: /trunk/src/libs/xpcom18a4/python/Makefile.kmk
===================================================================
--- /trunk/src/libs/xpcom18a4/python/Makefile.kmk	(revision 48281)
+++ /trunk/src/libs/xpcom18a4/python/Makefile.kmk	(revision 48282)
@@ -27,5 +27,5 @@
 #
 # List of supported Python versions, defining a number of
-# VBOX_PYTHON[25|26|27|28|DEF]_[INC|LIB] variables which get picked up below.
+# VBOX_PYTHON[25|26|27|DEF]_[INC|LIB] variables which get picked up below.
 #
 ifeq ($(KBUILD_TARGET),darwin) # Relatively predictable, don't script.
@@ -33,4 +33,5 @@
   VBOX_PYTHON25_INC = $(VBOX_PATH_MACOSX_SDK)/usr/include/python2.5
   VBOX_PYTHON25_LIB = $(VBOX_PATH_MACOSX_SDK)/usr/lib/libpython2.5.dylib
+  VBOX_PYTHON25_LIB_X86 = $(VBOX_PYTHON25_LIB)
  endif
  if  !defined(VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_6) \
@@ -39,4 +40,5 @@
   VBOX_PYTHON26_INC = $(VBOX_PATH_MACOSX_SDK_10_6)/usr/include/python2.6
   VBOX_PYTHON26_LIB = $(VBOX_PATH_MACOSX_SDK_10_6)/usr/lib/libpython2.6.dylib
+  VBOX_PYTHON26_LIB_X86 = $(VBOX_PYTHON26_LIB)
  endif
  if  !defined(VBOX_WITHOUT_VBOXPYTHON_FOR_OSX_10_7) \
@@ -45,4 +47,5 @@
   VBOX_PYTHON27_INC = $(VBOX_PATH_MACOSX_SDK_10_7)/usr/include/python2.7
   VBOX_PYTHON27_LIB = $(VBOX_PATH_MACOSX_SDK_10_7)/usr/lib/libpython2.7.dylib
+  VBOX_PYTHON27_LIB_X86 = $(VBOX_PYTHON27_LIB)
  endif
 
@@ -103,4 +106,12 @@
 	$(PATH_STAGE_BIN)/VBoxXPCOM$(VBOX_SUFF_DLL)
 
+# 32-bit base.
+VBoxPythonBase_x86_TEMPLATE = XPCOM-x86
+VBoxPythonBase_x86_EXTENDS  = VBoxPythonBase
+VBoxPythonBase_x86_DEFS     = MODULE_NAME_SUFFIX=_x86 $(VBoxPythonBase_DEFS)
+VBoxPythonBase_x86_LIBS     = \
+	$(PATH_STAGE_LIB)/VBoxCOM-x86$(VBOX_SUFF_LIB) \
+	$(PATH_STAGE_BIN)/VBoxXPCOM-x86$(VBOX_SUFF_DLL)
+
 
 ifdef VBOX_PYTHON23_INC
@@ -114,4 +125,13 @@
 VBoxPython2_3_INCS       = $(VBOX_PYTHON23_INC)
 VBoxPython2_3_LIBS       = $(VBOX_PYTHON23_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_3_x86
+VBoxPython2_3_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython2_3_x86_EXTENDS_BY = appending
+VBoxPython2_3_x86_TEMPLATE   = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX104,-x86)
+VBoxPython2_3_x86_INCS       = $(VBOX_PYTHON23_INC)
+VBoxPython2_3_x86_LIBS       = $(VBOX_PYTHON23_LIB_X86)
+ endif
 endif
 
@@ -125,4 +145,12 @@
 VBoxPython2_4_INCS       = $(VBOX_PYTHON24_INC)
 VBoxPython2_4_LIBS       = $(VBOX_PYTHON24_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_4_x86
+VBoxPython2_4_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython2_4_x86_EXTENDS_BY = appending
+VBoxPython2_4_x86_INCS       = $(VBOX_PYTHON24_INC)
+VBoxPython2_4_x86_LIBS       = $(VBOX_PYTHON24_LIB_X86)
+ endif
 endif
 
@@ -134,7 +162,14 @@
 VBoxPython2_5_EXTENDS    = VBoxPythonBase
 VBoxPython2_5_EXTENDS_BY = appending
-VBoxPython2_5_TEMPLATE   = XPCOM
 VBoxPython2_5_INCS       = $(VBOX_PYTHON25_INC)
 VBoxPython2_5_LIBS       = $(VBOX_PYTHON25_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_5_x86
+VBoxPython2_5_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython2_5_x86_EXTENDS_BY = appending
+VBoxPython2_5_x86_INCS       = $(VBOX_PYTHON25_INC)
+VBoxPython2_5_x86_LIBS       = $(VBOX_PYTHON25_LIB_X86)
+ endif
 endif
 
@@ -149,4 +184,13 @@
 VBoxPython2_6_INCS       = $(VBOX_PYTHON26_INC)
 VBoxPython2_6_LIBS       = $(VBOX_PYTHON26_LIB)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_6_x86
+VBoxPython2_6_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython2_6_x86_EXTENDS_BY = appending
+VBoxPython2_6_x86_TEMPLATE   = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX106,-x86)
+VBoxPython2_6_x86_INCS       = $(VBOX_PYTHON26_INC)
+VBoxPython2_6_x86_LIBS       = $(VBOX_PYTHON26_LIB_X86)
+ endif
 endif
 
@@ -160,16 +204,14 @@
 VBoxPython2_7_TEMPLATE   = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX107,)
 VBoxPython2_7_INCS       = $(VBOX_PYTHON27_INC)
-VBoxPython2_7_LIBS       = $(VBOX_PYTHON27_LIB)
-endif
-
-ifdef VBOX_PYTHON28_INC
-#
-# Python 2.8 version
-#
-DLLS += VBoxPython2_8
-VBoxPython2_8_EXTENDS    = VBoxPythonBase
-VBoxPython2_8_EXTENDS_BY = appending
-VBoxPython2_8_INCS       = $(VBOX_PYTHON28_INC)
-VBoxPython2_8_LIBS       = $(VBOX_PYTHON28_LIB)
+VBoxPython2_7_LIBS       = $(VBOX_PYTHON27_LIB_X86)
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+DLLS += VBoxPython2_7_x86
+VBoxPython2_7_x86_EXTENDS    = VBoxPythonBase_x86
+VBoxPython2_7_x86_EXTENDS_BY = appending
+VBoxPython2_7_x86_TEMPLATE   = XPCOM$(if-expr "$(KBUILD_TARGET)" == "darwin",OSX107,-x86)
+VBoxPython2_7_x86_INCS       = $(VBOX_PYTHON27_INC)
+VBoxPython2_7_x86_LIBS       = $(VBOX_PYTHON27_LIB_X86)
+ endif
 endif
 
@@ -187,4 +229,15 @@
  VBoxPython_LIBS        = $(VBoxPythonBase_LIBS) $(VBOX_PYTHONDEF_LIB)
 endif
+
+ ifdef VBOX_WITH_32_ON_64_MAIN_API
+VBoxPython_x86_EXTENDS      = VBoxPythonBase_x86
+VBoxPython_x86_DEFS         = $(filter-out VBOX_PYXPCOM_VERSIONED,$(VBoxPythonBase_x86_DEFS))
+VBoxPython_x86_INCS         = $(VBoxPythonBase_x86_INCS) $(VBOX_PYTHONDEF_INC)
+if "$(KBUILD_TARGET)" == "linux"
+ VBoxPython_x86_LIBS        = $(VBoxPythonBase_x86_LIBS)
+else
+ VBoxPython_x86_LIBS        = $(VBoxPythonBase_x86_LIBS) $(VBOX_PYTHONDEF_LIB_X86)
+endif
+ endif
 endif
 
Index: /trunk/src/libs/xpcom18a4/python/gen_python_deps.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/gen_python_deps.py	(revision 48281)
+++ /trunk/src/libs/xpcom18a4/python/gen_python_deps.py	(revision 48282)
@@ -15,5 +15,5 @@
 import os,sys
 
-versions = ["2.3", "2.4", "2.5", "2.6", "2.7", "2.8"]
+versions = ["2.3", "2.4", "2.5", "2.6", "2.7",]
 prefixes = ["/usr", "/usr/local", "/opt", "/opt/local"]
 known = {}
@@ -44,4 +44,5 @@
     if bitness_magic > 0:
         print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[2], sep)
+        print "VBOX_PYTHON%s_LIB_X86=%s%s" %(vers, known[1], sep)
     else:
         print "VBOX_PYTHON%s_LIB=%s%s" %(vers, known[1], sep)
Index: /trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp
===================================================================
--- /trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp	(revision 48281)
+++ /trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp	(revision 48282)
@@ -75,22 +75,42 @@
 
 #ifdef VBOX_PYXPCOM
+# include <iprt/cdefs.h>
+# ifndef MODULE_NAME_SUFFIX
+#  define MANGLE_MODULE_NAME(a_szName)  a_szName
+#  define MANGLE_MODULE_INIT(a_Name)    a_Name
+# else
+#  define MANGLE_MODULE_NAME(a_szName)  a_szName RT_XSTR(MODULE_NAME_SUFFIX)
+#  define MANGLE_MODULE_INIT(a_Name)    RT_CONCAT(a_Name, MODULE_NAME_SUFFIX)
+# endif
 # ifdef VBOX_PYXPCOM_VERSIONED
 #  if   PY_VERSION_HEX >= 0x02080000
-#   define MODULE_NAME "VBoxPython2_8"
+#   define MODULE_NAME    MANGLE_MODULE_NAME("VBoxPython2_8")
+#   define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_8)
+
 #  elif PY_VERSION_HEX >= 0x02070000
-#   define MODULE_NAME "VBoxPython2_7"
+#   define MODULE_NAME    MANGLE_MODULE_NAME("VBoxPython2_7")
+#   define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_7)
+
 #  elif PY_VERSION_HEX >= 0x02060000
-#   define MODULE_NAME "VBoxPython2_6"
+#   define MODULE_NAME    MANGLE_MODULE_NAME("VBoxPython2_6")
+#   define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_6)
+
 #  elif PY_VERSION_HEX >= 0x02050000
-#   define MODULE_NAME "VBoxPython2_5"
+#   define MODULE_NAME 	  MANGLE_MODULE_NAME("VBoxPython2_5")
+#   define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_5)
+
 #  elif PY_VERSION_HEX >= 0x02040000
-#   define MODULE_NAME "VBoxPython2_4"
+#   define MODULE_NAME    MANGLE_MODULE_NAME("VBoxPython2_4")
+#   define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_4)
+
 #  elif PY_VERSION_HEX >= 0x02030000
-#   define MODULE_NAME "VBoxPython2_3"
+#   define MODULE_NAME    MANGLE_MODULE_NAME("VBoxPython2_3")
+#   define initVBoxPython MANGLE_MODULE_INIT(initVBoxPython2_3)
 #  else
 #   error "Fix module versioning."
 #  endif
 # else
-#  define MODULE_NAME "VBoxPython"
+#  define MODULE_NAME 	  MANGLE_MODULE_NAME("VBoxPython")
+#  define initVBoxPython  MANGLE_MODULE_INIT(initVBoxPython)
 # endif
 #else
@@ -777,23 +797,5 @@
 extern "C" NS_EXPORT
 void
-# ifdef VBOX_PYXPCOM_VERSIONED
-#  if   PY_VERSION_HEX >= 0x02080000
-initVBoxPython2_8() {
-#  elif PY_VERSION_HEX >= 0x02070000
-initVBoxPython2_7() {
-#  elif PY_VERSION_HEX >= 0x02060000
-initVBoxPython2_6() {
-#  elif PY_VERSION_HEX >= 0x02050000
-initVBoxPython2_5() {
-#  elif PY_VERSION_HEX >= 0x02040000
-initVBoxPython2_4() {
-#  elif PY_VERSION_HEX >= 0x02030000
-initVBoxPython2_3() {
-#  else
-#   error "Fix module versioning."
-#  endif
-# else
-initVBoxPython() {
-# endif
+initVBoxPython() { /* NOTE! This name is redefined at the top of the file! */
   static bool s_vboxInited = false;
   if (!s_vboxInited) {
Index: /trunk/src/libs/xpcom18a4/python/vboxxpcom.py
===================================================================
--- /trunk/src/libs/xpcom18a4/python/vboxxpcom.py	(revision 48281)
+++ /trunk/src/libs/xpcom18a4/python/vboxxpcom.py	(revision 48282)
@@ -15,37 +15,48 @@
 import platform
 
-# this code overcomes somewhat unlucky feature of Python, where it searches
+#
+# This code overcomes somewhat unlucky feature of Python, where it searches
 # for binaries in the same place as platfom independent modules, while
 # rest of Python bindings expect _xpcom to be inside xpcom module
+#
 
-candidates = ['VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1]), 
-              'VBoxPython' + str(sys.version_info[0]), 
-              'VBoxPython']
+_asVBoxPythons = [
+    'VBoxPython' + str(sys.version_info[0]) + '_' + str(sys.version_info[1]),
+    'VBoxPython' + str(sys.version_info[0]),
+    'VBoxPython'
+];
+
+# On platforms where we ship both 32-bit and 64-bit API bindings, we have to
+# look for the right set if we're a 32-bit process.
+if platform.system() in [ 'SunOS', ] and sys.maxsize <= 2**32:
+    _asNew = [ sCandidate + '_x86' for sCandidate in _asVBoxPythons ];
+    _asNew.extend(_asVBoxPythons);
+    _asVBoxPythons = _asNew;
+    del _asNew;
+
+# On Darwin (aka Mac OS X) we know exactly where things are in a normal
+# VirtualBox installation.
+## @todo Edit this at build time to the actual VBox location set in the make files.
+## @todo We know the location for most hardened builds, not just darwin!
 if platform.system() == 'Darwin':
-    # On Darwin (aka Mac OS X) we know exactly where things are in a normal 
-    # VirtualBox installation. Also, there are two versions of python there
-    # (2.3.x and 2.5.x) depending on whether the os is striped or spotty, so
-    # we have to choose the right module to load.
-    # 
-    # XXX: This needs to be adjusted for OSE builds. A more general solution would 
-    #      be to to sed the file during install and inject the VBOX_PATH_APP_PRIVATE_ARCH
-    #      and VBOX_PATH_SHARED_LIBS when these are set.
     sys.path.append('/Applications/VirtualBox.app/Contents/MacOS')
 
-cglue = None
-for m in candidates:
-   try:
-      cglue =  __import__(m)
-      break
-   except:
-      pass
+_oVBoxPythonMod = None
+for m in _asVBoxPythons:
+    try:
+        _oVBoxPythonMod =  __import__(m)
+        break
+    except Exception, x:
+        print 'm=%s x=%s' % (m, x);
+    #except:
+    #    pass
 
 if platform.system() == 'Darwin':
     sys.path.remove('/Applications/VirtualBox.app/Contents/MacOS')
 
-if cglue == None:
-    raise Exception, "Cannot find VBoxPython module"
+if _oVBoxPythonMod == None:
+    raise Exception('Cannot find VBoxPython module (tried: %s)' % (', '.join(_asVBoxPythons),));
 
-sys.modules['xpcom._xpcom'] = cglue
-xpcom._xpcom = cglue
+sys.modules['xpcom._xpcom'] = _oVBoxPythonMod;
+xpcom._xpcom = _oVBoxPythonMod;
 
Index: /trunk/src/libs/xpcom18a4/xpcom/components/nsNativeComponentLoader.cpp
===================================================================
--- /trunk/src/libs/xpcom18a4/xpcom/components/nsNativeComponentLoader.cpp	(revision 48281)
+++ /trunk/src/libs/xpcom18a4/xpcom/components/nsNativeComponentLoader.cpp	(revision 48282)
@@ -675,4 +675,5 @@
     *registered = PR_FALSE;
 
+#ifndef VBOX
     /* this should be a pref or registry entry, or something */
     static const char *ValidDllExtensions[] = {
@@ -749,4 +750,51 @@
         // Skip invalid extensions
         return NS_OK;
+
+#else /* VBOX */
+    /* VBox: Only one valid suffix exist, so dispense with the the list. */
+# ifdef RT_OS_DARWIN
+#  ifdef VBOX_IN_32_ON_64_MAIN_API
+    static const char s_szSuff[]        = "-x86.dylib";
+#  else
+    static const char s_szSuff[]        = ".dylib";
+    static const char s_szSuffInvalid[] = "-x86.dylib";
+#  endif
+# elif defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
+#  ifdef VBOX_IN_32_ON_64_MAIN_API
+    static const char s_szSuff[]        = "-x86.dll";
+#else
+    static const char s_szSuff[]        = ".dll";
+    static const char s_szSuffInvalid[] = "-x86.dll";
+#  endif
+# else
+#  ifdef VBOX_IN_32_ON_64_MAIN_API
+    static const char s_szSuff[]        = "-x86.so";
+#else
+    static const char s_szSuff[]        = ".so";
+    static const char s_szSuffInvalid[] = "-x86.so";
+#  endif
+# endif
+
+    nsCAutoString strLeafName;
+    rv = component->GetNativeLeafName(strLeafName);
+    if (NS_FAILED(rv))
+        return rv;
+    size_t cchLeafName = strLeafName.Length();
+    if (   cchLeafName <= sizeof(s_szSuff)
+        || PL_strcasecmp(strLeafName.get() + cchLeafName - sizeof(s_szSuff) + 1, s_szSuff))
+    {
+        PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("Skipping '%s'...", strLeafName.get()));
+        return NS_OK; /* skip */
+    }
+# ifndef VBOX_IN_32_ON_64_MAIN_API
+    if (   cchLeafName >= sizeof(s_szSuffInvalid)
+        && !PL_strcasecmp(strLeafName.get() + cchLeafName - sizeof(s_szSuffInvalid) + 1, s_szSuffInvalid))
+    {
+        PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("Skipping '%s' (#2)...", strLeafName.get()));
+        return NS_OK; /* skip */
+    }
+# endif
+    PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("... '%s'", strLeafName.get()));
+#endif /* VBOX */
 
     nsXPIDLCString persistentDescriptor;
Index: /trunk/src/libs/zlib-1.2.6/Makefile.kmk
===================================================================
--- /trunk/src/libs/zlib-1.2.6/Makefile.kmk	(revision 48281)
+++ /trunk/src/libs/zlib-1.2.6/Makefile.kmk	(revision 48282)
@@ -47,4 +47,10 @@
 VBox-zlib-static_SOURCES = $(VBox-zlib_SOURCES)
 
+ifdef VBOX_WITH_32_ON_64_MAIN_API # 32-bit edition.
+ LIBRARIES += VBox-zlib-x86
+ VBox-zlib-x86_TEMPLATE = VBoxR3Dll-x86
+ VBox-zlib-x86_EXTENDS = VBox-zlib
+endif
+
 include $(FILE_KBUILD_SUB_FOOTER)
 
