Index: /trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp
===================================================================
--- /trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp	(revision 45316)
+++ /trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp	(revision 45317)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2010-2012 Oracle Corporation
+ * Copyright (C) 2010-2013 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -348,11 +348,11 @@
     /* Do not use a global namespace ("Global\\") for mutex name here, will blow up NT4 compatibility! */
     HANDLE hMutexAppRunning = CreateMutex(NULL, FALSE, "VBoxStubInstaller");
-    if (   (hMutexAppRunning != NULL)
-        && (GetLastError() == ERROR_ALREADY_EXISTS))
+    if (   hMutexAppRunning != NULL
+        && GetLastError() == ERROR_ALREADY_EXISTS)
     {
         /* Close the mutex for this application instance. */
         CloseHandle(hMutexAppRunning);
         hMutexAppRunning = NULL;
-        return 1;
+        return RTEXITCODE_FAILURE;
     }
 
@@ -360,5 +360,5 @@
     int vrc = RTR3InitExe(argc, &argv, 0);
     if (RT_FAILURE(vrc))
-        return vrc;
+        return RTMsgInitFailure(vrc);
 
     /*
@@ -494,9 +494,14 @@
     }
 
+    /** @todo The rest of this function should be done in smaller functions,
+     *        we've lost the overview here! Too much state going around! */
+
     HRESULT hr = S_OK;
 
     do /* break loop */
     {
-        /* Get/create our temp path (only if not already set). */
+        /*
+         * Determine and create our temp path (only if not already set).
+         */
         if (szExtractPath[0] == '\0')
         {
@@ -684,4 +689,5 @@
                                     if (hModule)
                                         FreeLibrary(hModule);
+                                    /** @todo program exit code needs to be set */
                                     break;
                                 }
@@ -690,4 +696,6 @@
                             vrc = VERR_NO_CHANGE; /* No change done to the system. */
                         }
+                        else
+                            /** @todo program exit code needs to be for ERROR_INSTALL_USEREXIT. */
                     }
                     RTStrFree(pszTempFile);
@@ -700,5 +708,5 @@
             && RT_SUCCESS(vrc))
         {
-            for (int i=0; i<5; i++)
+            for (int i = 0; i < 5; i++)
             {
                 vrc = RTDirRemoveRecursive(szExtractPath, 0 /*fFlags*/);
@@ -729,17 +737,11 @@
     }
 
-    /* Set final exit (return) code (error level). */
+    /*
+     * Figure the exit code (not very difficult at the moment).
+     */
+    RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
     if (RT_FAILURE(vrc))
-    {
-        switch(vrc)
-        {
-            case VERR_NO_CHANGE:
-            default:
-                vrc = 1;
-        }
-    }
-    else /* Always set to (VINF_SUCCESS), even if we got something else (like a VWRN etc). */
-        vrc = VINF_SUCCESS;
-    return vrc;
-}
-
+        rcExit = RTEXITCODE_FAILURE;
+    return rcExit;
+}
+
Index: /trunk/src/VBox/Installer/win/StubBld/VBoxStubBld.h
===================================================================
--- /trunk/src/VBox/Installer/win/StubBld/VBoxStubBld.h	(revision 45316)
+++ /trunk/src/VBox/Installer/win/StubBld/VBoxStubBld.h	(revision 45317)
@@ -16,36 +16,51 @@
  */
 
-#pragma once
+#ifndef ___VBoxStubBld_h___
+#define ___VBoxStubBld_h___
 
 #define VBOXSTUB_MAX_PACKAGES 128
 
-typedef struct
+typedef struct VBOXSTUBPKGHEADER
 {
-    char szMagic[9];
-    DWORD dwVersion;
-    BYTE byCntPkgs;
+    /** Some magic string not defined by this header? Turns out it's a write only
+     *  field... */
+    char    szMagic[9];
+    /* Inbetween szMagic and dwVersion there are 3 bytes of implicit padding. */
+    /** Some version number not defined by this header? Also write only field.
+     *  Should be a uint32_t, not DWORD. */
+    DWORD   dwVersion;
+    /** Number of packages following the header. byte is prefixed 'b', not 'by'!
+     *  Use uint8_t instead of BYTE. */
+    BYTE    byCntPkgs;
+    /* There are 3 bytes of implicit padding here. */
+} VBOXSTUBPKGHEADER;
+typedef VBOXSTUBPKGHEADER *PVBOXSTUBPKGHEADER;
 
-} VBOXSTUBPKGHEADER, *PVBOXSTUBPKGHEADER;
-
-enum VBOXSTUBPKGARCH
+typedef enum VBOXSTUBPKGARCH
 {
     VBOXSTUBPKGARCH_ALL = 0,
-    VBOXSTUBPKGARCH_X86 = 1,
-    VBOXSTUBPKGARCH_AMD64 = 2
-};
+    VBOXSTUBPKGARCH_X86
+    VBOXSTUBPKGARCH_AMD64
+} VBOXSTUBPKGARCH;
 
-typedef struct
+typedef struct VBOXSTUBPKG
 {
     BYTE byArch;
+    /** Probably the name of the PE resource or something, read the source to
+     *  find out for sure.  Don't use _MAX_PATH, define your own max lengths! */
     char szResourceName[_MAX_PATH];
     char szFileName[_MAX_PATH];
-} VBOXSTUBPKG, *PVBOXSTUBPKG;
+} VBOXSTUBPKG;
+typedef VBOXSTUBPKG *PVBOXSTUBPKG;
 
 /* Only for construction. */
+/* Since it's only used by VBoxStubBld.cpp, why not just keep it there? */
 
-typedef struct
+typedef struct VBOXSTUBBUILDPKG
 {
     char szSourcePath[_MAX_PATH];
     BYTE byArch;
-} VBOXSTUBBUILDPKG, *PVBOXSTUBBUILDPKG;
+} VBOXSTUBBUILDPKG;
+typedef VBOXSTUBBUILDPKG *PVBOXSTUBBUILDPKG;
 
+#endif
