VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditions.nsi@ 44529

Last change on this file since 44529 was 44484, checked in by vboxsync, 12 years ago

Windows Guest Additions installer: Relative jump bugfixes, simplified OS detection, logging.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 41.6 KB
Line 
1; $Id: VBoxGuestAdditions.nsi 44484 2013-01-31 11:36:25Z vboxsync $
2; @file
3; VBoxGuestAdditions.nsi - Main file for Windows Guest Additions installation.
4;
5
6;
7; Copyright (C) 2012-2013 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17
18!if $%BUILD_TYPE% == "debug"
19 !define _DEBUG ; Turn this on to get extra output
20!endif
21
22!ifdef _DEBUG
23 ; Scratch directory for plugin tests
24 !addincludedir .\PluginTest
25 !addplugindir .\PluginTest
26!endif
27
28; Defines for special functions
29!define WHQL_FAKE ; Enables faking of non WHQL signed / approved drivers
30 ; Needs the VBoxWHQLFake.exe in the additions output directory!
31!define WFP_FILE_EXCEPTION ; Enables setting a temporary file exception for WFP proctected files
32
33!define VENDOR_ROOT_KEY "SOFTWARE\$%VBOX_VENDOR_SHORT%"
34
35; Product defines
36!define PRODUCT_NAME "$%VBOX_PRODUCT% Guest Additions"
37!define PRODUCT_DESC "$%VBOX_PRODUCT% Guest Additions"
38!define PRODUCT_VERSION "$%VBOX_VERSION_MAJOR%.$%VBOX_VERSION_MINOR%.$%VBOX_VERSION_BUILD%.0"
39!define PRODUCT_PUBLISHER "$%VBOX_VENDOR%"
40!define PRODUCT_COPYRIGHT "(C) $%VBOX_C_YEAR% $%VBOX_VENDOR%"
41!define PRODUCT_OUTPUT "VBoxWindowsAdditions-$%BUILD_TARGET_ARCH%.exe"
42!define PRODUCT_WEB_SITE "http://www.virtualbox.org"
43!define PRODUCT_INSTALL_KEY "${VENDOR_ROOT_KEY}\VirtualBox Guest Additions"
44!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
45!define PRODUCT_UNINST_ROOT_KEY "HKLM"
46
47!define LICENSE_FILE_RTF "license.rtf"
48
49; Needed for InstallLib macro: Install libraries in every case
50!define LIBRARY_IGNORE_VERSION
51
52VIProductVersion "${PRODUCT_VERSION}"
53VIAddVersionKey "FileVersion" "$%VBOX_VERSION_STRING%"
54VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
55VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
56VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}"
57VIAddVersionKey "FileDescription" "${PRODUCT_DESC}"
58VIAddVersionKey "LegalCopyright" "${PRODUCT_COPYRIGHT}"
59VIAddVersionKey "InternalName" "${PRODUCT_OUTPUT}"
60
61; This registry key will hold the mouse driver path before install (NT4 only)
62!define ORG_MOUSE_PATH "MousePath"
63
64; If we have our guest install helper DLL, add the
65; plugin path so that NSIS can find it when compiling the installer
66; Note: NSIS plugins *always* have to be compiled in 32-bit!
67!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
68 !addplugindir "$%PATH_TARGET_X86%\VBoxGuestInstallHelper"
69!endif
70
71!include "LogicLib.nsh"
72!include "FileFunc.nsh"
73 !insertmacro GetParameters
74 !insertmacro GetOptions
75!include "WordFunc.nsh"
76 !insertmacro WordFind
77 !insertmacro StrFilter
78
79!include "nsProcess.nsh"
80!include "Library.nsh"
81!include "Sections.nsh"
82!include "strstr.nsh" ; Function "strstr"
83!include "servicepack.nsh" ; Function "GetServicePack"
84!include "winver.nsh" ; Function for determining Windows version
85!define REPLACEDLL_NOREGISTER ; Replace in use DLL function
86!include "ReplaceDLL.nsh"
87!include "dumplog.nsh" ; Dump log to file function
88
89!if $%BUILD_TARGET_ARCH% == "amd64"
90 !include "x64.nsh"
91!endif
92
93; Set Modern UI (MUI) as default
94!define USE_MUI
95
96!ifdef USE_MUI
97 ; Use modern UI, version 2
98 !include "MUI2.nsh"
99
100 ; MUI Settings
101 !define MUI_WELCOMEFINISHPAGE_BITMAP "$%VBOX_BRAND_WIN_ADD_INST_DLGBMP%"
102 !define MUI_ABORTWARNING
103 !define MUI_WELCOMEPAGE_TITLE_3LINES "Welcome to the ${PRODUCT_NAME} Additions Setup"
104
105 ; API defines
106 !define SM_CLEANBOOT 67
107
108 ; Icons
109 !if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
110 !define MUI_ICON "$%VBOX_NSIS_ICON_FILE%"
111 !define MUI_UNICON "$%VBOX_NSIS_ICON_FILE%"
112 !else ; 64-bit
113 !define MUI_ICON "$%VBOX_WINDOWS_ADDITIONS_ICON_FILE%"
114 !define MUI_UNICON "$%VBOX_WINDOWS_ADDITIONS_ICON_FILE%"
115 !endif
116
117 ; Welcome page
118 !insertmacro MUI_PAGE_WELCOME
119!ifdef VBOX_WITH_LICENSE_DISPLAY
120 ; License page
121 !insertmacro MUI_PAGE_LICENSE "$(VBOX_LICENSE)"
122 !define MUI_LICENSEPAGE_RADIOBUTTONS
123!endif
124 ; Directory page
125 !insertmacro MUI_PAGE_DIRECTORY
126 ; Components Page
127 !insertmacro MUI_PAGE_COMPONENTS
128 ; Instfiles page
129 !insertmacro MUI_PAGE_INSTFILES
130
131 !ifndef _DEBUG
132 !define MUI_FINISHPAGE_TITLE_3LINES ; Have a bit more vertical space for text
133 !insertmacro MUI_PAGE_FINISH ; Only show in release mode - useful information for debugging!
134 !endif
135
136 ; Uninstaller pages
137 !insertmacro MUI_UNPAGE_INSTFILES
138
139 ; Define languages we will use
140 !insertmacro MUI_LANGUAGE "English"
141 !insertmacro MUI_LANGUAGE "French"
142 !insertmacro MUI_LANGUAGE "German"
143
144 ; Set branding text which appears on the horizontal line at the bottom
145!ifdef _DEBUG
146 BrandingText "VirtualBox Windows Additions $%VBOX_VERSION_STRING% (r$%VBOX_SVN_REV%) - Debug Build"
147!else
148 BrandingText "VirtualBox Windows Additions $%VBOX_VERSION_STRING%"
149!endif
150
151!ifdef VBOX_WITH_LICENSE_DISPLAY
152 ; Set license language
153 LicenseLangString VBOX_LICENSE ${LANG_ENGLISH} "$%VBOX_BRAND_LICENSE_RTF%"
154
155 ; If license files not available (OSE / PUEL) build, then use the English one as default
156 !ifdef VBOX_BRAND_fr_FR_LICENSE_RTF
157 LicenseLangString VBOX_LICENSE ${LANG_FRENCH} "$%VBOX_BRAND_fr_FR_LICENSE_RTF%"
158 !else
159 LicenseLangString VBOX_LICENSE ${LANG_FRENCH} "$%VBOX_BRAND_LICENSE_RTF%"
160 !endif
161 !ifdef VBOX_BRAND_de_DE_LICENSE_RTF
162 LicenseLangString VBOX_LICENSE ${LANG_GERMAN} "$%VBOX_BRAND_de_DE_LICENSE_RTF%"
163 !else
164 LicenseLangString VBOX_LICENSE ${LANG_GERMAN} "$%VBOX_BRAND_LICENSE_RTF%"
165 !endif
166!endif
167
168 !insertmacro MUI_RESERVEFILE_LANGDLL
169!else ; !USE_MUI
170 XPStyle on
171!ifdef VBOX_WITH_LICENSE_DISPLAY
172 Page license
173!endif
174 Page components
175 Page directory
176 Page instfiles
177!endif
178
179; Language files
180!include "Languages\English.nsh"
181!include "Languages\French.nsh"
182!include "Languages\German.nsh"
183
184; Variables and output files
185Name "${PRODUCT_NAME} $%VBOX_VERSION_STRING%"
186!ifdef UNINSTALLER_ONLY
187 !echo "Uninstaller only!"
188 OutFile "$%PATH_TARGET%\VBoxWindowsAdditions-$%BUILD_TARGET_ARCH%-uninst.exe"
189!else
190 OutFile "VBoxWindowsAdditions-$%BUILD_TARGET_ARCH%.exe"
191!endif ; UNINSTALLER_ONLY
192
193; Define default installation directory
194!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
195 InstallDir "$PROGRAMFILES32\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions"
196!else ; 64-bit
197 InstallDir "$PROGRAMFILES64\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions"
198!endif
199
200InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
201ShowInstDetails show
202ShowUnInstDetails show
203RequestExecutionLevel highest
204
205; Internal parameters
206Var g_iSystemMode ; Current system mode (0 = Normal boot, 1 = Fail-safe boot, 2 = Fail-safe with network boot)
207Var g_strSystemDir ; Windows system directory
208Var g_strSysWow64 ; The SysWow64 directory on 64-bit systems
209Var g_strCurUser ; Current user using the system
210Var g_strAddVerMaj ; Installed Guest Additions: Major version
211Var g_strAddVerMin ; Installed Guest Additions: Minor version
212Var g_strAddVerBuild ; Installed Guest Additions: Build number
213Var g_strAddVerRev ; Installed Guest Additions: SVN revision
214Var g_strWinVersion ; Current Windows version we're running on
215Var g_bLogEnable ; Do logging when installing? "true" or "false"
216Var g_bWithWDDM ; Install the WDDM driver instead of the XPDM one
217Var g_bCapDllCache ; Capability: Does the (Windows) guest have have a DLL cache which needs to be taken care of?
218Var g_bCapWDDM ; Capability: Is the guest able to handle/use our WDDM driver?
219
220; Command line parameters - these can be set/modified
221; on the command line
222Var g_bFakeWHQL ; Cmd line: Fake Windows to install non WHQL certificated drivers (only for W2K and XP currently!!) ("/unsig_drv")
223Var g_bForceInstall ; Cmd line: Force installation on unknown Windows OS version
224Var g_bUninstall ; Cmd line: Just uninstall any previous Guest Additions and exit
225Var g_bRebootOnExit ; Cmd line: Auto-Reboot on successful installation. Good for unattended installations ("/reboot")
226Var g_iScreenBpp ; Cmd line: Screen depth ("/depth=X")
227Var g_iScreenX ; Cmd line: Screen resolution X ("/resx=X")
228Var g_iScreenY ; Cmd line: Screen resolution Y ("/resy=Y")
229Var g_iSfOrder ; Cmd line: Order of Shared Folders network provider (0=first, 1=second, ...)
230Var g_bIgnoreUnknownOpts ; Cmd line: Ignore unknown options (don't display the help)
231Var g_bNoVBoxServiceExit ; Cmd line: Do not quit VBoxService before updating - install on next reboot
232Var g_bNoVBoxTrayExit ; Cmd line: Do not quit VBoxTray before updating - install on next reboot
233Var g_bNoVideoDrv ; Cmd line: Do not install the VBoxVideo driver
234Var g_bNoGuestDrv ; Cmd line: Do not install the VBoxGuest driver
235Var g_bNoMouseDrv ; Cmd line: Do not install the VBoxMouse driver
236Var g_bWithAutoLogon ; Cmd line: Install VBoxGINA / VBoxCredProv for auto logon support
237Var g_bWithD3D ; Cmd line: Install Direct3D support
238Var g_bOnlyExtract ; Cmd line: Only extract all files, do *not* install them. Only valid with param "/D" (target directory)
239Var g_bPostInstallStatus ; Cmd line: Post the overall installation status to some external program (VBoxTray)
240
241; Platform parts of this installer
242!include "VBoxGuestAdditionsLog.nsh"
243!include "VBoxGuestAdditionsExternal.nsh"
244!include "VBoxGuestAdditionsCommon.nsh"
245!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit only
246 !include "VBoxGuestAdditionsNT4.nsh"
247!endif
248!include "VBoxGuestAdditionsW2KXP.nsh"
249!include "VBoxGuestAdditionsVista.nsh"
250!include "VBoxGuestAdditionsUninstall.nsh" ; Product uninstallation
251!include "VBoxGuestAdditionsUninstallOld.nsh" ; Uninstallation of deprecated versions which must be removed first
252
253Function HandleCommandLine
254
255 Push $0 ; Command line (without process name)
256 Push $1 ; Number of parameters
257 Push $2 ; Current parameter index
258 Push $3 ; Current parameter pair (name=value)
259 Push $4 ; Current parameter name
260 Push $5 ; Current parameter value (if present)
261
262 StrCpy $1 "0" ; Init param counter
263 StrCpy $2 "1" ; Init current param counter
264
265 ${GetParameters} $0 ; Extract command line
266 ${If} $0 == "" ; If no parameters at all exit
267 Goto exit
268 ${EndIf}
269
270 ; Enable for debugging
271 ;MessageBox MB_OK "CmdLine: $0"
272
273 ${WordFind} $0 " " "#" $1 ; Get number of parameters in cmd line
274 ${If} $0 == $1 ; If result matches the input then
275 StrCpy $1 "1" ; no delimiter was found. Correct to 1 word total
276 ${EndIf}
277
278 ${While} $2 <= $1 ; Loop through all params
279
280 ${WordFind} $0 " " "+$2" $3 ; Get current name=value pair
281 ${WordFind} $3 "=" "+1" $4 ; Get current param name
282 ${WordFind} $3 "=" "+2" $5 ; Get current param value
283
284 ${StrFilter} $4 "-" "" "" $4 ; Transfer param name to lowercase
285
286 ; Enable for debugging
287 ;MessageBox MB_OK "#$2 of #$1, param='$3', name=$4, val=$5"
288
289 ${Switch} $4
290
291 ${Case} '/d' ; NSIS: /D=<instdir> switch, skip
292 ${Break}
293
294 ${Case} '/depth'
295 ${Case} 'depth'
296 StrCpy $g_iScreenBpp $5
297 ${Break}
298
299 ${Case} '/extract'
300 StrCpy $g_bOnlyExtract "true"
301 ${Break}
302
303 ${Case} '/force'
304 StrCpy $g_bForceInstall "true"
305 ${Break}
306
307 ${Case} '/help'
308 ${Case} '/H'
309 ${Case} '/h'
310 ${Case} '/?'
311 Goto usage
312 ${Break}
313
314 ${Case} '/ignore_unknownopts' ; Not officially documented
315 StrCpy $g_bIgnoreUnknownOpts "true"
316 ${Break}
317
318 ${Case} '/l'
319 ${Case} '/log'
320 ${Case} '/logging'
321 StrCpy $g_bLogEnable "true"
322 ${Break}
323
324 ${Case} '/ncrc' ; NSIS: /NCRC switch, skip
325 ${Break}
326
327 ${Case} '/no_vboxservice_exit' ; Not officially documented
328 StrCpy $g_bNoVBoxServiceExit "true"
329 ${Break}
330
331 ${Case} '/no_vboxtray_exit' ; Not officially documented
332 StrCpy $g_bNoVBoxTrayExit "true"
333 ${Break}
334
335 ${Case} '/no_videodrv' ; Not officially documented
336 StrCpy $g_bNoVideoDrv "true"
337 ${Break}
338
339 ${Case} '/no_guestdrv' ; Not officially documented
340 StrCpy $g_bNoGuestDrv "true"
341 ${Break}
342
343 ${Case} '/no_mousedrv' ; Not officially documented
344 StrCpy $g_bNoMouseDrv "true"
345 ${Break}
346
347!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
348 ; This switch tells our installer that it
349 ; - should not quit VBoxTray during the update, because ...
350 ; - ... it should show the overall installation status
351 ; using VBoxTray's balloon message feature (since VBox 4.0)
352 ${Case} '/post_installstatus' ; Not officially documented
353 StrCpy $g_bNoVBoxTrayExit "true"
354 StrCpy $g_bPostInstallStatus "true"
355 ${Break}
356!endif
357
358 ${Case} '/reboot'
359 StrCpy $g_bRebootOnExit "true"
360 ${Break}
361
362 ${Case} '/s' ; NSIS: /S switch, skip
363 ${Break}
364
365 ${Case} '/sforder'
366 ${Case} 'sforder'
367 StrCpy $g_iSfOrder $5
368 ${Break}
369
370 !ifdef WHQL_FAKE
371 ${Case} '/unsig_drv'
372 StrCpy $g_bFakeWHQL "true"
373 ${Break}
374 !endif
375
376 ${Case} '/uninstall'
377 StrCpy $g_bUninstall "true"
378 ${Break}
379
380 ${Case} '/with_autologon'
381 StrCpy $g_bWithAutoLogon "true"
382 ${Break}
383
384 !if $%VBOX_WITH_CROGL% == "1"
385 ${Case} '/with_d3d'
386 ${Case} '/with_direct3d'
387 StrCpy $g_bWithD3D "true"
388 ${Break}
389 !endif
390
391 ${Case} '/xres'
392 ${Case} 'xres'
393 StrCpy $g_iScreenX $5
394 ${Break}
395
396 ${Case} '/yres'
397 ${Case} 'yres'
398 StrCpy $g_iScreenY $5
399 ${Break}
400
401 ${Default} ; Unknown parameter, print usage message
402 ; Prevent popping up usage message on (yet) unknown parameters
403 ; in silent mode, just skip
404 IfSilent +1 +2
405 ${Break}
406 goto usage
407 ${Break}
408
409 ${EndSwitch}
410
411next_param:
412
413 IntOp $2 $2 + 1
414
415 ${EndWhile}
416 Goto exit
417
418usage:
419
420 ; If we were told to ignore unknown (invalid) options, just return to
421 ; the parsing loop ...
422 ${If} $g_bIgnoreUnknownOpts == "true"
423 Goto next_param
424 ${EndIf}
425 MessageBox MB_OK "${PRODUCT_NAME} Installer$\r$\n$\r$\n \
426 Usage: VBoxWindowsAdditions-$%BUILD_TARGET_ARCH% [OPTIONS] [/l] [/S] [/D=<PATH>]$\r$\n$\r$\n \
427 Options:$\r$\n \
428 /depth=BPP$\tSets the guest's display color depth (bits per pixel)$\r$\n \
429 /extract$\t$\tOnly extract installation files$\r$\n \
430 /force$\t$\tForce installation on unknown/undetected Windows versions$\r$\n \
431 /uninstall$\t$\tJust uninstalls the Guest Additions and exits$\r$\n \
432 /with_autologon$\tInstalls auto-logon support$\r$\n \
433 /with_d3d$\tInstalls D3D support$\r$\n \
434 /xres=X$\t$\tSets the guest's display resolution (width in pixels)$\r$\n \
435 /yres=Y$\t$\tSets the guest's display resolution (height in pixels)$\r$\n \
436 $\r$\n \
437 Installer parameters:$\r$\n \
438 /l$\t$\tEnables logging$\r$\n \
439 /S$\t$\tSilent install$\r$\n \
440 /D=<PATH>$\tSets the default install path$\r$\n \
441 $\r$\n \
442 Note: Order of options and installer parameters are mandatory." /SD IDOK
443
444 ; No stack restore needed, we're about to quit
445 Quit
446
447done:
448
449!ifdef _DEBUG
450 ${LogVerbose} "Property: XRes: $g_iScreenX"
451 ${LogVerbose} "Property: YRes: $g_iScreenY"
452 ${LogVerbose} "Property: BPP: $g_iScreenBpp"
453 ${LogVerbose} "Property: Logging enabled: $g_bLogEnable"
454!endif
455
456exit:
457
458 Pop $5
459 Pop $4
460 Pop $3
461 Pop $2
462 Pop $1
463 Pop $0
464
465FunctionEnd
466
467Function CheckForOldGuestAdditions
468
469 Push $0
470 Push $1
471 Push $2
472
473begin:
474
475 ${LogVerbose} "Checking for old Guest Additions ..."
476
477sun_check:
478
479 ; Check for old "Sun VirtualBox Guest Additions"
480 ; - before rebranding to Oracle
481 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions" "UninstallString"
482 StrCmp $0 "" sun_xvm_check ; If string is empty, Sun additions are probably not installed (anymore)
483
484 MessageBox MB_YESNO $(VBOX_SUN_FOUND) /SD IDYES IDYES sun_uninstall
485 Pop $2
486 Pop $1
487 Pop $0
488 MessageBox MB_ICONSTOP $(VBOX_SUN_ABORTED) /SD IDOK
489 Quit
490
491sun_uninstall:
492
493 Call Uninstall_Sun
494 Goto success
495
496sun_xvm_check:
497
498 ; Check for old "Sun xVM VirtualBox Guest Additions"
499 ; - before getting rid of the "xVM" namespace
500 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions" "UninstallString"
501 StrCmp $0 "" innotek_check ; If string is empty, Sun xVM additions are probably not installed (anymore)
502
503 MessageBox MB_YESNO $(VBOX_SUN_FOUND) /SD IDYES IDYES sun_xvm_uninstall
504 Pop $2
505 Pop $1
506 Pop $0
507 MessageBox MB_ICONSTOP $(VBOX_SUN_ABORTED) /SD IDOK
508 Quit
509
510sun_xvm_uninstall:
511
512 Call Uninstall_SunXVM
513 Goto success
514
515innotek_check:
516
517 ; Check for old "innotek" Guest Additions" before rebranding to "Sun"
518 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions" "UninstallString"
519 StrCmp $0 "" exit ; If string is empty, innotek Guest Additions are probably not installed (anymore)
520
521 MessageBox MB_YESNO $(VBOX_INNOTEK_FOUND) /SD IDYES IDYES innotek_uninstall
522 Pop $2
523 Pop $1
524 Pop $0
525 MessageBox MB_ICONSTOP $(VBOX_INNOTEK_ABORTED) /SD IDOK
526 Quit
527
528innotek_uninstall:
529
530 Call Uninstall_Innotek
531 Goto success
532
533success:
534
535 ; Nothing to do here yet
536
537exit:
538
539 Pop $2
540 Pop $1
541 Pop $0
542
543FunctionEnd
544
545Function CheckForInstalledComponents
546
547 Push $0
548 Push $1
549
550 ${LogVerbose} "Checking for installed components ..."
551 StrCpy $1 ""
552
553 Call SetAppMode64
554
555 ; VBoxGINA already installed? So we need to update the installed version as well,
556 ; regardless whether the user used "/with_autologon" or not
557 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" "GinaDLL"
558 ${If} $0 == "VBoxGINA.dll"
559 StrCpy $1 "GINA"
560 ${Else}
561 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}" ""
562 ${If} $0 == "VBoxCredProv"
563 StrCpy $1 "Credential Provider"
564 ${EndIf}
565 ${EndIf}
566
567!ifdef _DEBUG
568 ${LogVerbose} "Auto-logon module: $0"
569!endif
570
571 ${IfNot} $1 == ""
572 ${LogVerbose} "Auto-logon support ($1) was installed previously"
573 StrCpy $g_bWithAutoLogon "true" ; Force update
574 ${Else}
575 ${LogVerbose} "Auto-logon support was not installed previously"
576 ${EndIf}
577
578 Pop $1
579 Pop $0
580
581FunctionEnd
582
583; Main Files
584Section $(VBOX_COMPONENT_MAIN) SEC01
585
586 SectionIn RO ; Section cannot be unselected (read-only)
587 ${If} $g_bPostInstallStatus == "true"
588 ${LogToVBoxTray} "0" "${PRODUCT_NAME} update started, please wait ..."
589 ${EndIf}
590
591 IfSilent +1 +2
592 StrCpy $g_bLogEnable "true" ; Force logging in silent mode
593
594 ${LogEnable} "$g_bLogEnable"
595 IfSilent +1 +2 ; NSIS will expand ${LogVerbose} before doing relative jumps!
596 LogText "Installer runs in silent mode"
597
598 SetOutPath "$INSTDIR"
599 SetOverwrite on
600
601 Call SetAppMode64
602
603 StrCpy $g_strSystemDir "$SYSDIR"
604
605 ${LogVerbose} "Version: $%VBOX_VERSION_STRING% (Rev $%VBOX_SVN_REV%)"
606 ${If} $g_strAddVerMaj != ""
607 ${LogVerbose} "Previous version: $g_strAddVerMaj.$g_strAddVerMin.$g_strAddVerBuild (Rev $g_strAddVerRev)"
608 ${Else}
609 ${LogVerbose} "No previous version of ${PRODUCT_NAME} detected"
610 ${EndIf}
611!if $%BUILD_TARGET_ARCH% == "amd64"
612 ${LogVerbose} "Detected OS: Windows $g_strWinVersion (64-bit)"
613!else
614 ${LogVerbose} "Detected OS: Windows $g_strWinVersion (32-bit)"
615!endif
616 ${LogVerbose} "System Directory: $g_strSystemDir"
617
618!ifdef _DEBUG
619 ${LogVerbose} "Installer runs in debug mode"
620!endif
621
622 ; Retrieve capabilities
623 Call CheckForCapabilities
624
625 ;
626 ; Here starts the main dispatcher (based on guest OS)
627 ;
628
629 ; Which OS are we using?
630!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
631 StrCmp $g_strWinVersion "NT4" nt4 ; Windows NT 4.0
632!endif
633 StrCmp $g_strWinVersion "2000" w2k ; Windows 2000
634 StrCmp $g_strWinVersion "XP" w2k ; Windows XP
635 StrCmp $g_strWinVersion "2003" w2k ; Windows 2003 Server
636 StrCmp $g_strWinVersion "Vista" vista ; Windows Vista
637 StrCmp $g_strWinVersion "7" vista ; Windows 7
638 StrCmp $g_strWinVersion "8" vista ; Windows 8
639
640 ${If} $g_bForceInstall == "true"
641 Goto vista ; Assume newer OS than we know of ...
642 ${EndIf}
643
644 Goto notsupported
645
646!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
647nt4: ; Windows NT4
648
649 Call GetServicePack
650 Pop $R0 ; Major version
651 Pop $R1 ; Minor version
652
653 ; At least Service Pack 6 installed?
654 ${If} $R0 <> "6"
655 MessageBox MB_YESNO $(VBOX_NT4_NO_SP6) /SD IDYES IDYES +2
656 Quit
657 ${EndIf}
658
659 ; Copy some common files ...
660 Call Common_CopyFiles
661
662 Call NT4_Main
663 goto success
664!endif
665
666w2k: ; Windows 2000 and XP ...
667
668 ; Copy some common files ...
669 Call Common_CopyFiles
670
671 Call W2K_Main
672 goto success
673
674vista: ; Windows Vista / Windows 7 / Windows 8
675
676 ; Check requirments; this function can abort the installation if necessary!
677 Call Vista_CheckForRequirements
678
679 ; Copy some common files ...
680 Call Common_CopyFiles
681
682 Call W2K_Main ; First install stuff from Windows 2000 / XP
683 Call Vista_Main ; ... and some specific stuff for Vista / Windows 7
684 goto success
685
686notsupported:
687
688 MessageBox MB_ICONSTOP $(VBOX_PLATFORM_UNSUPPORTED) /SD IDOK
689 goto exit
690
691success:
692
693 ; Write a registry key with version and installation path for later lookup
694 WriteRegStr HKLM "${PRODUCT_INSTALL_KEY}" "Version" "$%VBOX_VERSION_STRING_RAW%"
695 WriteRegStr HKLM "${PRODUCT_INSTALL_KEY}" "VersionExt" "$%VBOX_VERSION_STRING%"
696 WriteRegStr HKLM "${PRODUCT_INSTALL_KEY}" "Revision" "$%VBOX_SVN_REV%"
697 WriteRegStr HKLM "${PRODUCT_INSTALL_KEY}" "InstallDir" "$INSTDIR"
698
699 ; Set the reboot flag to tell the finish page that is should
700 ; default to the "reboot now" entry
701 SetRebootFlag true
702
703exit:
704
705SectionEnd
706
707; Auto-logon support (section is hidden at the moment -- only can be enabled via command line switch)
708Section /o -$(VBOX_COMPONENT_AUTOLOGON) SEC02
709
710 Call SetAppMode64
711
712 Call GetWindowsVersion
713 Pop $R0 ; Windows Version
714
715 ${LogVerbose} "Installing auto-logon support ..."
716
717 ; Another GINA already is installed? Check if this is ours, otherwise let the user decide (unless it's a silent setup)
718 ; whether to replace it with the VirtualBox one or not
719 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" "GinaDLL"
720 ${If} $0 != ""
721 ${If} $0 != "VBoxGINA.dll"
722 ${LogVerbose} "Found another already installed GINA module: $0"
723 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1 $(VBOX_COMPONENT_AUTOLOGON_WARN_3RDPARTY) /SD IDYES IDYES install
724 ${LogVerbose} "Skipping GINA installation, keeping: $0"
725 goto skip
726 ${EndIf}
727 ${EndIf}
728
729install:
730
731 ; Do we need VBoxCredProv or VBoxGINA?
732 ${If} $R0 == 'Vista' ; Windows Vista.
733 ${OrIf} $R0 == '7' ; Windows 7.
734 ${OrIf} $R0 == '8' ; Windows 8.
735 ; Use VBoxCredProv on Vista and up.
736 ${LogVerbose} "Installing VirtualBox credential provider ..."
737 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxCredProv.dll" "$g_strSystemDir\VBoxCredProv.dll" "$INSTDIR"
738 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}" "" "VBoxCredProv" ; adding to (default) key
739 WriteRegStr HKCR "CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}" "" "VBoxCredProv" ; adding to (Default) key
740 WriteRegStr HKCR "CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}\InprocServer32" "" "VBoxCredProv.dll" ; adding to (Default) key
741 WriteRegStr HKCR "CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}\InprocServer32" "ThreadingModel" "Apartment"
742 ${Else} ; Use VBoxGINA on older Windows OSes (< Vista)
743 ${LogVerbose} "Installing VirtualBox GINA ..."
744 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxGINA.dll" "$g_strSystemDir\VBoxGINA.dll" "$INSTDIR"
745 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" "GinaDLL" "VBoxGINA.dll"
746 ; Add Windows notification package callbacks for VBoxGINA
747 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\VBoxGINA" "DLLName" "VBoxGINA.dll"
748 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\VBoxGINA" "Impersonate" 0
749 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\VBoxGINA" "StopScreenSaver" "WnpScreenSaverStop"
750 ${EndIf}
751
752skip:
753
754 ; Nothing to do here right now
755
756exit:
757
758SectionEnd
759
760; Prepares the access rights for replacing
761; a WRP (Windows Resource Protection) protected file
762Function PrepareWRPFile
763
764 Pop $0
765
766 ${IfNot} ${FileExists} "$0"
767 ${LogVerbose} "WRP: File $0 does not exist, skipping"
768 Return
769 ${EndIf}
770
771 ${If} ${FileExists} "$g_strSystemDir\takeown.exe"
772 ${CmdExecute} "$\"$g_strSystemDir\takeown.exe$\" /F $\"$0$\"" "true"
773 ${Else}
774 ${LogVerbose} "WRP: Warning: takeown.exe not found, skipping"
775 ${EndIf}
776
777 AccessControl::SetFileOwner "$0" "(S-1-5-32-545)"
778 Pop $1
779 ${LogVerbose} "WRP: Setting file owner for $0 returned: $1"
780
781 AccessControl::GrantOnFile "$0" "(S-1-5-32-545)" "FullAccess"
782 Pop $1
783 ${LogVerbose} "WRP: Setting access rights for $0 returned: $1"
784
785!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
786 !ifdef WFP_FILE_EXCEPTION
787 VBoxGuestInstallHelper::DisableWFP "$0"
788 Pop $1 ; Get return value (ignored for now)
789 ${LogVerbose} "WRP: Setting WFP exception for $0 returned: $1"
790 !endif
791!endif
792
793FunctionEnd
794
795; Direct3D support
796Section /o $(VBOX_COMPONENT_D3D) SEC03
797
798!if $%VBOX_WITH_WDDM% == "1"
799 ${If} $g_bWithWDDM == "true"
800 ; All D3D components are installed with WDDM driver package, nothing to be done here
801 Return
802 ${EndIf}
803!endif
804
805 SetOverwrite on
806
807 ${If} $g_strSystemDir == ''
808 StrCpy $g_strSystemDir "$SYSDIR"
809 ${EndIf}
810
811 SetOutPath $g_strSystemDir
812 ${LogVerbose} "Installing Direct3D support ..."
813 FILE "$%PATH_OUT%\bin\additions\VBoxD3D8.dll"
814 FILE "$%PATH_OUT%\bin\additions\VBoxD3D9.dll"
815 FILE "$%PATH_OUT%\bin\additions\wined3d.dll"
816
817 ;
818 ; Update DLL cache
819 ;
820 ${If} $g_bCapDllCache == "true"
821 ${If} ${FileExists} "$g_strSystemDir\dllcache"
822 SetOutPath "$g_strSystemDir\dllcache"
823 ${CopyFileEx} "" "$g_strSystemDir\dllcache\d3d8.dll" "$g_strSystemDir\dllcache\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
824 ${CopyFileEx} "" "$g_strSystemDir\dllcache\d3d9.dll" "$g_strSystemDir\dllcache\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
825
826 Push "$g_strSystemDir\dllcache\d3d8.dll"
827 Call PrepareWRPFile
828
829 Push "$g_strSystemDir\dllcache\d3d9.dll"
830 Call PrepareWRPFile
831
832 ; Exchange DLLs
833 ${InstallFileEx} "" "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\dllcache\d3d8.dll" "$TEMP"
834 ${InstallFileEx} "" "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\dllcache\d3d9.dll" "$TEMP"
835 ${Else}
836 ${LogVerbose} "DLL cache does not exist, skipping"
837 ${EndIf}
838 ${EndIf}
839
840 ;
841 ; Save original DLLs (only if msd3d*.dll does not exist) ...
842 ;
843 SetOutPath $g_strSystemDir
844 ${CopyFileEx} "" "$g_strSystemDir\d3d8.dll" "$g_strSystemDir\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
845 ${CopyFileEx} "" "$g_strSystemDir\d3d9.dll" "$g_strSystemDir\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
846
847 Push "$g_strSystemDir\d3d8.dll"
848 Call PrepareWRPFile
849
850 Push "$g_strSystemDir\d3d9.dll"
851 Call PrepareWRPFile
852
853 ; Exchange DLLs
854 ${InstallFileEx} "" "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\d3d8.dll" "$TEMP"
855 ${InstallFileEx} "" "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\d3d9.dll" "$TEMP"
856
857!if $%BUILD_TARGET_ARCH% == "amd64"
858 ; Only 64-bit installer:
859 ; Also copy 32-bit DLLs on 64-bit Windows in SysWOW64 node
860 SetOutPath $g_strSysWow64
861 ${LogVerbose} "Installing Direct3D support for 32-bit applications (SysWOW64: $g_strSysWow64) ..."
862 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D8.dll"
863 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D9.dll"
864 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\wined3d.dll"
865
866 ;
867 ; Update DLL cache
868 ;
869 ${If} $g_bCapDllCache == "true"
870 ${If} ${FileExists} "$g_strSysWow64\dllcache"
871 SetOutPath "$g_strSysWow64\dllcache"
872 ${CopyFileEx} "" "$g_strSysWow64\dllcache\d3d8.dll" "$g_strSysWow64\dllcache\msd3d8.dll" "Microsoft Corporation" "x86"
873 ${CopyFileEx} "" "$g_strSysWow64\dllcache\d3d9.dll" "$g_strSysWow64\dllcache\msd3d9.dll" "Microsoft Corporation" "x86"
874
875 Push "$g_strSysWow64\dllcache\d3d8.dll"
876 Call PrepareWRPFile
877
878 Push "$g_strSysWow64\dllcache\d3d9.dll"
879 Call PrepareWRPFile
880
881 ; Exchange DLLs
882 ${InstallFileEx} "" "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "$TEMP"
883 ${InstallFileEx} "" "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "$TEMP"
884 ${Else}
885 ${LogVerbose} "DLL cache does not exist, skipping"
886 ${EndIf}
887 ${EndIf}
888
889 ;
890 ; Update original DLLs
891 ;
892
893 ; Save original DLLs (only if msd3d*.dll does not exist) ...
894 ${CopyFileEx} "" "$g_strSysWow64\d3d8.dll" "$g_strSysWow64\msd3d8.dll" "Microsoft Corporation" "x86"
895 ${CopyFileEx} "" "$g_strSysWow64\d3d9.dll" "$g_strSysWow64\msd3d9.dll" "Microsoft Corporation" "x86"
896
897 Push "$g_strSysWow64\d3d8.dll"
898 Call PrepareWRPFile
899
900 Push "$g_strSysWow64\d3d9.dll"
901 Call PrepareWRPFile
902
903 ; Exchange DLLs
904 ${InstallFileEx} "" "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\d3d8.dll" "$TEMP"
905 ${InstallFileEx} "" "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\d3d9.dll" "$TEMP"
906
907!endif ; amd64
908 Goto done
909
910error:
911 ; @todo
912 Goto exit
913
914done:
915
916!ifndef WFP_FILE_EXCEPTION
917 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_WFP_WARN_REPLACE) /SD IDOK
918!endif
919 Goto exit
920
921exit:
922
923SectionEnd
924
925!ifdef USE_MUI
926 ;Assign language strings to sections
927 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
928 !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(VBOX_COMPONENT_MAIN_DESC)
929 !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} $(VBOX_COMPONENT_AUTOLOGON_DESC)
930 !if $%VBOX_WITH_CROGL% == "1"
931 !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $(VBOX_COMPONENT_D3D_DESC)
932 !endif
933 !insertmacro MUI_FUNCTION_DESCRIPTION_END
934!endif ; USE_MUI
935
936Section -Content
937
938 WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
939
940SectionEnd
941
942Section -StartMenu
943
944 CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
945 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" "" "$INSTDIR\iexplore.ico"
946 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninst.exe"
947
948SectionEnd
949
950; This section is called after all the files are in place
951Section -Post
952
953!ifdef _DEBUG
954 ${LogVerbose} "Doing post install ..."
955!endif
956
957!ifdef EXTERNAL_UNINSTALLER
958 SetOutPath "$INSTDIR"
959 FILE "$%PATH_TARGET%\uninst.exe"
960!else
961 WriteUninstaller "$INSTDIR\uninst.exe"
962!endif
963
964 ; Write uninstaller in "Add / Remove programs"
965 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
966 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
967 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
968 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
969 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
970
971 ; Tune TcpWindowSize for a better network throughput
972 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" "TcpWindowSize" 64240
973
974 ; Add Sun Ray client info keys
975 ; Note: We only need 32-bit keys (HKLM\Software / HKLM\Software\Wow6432Node)
976!if $%BUILD_TARGET_ARCH% == "amd64"
977 WriteRegStr HKLM "SOFTWARE\Wow6432Node\Oracle\Sun Ray\ClientInfoAgent\ReconnectActions" "" ""
978 WriteRegStr HKLM "SOFTWARE\Wow6432Node\Oracle\Sun Ray\ClientInfoAgent\DisconnectActions" "" ""
979!else
980 WriteRegStr HKLM "SOFTWARE\Oracle\Sun Ray\ClientInfoAgent\ReconnectActions" "" ""
981 WriteRegStr HKLM "SOFTWARE\Oracle\Sun Ray\ClientInfoAgent\DisconnectActions" "" ""
982!endif
983
984 ${LogVerbose} "Installation completed."
985
986SectionEnd
987
988; !!! NOTE: This function *has* to be right under the last section; otherwise it does
989; *not* get called! Don't ask me why ... !!!
990Function .onSelChange
991
992 Push $0
993
994 ; Handle selection of D3D component
995 SectionGetFlags ${SEC03} $0
996 ${If} $0 == ${SF_SELECTED}
997
998 StrCpy $g_bWithD3D "true"
999
1000!if $%VBOX_WITH_WDDM% == "1"
1001 ; If we're able to use the WDDM driver just use it instead of the replaced
1002 ; D3D components below
1003 ${If} $g_bCapWDDM == "true"
1004 ;
1005 ; Temporary solution: Since WDDM is marked as experimental yet we notify the user
1006 ; that WDDM (Aero) support is available but not recommended for production use. He now
1007 ; can opt-in for installing WDDM or still go for the old (XPDM) way -- safe mode still required!
1008 ;
1009 MessageBox MB_ICONQUESTION|MB_YESNO $(VBOX_COMPONENT_D3D_OR_WDDM) /SD IDNO IDYES d3d_install
1010 ; Display an unconditional hint about needed VRAM sizes
1011 ; Note: We also could use the PCI configuration space (WMI: Win32_SystemSlot Class) for querying
1012 ; the current VRAM size, but let's keep it simple for now
1013 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_COMPONENT_D3D_HINT_VRAM) /SD IDOK
1014 StrCpy $g_bWithWDDM "true"
1015 Goto exit
1016 ${EndIf}
1017
1018d3d_install:
1019
1020!endif ; $%VBOX_WITH_WDDM% == "1"
1021
1022 ${If} $g_bForceInstall != "true"
1023 ; Do not install on < XP
1024 ${If} $g_strWinVersion == "NT4"
1025 ${OrIf} $g_strWinVersion == "2000"
1026 ${OrIf} $g_strWinVersion == ""
1027 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_COMPONENT_D3D_NOT_SUPPORTED) /SD IDOK
1028 Goto d3d_disable
1029 ${EndIf}
1030 ${EndIf}
1031
1032 ; If force flag is set skip the safe mode check
1033 ${If} $g_bForceInstall != "true"
1034 ; If we're not in safe mode, print a warning and don't install D3D support
1035 ${If} $g_iSystemMode == '0'
1036 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_COMPONENT_D3D_NO_SM) /SD IDOK
1037 Goto d3d_disable
1038 ${EndIf}
1039 ${EndIf}
1040
1041 ${Else} ; D3D unselected again
1042
1043 ${If} $g_strWinVersion != "8" ; On Windows 8 WDDM is mandatory
1044 StrCpy $g_bWithWDDM "false"
1045 ${EndIf}
1046
1047 ${EndIf}
1048 Goto exit
1049
1050d3d_disable:
1051
1052 StrCpy $g_bWithD3D "false"
1053 IntOp $0 $0 & ${SECTION_OFF} ; Unselect section again
1054 SectionSetFlags ${SEC03} $0
1055 Goto exit
1056
1057exit:
1058
1059 Pop $0
1060
1061FunctionEnd
1062
1063; This function is called when a critical error occurred, caused by
1064; the Abort command
1065Function .onInstFailed
1066
1067 ${LogVerbose} "$(VBOX_ERROR_INST_FAILED)"
1068 MessageBox MB_ICONSTOP $(VBOX_ERROR_INST_FAILED) /SD IDOK
1069
1070 ${If} $g_bPostInstallStatus == "true"
1071 ${LogToVBoxTray} "2" "Error while installing ${PRODUCT_NAME}!"
1072 ${EndIf}
1073
1074 ; Set overall exit code
1075 SetErrorLevel 1
1076
1077FunctionEnd
1078
1079; This function is called when installation was successful!
1080Function .onInstSuccess
1081
1082 ${LogVerbose} "${PRODUCT_NAME} successfully installed"
1083
1084 ${If} $g_bPostInstallStatus == "true"
1085 ${LogToVBoxTray} "0" "${PRODUCT_NAME} successfully updated!"
1086 ${EndIf}
1087
1088 SetErrorLevel 0
1089
1090FunctionEnd
1091
1092; This function is called at the very beginning of installer execution
1093Function .onInit
1094
1095 Push $0
1096
1097 ; Init values
1098 StrCpy $g_iSystemMode "0"
1099 StrCpy $g_strCurUser "<None>"
1100 StrCpy $g_strAddVerMaj "0"
1101 StrCpy $g_strAddVerMin "0"
1102 StrCpy $g_strAddVerBuild "0"
1103 StrCpy $g_strAddVerRev "0"
1104
1105 StrCpy $g_bIgnoreUnknownOpts "false"
1106 StrCpy $g_bLogEnable "false"
1107 StrCpy $g_bFakeWHQL "false"
1108 StrCpy $g_bForceInstall "false"
1109 StrCpy $g_bUninstall "false"
1110 StrCpy $g_bRebootOnExit "false"
1111 StrCpy $g_iScreenX "0"
1112 StrCpy $g_iScreenY "0"
1113 StrCpy $g_iScreenBpp "0"
1114 StrCpy $g_iSfOrder "0"
1115 StrCpy $g_bNoVBoxServiceExit "false"
1116 StrCpy $g_bNoVBoxTrayExit "false"
1117 StrCpy $g_bNoVideoDrv "false"
1118 StrCpy $g_bNoGuestDrv "false"
1119 StrCpy $g_bNoMouseDrv "false"
1120 StrCpy $g_bWithAutoLogon "false"
1121 StrCpy $g_bWithD3D "false"
1122 StrCpy $g_bOnlyExtract "false"
1123 StrCpy $g_bWithWDDM "false"
1124 StrCpy $g_bCapDllCache "false"
1125 StrCpy $g_bCapWDDM "false"
1126 StrCpy $g_bPostInstallStatus "false"
1127
1128 ; We need a special directory set to SysWOW64 because some
1129 ; shell operations don't support file redirection (yet)
1130 StrCpy $g_strSysWow64 "$WINDIR\SysWOW64"
1131
1132 SetErrorLevel 0
1133 ClearErrors
1134
1135!ifdef UNINSTALLER_ONLY
1136
1137 ;
1138 ; If UNINSTALLER_ONLY is defined, we're only interested in uninst.exe
1139 ; so we can sign it
1140 ;
1141 ; Note that the Quit causes the exit status to be 2 instead of 0
1142 ;
1143 WriteUninstaller "$%PATH_TARGET%\uninst.exe"
1144 Quit
1145
1146!else
1147
1148 ; Handle command line
1149 Call HandleCommandLine
1150
1151 ; Check if there's already another instance of the installer is running -
1152 ; important for preventing NT4 to spawn the installer twice
1153 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "VBoxGuestInstaller") ?e'
1154 Pop $0
1155 ${If} $0 != 0
1156 Quit
1157 ${EndIf}
1158
1159 ; Retrieve Windows version and store result in $g_strWinVersion
1160 Call GetWindowsVersionEx
1161 Pop $g_strWinVersion
1162
1163 ; Get user Name
1164 AccessControl::GetCurrentUserName
1165 Pop $g_strCurUser
1166 ${LogVerbose} "Current user: $g_strCurUser"
1167
1168 ; Only extract files? This action can be called even from non-Admin users
1169 ; and non-compatible architectures
1170 ${If} $g_bOnlyExtract == "true"
1171 Call ExtractFiles
1172 MessageBox MB_OK|MB_ICONINFORMATION $(VBOX_EXTRACTION_COMPLETE) /SD IDOK
1173 Quit
1174 ${EndIf}
1175
1176 ; Check for correct architecture
1177 Call CheckArchitecture
1178 Pop $0
1179 ${If} $0 <> 0 ; Wrong architecture? Tell the world
1180!if $%BUILD_TARGET_ARCH% == "amd64"
1181 MessageBox MB_ICONSTOP $(VBOX_NOTICE_ARCH_AMD64) /SD IDOK
1182!else
1183 MessageBox MB_ICONSTOP $(VBOX_NOTICE_ARCH_X86) /SD IDOK
1184!endif
1185 Abort "$(VBOX_NOTICE_ARCH_AMD64)"
1186 ${EndIf}
1187
1188 ; Has the user who calls us admin rights?
1189 UserInfo::GetAccountType
1190 Pop $0
1191 ${If} $0 != "Admin"
1192 MessageBox MB_ICONSTOP $(VBOX_NOADMIN) /SD IDOK
1193 Abort
1194 ${EndIf}
1195
1196 ; Only uninstall?
1197 ${If} $g_bUninstall == "true"
1198 Call Uninstall_Innotek
1199 Call Uninstall
1200 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_UNINST_SUCCESS) /SD IDOK
1201 Quit
1202 ${EndIf}
1203
1204 Call CheckForInstalledComponents
1205
1206 ; Set section bits
1207 ${If} $g_bWithAutoLogon == "true" ; Auto-logon support
1208 !insertmacro SelectSection ${SEC02}
1209 ${EndIf}
1210!if $%VBOX_WITH_CROGL% == "1"
1211 ${If} $g_bWithD3D == "true" ; D3D support
1212 !insertmacro SelectSection ${SEC03}
1213 ${EndIf}
1214!endif
1215 ; On Windows 8 we always select the 3D section and
1216 ; disable it so that it cannot be deselected again
1217 ${If} $g_strWinVersion == "8"
1218 IntOp $0 ${SF_SELECTED} | ${SF_RO}
1219 SectionSetFlags ${SEC03} $0
1220 ${EndIf}
1221
1222!ifdef USE_MUI
1223 ; Display language selection dialog (will be hidden in silent mode!)
1224 !ifdef VBOX_INSTALLER_ADD_LANGUAGES
1225 !insertmacro MUI_LANGDLL_DISPLAY
1226 !endif
1227!endif
1228
1229 Call SetAppMode64
1230
1231 ; Check for old additions
1232 Call CheckForOldGuestAdditions
1233 Call GetAdditionsVersion
1234
1235 ; Due to some bug in NSIS the license page won't be displayed if we're in
1236 ; 64-bit registry view, so as a workaround switch back to 32-bit (Wow6432Node)
1237 ; mode for now
1238 Call SetAppMode32
1239
1240!endif ; UNINSTALLER_ONLY
1241
1242 Pop $0
1243
1244FunctionEnd
1245
1246;
1247; The uninstaller is built separately when doing code signing
1248; For some reason NSIS still finds the Uninstall section even
1249; when EXTERNAL_UNINSTALLER is defined. This causes a silly warning
1250;
1251!ifndef EXTERNAL_UNINSTALLER
1252
1253Function un.onUninstSuccess
1254
1255 HideWindow
1256 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_UNINST_SUCCESS) /SD IDOK
1257
1258FunctionEnd
1259
1260Function un.onInit
1261
1262 ; Has the user who calls us admin rights?
1263 UserInfo::GetAccountType
1264 Pop $0
1265 ${If} $0 != "Admin"
1266 MessageBox MB_ICONSTOP $(VBOX_NOADMIN) /SD IDOK
1267 Abort
1268 ${EndIf}
1269
1270 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(VBOX_UNINST_CONFIRM) /SD IDYES IDYES proceed
1271 Quit
1272
1273proceed:
1274
1275 Call un.SetAppMode64
1276
1277 ; Set system directory
1278 StrCpy $g_strSystemDir "$SYSDIR"
1279
1280 ; We need a special directory set to SysWOW64 because some
1281 ; shell operations don't support file redirection (yet)
1282 StrCpy $g_strSysWow64 "$WINDIR\SysWOW64"
1283
1284 ; Retrieve Windows version we're running on and store it in $g_strWinVersion
1285 Call un.GetWindowsVersionEx
1286 Pop $g_strWinVersion
1287
1288 ; Retrieve capabilities
1289 Call un.CheckForCapabilities
1290
1291FunctionEnd
1292
1293Section Uninstall
1294
1295!ifdef _DEBUG
1296 ${LogEnable} "true"
1297!endif
1298
1299 Call un.SetAppMode64
1300
1301 ; Call the uninstall main function
1302 Call un.Uninstall
1303
1304 ; ... and remove the local install directory
1305 Call un.UninstallInstDir
1306
1307!ifndef _DEBUG
1308 SetAutoClose true
1309 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(VBOX_REBOOT_REQUIRED) /SD IDNO IDYES restart
1310 StrCmp $g_bRebootOnExit "true" restart
1311!endif
1312
1313 Goto exit
1314
1315restart:
1316
1317 ${LogVerbose} "Rebooting ..."
1318 Reboot
1319
1320exit:
1321
1322SectionEnd
1323
1324; !EXTERNAL_UNINSTALLER
1325!endif
1326
1327;Direct the output to our bin dir
1328!cd "$%PATH_OUT%\bin\additions"
Note: See TracBrowser for help on using the repository browser.

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