Index: /trunk/src/VBox/Main/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Main/Makefile.kmk	(revision 49907)
+++ /trunk/src/VBox/Main/Makefile.kmk	(revision 49908)
@@ -908,4 +908,20 @@
 
 
+if defined(VBOX_WITH_MIDL_PROXY_STUB) && "$(KBUILD_TARGET)" == "win"
+ #
+ # Experimental COM proxy + stub DLL.
+ #
+ DLLS += VBoxProxyStub
+ VBoxProxyStub_TEMPLATE = VBOXMAINCOMP
+ VBoxProxyStub_DEFS     = REGISTER_PROXY_DLL
+ VBoxProxyStub_SOURCES  = \
+ 	$(VBoxCOM_0_OUTDIR)/dlldata.c \
+ 	$(VBoxCOM_0_OUTDIR)/VirtualBox_p.c \
+ 	$(VBoxCOM_0_OUTDIR)/VirtualBox_i.c \
+       src-all/win/VBoxProxyStub.def
+endif
+
+
+
 # generate rules
 include $(FILE_KBUILD_SUB_FOOTER)
@@ -950,4 +966,5 @@
 $(VBoxCOM_0_OUTDIR)/VirtualBox_i.c \
 + $(VBoxCOM_0_OUTDIR)/VirtualBox.h \
+$(if $(VBOX_WITH_MIDL_PROXY_STUB),+ $(VBoxCOM_0_OUTDIR)/VirtualBox_p.c + $(VBoxCOM_0_OUTDIR)/dlldata.c,) \
 + $(VBoxCOM_0_OUTDIR)/VirtualBox.tlb: $(VBOX_IDL_FILE.MSCOM) | $$(dir $$@)
 	$(VBOX_WIN_MIDL) /nologo \
@@ -961,4 +978,5 @@
 $(VBoxCOM-x86_0_OUTDIR)/VirtualBox_i.c \
 + $(VBoxCOM-x86_0_OUTDIR)/VirtualBox.h \
+$(if $(VBOX_WITH_MIDL_PROXY_STUB),+ $(VBoxCOM-x86_0_OUTDIR)/VirtualBox_p.c + $(VBoxCOM-x86_0_OUTDIR)/dlldata.c,) \
 + $(VBoxCOM-x86_0_OUTDIR)/VirtualBox-x86.tlb: $(VBOX_IDL_FILE.MSCOM) | $$(dir $$@)
 	$(VBOX_WIN_MIDL) /nologo /env win32 /target NT51 \
Index: /trunk/src/VBox/Main/idl/midl.xsl
===================================================================
--- /trunk/src/VBox/Main/idl/midl.xsl	(revision 49907)
+++ /trunk/src/VBox/Main/idl/midl.xsl	(revision 49908)
@@ -158,7 +158,6 @@
     <!-- all enums go first -->
     <xsl:apply-templates select="enum | if/enum"/>
-    <!-- everything else but result codes and enums -->
-    <xsl:apply-templates select="*[not(self::result or self::enum) and
-                                   not(self::if[result] or self::if[enum])]"/>
+    <!-- declare the interfaces -->
+    <xsl:apply-templates select="if | interface"/>
   </xsl:if>
 
@@ -177,13 +176,16 @@
   </xsl:for-each>
   <xsl:text>&#x0A;</xsl:text>
-  <!-- forward declarations -->
-  <xsl:apply-templates select="if | interface" mode="forward"/>
   <xsl:text>&#x0A;</xsl:text>
   <xsl:choose>
     <xsl:when test="$g_fGenProxy = 'yes'">
-      <!-- all enums go first -->
+      <!-- reference enums and interfaces -->
+      <xsl:apply-templates select="if | interface" mode="forward"/>
       <xsl:apply-templates select="enum | if/enum" mode="forward"/>
+      <!-- the modules (i.e. everything else) -->
+      <xsl:apply-templates select="module | if/module"/>
     </xsl:when>
     <xsl:otherwise>
+      <!-- forward declarations -->
+      <xsl:apply-templates select="if | interface" mode="forward"/>
       <!-- all enums go first -->
       <xsl:apply-templates select="enum | if/enum"/>
Index: /trunk/src/VBox/Main/src-all/win/VBoxProxyStub.def
===================================================================
--- /trunk/src/VBox/Main/src-all/win/VBoxProxyStub.def	(revision 49908)
+++ /trunk/src/VBox/Main/src-all/win/VBoxProxyStub.def	(revision 49908)
@@ -0,0 +1,25 @@
+; $Id$
+;; @file
+; VBoxC DLL Definition File.
+;
+
+;
+; Copyright (C) 2006-2013 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.
+;
+
+LIBRARY VBoxProxyStub.dll
+
+EXPORTS
+    DllGetClassObject   PRIVATE
+    DllCanUnloadNow     PRIVATE
+    DllRegisterServer   PRIVATE
+    DllUnregisterServer PRIVATE
+
