VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsW2KXP.nsh@ 96692

Last change on this file since 96692 was 96692, checked in by vboxsync, 21 months ago

Add/Nt/Installer,/Config.kmk,SupDrv/Certs: Check for and install missing root certificates. This is a real problem with vista and older. bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 29.0 KB
Line 
1; $Id: VBoxGuestAdditionsW2KXP.nsh 96692 2022-09-12 00:39:59Z vboxsync $
2;; @file
3; VBoxGuestAdditionsW2KXP.nsh - Guest Additions installation for Windows 2000/XP.
4;
5
6;
7; Copyright (C) 2006-2022 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; SPDX-License-Identifier: GPL-3.0-only
26;
27
28Function W2K_SetVideoResolution
29
30 ; NSIS only supports global vars, even in functions -- great
31 Var /GLOBAL i
32 Var /GLOBAL tmp
33 Var /GLOBAL tmppath
34 Var /GLOBAL dev_id
35 Var /GLOBAL dev_desc
36
37 ; Check for all required parameters
38 StrCmp $g_iScreenX "0" exit
39 StrCmp $g_iScreenY "0" exit
40 StrCmp $g_iScreenBpp "0" exit
41
42 ${LogVerbose} "Setting display parameters ($g_iScreenXx$g_iScreenY, $g_iScreenBpp BPP) ..."
43
44 ; Enumerate all video devices (up to 32 at the moment, use key "MaxObjectNumber" key later)
45 ${For} $i 0 32
46
47 ReadRegStr $tmp HKLM "HARDWARE\DEVICEMAP\VIDEO" "\Device\Video$i"
48 StrCmp $tmp "" dev_not_found
49
50 ; Extract path to video settings
51 ; Ex: \Registry\Machine\System\CurrentControlSet\Control\Video\{28B74D2B-F0A9-48E0-8028-D76F6BB1AE65}\0000
52 ; Or: \Registry\Machine\System\CurrentControlSet\Control\Video\vboxvideo\Device0
53 ; Result: Machine\System\CurrentControlSet\Control\Video\{28B74D2B-F0A9-48E0-8028-D76F6BB1AE65}\0000
54 Push "$tmp" ; String
55 Push "\" ; SubString
56 Push ">" ; SearchDirection
57 Push ">" ; StrInclusionDirection
58 Push "0" ; IncludeSubString
59 Push "2" ; Loops
60 Push "0" ; CaseSensitive
61 Call StrStrAdv
62 Pop $tmppath ; $1 only contains the full path
63 StrCmp $tmppath "" dev_not_found
64
65 ; Get device description
66 ReadRegStr $dev_desc HKLM "$tmppath" "Device Description"
67!ifdef _DEBUG
68 ${LogVerbose} "Registry path: $tmppath"
69 ${LogVerbose} "Registry path to device name: $temp"
70!endif
71 ${LogVerbose} "Detected video device: $dev_desc"
72
73 ${If} $dev_desc == "VirtualBox Graphics Adapter"
74 ${LogVerbose} "VirtualBox video device found!"
75 Goto dev_found
76 ${EndIf}
77 ${Next}
78 Goto dev_not_found
79
80dev_found:
81
82 ; If we're on Windows 2000, skip the ID detection ...
83 ${If} $g_strWinVersion == "2000"
84 Goto change_res
85 ${EndIf}
86 Goto dev_found_detect_id
87
88dev_found_detect_id:
89
90 StrCpy $i 0 ; Start at index 0
91 ${LogVerbose} "Detecting device ID ..."
92
93dev_found_detect_id_loop:
94
95 ; Resolve real path to hardware instance "{GUID}"
96 EnumRegKey $dev_id HKLM "SYSTEM\CurrentControlSet\Control\Video" $i
97 StrCmp $dev_id "" dev_not_found ; No more entries? Jump out
98!ifdef _DEBUG
99 ${LogVerbose} "Got device ID: $dev_id"
100!endif
101 ReadRegStr $dev_desc HKLM "SYSTEM\CurrentControlSet\Control\Video\$dev_id\0000" "Device Description" ; Try to read device name
102 ${If} $dev_desc == "VirtualBox Graphics Adapter"
103 ${LogVerbose} "Device ID of $dev_desc: $dev_id"
104 Goto change_res
105 ${EndIf}
106
107 IntOp $i $i + 1 ; Increment index
108 goto dev_found_detect_id_loop
109
110dev_not_found:
111
112 ${LogVerbose} "No VirtualBox video device (yet) detected! No custom mode set."
113 Goto exit
114
115change_res:
116
117!ifdef _DEBUG
118 ${LogVerbose} "Device description: $dev_desc"
119 ${LogVerbose} "Device ID: $dev_id"
120!endif
121
122 Var /GLOBAL reg_path_device
123 Var /GLOBAL reg_path_monitor
124
125 ${LogVerbose} "Custom mode set: Platform is Windows $g_strWinVersion"
126 ${If} $g_strWinVersion == "2000"
127 ${OrIf} $g_strWinVersion == "Vista"
128 StrCpy $reg_path_device "SYSTEM\CurrentControlSet\SERVICES\VBoxVideo\Device0"
129 StrCpy $reg_path_monitor "SYSTEM\CurrentControlSet\SERVICES\VBoxVideo\Device0\Mon00000001"
130 ${ElseIf} $g_strWinVersion == "XP"
131 ${OrIf} $g_strWinVersion == "7"
132 ${OrIf} $g_strWinVersion == "8"
133 ${OrIf} $g_strWinVersion == "8_1"
134 ${OrIf} $g_strWinVersion == "10"
135 StrCpy $reg_path_device "SYSTEM\CurrentControlSet\Control\Video\$dev_id\0000"
136 StrCpy $reg_path_monitor "SYSTEM\CurrentControlSet\Control\VIDEO\$dev_id\0000\Mon00000001"
137 ${Else}
138 ${LogVerbose} "Custom mode set: Windows $g_strWinVersion not supported yet"
139 Goto exit
140 ${EndIf}
141
142 ; Write the new value in the adapter config (VBoxVideo.sys) using hex values in binary format
143 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" registry write HKLM $reg_path_device CustomXRes REG_BIN $g_iScreenX DWORD" 'non-zero-exitcode=abort'
144 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" registry write HKLM $reg_path_device CustomYRes REG_BIN $g_iScreenY DWORD" 'non-zero-exitcode=abort'
145 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" registry write HKLM $reg_path_device CustomBPP REG_BIN $g_iScreenBpp DWORD" 'non-zero-exitcode=abort'
146
147 ; ... and tell Windows to use that mode on next start!
148 WriteRegDWORD HKCC $reg_path_device "DefaultSettings.XResolution" "$g_iScreenX"
149 WriteRegDWORD HKCC $reg_path_device "DefaultSettings.YResolution" "$g_iScreenY"
150 WriteRegDWORD HKCC $reg_path_device "DefaultSettings.BitsPerPixel" "$g_iScreenBpp"
151
152 WriteRegDWORD HKCC $reg_path_monitor "DefaultSettings.XResolution" "$g_iScreenX"
153 WriteRegDWORD HKCC $reg_path_monitor "DefaultSettings.YResolution" "$g_iScreenY"
154 WriteRegDWORD HKCC $reg_path_monitor "DefaultSettings.BitsPerPixel" "$g_iScreenBpp"
155
156 ${LogVerbose} "Custom mode set to $g_iScreenXx$g_iScreenY, $g_iScreenBpp BPP on next restart."
157
158exit:
159
160FunctionEnd
161
162!ifdef VBOX_SIGN_ADDITIONS
163 !ifdef VBOX_WITH_GA_ROOT_VERISIGN_G5 | VBOX_WITH_GA_ROOT_DIGICERT_ASSURED_ID | VBOX_WITH_GA_ROOT_DIGICERT_HIGH_ASSURANCE_EV
164
165;;
166; Checks
167;
168; @param pop1 The RDN of the certificate.
169; @param pop2 Filename (cert dir) if we're shipping it (VBOX_WITH_GA_ROOT_CERTS_INCLUDED).
170; @param pop3 The direct download URL link.
171; @param pop4 The message to display if missing.
172;
173Function W2K_RootCertCheck
174 ;
175 ; Prolog: Save $0, $1, $2, $3 and move the parameters into them. Also save $4 for results.
176 ;
177 Push $0
178 Exch 4
179 Push $1
180 Exch 4
181 Push $2
182 Exch 4
183 Push $3
184 Exch 4
185 Pop $0 ; RDN
186 Pop $1 ; Filename
187 Pop $2 ; Direct URL
188 Pop $3 ; Missing message
189 Push $4
190
191 ;
192 ; Run VBoxCertUtil to check.
193 ;
194 ${LogVerbose} "Checking if $0 is installed ..."
195 ${If} ${Silent}
196 nsExec::ExecToStack "$\"$INSTDIR\cert\VBoxCertUtil.exe$\" root-exists $\"$0$\""
197 Exch 1
198 Pop $4 ; output
199 ${LogVerbose} "$4"
200 Pop $4 ; exit code
201 ${Else}
202 nsExec::ExecToLog "$\"$INSTDIR\cert\VBoxCertUtil.exe$\" root-exists $\"$0$\""
203 Pop $4 ; exit code
204 ${EndIf}
205 ${LogVerbose} "Exit code: $4"
206
207 ;
208 ; VBoxCertUtil terminates with exit code 10 if not found, 0 if found and something else on failure.
209 ;
210 ${If} $4 == 0
211 ${LogVerbose} "Root certificate is present."
212 ${ElseIf} $4 == 10
213 !ifdef VBOX_WITH_GA_ROOT_CERTS_INCLUDED
214 ${LogVerbose} "Root certificate is _NOT_ present. Installing it ..."
215 ${CmdExecute} "$\"$INSTDIR\cert\VBoxCertUtil.exe$\" add-root $\"$INSTDIR\cert\$1$\"" 'non-zero-exitcode=abort'
216 !else
217 ${LogVerbose} "Root certificate is _NOT_ present. The certificate can be downloaded from $2 and installed using '$INSTDIR\cert\VBoxCertUtil.exe'."
218 MessageBox MB_YESNO $3 /SD IDYES IDYES l_dont_abort
219 Abort "Missing signing root certificate $0"
220l_dont_abort:
221 !endif
222 ${ElseIf} $R4 <> 0
223 ${LogVerbose} "Unable to determine whether the root certificate was present. Assuming the worst."
224 Abort "Error when checking whether signing root certificate '$0' was present: $4"
225 ${EndIf}
226
227 ;
228 ; Epilog: Restore $0-$4 (we return nothing).
229 ;
230 Pop $4
231 Pop $3
232 Pop $2
233 Pop $1
234 Pop $0
235FunctionEnd
236 !endif
237!endif
238
239Function W2K_Prepare
240 ; Save registers
241 Push $R0
242 Push $R1
243 Push $R2
244 Push $R3
245 Push $R4
246
247 ${If} $g_bNoVBoxServiceExit == "false"
248 ; Stop / kill VBoxService
249 Call StopVBoxService
250 ${EndIf}
251
252 ${If} $g_bNoVBoxTrayExit == "false"
253 ; Stop / kill VBoxTray
254 Call StopVBoxTray
255 ${EndIf}
256
257 ; Delete VBoxService from registry
258 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxService"
259
260 ; Delete old VBoxService.exe from install directory (replaced by VBoxTray.exe)
261 Delete /REBOOTOK "$INSTDIR\VBoxService.exe"
262
263!ifdef VBOX_SIGN_ADDITIONS
264 ;
265 ; When installing signed GAs, we need to check whether the root certs are
266 ; present, we use VBoxCertUtil for this task. This utility is also used
267 ; for installing missing root certs we can ship, like the special timestamp
268 ; root further down.
269 ;
270 ${LogVerbose} "Installing VBoxCertUtil.exe ..."
271 SetOutPath "$INSTDIR\cert"
272 FILE "$%PATH_OUT%\bin\additions\VBoxCertUtil.exe"
273 !ifdef VBOX_WITH_VBOX_LEGACY_TS_CA
274 FILE "$%PATH_OUT%\bin\additions\vbox-legacy-timestamp-ca.cer"
275 !endif
276 !ifdef VBOX_WITH_GA_ROOT_CERTS_INCLUDED
277 !ifdef VBOX_WITH_GA_ROOT_VERISIGN_G5
278 FILE "$%PATH_OUT%\bin\additions\root-versign-pca3-g5.cer"
279 !endif
280 !ifdef VBOX_WITH_GA_ROOT_DIGICERT_ASSURED_ID
281 FILE "$%PATH_OUT%\bin\additions\root-digicert-assured-id.cer"
282 !endif
283 !ifdef VBOX_WITH_GA_ROOT_DIGICERT_HIGH_ASSURANCE_EV
284 FILE "$%PATH_OUT%\bin\additions\root-digicert-high-assurance-ev.cer"
285 !endif
286 !endif
287
288 ; Now that the files are in place, do the checking.
289 !ifdef VBOX_WITH_GA_ROOT_VERISIGN_G5
290 Push $(VBOX_CA_CHECK_VERISIGN_G5)
291 Push "http://cacerts.digicert.com/pca3-g5.crt"
292 Push "root-versign-pca3-g5.cer"
293 Push "C=US; O=VeriSign, Inc.; OU=VeriSign Trust Network; OU=(c) 2006 VeriSign, Inc. - For authorized use only; CN=VeriSign Class 3 Public Primary Certification Authority - G5"
294 Call W2K_RootCertCheck
295 !endif
296
297 !ifdef VBOX_WITH_GA_ROOT_DIGICERT_ASSURED_ID
298 Push $(VBOX_CA_CHECK_DIGICERT_ASSURED_ID)
299 Push "https://cacerts.digicert.com/DigiCertAssuredIDRootCA.crt"
300 Push "root-digicert-assured-id.cer"
301 Push "C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert Assured ID Root CA"
302 Call W2K_RootCertCheck
303 !endif
304
305 !ifdef VBOX_WITH_GA_ROOT_DIGICERT_HIGH_ASSURANCE_EV
306 Push $(VBOX_CA_CHECK_DIGICERT_HIGH_ASSURANCE_EV)
307 Push "https://cacerts.digicert.com/DigiCertHighAssuranceEVRootCA.crt"
308 Push "root-digicert-high-assurance-ev.cer"
309 Push "C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Assurance EV Root CA"
310 Call W2K_RootCertCheck
311 !endif
312
313 !ifdef VBOX_WITH_VBOX_LEGACY_TS_CA
314 ;
315 ; Install the legacy timestamp CA if required/requested.
316 ;
317
318 ; NSIS only supports global vars, even in functions -- great ;; @todo r=bird: why don't you just change $g_bInstallTimestampCA?
319 Var /GLOBAL bDoInstallCA
320 StrCpy $bDoInstallCA "false" ; Set a default value
321
322 ; If not explicitly specified, let the detected Windows version decide what to do.
323 ${If} $g_bInstallTimestampCA == "unset"
324 ${If} $g_strWinVersion != "10"
325 ; On guest OSes < Windows 10 we always go for the PreW10 drivers and install our legacy timestamp CA.
326 StrCpy $bDoInstallCA "true"
327 ${EndIf}
328 ${Else}
329 StrCpy $bDoInstallCA $g_bInstallTimestampCA
330 ${EndIf}
331
332 ${If} $bDoInstallCA == "true"
333 ${LogVerbose} "Installing legacy timestamp CA certificate ..."
334 ${CmdExecute} "$\"$INSTDIR\cert\VBoxCertUtil.exe$\" add-root $\"$INSTDIR\cert\vbox-legacy-timestamp-ca.cer$\"" 'non-zero-exitcode=log'
335 ${CmdExecute} "$\"$INSTDIR\cert\VBoxCertUtil.exe$\" display-all" 'non-zero-exitcode=log'
336 ${EndIf}
337 !endif ; VBOX_WITH_VBOX_LEGACY_TS_CA
338
339!endif ; VBOX_SIGN_ADDITIONS
340
341 ; Restore registers
342 Pop $R4
343 Pop $R3
344 Pop $R2
345 Pop $R1
346 Pop $R0
347FunctionEnd
348
349Function W2K_CopyFiles
350
351 Push $0
352 SetOutPath "$INSTDIR"
353
354 ; Video driver
355 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.sys"
356 FILE "$%PATH_OUT%\bin\additions\VBoxDisp.dll"
357
358 ; Mouse driver
359 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.sys"
360 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.inf"
361!ifdef VBOX_SIGN_ADDITIONS
362 ${If} $g_strWinVersion == "10"
363 FILE "$%PATH_OUT%\bin\additions\VBoxMouse.cat"
364 ${Else}
365 FILE "/oname=VBoxMouse.cat" "$%PATH_OUT%\bin\additions\VBoxMouse-PreW10.cat"
366 ${EndIf}
367!endif
368
369 ; Guest driver
370 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.sys"
371 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.inf"
372!ifdef VBOX_SIGN_ADDITIONS
373 ${If} $g_strWinVersion == "10"
374 FILE "$%PATH_OUT%\bin\additions\VBoxGuest.cat"
375 ${Else}
376 FILE "/oname=VBoxGuest.cat" "$%PATH_OUT%\bin\additions\VBoxGuest-PreW10.cat"
377 ${EndIf}
378!endif
379
380 ; Guest driver files
381 FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
382 FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
383
384 ; Misc
385!ifdef VBOX_WITH_ADDITIONS_SHIPPING_AUDIO_TEST
386 FILE "$%PATH_OUT%\bin\additions\VBoxAudioTest.exe"
387!endif
388
389 SetOutPath $g_strSystemDir
390
391 ; VBoxService
392 ${If} $g_bNoVBoxServiceExit == "false"
393 ; VBoxService has been terminated before, so just install the file
394 ; in the regular way
395 FILE "$%PATH_OUT%\bin\additions\VBoxService.exe"
396 ${Else}
397 ; VBoxService is in use and wasn't terminated intentionally. So extract the
398 ; new version into a temporary location and install it on next reboot
399 Push $0
400 ClearErrors
401 GetTempFileName $0
402 IfErrors 0 +3
403 ${LogVerbose} "Error getting temp file for VBoxService.exe"
404 StrCpy "$0" "$INSTDIR\VBoxServiceTemp.exe"
405 ${LogVerbose} "VBoxService is in use, will be installed on next reboot (from '$0')"
406 File "/oname=$0" "$%PATH_OUT%\bin\additions\VBoxService.exe"
407 IfErrors 0 +2
408 ${LogVerbose} "Error copying VBoxService.exe to '$0'"
409 Rename /REBOOTOK "$0" "$g_strSystemDir\VBoxService.exe"
410 IfErrors 0 +2
411 ${LogVerbose} "Error renaming '$0' to '$g_strSystemDir\VBoxService.exe'"
412 Pop $0
413 ${EndIf}
414
415!if $%VBOX_WITH_WDDM% == "1"
416 ${If} $g_bWithWDDM == "true"
417 ; WDDM Video driver
418 SetOutPath "$INSTDIR"
419
420 !ifdef VBOX_SIGN_ADDITIONS
421 ${If} $g_strWinVersion == "10"
422 FILE "$%PATH_OUT%\bin\additions\VBoxWddm.cat"
423 ${Else}
424 FILE "/oname=VBoxWddm.cat" "$%PATH_OUT%\bin\additions\VBoxWddm-PreW10.cat"
425 ${EndIf}
426 !endif
427 FILE "$%PATH_OUT%\bin\additions\VBoxWddm.sys"
428 FILE "$%PATH_OUT%\bin\additions\VBoxWddm.inf"
429
430 FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D.dll"
431 !if $%VBOX_WITH_WDDM_DX% == "1"
432 FILE "$%PATH_OUT%\bin\additions\VBoxDX.dll"
433 !endif
434 !if $%VBOX_WITH_MESA3D% == "1"
435 FILE "$%PATH_OUT%\bin\additions\VBoxNine.dll"
436 FILE "$%PATH_OUT%\bin\additions\VBoxSVGA.dll"
437 FILE "$%PATH_OUT%\bin\additions\VBoxGL.dll"
438 !endif
439
440 !if $%KBUILD_TARGET_ARCH% == "amd64"
441 FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D-x86.dll"
442 !if $%VBOX_WITH_WDDM_DX% == "1"
443 FILE "$%PATH_OUT%\bin\additions\VBoxDX-x86.dll"
444 !endif
445 !if $%VBOX_WITH_MESA3D% == "1"
446 FILE "$%PATH_OUT%\bin\additions\VBoxNine-x86.dll"
447 FILE "$%PATH_OUT%\bin\additions\VBoxSVGA-x86.dll"
448 FILE "$%PATH_OUT%\bin\additions\VBoxGL-x86.dll"
449 !endif
450 !endif ; $%KBUILD_TARGET_ARCH% == "amd64"
451
452 ${EndIf}
453!endif ; $%VBOX_WITH_WDDM% == "1"
454
455 Pop $0
456
457FunctionEnd
458
459
460Function W2K_InstallFiles
461
462 ; The Shared Folder IFS goes to the system directory
463 !if $%BUILD_TARGET_ARCH% == "x86"
464 ; On x86 we have to use a different shared folder driver linked against an older RDBSS for Windows 7 and older.
465 ${If} $g_strWinVersion == "2000"
466 ${OrIf} $g_strWinVersion == "XP"
467 ${OrIf} $g_strWinVersion == "2003"
468 ${OrIf} $g_strWinVersion == "Vista"
469 ${OrIf} $g_strWinVersion == "7"
470 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxSFW2K.sys" "$g_strSystemDir\drivers\VBoxSF.sys" "$INSTDIR"
471 ${Else}
472 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxSF.sys" "$g_strSystemDir\drivers\VBoxSF.sys" "$INSTDIR"
473 ${EndIf}
474 !else
475 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxSF.sys" "$g_strSystemDir\drivers\VBoxSF.sys" "$INSTDIR"
476 !endif
477
478 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxMRXNP.dll" "$g_strSystemDir\VBoxMRXNP.dll" "$INSTDIR"
479 AccessControl::GrantOnFile "$g_strSystemDir\VBoxMRXNP.dll" "(BU)" "GenericRead"
480 !if $%KBUILD_TARGET_ARCH% == "amd64"
481 ; Only 64-bit installer: Copy the 32-bit DLL for 32 bit applications.
482 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxMRXNP-x86.dll" "$g_strSysWow64\VBoxMRXNP.dll" "$INSTDIR"
483 AccessControl::GrantOnFile "$g_strSysWow64\VBoxMRXNP.dll" "(BU)" "GenericRead"
484 !endif
485
486 ; The VBoxTray hook DLL also goes to the system directory; it might be locked
487 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxHook.dll" "$g_strSystemDir\VBoxHook.dll" "$INSTDIR"
488 AccessControl::GrantOnFile "$g_strSystemDir\VBoxHook.dll" "(BU)" "GenericRead"
489
490 ${LogVerbose} "Installing drivers ..."
491
492 Push $0 ; For fetching results
493
494 SetOutPath "$INSTDIR"
495
496 ${If} $g_bNoGuestDrv == "false"
497 ${LogVerbose} "Installing guest driver ..."
498 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver install $\"$INSTDIR\VBoxGuest.inf$\" $\"$INSTDIR\install_drivers.log$\"" 'non-zero-exitcode=abort'
499 ${Else}
500 ${LogVerbose} "Guest driver installation skipped!"
501 ${EndIf}
502
503 ${If} $g_bNoVideoDrv == "false"
504 ${If} $g_bWithWDDM == "true"
505 ${LogVerbose} "Installing WDDM video driver..."
506 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver install $\"$INSTDIR\VBoxWddm.inf$\" $\"$INSTDIR\install_drivers.log$\"" 'non-zero-exitcode=abort'
507 ${Else}
508 ${LogVerbose} "Installing video driver ..."
509 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver install $\"$INSTDIR\VBoxVideo.inf$\" $\"$INSTDIR\install_drivers.log$\"" 'non-zero-exitcode=abort'
510 ${EndIf}
511 ${Else}
512 ${LogVerbose} "Video driver installation skipped!"
513 ${EndIf}
514
515 ;
516 ; Mouse driver.
517 ;
518 ${If} $g_bNoMouseDrv == "false"
519 ${LogVerbose} "Installing mouse driver ..."
520 ; The mouse filter does not contain any device IDs but a "DefaultInstall" section;
521 ; so this .INF file needs to be installed using "InstallHinfSection" which is implemented
522 ; with VBoxDrvInst's "driver executeinf" routine
523 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver install $\"$INSTDIR\VBoxMouse.inf$\"" 'non-zero-exitcode=abort'
524 ${Else}
525 ${LogVerbose} "Mouse driver installation skipped!"
526 ${EndIf}
527
528 ;
529 ; Create the VBoxService service
530 ; No need to stop/remove the service here! Do this only on uninstallation!
531 ;
532 ${LogVerbose} "Installing VirtualBox service ..."
533 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service create $\"VBoxService$\" $\"VirtualBox Guest Additions Service$\" 16 2 $\"%SystemRoot%\System32\VBoxService.exe$\" $\"Base$\"" 'non-zero-exitcode=abort'
534
535 ; Set service description
536 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxService" "Description" "Manages VM runtime information, time synchronization, remote sysprep execution and miscellaneous utilities for guest operating systems."
537
538
539 ;
540 ; Shared folders.
541 ;
542 ${LogVerbose} "Installing Shared Folders service ..."
543
544 ; Create the Shared Folders service ...
545 ; No need to stop/remove the service here! Do this only on uninstallation!
546 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service create $\"VBoxSF$\" $\"VirtualBox Shared Folders$\" 2 1 $\"\SystemRoot\System32\drivers\VBoxSF.sys$\" $\"NetworkProvider$\"" 'non-zero-exitcode=abort'
547
548 ; ... and the link to the network provider
549 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "DeviceName" "\Device\VBoxMiniRdr"
550 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "Name" "VirtualBox Shared Folders"
551 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "ProviderPath" "$SYSDIR\VBoxMRXNP.dll"
552
553 ; Add default network providers (if not present or corrupted)
554 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" netprovider add WebClient" 'non-zero-exitcode=abort'
555 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" netprovider add LanmanWorkstation" 'non-zero-exitcode=abort'
556 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" netprovider add RDPNP" 'non-zero-exitcode=abort'
557
558 ; Add the shared folders network provider
559 ${LogVerbose} "Adding network provider (Order = $g_iSfOrder) ..."
560 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" netprovider add VBoxSF $g_iSfOrder" 'non-zero-exitcode=abort'
561
562
563 Pop $0
564
565FunctionEnd
566
567Function W2K_Main
568
569 SetOutPath "$INSTDIR"
570 SetOverwrite on
571
572 Call W2K_Prepare
573 Call W2K_CopyFiles
574 Call W2K_InstallFiles
575 Call W2K_SetVideoResolution
576
577FunctionEnd
578
579!macro W2K_UninstallInstDir un
580Function ${un}W2K_UninstallInstDir
581
582 Delete /REBOOTOK "$INSTDIR\VBoxVideo.sys"
583 Delete /REBOOTOK "$INSTDIR\VBoxVideo.inf"
584 Delete /REBOOTOK "$INSTDIR\VBoxVideo.cat"
585 Delete /REBOOTOK "$INSTDIR\VBoxDisp.dll"
586
587 Delete /REBOOTOK "$INSTDIR\VBoxMouse.sys"
588 Delete /REBOOTOK "$INSTDIR\VBoxMouse.inf"
589 Delete /REBOOTOK "$INSTDIR\VBoxMouse.cat"
590
591 Delete /REBOOTOK "$INSTDIR\VBoxTray.exe"
592
593 Delete /REBOOTOK "$INSTDIR\VBoxGuest.sys"
594 Delete /REBOOTOK "$INSTDIR\VBoxGuest.inf"
595 Delete /REBOOTOK "$INSTDIR\VBoxGuest.cat"
596
597 Delete /REBOOTOK "$INSTDIR\VBCoInst.dll" ; Deprecated, does not get installed anymore
598 Delete /REBOOTOK "$INSTDIR\VBoxControl.exe"
599 Delete /REBOOTOK "$INSTDIR\VBoxService.exe" ; Deprecated, does not get installed anymore
600
601!if $%VBOX_WITH_WDDM% == "1"
602 Delete /REBOOTOK "$INSTDIR\VBoxWddm.cat"
603 Delete /REBOOTOK "$INSTDIR\VBoxWddm.sys"
604 Delete /REBOOTOK "$INSTDIR\VBoxWddm.inf"
605 ; Obsolete files begin
606 Delete /REBOOTOK "$INSTDIR\VBoxVideoWddm.cat"
607 Delete /REBOOTOK "$INSTDIR\VBoxVideoWddm.sys"
608 Delete /REBOOTOK "$INSTDIR\VBoxVideoWddm.inf"
609 Delete /REBOOTOK "$INSTDIR\VBoxVideoW8.cat"
610 Delete /REBOOTOK "$INSTDIR\VBoxVideoW8.sys"
611 Delete /REBOOTOK "$INSTDIR\VBoxVideoW8.inf"
612 ; Obsolete files end
613 Delete /REBOOTOK "$INSTDIR\VBoxDispD3D.dll"
614 !if $%VBOX_WITH_WDDM_DX% == "1"
615 Delete /REBOOTOK "$INSTDIR\VBoxDX.dll"
616 !endif
617 !if $%VBOX_WITH_MESA3D% == "1"
618 Delete /REBOOTOK "$INSTDIR\VBoxNine.dll"
619 Delete /REBOOTOK "$INSTDIR\VBoxSVGA.dll"
620 Delete /REBOOTOK "$INSTDIR\VBoxICD.dll"
621 Delete /REBOOTOK "$INSTDIR\VBoxGL.dll"
622 !endif
623
624 Delete /REBOOTOK "$INSTDIR\VBoxD3D9wddm.dll"
625 Delete /REBOOTOK "$INSTDIR\wined3dwddm.dll"
626 ; Try to delete libWine in case it is there from old installation
627 Delete /REBOOTOK "$INSTDIR\libWine.dll"
628
629 !if $%KBUILD_TARGET_ARCH% == "amd64"
630 Delete /REBOOTOK "$INSTDIR\VBoxDispD3D-x86.dll"
631 !if $%VBOX_WITH_WDDM_DX% == "1"
632 Delete /REBOOTOK "$INSTDIR\VBoxDX-x86.dll"
633 !endif
634 !if $%VBOX_WITH_MESA3D% == "1"
635 Delete /REBOOTOK "$INSTDIR\VBoxNine-x86.dll"
636 Delete /REBOOTOK "$INSTDIR\VBoxSVGA-x86.dll"
637 Delete /REBOOTOK "$INSTDIR\VBoxICD-x86.dll"
638 Delete /REBOOTOK "$INSTDIR\VBoxGL-x86.dll"
639 !endif
640
641 Delete /REBOOTOK "$INSTDIR\VBoxD3D9wddm-x86.dll"
642 Delete /REBOOTOK "$INSTDIR\wined3dwddm-x86.dll"
643 !endif ; $%KBUILD_TARGET_ARCH% == "amd64"
644!endif ; $%VBOX_WITH_WDDM% == "1"
645
646 ; Log file
647 Delete /REBOOTOK "$INSTDIR\install.log"
648 Delete /REBOOTOK "$INSTDIR\install_ui.log"
649
650FunctionEnd
651!macroend
652!insertmacro W2K_UninstallInstDir ""
653!insertmacro W2K_UninstallInstDir "un."
654
655!macro W2K_Uninstall un
656Function ${un}W2K_Uninstall
657
658 Push $0
659
660 ; Remove VirtualBox video driver
661 ${LogVerbose} "Uninstalling video driver ..."
662 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver uninstall $\"$INSTDIR\VBoxVideo.inf$\"" 'non-zero-exitcode=log'
663 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxVideo" 'non-zero-exitcode=log'
664 Delete /REBOOTOK "$g_strSystemDir\drivers\VBoxVideo.sys"
665 Delete /REBOOTOK "$g_strSystemDir\VBoxDisp.dll"
666
667 ; Remove video driver
668!if $%VBOX_WITH_WDDM% == "1"
669
670 ${LogVerbose} "Uninstalling WDDM video driver..."
671 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver uninstall $\"$INSTDIR\VBoxWddm.inf$\"" 'non-zero-exitcode=log'
672 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxWddm" 'non-zero-exitcode=log'
673 ;misha> @todo driver file removal (as well as service removal) should be done as driver package uninstall
674 ; could be done with "VBoxDrvInst.exe /u", e.g. by passing additional arg to it denoting that driver package is to be uninstalled
675 Delete /REBOOTOK "$g_strSystemDir\drivers\VBoxWddm.sys"
676
677 ; Obsolete files begin
678 ${LogVerbose} "Uninstalling WDDM video driver for Windows 8..."
679 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver uninstall $\"$INSTDIR\VBoxVideoW8.inf$\"" 'non-zero-exitcode=log'
680 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxVideoW8" 'non-zero-exitcode=log'
681 ;misha> @todo driver file removal (as well as service removal) should be done as driver package uninstall
682 ; could be done with "VBoxDrvInst.exe /u", e.g. by passing additional arg to it denoting that driver package is to be uninstalled
683 Delete /REBOOTOK "$g_strSystemDir\drivers\VBoxVideoW8.sys"
684
685 ${LogVerbose} "Uninstalling WDDM video driver for Windows Vista and 7..."
686 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver uninstall $\"$INSTDIR\VBoxVideoWddm.inf$\"" 'non-zero-exitcode=log'
687 ; Always try to remove both VBoxVideoWddm & VBoxVideo services no matter what is installed currently
688 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxVideoWddm" 'non-zero-exitcode=log'
689 ;misha> @todo driver file removal (as well as service removal) should be done as driver package uninstall
690 ; could be done with "VBoxDrvInst.exe /u", e.g. by passing additional arg to it denoting that driver package is to be uninstalled
691 Delete /REBOOTOK "$g_strSystemDir\drivers\VBoxVideoWddm.sys"
692 ; Obsolete files end
693
694 Delete /REBOOTOK "$g_strSystemDir\VBoxDispD3D.dll"
695 !if $%KBUILD_TARGET_ARCH% == "amd64"
696 Delete /REBOOTOK "$g_strSysWow64\VBoxDispD3D-x86.dll"
697 !endif
698
699 !if $%VBOX_WITH_WDDM_DX% == "1"
700 Delete /REBOOTOK "$g_strSystemDir\VBoxDX.dll"
701 !if $%KBUILD_TARGET_ARCH% == "amd64"
702 Delete /REBOOTOK "$g_strSysWow64\VBoxDX-x86.dll"
703 !endif
704 !endif
705
706 !if $%VBOX_WITH_MESA3D% == "1"
707 Delete /REBOOTOK "$g_strSystemDir\VBoxNine.dll"
708 Delete /REBOOTOK "$g_strSystemDir\VBoxSVGA.dll"
709 Delete /REBOOTOK "$g_strSystemDir\VBoxICD.dll"
710 Delete /REBOOTOK "$g_strSystemDir\VBoxGL.dll"
711
712 !if $%KBUILD_TARGET_ARCH% == "amd64"
713 Delete /REBOOTOK "$g_strSysWow64\VBoxNine-x86.dll"
714 Delete /REBOOTOK "$g_strSysWow64\VBoxSVGA-x86.dll"
715 Delete /REBOOTOK "$g_strSysWow64\VBoxICD-x86.dll"
716 Delete /REBOOTOK "$g_strSysWow64\VBoxGL-x86.dll"
717 !endif
718 !endif
719!endif ; $%VBOX_WITH_WDDM% == "1"
720
721 ; Remove mouse driver
722 ${LogVerbose} "Removing mouse driver ..."
723 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxMouse" 'non-zero-exitcode=log'
724 Delete /REBOOTOK "$g_strSystemDir\drivers\VBoxMouse.sys"
725 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" registry delmultisz $\"SYSTEM\CurrentControlSet\Control\Class\{4D36E96F-E325-11CE-BFC1-08002BE10318}$\" $\"UpperFilters$\" $\"VBoxMouse$\"" 'non-zero-exitcode=log'
726
727 ; Delete the VBoxService service
728 Call ${un}StopVBoxService
729 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxService" 'non-zero-exitcode=log'
730 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxService"
731 Delete /REBOOTOK "$g_strSystemDir\VBoxService.exe"
732
733 ; VBoxGINA
734 Delete /REBOOTOK "$g_strSystemDir\VBoxGINA.dll"
735 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" "GinaDLL"
736 ${If} $0 == "VBoxGINA.dll"
737 ${LogVerbose} "Removing auto-logon support ..."
738 DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" "GinaDLL"
739 ${EndIf}
740 DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\VBoxGINA"
741
742 ; Delete VBoxTray
743 Call ${un}StopVBoxTray
744 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray"
745
746 ; Remove guest driver
747 ${LogVerbose} "Removing guest driver ..."
748 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver uninstall $\"$INSTDIR\VBoxGuest.inf$\"" 'non-zero-exitcode=log'
749
750 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxGuest" 'non-zero-exitcode=log'
751 Delete /REBOOTOK "$g_strSystemDir\drivers\VBoxGuest.sys"
752 Delete /REBOOTOK "$g_strSystemDir\VBCoInst.dll" ; Deprecated, does not get installed anymore
753 Delete /REBOOTOK "$g_strSystemDir\VBoxTray.exe"
754 Delete /REBOOTOK "$g_strSystemDir\VBoxHook.dll"
755 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray" ; Remove VBoxTray autorun
756 Delete /REBOOTOK "$g_strSystemDir\VBoxControl.exe"
757
758 ; Remove shared folders driver
759 ${LogVerbose} "Removing shared folders driver ..."
760 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" netprovider remove VBoxSF" 'non-zero-exitcode=log'
761 ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxSF" 'non-zero-exitcode=log'
762 Delete /REBOOTOK "$g_strSystemDir\VBoxMRXNP.dll" ; The network provider DLL will be locked
763 !if $%KBUILD_TARGET_ARCH% == "amd64"
764 ; Only 64-bit installer: Also remove 32-bit DLLs on 64-bit target arch in Wow64 node
765 Delete /REBOOTOK "$g_strSysWow64\VBoxMRXNP.dll"
766 !endif ; amd64
767 Delete /REBOOTOK "$g_strSystemDir\drivers\VBoxSF.sys"
768
769 Pop $0
770
771FunctionEnd
772!macroend
773!insertmacro W2K_Uninstall ""
774!insertmacro W2K_Uninstall "un."
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use