VirtualBox

Changeset 39549 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Dec 7, 2011 3:43:14 PM (13 years ago)
Author:
vboxsync
Message:

Windows Guest Additions installer: Validation of D3D files (work in progress).

Location:
trunk/src/VBox/Additions/WINNT/Installer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditions.nsi

    r39516 r39549  
    205205Var g_iSystemMode                       ; Current system mode (0 = Normal boot, 1 = Fail-safe boot, 2 = Fail-safe with network boot)
    206206Var g_strSystemDir                      ; Windows system directory
     207Var g_strSysWow64                       ; The SysWow64 directory on 64-bit systems
    207208Var g_strCurUser                        ; Current user using the system
    208209Var g_strAddVerMaj                      ; Installed Guest Additions: Major version
     
    835836
    836837  !if $%BUILD_TARGET_ARCH% == "amd64"
    837     ; We need a special directory set to SysWOW64 because some
    838     ; shell operations don't support file redirection (yet)
    839     Var /GLOBAL SYSWOW64DIR
    840     StrCpy $SYSWOW64DIR "$WINDIR\SysWOW64"
    841838    ; Only 64-bit installer:
    842839    ; Also copy 32-bit DLLs on 64-bit Windows in SysWOW64 node
    843     SetOutPath $SYSWOW64DIR
    844     DetailPrint "Installing Direct3D support (SysWOW64: $SYSWOW64DIR) ..."
     840    SetOutPath $g_strSysWow64
     841    DetailPrint "Installing Direct3D support (SysWOW64: $g_strSysWow64) ..."
    845842    FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\libWine.dll"
    846843    FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D8.dll"
     
    853850
    854851    ; Save original DLLs (only if msd3d*.dll does not exist) ...
    855     SetOutPath "$SYSWOW64DIR\dllcache"
    856     IfFileExists "$SYSWOW64DIR\dllcache\msd3d8.dll" +2
    857       CopyFiles /SILENT "$SYSWOW64DIR\dllcache\d3d8.dll" "$SYSWOW64DIR\dllcache\msd3d8.dll"
    858     IfFileExists "$SYSWOW64DIR\dllcache\msd3d9.dll" +2
    859       CopyFiles /SILENT "$SYSWOW64DIR\dllcache\d3d9.dll" "$SYSWOW64DIR\dllcache\msd3d9.dll"
    860 
    861     Push "$SYSWOW64DIR\dllcache\d3d8.dll"
     852    SetOutPath "$g_strSysWow64\dllcache"
     853    IfFileExists "$g_strSysWow64\dllcache\msd3d8.dll" +2
     854      CopyFiles /SILENT "$g_strSysWow64\dllcache\d3d8.dll" "$g_strSysWow64\dllcache\msd3d8.dll"
     855    IfFileExists "$g_strSysWow64\dllcache\msd3d9.dll" +2
     856      CopyFiles /SILENT "$g_strSysWow64\dllcache\d3d9.dll" "$g_strSysWow64\dllcache\msd3d9.dll"
     857
     858    Push "$g_strSysWow64\dllcache\d3d8.dll"
    862859    Call PrepareWRPFile
    863860
    864     Push "$SYSWOW64DIR\dllcache\d3d9.dll"
     861    Push "$g_strSysWow64\dllcache\d3d9.dll"
    865862    Call PrepareWRPFile
    866863
    867864    ; Exchange DLLs
    868     !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$SYSWOW64DIR\dllcache\d3d8.dll" "$TEMP"
    869     !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$SYSWOW64DIR\dllcache\d3d9.dll" "$TEMP"
     865    !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "$TEMP"
     866    !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "$TEMP"
    870867
    871868    ; If exchange above failed, do it on reboot
    872     !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$SYSWOW64DIR\dllcache\d3d8.dll" "$TEMP"
    873     !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$SYSWOW64DIR\dllcache\d3d9.dll" "$TEMP"
     869    !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "$TEMP"
     870    !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "$TEMP"
    874871
    875872    ;
     
    878875
    879876    ; Save original DLLs (only if msd3d*.dll does not exist) ...
    880     IfFileExists "$SYSWOW64DIR\msd3d8.dll" +2
    881       CopyFiles /SILENT "$SYSWOW64DIR\d3d8.dll" "$SYSWOW64DIR\msd3d8.dll"
    882     IfFileExists "$SYSWOW64DIR\msd3d9.dll" +2
    883       CopyFiles /SILENT "$SYSWOW64DIR\d3d9.dll" "$SYSWOW64DIR\msd3d9.dll"
    884 
    885     Push "$SYSWOW64DIR\d3d8.dll"
     877    IfFileExists "$g_strSysWow64\msd3d8.dll" +2
     878      CopyFiles /SILENT "$g_strSysWow64\d3d8.dll" "$g_strSysWow64\msd3d8.dll"
     879    IfFileExists "$g_strSysWow64\msd3d9.dll" +2
     880      CopyFiles /SILENT "$g_strSysWow64\d3d9.dll" "$g_strSysWow64\msd3d9.dll"
     881
     882    Push "$g_strSysWow64\d3d8.dll"
    886883    Call PrepareWRPFile
    887884
    888     Push "$SYSWOW64DIR\d3d9.dll"
     885    Push "$g_strSysWow64\d3d9.dll"
    889886    Call PrepareWRPFile
    890887
    891888    ; Exchange DLLs
    892     !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$SYSWOW64DIR\d3d8.dll" "$TEMP"
    893     !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$SYSWOW64DIR\d3d9.dll" "$TEMP"
     889    !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\d3d8.dll" "$TEMP"
     890    !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\d3d9.dll" "$TEMP"
    894891
    895892    ; If exchange above failed, do it on reboot
    896     !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$SYSWOW64DIR\d3d8.dll" "$TEMP"
    897     !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$SYSWOW64DIR\d3d9.dll" "$TEMP"
     893    !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\d3d8.dll" "$TEMP"
     894    !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\d3d9.dll" "$TEMP"
    898895
    899896  !endif ; amd64
     
    10181015      ${EndIf}
    10191016    ${EndIf}
     1017
     1018    ; Validate D3D files
     1019    Call ValidateD3DFiles
     1020    Pop $0
     1021    ${If} $0 == "1"
     1022      MessageBox MB_ICONINFORMATION|MB_OK "D3D files invalid!" /SD IDOK
     1023      Goto d3d_disable
     1024    ${EndIf}
     1025
    10201026  ${Else} ; D3D unselected again
    10211027    ${If} $g_strWinVersion != "8" ; On Windows 8 WDDM is mandatory
     
    10961102  StrCpy $g_bPostInstallStatus "false"
    10971103
     1104  ; We need a special directory set to SysWOW64 because some
     1105  ; shell operations don't support file redirection (yet)
     1106  StrCpy $g_strSysWow64 "$WINDIR\SysWOW64"
     1107
    10981108  SetErrorLevel 0
    10991109  ClearErrors
  • trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsCommon.nsh

    r38935 r39549  
    575575!insertmacro SetAppMode64 "un."
    576576
     577;
     578; Retrieves the vendor ("CompanyName" of FILEINFO structure)
     579; of a given file.
     580; @return  Stack: Company name, or "" on error/if not found.
     581; @param   Stack: File name to retrieve vendor for.
     582;
     583!macro GetFileVendor un
     584Function ${un}GetFileVendor
     585
     586  ; Preserve values
     587  Exch $0 ; Stack: $0 <filename> (Get file name into $0)
     588  Push $1
     589
     590  IfFileExists "$0" found
     591  Goto not_found
     592
     593found:
     594
     595  VBoxGuestInstallHelper::FileGetVendor "$0"
     596  ; Stack: <vendor> $1 $0
     597  Pop  $0 ; Get vendor
     598  Pop  $1 ; Restore $1
     599  Exch $0 ; Restore $0, push vendor on top of stack
     600  Goto end
     601
     602not_found:
     603
     604  Pop $1
     605  Pop $0
     606  Push "File not found"
     607  Goto end
     608
     609end:
     610
     611FunctionEnd
     612!macroend
     613!insertmacro GetFileVendor ""
     614!insertmacro GetFileVendor "un."
     615
     616;
     617; Retrieves the architecture of a given file.
     618; @return  Stack: Architecture ("x86", "amd64") or error message.
     619; @param   Stack: File name to retrieve architecture for.
     620;
     621!macro GetFileArchitecture un
     622Function ${un}GetFileArchitecture
     623
     624  ; Preserve values
     625  Exch $0 ; Stack: $0 <filename> (Get file name into $0)
     626  Push $1
     627
     628  IfFileExists "$0" found
     629  Goto not_found
     630
     631found:
     632
     633  VBoxGuestInstallHelper::FileGetArchitecture "$0"
     634  ; Stack: <architecture> $1 $0
     635  Pop  $0 ; Get architecture string
     636  Pop  $1 ; Restore $1
     637  Exch $0 ; Restore $0, push vendor on top of stack
     638  Goto end
     639
     640not_found:
     641
     642  Pop $1
     643  Pop $0
     644  Push "File not found"
     645  Goto end
     646
     647end:
     648
     649FunctionEnd
     650!macroend
     651!insertmacro GetFileArchitecture ""
     652!insertmacro GetFileArchitecture "un."
     653
     654;
     655; Verifies a given file by checking its file vendor and target
     656; architecture.
     657; @return  Stack: "0" if verify, "1" if not, "2" on error / not found.
     658; @param   Stack: Architecture ("x86" or "amd64").
     659; @param   Stack: Vendor.
     660; @param   Stack: File name to verify.
     661;
     662!macro VerifyFile un
     663Function ${un}VerifyFile
     664
     665  ; Preserve values
     666  Exch $0 ; File;         S: old$0 vendor arch
     667  Exch    ;               S: vendor old$0 arch
     668  Exch $1 ; Vendor;       S: old$1 old$0 arch
     669  Exch    ;               S: old$0 old$1 arch
     670  Exch 2  ;               S: arch old$1 old$0
     671  Exch $2 ; Architecture; S: old$2 old$1 old$0
     672  Push $3 ;               S: old$3 old$2 old$1 old$0
     673
     674MessageBox MB_ICONSTOP "Vendor $1" /SD IDOK
     675  IfFileExists "$0" check_vendor
     676  Goto not_found
     677
     678check_vendor:
     679
     680  Push $0
     681  Call ${un}GetFileVendor
     682  Pop $3
     683MessageBox MB_ICONSTOP "$3 vs. $1" /SD IDOK
     684  ${If} $3 == $1
     685    Goto check_arch
     686  ${EndIf}
     687  StrCpy $3 "1" ; Invalid
     688  Goto end
     689
     690check_arch:
     691
     692  Push $0
     693  Call ${un}GetFileArchitecture
     694  Pop $3
     695MessageBox MB_ICONSTOP "$3 vs. $2" /SD IDOK
     696  ${If} $3 == $2
     697    StrCpy $3 "0" ; Valid
     698  ${Else}
     699    StrCpy $3 "1" ; Invalid
     700  ${EndIf}
     701  Goto end
     702
     703not_found:
     704
     705  StrCpy $3 "2" ; Not found
     706  Goto end
     707
     708end:
     709MessageBox MB_ICONSTOP "Res: $3" /SD IDOK
     710  ; S: old$3 old$2 old$1 old$0
     711  Exch $3 ; S: $3 old$2 old$1 old$0
     712  Exch    ; S: old$2 $3 old$1
     713  Pop $2  ; S: $3 old$1 old$0
     714  Exch    ; S: old$1 $3 old$0
     715  Pop $1  ; S: $3 old$0
     716  Exch    ; S: old$0 $3
     717  Pop $0  ; S: $3
     718
     719FunctionEnd
     720!macroend
     721!insertmacro VerifyFile ""
     722!insertmacro VerifyFile "un."
     723
     724!macro VerifyFileEx un File Vendor Architecture
     725  Push "${Architecture}"
     726  Push "${Vendor}"
     727  Push "${File}"
     728  Call ${un}VerifyFile
     729!macroend
     730!define VerifyFileEx "!insertmacro VerifyFileEx"
     731
     732;
     733; Validates backed up original Direct3D files.
     734; @return  Stack: "0" if files are valid; otherwise "1".
     735;
     736!macro ValidateFilesDirect3D un
     737Function ${un}ValidateD3DFiles
     738
     739  ; TODO: Here comes the check
     740  ${VerifyFileEx} "${un}" "$SYSDIR\foo.dll" "Microsoft Corporation" "x86"
     741
     742end:
     743
     744FunctionEnd
     745!macroend
     746!insertmacro ValidateFilesDirect3D ""
     747!insertmacro ValidateFilesDirect3D "un."
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette