Index: trunk/src/VBox/Additions/WINNT/Installer/Languages/English.nsh
===================================================================
--- trunk/src/VBox/Additions/WINNT/Installer/Languages/English.nsh	(revision 39554)
+++ trunk/src/VBox/Additions/WINNT/Installer/Languages/English.nsh	(revision 39558)
@@ -30,4 +30,6 @@
 LangString VBOX_COMPONENT_D3D_OR_WDDM ${LANG_ENGLISH}               "This system supports the Windows Aero (WDDM) interface.$\r$\nVirtualBox support for this feature is experimental and should not be used on production systems yet.$\r$\n$\r$\nWould you like to install basic Direct3D support instead?"
 LangString VBOX_COMPONENT_D3D_HINT_VRAM ${LANG_ENGLISH}             "Please note that in order to use 3D acceleration the virtual machine requires at least 128 MB of video memory with 256 MB recommended if you wish to use it with multiple monitors.$\r$\n$\r$\nIf necessary you can change the video memory size in the $\"Display$\" section of the virtual machine settings."
+LangString VBOX_COMPONENT_D3D_INVALID_WDDM ${LANG_ENGLISH}          "The setup detected a corrupt/invalid DirectX installation and cannot continue.$\r$\n$\r$\nIn order to get Direct3D support working, please re-install the DirectX runtime first.$\r$\n$\r$\nThis setup will abort now."
+LangString VBOX_COMPONENT_D3D_INVALID_XPDM ${LANG_ENGLISH}          "The setup detected a corrupt/invalid DirectX installation.$\r$\n$\r$\nIn order to get Direct3D support working, re-installing the DirectX runtime first is highly recommended.$\r$\n$\r$\nContinue anyway?"
 
 LangString VBOX_WFP_WARN_REPLACE ${LANG_ENGLISH}         "In order to make ${PRODUCT_NAME} work correctly some system files have been replaced.$\r$\nIf the Windows File Protection service offers to restore the original files you should cancel the request to retain the newly installed functionality."
Index: trunk/src/VBox/Additions/WINNT/Installer/Languages/French.nsh
===================================================================
--- trunk/src/VBox/Additions/WINNT/Installer/Languages/French.nsh	(revision 39554)
+++ trunk/src/VBox/Additions/WINNT/Installer/Languages/French.nsh	(revision 39558)
@@ -30,4 +30,6 @@
 LangString VBOX_COMPONENT_D3D_OR_WDDM ${LANG_FRENCH}                "Ce système supporte l'interface Windows Aero (WDDM).$\r$\nLe support VirtualBox pour cette fonctionalité est expérimental et ne devrait pas encore être utilisé sur des systèmes importants.$\r$\n$\r$\nVoulez-vous installer le support Direct3D de base à la place?"
 LangString VBOX_COMPONENT_D3D_HINT_VRAM ${LANG_FRENCH}              "Veuillez noter que l'utilisation de l'accélération 3D nécécssite au moins 128 MB de mémoire vidéo ; pour un utilisation avec plusieurs écrans nous recommandons  d'affecter 256 MB.$\r$\n$\r$\nSi nécéssaire vous pouvez changer la taille du mémoire vidéo dans la sous-section $\"Affichage$\" des paramètres de la machine virtuelle."
+LangString VBOX_COMPONENT_D3D_INVALID_WDDM ${LANG_FRENCH}           "The setup detected a corrupt/invalid DirectX installation and cannot continue.$\r$\n$\r$\nIn order to get Direct3D support working, please re-install the DirectX runtime first.$\r$\n$\r$\nThis setup will abort now."
+LangString VBOX_COMPONENT_D3D_INVALID_XPDM ${LANG_FRENCH}           "The setup detected a corrupt/invalid DirectX installation.$\r$\n$\r$\nIn order to get Direct3D support working, re-installing the DirectX runtime first is highly recommended.$\r$\n$\r$\nContinue anyway?"
 
 LangString VBOX_WFP_WARN_REPLACE ${LANG_FRENCH}          "Le programme d'installation vient de remplacer certains fichiers systèmes afin de faire fonctionner correctement ${PRODUCT_NAME}.$\r$\nPour le cas qu'un avertissement de la Protection de fichiers Windows apparaisse, veuiller l'annuler sans restaurer les fichiers originaux!"
