VBoxGuestAdditionsCommon.nsh revision a84f36110fcbb483c1d6ff593390292d2d50f771
2N/A
2N/A!ifndef UNINSTALLER_ONLY
2N/AFunction ExtractFiles
2N/A
2N/A ; @todo: Use a define for all the file specs to group the files per module
2N/A ; and keep the redundancy low
2N/A
2N/A Push $0
2N/A StrCpy "$0" "$INSTDIR\$%BUILD_TARGET_ARCH%"
2N/A
2N/A!ifdef VBOX_WITH_LICENSE_INSTALL_RTF
2N/A FILE "/oname=$0\${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
2N/A!endif
2N/A
2N/A ; Video driver
2N/A SetOutPath "$0\VBoxVideo"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxVideo.sys"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
2N/A!ifdef VBOX_SIGN_ADDITIONS
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
2N/A!endif
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxDisp.dll"
2N/A
2N/A!if $%VBOX_WITH_CROGL% == "1"
2N/A ; crOpenGL
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxOGLarrayspu.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxOGLcrutil.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxOGLerrorspu.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxOGLpackspu.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxOGLpassthroughspu.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxOGLfeedbackspu.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxOGL.dll"
2N/A
2N/A ; Do *not* install 64-bit d3d files - they don't work yet
2N/A !if $%BUILD_TARGET_ARCH% == "x86"
2N/A SetOutPath "$0\VBoxVideo\OpenGL"
2N/A FILE "$%PATH_OUT%\bin\additions\d3d8.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\d3d9.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\libWine.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxD3D8.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxD3D9.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\wined3d.dll"
2N/A !endif
2N/A
2N/A !if $%BUILD_TARGET_ARCH% == "amd64"
2N/A ; Only 64-bit installer: Also copy 32-bit DLLs on 64-bit target
2N/A SetOutPath "$0\VBoxVideo\OpenGL\SysWow64"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\libWine.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLarrayspu.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLcrutil.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLerrorspu.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLpackspu.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLpassthroughspu.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGLfeedbackspu.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxOGL.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D8.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D9.dll"
2N/A FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\wined3d.dll"
2N/A !endif
2N/A!endif
2N/A
2N/A ; Mouse driver
2N/A SetOutPath "$0\VBoxMouse"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxMouse.sys"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxMouse.inf"
2N/A!ifdef VBOX_SIGN_ADDITIONS
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxMouse.cat"
2N/A!endif
2N/A
2N/A!if $%BUILD_TARGET_ARCH% == "x86"
2N/A SetOutPath "$0\VBoxMouse\NT4"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxMouseNT.sys"
2N/A!endif
2N/A
2N/A ; Guest driver
2N/A SetOutPath "$0\VBoxGuest"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxGuest.sys"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxGuest.inf"
2N/A!ifdef VBOX_SIGN_ADDITIONS
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxGuest.cat"
2N/A!endif
2N/A FILE "$%PATH_OUT%\bin\additions\VBCoInst.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxHook.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
2N/A
2N/A!if $%BUILD_TARGET_ARCH% == "x86"
2N/A SetOutPath "$0\VBoxGuest\NT4"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxGuestNT.sys"
2N/A!endif
2N/A
2N/A ; VBoxService
2N/A SetOutPath "$0\Bin"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxService.exe"
2N/A!if $%BUILD_TARGET_ARCH% == "x86"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxServiceNT.exe"
2N/A!endif
2N/A
2N/A ; Shared Folders
2N/A SetOutPath "$0\VBoxSF"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxSF.sys"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxMRXNP.dll"
2N/A
2N/A ; Auto-Logon
2N/A SetOutPath "$0\AutoLogon"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxGINA.dll"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxCredProv.dll"
2N/A
2N/A ; Misc tools
2N/A SetOutPath "$0\Tools"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
2N/A
2N/A!if $%BUILD_TARGET_ARCH% == "x86"
2N/A SetOutPath "$0\Tools\NT4"
2N/A FILE "$%PATH_OUT%\bin\additions\VBoxGuestDrvInst.exe"
2N/A FILE "$%PATH_OUT%\bin\additions\RegCleanup.exe"
2N/A!endif
2N/A
2N/A Pop $0
2N/A
2N/AFunctionEnd
2N/A!endif ; UNINSTALLER_ONLY
2N/A
2N/A!macro EnableLog un
2N/AFunction ${un}EnableLog
2N/A
2N/A!ifdef _DEBUG
2N/A Goto log
2N/A!endif
2N/A
2N/A StrCmp $g_bLogEnable "true" log
2N/A Goto exit
2N/A
2N/Alog:
2N/A
2N/A LogSet on
2N/A LogText "Start logging."
2N/A
2N/Aexit:
2N/A
2N/AFunctionEnd
2N/A!macroend
2N/A!insertmacro EnableLog ""
2N/A!insertmacro EnableLog "un."
2N/A
2N/A!macro WriteLogUI un
2N/AFunction ${un}WriteLogUI
2N/A
2N/A IfSilent exit
2N/A
2N/A!ifdef _DEBUG
2N/A Goto log
2N/A!endif
2N/A
2N/A StrCmp $g_bLogEnable "true" log
2N/A Goto exit
2N/A
2N/Alog:
2N/A
2N/A ; Dump log to see what happened
2N/A StrCpy $0 "$INSTDIR\${un}install_ui.log"
2N/A Push $0
2N/A Call ${un}DumpLog
2N/A
2N/Aexit:
2N/A
2N/AFunctionEnd
2N/A!macroend
2N/A!insertmacro WriteLogUI ""
2N/A!insertmacro WriteLogUI "un."
2N/A
2N/A!macro WriteLogVBoxTray un
2N/AFunction ${un}WriteLogVBoxTray
2N/A
2N/A ; Pop function parameters off the stack
2N/A ; in reverse order
2N/A Exch $1 ; Message type (0=Info, 1=Warning, 2=Error)
2N/A Exch
Exch $0 ; Body string
; @todo Add more paramters here!
!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
${If} $g_bPostInstallStatus == "true"
; Parameters:
; - String: Description / Body
; - String: Title / Name of application
; - Integer: Type of message: 0 (Info), 1 (Warning), 2 (Error)
; - Integer: Time (in msec) to show the notification
VBoxGuestInstallHelper::VBoxTrayShowBallonMsg "$0" "VirtualBox Guest Additions Setup" $1 5000
Pop $0 ; Get return value (ignored for now)
${EndIf}
!endif
Pop $0
Pop $1
FunctionEnd
!macroend
!insertmacro WriteLogVBoxTray ""
!insertmacro WriteLogVBoxTray "un."
!macro CheckArchitecture un
Function ${un}CheckArchitecture
Push $0
System::Call "kernel32::GetCurrentProcess() i .s"
System::Call "kernel32::IsWow64Process(i s, *i .r0)"
; R0 now contains 1 if we're a 64-bit process, or 0 if not
!if $%BUILD_TARGET_ARCH% == "amd64"
IntCmp $0 0 wrong_platform
!else ; 32-bit
IntCmp $0 1 wrong_platform
!endif
Push 0
Goto exit
wrong_platform:
Push 1
Goto exit
exit:
FunctionEnd
!macroend
!insertmacro CheckArchitecture ""
!insertmacro CheckArchitecture "un."
!macro IsRebootNeeded un
Function ${un}IsRebootNeeded
Push $0
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce\VBoxGuestAdditions" "RebootNeeded"
Push $0
FunctionEnd
!macroend
!insertmacro IsRebootNeeded ""
!insertmacro IsRebootNeeded "un."
!macro SetRebootNeeded un
Function ${un}SetRebootNeeded
Pop $0
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce\VBoxGuestAdditions" "RebootNeeded" $0
FunctionEnd
!macroend
!insertmacro SetRebootNeeded ""
!insertmacro SetRebootNeeded "un."
!macro GetWindowsVer un
Function ${un}GetWindowsVer
; Check if we are running on w2k or above
; For other windows versions (>XP) it may be necessary to change winver.nsh
Call ${un}GetWindowsVersion
Pop $R3 ; Windows Version
Push $R3 ; The windows version string
Push "NT" ; String to search for. Win 2k family returns no string containing 'NT'
Call ${un}StrStr
Pop $R0
StrCmp $R0 '' nt5plus ; Not NT 3.XX or 4.XX
; Ok we know it is NT. Must be a string like NT X.XX
Push $R3 ; The windows version string
Push "4." ; String to search for
Call ${un}StrStr
Pop $R0
StrCmp $R0 "" nt5plus nt4 ; If empty -> not NT 4
nt5plus: ; Windows 2000+ (XP, Vista, ...)
StrCpy $g_strWinVersion $R3
goto exit
nt4: ; NT 4.0
StrCpy $g_strWinVersion "NT4"
goto exit
exit:
FunctionEnd
!macroend
!insertmacro GetWindowsVer ""
!insertmacro GetWindowsVer "un."
!macro GetAdditionsVersion un
Function ${un}GetAdditionsVersion
Push $0
Push $1
; Get additions version
ReadRegStr $0 HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Version"
; Get revision
ReadRegStr $g_strAddVerRev HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Revision"
; Extract major version
Push "$0" ; String
Push "." ; SubString
Push ">" ; SearchDirection
Push "<" ; StrInclusionDirection
Push "0" ; IncludeSubString
Push "0" ; Loops
Push "0" ; CaseSensitive
Call ${un}StrStrAdv
Pop $g_strAddVerMaj
; Extract minor version
Push "$0" ; String
Push "." ; SubString
Push ">" ; SearchDirection
Push ">" ; StrInclusionDirection
Push "0" ; IncludeSubString
Push "0" ; Loops
Push "0" ; CaseSensitive
Call ${un}StrStrAdv
Pop $1 ; Got first part (e.g. "1.5")
Push "$1" ; String
Push "." ; SubString
Push ">" ; SearchDirection
Push "<" ; StrInclusionDirection
Push "0" ; IncludeSubString
Push "0" ; Loops
Push "0" ; CaseSensitive
Call ${un}StrStrAdv
Pop $g_strAddVerMin ; Extracted second part (e.g. "5" from "1.5")
; Extract build number
Push "$0" ; String
Push "." ; SubString
Push "<" ; SearchDirection
Push ">" ; StrInclusionDirection
Push "0" ; IncludeSubString
Push "0" ; Loops
Push "0" ; CaseSensitive
Call ${un}StrStrAdv
Pop $g_strAddVerBuild
exit:
Pop $1
Pop $0
FunctionEnd
!macroend
!insertmacro GetAdditionsVersion ""
!insertmacro GetAdditionsVersion "un."
!macro StopVBoxService un
Function ${un}StopVBoxService
Push $0 ; Temp results
Push $1
Push $2 ; Image name of VBoxService
Push $3 ; Safety counter
StrCpy $3 "0" ; Init counter
DetailPrint "Stopping VBoxService ..."
svc_stop:
LogText "Stopping VBoxService (as service) ..."
${If} $g_strWinVersion == "NT4"
nsExec::Exec '"$SYSDIR\net.exe" stop VBoxService'
${Else}
nsExec::Exec '"$SYSDIR\SC.exe" stop VBoxService'
${EndIf}
Sleep "1000" ; Wait a bit
exe_stop:
!ifdef _DEBUG
DetailPrint "Stopping VBoxService (as exe) ..."
!endif
exe_stop_loop:
IntCmp $3 10 exit ; Only try this loop 10 times max
IntOp $3 $3 + 1 ; Increment
LogText "Try: $3"
${If} $g_strWinVersion == "NT4"
StrCpy $2 "VBoxServiceNT.exe"
${Else}
StrCpy $2 "VBoxService.exe"
${EndIf}
${nsProcess::FindProcess} $2 $0
StrCmp $0 0 0 exit
${nsProcess::KillProcess} $2 $0
Sleep "1000" ; Wait a bit
Goto exe_stop_loop
exit:
DetailPrint "Stopping VBoxService done."
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
!macroend
!insertmacro StopVBoxService ""
!insertmacro StopVBoxService "un."
!macro StopVBoxTray un
Function ${un}StopVBoxTray
Push $0 ; Temp results
Push $1 ; Safety counter
StrCpy $1 "0" ; Init counter
DetailPrint "Stopping VBoxTray ..."
exe_stop:
IntCmp $1 10 exit ; Only try this loop 10 times max
IntOp $1 $1 + 1 ; Increment
${nsProcess::FindProcess} "VBoxTray.exe" $0
StrCmp $0 0 0 exit
${nsProcess::KillProcess} "VBoxTray.exe" $0
Sleep "1000" ; Wait a bit
Goto exe_stop
exit:
DetailPrint "Stopping VBoxTray done."
Pop $1
Pop $0
FunctionEnd
!macroend
!insertmacro StopVBoxTray ""
!insertmacro StopVBoxTray "un."
!macro WriteRegBinR ROOT KEY NAME VALUE
WriteRegBin "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
!macroend
!macro AbortShutdown un
Function ${un}AbortShutdown
Push $0
; Try to abort the shutdown
nsExec::ExecToLog '"$g_strSystemDir\shutdown.exe" -a' $0
Pop $0
FunctionEnd
!macroend
!insertmacro AbortShutdown ""
!insertmacro AbortShutdown "un."
!macro CheckForWDDMCapability un
Function ${un}CheckForWDDMCapability
!if $%VBOX_WITH_WDDM% == "1"
!if $%BUILD_TARGET_ARCH% == "x86"
; If we're on a 32-bit Windows Vista / 7 we can use the WDDM driver
${If} $g_strWinVersion == "Vista"
${OrIf} $g_strWinVersion == "7"
StrCpy $g_bCapWDDM "true"
${EndIf}
!endif
!endif
FunctionEnd
!macroend
!insertmacro CheckForWDDMCapability ""
!insertmacro CheckForWDDMCapability "un."
!macro CheckForCapabilities un
Function ${un}CheckForCapabilities
Push $0
; Retrieve system mode and store result in
System::Call 'user32::GetSystemMetrics(i ${SM_CLEANBOOT}) i .r0'
StrCpy $g_iSystemMode $0
; Check whether this OS is capable of handling WDDM drivers
Call ${un}CheckForWDDMCapability
Pop $0
FunctionEnd
!macroend
!insertmacro CheckForCapabilities ""
!insertmacro CheckForCapabilities "un."