Index: trunk/src/VBox/Additions/WINNT/Installer/Languages/German.nsh
===================================================================
--- trunk/src/VBox/Additions/WINNT/Installer/Languages/German.nsh	(revision 39554)
+++ trunk/src/VBox/Additions/WINNT/Installer/Languages/German.nsh	(revision 39558)
@@ -30,4 +30,6 @@
 LangString VBOX_COMPONENT_D3D_OR_WDDM ${LANG_GERMAN}                "Für diesen Gast ist Windows Aero (WDDM)-Unterstützung verfügbar.$\r$\nDieses Feature ist jedoch noch experimentell und sollte daher noch nicht auf produktiven Systemen eingesetzt werden.$\r$\n$\r$\nMöchten Sie stattdessen die reguläre Direct3D-Unterstützung installieren?"
 LangString VBOX_COMPONENT_D3D_HINT_VRAM ${LANG_GERMAN}              "Bitte beachten Sie, dass die virtuelle Maschine für die Benutzung von 3D-Beschleunigung einen Grafikspeicher von mindestens 128 MB für einen Monitor benötigt und für den Multi-Monitor-Betrieb bis zu 256 MB empfohlen wird.$\r$\n$\r$\nSie können den Grafikspeicher in den VM-Einstellungen in der Kategorie $\"Anzeige$\" ändern."
+LangString VBOX_COMPONENT_D3D_INVALID_WDDM ${LANG_GERMAN}           "Das Setup hat eine ungültige/beschädigte DirectX-Installation festgestellt und kann nicht fortfahren.$\r$\n$\r$\nUm die Direct3D-Unterstützung installieren zu können, muss die DirectX-Runtime neu installiert werden.$\r$\n$\r$\nDas Setup wird nun beendet."
+LangString VBOX_COMPONENT_D3D_INVALID_XPDM ${LANG_GERMAN}           "Das Setup hat eine ungültige/beschädigte DirectX-Installation festgestellt.$\r$\n$\r$\nUm die Direct3D-Unterstützung installieren zu können wird empfohlen, zuerst die DirectX-Runtime neu zu installieren.$\r$\n$\r$\nMit der Installation jetzt trotzdem fortfahren?"
 
 LangString VBOX_WFP_WARN_REPLACE ${LANG_GERMAN}         "Das Setup hat gerade Systemdateien ersetzt um die ${PRODUCT_NAME} korrekt installieren zu können.$\r$\nFalls nun ein Warn-Dialog des Windows-Dateischutzes erscheint, diesen bitte abbrechen und die Dateien nicht wiederherstellen lassen!"
Index: trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditions.nsi
===================================================================
--- trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditions.nsi	(revision 39554)
+++ trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditions.nsi	(revision 39558)
@@ -558,26 +558,4 @@
 FunctionEnd
 
-Function Common_CopyFiles
-
-  SetOutPath "$INSTDIR"
-  SetOverwrite on
-
-!ifdef VBOX_WITH_LICENSE_INSTALL_RTF
-  ; Copy license file (if any) into the installation directory
-  FILE "/oname=${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
-!endif
-
-  FILE "$%VBOX_PATH_DIFX%\DIFxAPI.dll"
-  FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
-
-  FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
-!ifdef VBOX_SIGN_ADDITIONS
-  FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
-!endif
-
-  FILE "iexplore.ico"
-
-FunctionEnd
-
 ; Main Files
 Section $(VBOX_COMPONENT_MAIN) SEC01
@@ -614,4 +592,8 @@
   DetailPrint "Debug!"
 !endif
+
+  ;
+  ; Here starts the main dispatcher (based on guest OS)
+  ;
 
   ; Which OS are we using?
@@ -652,19 +634,22 @@
 !endif
 
-vista: ; Windows Vista / Windows 7 / Windows 8
+w2k: ; Windows 2000 and XP ...
 
   ; Copy some common files ...
   Call Common_CopyFiles
 
+  Call W2K_Main
+  goto success
+
+vista: ; Windows Vista / Windows 7 / Windows 8
+
+  ; Check requirments; this function can abort the installation if necessary!
+  Call Vista_CheckForRequirements
+
+  ; Copy some common files ...
+  Call Common_CopyFiles
+
   Call W2K_Main     ; First install stuff from Windows 2000 / XP
   Call Vista_Main   ; ... and some specific stuff for Vista / Windows 7
-  goto success
-
-w2k: ; Windows 2000 and XP ...
-
-  ; Copy some common files ...
-  Call Common_CopyFiles
-
-  Call W2K_Main
   goto success
 
@@ -974,4 +959,6 @@
   SectionGetFlags ${SEC03} $0
   ${If} $0 == ${SF_SELECTED}
+
+    StrCpy $g_bWithD3D "true"
 
 !if $%VBOX_WITH_WDDM% == "1"
@@ -995,5 +982,5 @@
 d3d_install:
 
-!endif
+!endif ; $%VBOX_WITH_WDDM% == "1"
 
     ${If} $g_bForceInstall != "true"
@@ -1016,16 +1003,10 @@
     ${EndIf}
 
-    ; Validate D3D files
-    Call ValidateD3DFiles
-    Pop $0
-    ${If} $0 == "1"
-      MessageBox MB_ICONINFORMATION|MB_OK "D3D files invalid!" /SD IDOK
-      Goto d3d_disable
-    ${EndIf}
-
   ${Else} ; D3D unselected again
+
     ${If} $g_strWinVersion != "8" ; On Windows 8 WDDM is mandatory
       StrCpy $g_bWithWDDM "false"
     ${EndIf}
+
   ${EndIf}
   Goto exit
@@ -1033,4 +1014,5 @@
 d3d_disable:
 
+  StrCpy $g_bWithD3D "false"
   IntOp $0 $0 & ${SECTION_OFF} ; Unselect section again
   SectionSetFlags ${SEC03} $0
Index: trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsCommon.nsh
===================================================================
--- trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsCommon.nsh	(revision 39554)
+++ trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsCommon.nsh	(revision 39558)
@@ -15,4 +15,26 @@
 ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 ;
+
+Function Common_CopyFiles
+
+  SetOutPath "$INSTDIR"
+  SetOverwrite on
+
+!ifdef VBOX_WITH_LICENSE_INSTALL_RTF
+  ; Copy license file (if any) into the installation directory
+  FILE "/oname=${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
+!endif
+
+  FILE "$%VBOX_PATH_DIFX%\DIFxAPI.dll"
+  FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
+
+  FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
+!ifdef VBOX_SIGN_ADDITIONS
+  FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
+!endif
+
+  FILE "iexplore.ico"
+
+FunctionEnd
 
 !ifndef UNINSTALLER_ONLY
@@ -655,5 +677,5 @@
 ; Verifies a given file by checking its file vendor and target
 ; architecture.
-; @return  Stack: "0" if verify, "1" if not, "2" on error / not found.
+; @return  Stack: "0" if valid, "1" if not, "2" on error / not found.
 ; @param   Stack: Architecture ("x86" or "amd64").
 ; @param   Stack: Vendor.
@@ -672,5 +694,4 @@
   Push $3 ;               S: old$3 old$2 old$1 old$0
 
-MessageBox MB_ICONSTOP "Vendor $1" /SD IDOK
   IfFileExists "$0" check_vendor
   Goto not_found
@@ -681,5 +702,5 @@
   Call ${un}GetFileVendor
   Pop $3
-MessageBox MB_ICONSTOP "$3 vs. $1" /SD IDOK
+
   ${If} $3 == $1
     Goto check_arch
@@ -693,5 +714,5 @@
   Call ${un}GetFileArchitecture
   Pop $3
-MessageBox MB_ICONSTOP "$3 vs. $2" /SD IDOK
+
   ${If} $3 == $2
     StrCpy $3 "0" ; Valid
@@ -707,5 +728,5 @@
 
 end:
-MessageBox MB_ICONSTOP "Res: $3" /SD IDOK
+
   ; S: old$3 old$2 old$1 old$0
   Exch $3 ; S: $3 old$2 old$1 old$0
@@ -722,4 +743,13 @@
 !insertmacro VerifyFile "un."
 
+;
+; Macro for accessing VerifyFile in a more convenient way by using
+; a parameter list.
+; @return  Stack: "0" if valid, "1" if not, "2" on error / not found.
+; @param   Un/Installer prefix; either "" or "un".
+; @param   Name of file to verify.
+; @param   Vendor to check for.
+; @param   Architecture ("x86" or "amd64") to check for.
+;
 !macro VerifyFileEx un File Vendor Architecture
   Push "${Architecture}"
@@ -731,5 +761,7 @@
 
 ;
-; Validates backed up original Direct3D files.
+; Validates backed up and replaced Direct3D files; either the d3d*.dll have
+; to be from Microsoft or the (already) backed up msd3d*.dll files. If both
+; don't match we have a corrupted / invalid installation.
 ; @return  Stack: "0" if files are valid; otherwise "1".
 ;
@@ -737,8 +769,128 @@
 Function ${un}ValidateD3DFiles
 
-  ; TODO: Here comes the check
-  ${VerifyFileEx} "${un}" "$SYSDIR\foo.dll" "Microsoft Corporation" "x86"
+  Push $0
+
+  ; We need to switch to 64-bit app mode to handle the "real" 64-bit files in
+  ; ""system32" on a 64-bit guest
+  Call ${un}SetAppMode64
+
+  ; Note: Not finding a file (like *d3d8.dll) on Windows Vista/7 is fine;
+  ;       it simply is not present there.
+
+  ${VerifyFileEx} "${un}" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
+  Pop $0
+  ${If} $0 == "1"
+    Goto verify_msd3d
+  ${EndIf}
+  ${VerifyFileEx} "${un}" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
+  Pop $0
+  ${If} $0 == "1"
+    Goto verify_msd3d
+  ${EndIf}
+
+  ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
+  Pop $0
+  ${If} $0 == "1"
+    Goto verify_msd3d
+  ${EndIf}
+  ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
+  Pop $0
+  ${If} $0 == "1"
+    Goto verify_msd3d
+  ${EndIf}
+
+!if $%BUILD_TARGET_ARCH% == "amd64"
+
+  ${VerifyFileEx} "${un}" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
+  Pop $0
+  ${If} $0 == "1"
+    Goto verify_msd3d
+  ${EndIf}
+  ${VerifyFileEx} "${un}" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
+  Pop $0
+  ${If} $0 == "1"
+    Goto verify_msd3d
+  ${EndIf}
+
+  ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
+  Pop $0
+  ${If} $0 == "1"
+    Goto verify_msd3d
+  ${EndIf}
+  ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
+  Pop $0
+  ${If} $0 == "1"
+    Goto verify_msd3d
+  ${EndIf}
+
+!endif
+
+  Goto valid
+
+verify_msd3d:
+
+  ${VerifyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
+  Pop $0
+  ${If} $0 == "1"
+    Goto invalid
+  ${EndIf}
+  ${VerifyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
+  Pop $0
+  ${If} $0 == "1"
+    Goto invalid
+  ${EndIf}
+
+  ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
+  Pop $0
+  ${If} $0 == "1"
+    Goto invalid
+  ${EndIf}
+  ${VerifyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
+  Pop $0
+  ${If} $0 == "1"
+    Goto invalid
+  ${EndIf}
+
+!if $%BUILD_TARGET_ARCH% == "amd64"
+
+  ${VerifyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "Microsoft Corporation" "x86"
+  Pop $0
+  ${If} $0 == "1"
+    Goto invalid
+  ${EndIf}
+  ${VerifyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "Microsoft Corporation" "x86"
+  Pop $0
+  ${If} $0 == "1"
+    Goto invalid
+  ${EndIf}
+
+  ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "Microsoft Corporation" "x86"
+  Pop $0
+  ${If} $0 == "1"
+    Goto invalid
+  ${EndIf}
+  ${VerifyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "Microsoft Corporation" "x86"
+  Pop $0
+  ${If} $0 == "1"
+    Goto invalid
+  ${EndIf}
+
+!endif
+
+  Goto valid
+
+valid:
+
+  StrCpy $0 "0" ; Installation valid
+  Goto end
+
+invalid:
+
+  StrCpy $0 "1" ; Installation invalid / corrupted
+  Goto end
 
 end:
+
+  Exch $0
 
 FunctionEnd
Index: trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsVista.nsh
===================================================================
--- trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsVista.nsh	(revision 39554)
+++ trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsVista.nsh	(revision 39558)
@@ -15,4 +15,47 @@
 ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 ;
+
+Function Vista_CheckForRequirements
+
+  Push $0
+
+  DetailPrint "Checking for installation requirements for Vista / Windows 7 / Windows 8 ..."
+
+  ${If} $g_bForceInstall == "true"
+    DetailPrint "Forcing installatoin, checking requirements skipped"
+    goto success
+  ${EndIf}
+
+  ${If} $g_bWithD3D == "true"
+    ; Validate D3D files
+    Call ValidateD3DFiles
+    Pop $0
+    ${If} $0 == "1" ; D3D files are invalid
+      ${If} $g_bWithWDDM == "true"
+        MessageBox MB_ICONSTOP|MB_OK $(VBOX_COMPONENT_D3D_INVALID_WDDM) /SD IDOK
+        goto failure
+      ${Else}
+        MessageBox MB_ICONSTOP|MB_OKCANCEL $(VBOX_COMPONENT_D3D_INVALID_XPDM) /SD IDCANCEL IDCANCEL failure
+      ${EndIf}
+    ${EndIf}
+  ${EndIf}
+
+  Goto success
+
+failure:
+
+  Abort "ERROR: Requirements not met! Installation aborted."
+  goto exit
+
+success:
+
+  ; Nothing to do here right now
+  Goto exit
+
+exit:
+
+  Pop $0
+
+FunctionEnd
 
 Function Vista_CopyFiles
@@ -39,5 +82,6 @@
 
 error:
-  Abort "ERROR: Could not install files for Vista / Windows 7 / Windows 8! Installation aborted."
+
+  Abort "ERROR: Could not install files! Installation aborted."
 
 done:
