1 | ; $Id: VBoxGuestAdditionsCommon.nsh 96605 2022-09-05 19:08:21Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; VBoxGuestAdditionsCommon.nsh - Common / shared utility functions.
|
---|
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 |
|
---|
28 | Function Common_CopyFiles
|
---|
29 |
|
---|
30 | SetOutPath "$INSTDIR"
|
---|
31 | SetOverwrite on
|
---|
32 |
|
---|
33 | !ifdef VBOX_WITH_LICENSE_INSTALL_RTF
|
---|
34 | ; Copy license file (if any) into the installation directory
|
---|
35 | FILE "/oname=${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
|
---|
36 | !endif
|
---|
37 |
|
---|
38 | FILE "$%VBOX_PATH_DIFX%\DIFxAPI.dll"
|
---|
39 | FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
|
---|
40 |
|
---|
41 | FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
|
---|
42 | !ifdef VBOX_SIGN_ADDITIONS
|
---|
43 | ${If} $g_strWinVersion == "10"
|
---|
44 | FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
|
---|
45 | ${Else}
|
---|
46 | FILE "/oname=VBoxVideo.cat" "$%PATH_OUT%\bin\additions\VBoxVideo-PreW10.cat"
|
---|
47 | ${EndIf}
|
---|
48 | !endif
|
---|
49 |
|
---|
50 | FILE "iexplore.ico"
|
---|
51 |
|
---|
52 | FunctionEnd
|
---|
53 |
|
---|
54 | !ifndef UNINSTALLER_ONLY
|
---|
55 | Function ExtractFiles
|
---|
56 |
|
---|
57 | ; @todo: Use a define for all the file specs to group the files per module
|
---|
58 | ; and keep the redundancy low
|
---|
59 |
|
---|
60 | Push $0
|
---|
61 | StrCpy "$0" "$INSTDIR\$%KBUILD_TARGET_ARCH%"
|
---|
62 |
|
---|
63 | ; Root files
|
---|
64 | SetOutPath "$0"
|
---|
65 | !if $%VBOX_WITH_LICENSE_INSTALL_RTF% == "1"
|
---|
66 | FILE "/oname=${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
|
---|
67 | !endif
|
---|
68 |
|
---|
69 | ; Video driver
|
---|
70 | SetOutPath "$0\VBoxVideo"
|
---|
71 | FILE "$%PATH_OUT%\bin\additions\VBoxVideo.sys"
|
---|
72 | FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
|
---|
73 | !ifdef VBOX_SIGN_ADDITIONS
|
---|
74 | ${If} $g_strWinVersion == "10"
|
---|
75 | FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
|
---|
76 | ${Else}
|
---|
77 | FILE "/oname=VBoxVideo.cat" "$%PATH_OUT%\bin\additions\VBoxVideo-PreW10.cat"
|
---|
78 | ${EndIf}
|
---|
79 | !endif
|
---|
80 | FILE "$%PATH_OUT%\bin\additions\VBoxDisp.dll"
|
---|
81 |
|
---|
82 | !if $%VBOX_WITH_WDDM% == "1"
|
---|
83 | ; WDDM Video driver
|
---|
84 | SetOutPath "$0\VBoxWddm"
|
---|
85 |
|
---|
86 | !ifdef VBOX_SIGN_ADDITIONS
|
---|
87 | ${If} $g_strWinVersion == "10"
|
---|
88 | FILE "$%PATH_OUT%\bin\additions\VBoxWddm.cat"
|
---|
89 | ${Else}
|
---|
90 | FILE "/oname=VBoxWddm.cat" "$%PATH_OUT%\bin\additions\VBoxWddm-PreW10.cat"
|
---|
91 | ${EndIf}
|
---|
92 | !endif
|
---|
93 | FILE "$%PATH_OUT%\bin\additions\VBoxWddm.sys"
|
---|
94 | FILE "$%PATH_OUT%\bin\additions\VBoxWddm.inf"
|
---|
95 | FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D.dll"
|
---|
96 | !if $%VBOX_WITH_WDDM_DX% == "1"
|
---|
97 | FILE "$%PATH_OUT%\bin\additions\VBoxDX.dll"
|
---|
98 | !endif
|
---|
99 | !if $%VBOX_WITH_MESA3D% == "1"
|
---|
100 | FILE "$%PATH_OUT%\bin\additions\VBoxNine.dll"
|
---|
101 | FILE "$%PATH_OUT%\bin\additions\VBoxSVGA.dll"
|
---|
102 | FILE "$%PATH_OUT%\bin\additions\VBoxGL.dll"
|
---|
103 | !endif
|
---|
104 |
|
---|
105 | !if $%KBUILD_TARGET_ARCH% == "amd64"
|
---|
106 | FILE "$%PATH_OUT%\bin\additions\VBoxDispD3D-x86.dll"
|
---|
107 | !if $%VBOX_WITH_WDDM_DX% == "1"
|
---|
108 | FILE "$%PATH_OUT%\bin\additions\VBoxDX-x86.dll"
|
---|
109 | !endif
|
---|
110 | !if $%VBOX_WITH_MESA3D% == "1"
|
---|
111 | FILE "$%PATH_OUT%\bin\additions\VBoxNine-x86.dll"
|
---|
112 | FILE "$%PATH_OUT%\bin\additions\VBoxSVGA-x86.dll"
|
---|
113 | FILE "$%PATH_OUT%\bin\additions\VBoxGL-x86.dll"
|
---|
114 | !endif
|
---|
115 |
|
---|
116 | !endif ; $%KBUILD_TARGET_ARCH% == "amd64"
|
---|
117 | !endif ; $%VBOX_WITH_WDDM% == "1"
|
---|
118 |
|
---|
119 | ; Mouse driver
|
---|
120 | SetOutPath "$0\VBoxMouse"
|
---|
121 | FILE "$%PATH_OUT%\bin\additions\VBoxMouse.sys"
|
---|
122 | FILE "$%PATH_OUT%\bin\additions\VBoxMouse.inf"
|
---|
123 | !ifdef VBOX_SIGN_ADDITIONS
|
---|
124 | ${If} $g_strWinVersion == "10"
|
---|
125 | FILE "$%PATH_OUT%\bin\additions\VBoxMouse.cat"
|
---|
126 | ${Else}
|
---|
127 | FILE "/oname=VBoxMouse.cat" "$%PATH_OUT%\bin\additions\VBoxMouse-PreW10.cat"
|
---|
128 | ${EndIf}
|
---|
129 | !endif
|
---|
130 |
|
---|
131 | !if $%KBUILD_TARGET_ARCH% == "x86"
|
---|
132 | SetOutPath "$0\VBoxMouse\NT4"
|
---|
133 | FILE "$%PATH_OUT%\bin\additions\VBoxMouseNT.sys"
|
---|
134 | !endif
|
---|
135 |
|
---|
136 | ; Guest driver
|
---|
137 | SetOutPath "$0\VBoxGuest"
|
---|
138 | FILE "$%PATH_OUT%\bin\additions\VBoxGuest.sys"
|
---|
139 | FILE "$%PATH_OUT%\bin\additions\VBoxGuest.inf"
|
---|
140 | !ifdef VBOX_SIGN_ADDITIONS
|
---|
141 | ${If} $g_strWinVersion == "10"
|
---|
142 | FILE "$%PATH_OUT%\bin\additions\VBoxGuest.cat"
|
---|
143 | ${Else}
|
---|
144 | FILE "/oname=VBoxGuest.cat" "$%PATH_OUT%\bin\additions\VBoxGuest-PreW10.cat"
|
---|
145 | ${EndIf}
|
---|
146 | !endif
|
---|
147 | FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
|
---|
148 | FILE "$%PATH_OUT%\bin\additions\VBoxHook.dll"
|
---|
149 | FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
|
---|
150 |
|
---|
151 | ; VBoxService
|
---|
152 | SetOutPath "$0\Bin"
|
---|
153 | FILE "$%PATH_OUT%\bin\additions\VBoxService.exe"
|
---|
154 |
|
---|
155 | ; Shared Folders
|
---|
156 | SetOutPath "$0\VBoxSF"
|
---|
157 | FILE "$%PATH_OUT%\bin\additions\VBoxSF.sys"
|
---|
158 | FILE "$%PATH_OUT%\bin\additions\VBoxMRXNP.dll"
|
---|
159 | !if $%KBUILD_TARGET_ARCH% == "amd64"
|
---|
160 | ; Only 64-bit installer: Also copy 32-bit DLLs on 64-bit target
|
---|
161 | FILE "$%PATH_OUT%\bin\additions\VBoxMRXNP-x86.dll"
|
---|
162 | !endif
|
---|
163 |
|
---|
164 | ; Auto-Logon
|
---|
165 | SetOutPath "$0\AutoLogon"
|
---|
166 | FILE "$%PATH_OUT%\bin\additions\VBoxGINA.dll"
|
---|
167 | FILE "$%PATH_OUT%\bin\additions\VBoxCredProv.dll"
|
---|
168 |
|
---|
169 | ; Misc tools
|
---|
170 | SetOutPath "$0\Tools"
|
---|
171 | FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
|
---|
172 | FILE "$%VBOX_PATH_DIFX%\DIFxAPI.dll"
|
---|
173 | !ifdef VBOX_WITH_ADDITIONS_SHIPPING_AUDIO_TEST
|
---|
174 | FILE "$%PATH_OUT%\bin\additions\VBoxAudioTest.exe"
|
---|
175 | !endif
|
---|
176 |
|
---|
177 | !if $%KBUILD_TARGET_ARCH% == "x86"
|
---|
178 | SetOutPath "$0\Tools\NT4"
|
---|
179 | FILE "$%PATH_OUT%\bin\additions\RegCleanup.exe"
|
---|
180 | !endif
|
---|
181 |
|
---|
182 | Pop $0
|
---|
183 |
|
---|
184 | FunctionEnd
|
---|
185 | !endif ; UNINSTALLER_ONLY
|
---|
186 |
|
---|
187 | !macro CheckArchitecture un
|
---|
188 | Function ${un}CheckArchitecture
|
---|
189 |
|
---|
190 | Push $0
|
---|
191 |
|
---|
192 | System::Call "kernel32::GetCurrentProcess() i .s"
|
---|
193 | System::Call "kernel32::IsWow64Process(i s, *i .r0)"
|
---|
194 | ; R0 now contains 1 if we're a 64-bit process, or 0 if not
|
---|
195 |
|
---|
196 | !if $%KBUILD_TARGET_ARCH% == "amd64"
|
---|
197 | IntCmp $0 0 wrong_platform
|
---|
198 | !else ; 32-bit
|
---|
199 | IntCmp $0 1 wrong_platform
|
---|
200 | !endif
|
---|
201 |
|
---|
202 | Push 0
|
---|
203 | Goto exit
|
---|
204 |
|
---|
205 | wrong_platform:
|
---|
206 |
|
---|
207 | Push 1
|
---|
208 | Goto exit
|
---|
209 |
|
---|
210 | exit:
|
---|
211 |
|
---|
212 | FunctionEnd
|
---|
213 | !macroend
|
---|
214 | !insertmacro CheckArchitecture ""
|
---|
215 | !insertmacro CheckArchitecture "un."
|
---|
216 |
|
---|
217 | ;
|
---|
218 | ; Macro for retrieving the Windows version this installer is running on.
|
---|
219 | ;
|
---|
220 | ; @return Stack: Windows version string. Empty on error /
|
---|
221 | ; if not able to identify.
|
---|
222 | ;
|
---|
223 | !macro GetWindowsVersionEx un
|
---|
224 | Function ${un}GetWindowsVersionEx
|
---|
225 |
|
---|
226 | Push $0
|
---|
227 | Push $1
|
---|
228 |
|
---|
229 | ; Check if we are running on Windows 2000 or above
|
---|
230 | ; For other windows versions (> XP) it may be necessary to change winver.nsh
|
---|
231 | Call ${un}GetWindowsVersion
|
---|
232 | Pop $0 ; Windows Version
|
---|
233 |
|
---|
234 | Push $0 ; The windows version string
|
---|
235 | Push "NT" ; String to search for. W2K+ returns no string containing "NT"
|
---|
236 | Call ${un}StrStr
|
---|
237 | Pop $1
|
---|
238 |
|
---|
239 | ${If} $1 == "" ; If empty -> not NT 3.XX or 4.XX
|
---|
240 | ; $0 contains the original version string
|
---|
241 | ${Else}
|
---|
242 | ; Ok we know it is NT. Must be a string like NT X.XX
|
---|
243 | Push $0 ; The windows version string
|
---|
244 | Push "4." ; String to search for
|
---|
245 | Call ${un}StrStr
|
---|
246 | Pop $1
|
---|
247 | ${If} $1 == "" ; If empty -> not NT 4
|
---|
248 | ;; @todo NT <= 3.x ?
|
---|
249 | ; $0 contains the original version string
|
---|
250 | ${Else}
|
---|
251 | StrCpy $0 "NT4"
|
---|
252 | ${EndIf}
|
---|
253 | ${EndIf}
|
---|
254 |
|
---|
255 | Pop $1
|
---|
256 | Exch $0
|
---|
257 |
|
---|
258 | FunctionEnd
|
---|
259 | !macroend
|
---|
260 | !insertmacro GetWindowsVersionEx ""
|
---|
261 | !insertmacro GetWindowsVersionEx "un."
|
---|
262 |
|
---|
263 | !macro GetAdditionsVersion un
|
---|
264 | Function ${un}GetAdditionsVersion
|
---|
265 |
|
---|
266 | Push $0
|
---|
267 | Push $1
|
---|
268 |
|
---|
269 | ; Get additions version
|
---|
270 | ReadRegStr $0 HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Version"
|
---|
271 |
|
---|
272 | ; Get revision
|
---|
273 | ReadRegStr $g_strAddVerRev HKLM "SOFTWARE\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions" "Revision"
|
---|
274 |
|
---|
275 | ; Extract major version
|
---|
276 | Push "$0" ; String
|
---|
277 | Push "." ; SubString
|
---|
278 | Push ">" ; SearchDirection
|
---|
279 | Push "<" ; StrInclusionDirection
|
---|
280 | Push "0" ; IncludeSubString
|
---|
281 | Push "0" ; Loops
|
---|
282 | Push "0" ; CaseSensitive
|
---|
283 | Call ${un}StrStrAdv
|
---|
284 | Pop $g_strAddVerMaj
|
---|
285 |
|
---|
286 | ; Extract minor version
|
---|
287 | Push "$0" ; String
|
---|
288 | Push "." ; SubString
|
---|
289 | Push ">" ; SearchDirection
|
---|
290 | Push ">" ; StrInclusionDirection
|
---|
291 | Push "0" ; IncludeSubString
|
---|
292 | Push "0" ; Loops
|
---|
293 | Push "0" ; CaseSensitive
|
---|
294 | Call ${un}StrStrAdv
|
---|
295 | Pop $1 ; Got first part (e.g. "1.5")
|
---|
296 |
|
---|
297 | Push "$1" ; String
|
---|
298 | Push "." ; SubString
|
---|
299 | Push ">" ; SearchDirection
|
---|
300 | Push "<" ; StrInclusionDirection
|
---|
301 | Push "0" ; IncludeSubString
|
---|
302 | Push "0" ; Loops
|
---|
303 | Push "0" ; CaseSensitive
|
---|
304 | Call ${un}StrStrAdv
|
---|
305 | Pop $g_strAddVerMin ; Extracted second part (e.g. "5" from "1.5")
|
---|
306 |
|
---|
307 | ; Extract build number
|
---|
308 | Push "$0" ; String
|
---|
309 | Push "." ; SubString
|
---|
310 | Push "<" ; SearchDirection
|
---|
311 | Push ">" ; StrInclusionDirection
|
---|
312 | Push "0" ; IncludeSubString
|
---|
313 | Push "0" ; Loops
|
---|
314 | Push "0" ; CaseSensitive
|
---|
315 | Call ${un}StrStrAdv
|
---|
316 | Pop $g_strAddVerBuild
|
---|
317 |
|
---|
318 | exit:
|
---|
319 |
|
---|
320 | Pop $1
|
---|
321 | Pop $0
|
---|
322 |
|
---|
323 | FunctionEnd
|
---|
324 | !macroend
|
---|
325 | !insertmacro GetAdditionsVersion ""
|
---|
326 | !insertmacro GetAdditionsVersion "un."
|
---|
327 |
|
---|
328 | !macro StopVBoxService un
|
---|
329 | Function ${un}StopVBoxService
|
---|
330 |
|
---|
331 | Push $0 ; Temp results
|
---|
332 | Push $1
|
---|
333 | Push $2 ; Image name of VBoxService
|
---|
334 | Push $3 ; Safety counter
|
---|
335 |
|
---|
336 | StrCpy $3 "0" ; Init counter
|
---|
337 | ${LogVerbose} "Stopping VBoxService ..."
|
---|
338 |
|
---|
339 | svc_stop:
|
---|
340 |
|
---|
341 | ${LogVerbose} "Stopping VBoxService via SCM ..."
|
---|
342 | ${If} $g_strWinVersion == "NT4"
|
---|
343 | nsExec::Exec '"$SYSDIR\net.exe" stop VBoxService'
|
---|
344 | ${Else}
|
---|
345 | nsExec::Exec '"$SYSDIR\SC.exe" stop VBoxService'
|
---|
346 | ${EndIf}
|
---|
347 | Sleep "1000" ; Wait a bit
|
---|
348 |
|
---|
349 | exe_stop:
|
---|
350 |
|
---|
351 | !ifdef _DEBUG
|
---|
352 | ${LogVerbose} "Stopping VBoxService (as exe) ..."
|
---|
353 | !endif
|
---|
354 |
|
---|
355 | exe_stop_loop:
|
---|
356 |
|
---|
357 | IntCmp $3 10 exit ; Only try this loop 10 times max
|
---|
358 | IntOp $3 $3 + 1 ; Increment
|
---|
359 |
|
---|
360 | !ifdef _DEBUG
|
---|
361 | ${LogVerbose} "Stopping attempt #$3"
|
---|
362 | !endif
|
---|
363 |
|
---|
364 | StrCpy $2 "VBoxService.exe"
|
---|
365 |
|
---|
366 | ${nsProcess::FindProcess} $2 $0
|
---|
367 | StrCmp $0 0 0 exit
|
---|
368 |
|
---|
369 | ${nsProcess::KillProcess} $2 $0
|
---|
370 | Sleep "1000" ; Wait a bit
|
---|
371 | Goto exe_stop_loop
|
---|
372 |
|
---|
373 | exit:
|
---|
374 |
|
---|
375 | ${LogVerbose} "Stopping VBoxService done"
|
---|
376 |
|
---|
377 | Pop $3
|
---|
378 | Pop $2
|
---|
379 | Pop $1
|
---|
380 | Pop $0
|
---|
381 |
|
---|
382 | FunctionEnd
|
---|
383 | !macroend
|
---|
384 | !insertmacro StopVBoxService ""
|
---|
385 | !insertmacro StopVBoxService "un."
|
---|
386 |
|
---|
387 | !macro StopVBoxTray un
|
---|
388 | Function ${un}StopVBoxTray
|
---|
389 |
|
---|
390 | Push $0 ; Temp results
|
---|
391 | Push $1 ; Safety counter
|
---|
392 |
|
---|
393 | StrCpy $1 "0" ; Init counter
|
---|
394 | ${LogVerbose} "Stopping VBoxTray ..."
|
---|
395 |
|
---|
396 | exe_stop:
|
---|
397 |
|
---|
398 | IntCmp $1 10 exit ; Only try this loop 10 times max
|
---|
399 | IntOp $1 $1 + 1 ; Increment
|
---|
400 |
|
---|
401 | ${nsProcess::FindProcess} "VBoxTray.exe" $0
|
---|
402 | StrCmp $0 0 0 exit
|
---|
403 |
|
---|
404 | ${nsProcess::KillProcess} "VBoxTray.exe" $0
|
---|
405 | Sleep "1000" ; Wait a bit
|
---|
406 | Goto exe_stop
|
---|
407 |
|
---|
408 | exit:
|
---|
409 |
|
---|
410 | ${LogVerbose} "Stopping VBoxTray done"
|
---|
411 |
|
---|
412 | Pop $1
|
---|
413 | Pop $0
|
---|
414 |
|
---|
415 | FunctionEnd
|
---|
416 | !macroend
|
---|
417 | !insertmacro StopVBoxTray ""
|
---|
418 | !insertmacro StopVBoxTray "un."
|
---|
419 |
|
---|
420 | !macro StopVBoxMMR un
|
---|
421 | Function ${un}StopVBoxMMR
|
---|
422 |
|
---|
423 | Push $0 ; Temp results
|
---|
424 | Push $1 ; Safety counter
|
---|
425 |
|
---|
426 | StrCpy $1 "0" ; Init counter
|
---|
427 | DetailPrint "Stopping VBoxMMR ..."
|
---|
428 |
|
---|
429 | exe_stop:
|
---|
430 |
|
---|
431 | IntCmp $1 10 exit ; Only try this loop 10 times max
|
---|
432 | IntOp $1 $1 + 1 ; Increment
|
---|
433 |
|
---|
434 | ${nsProcess::FindProcess} "VBoxMMR.exe" $0
|
---|
435 | StrCmp $0 0 0 exit
|
---|
436 |
|
---|
437 | ${nsProcess::KillProcess} "VBoxMMR.exe" $0
|
---|
438 | Sleep "1000" ; Wait a bit
|
---|
439 | Goto exe_stop
|
---|
440 |
|
---|
441 | exit:
|
---|
442 |
|
---|
443 | DetailPrint "Stopping VBoxMMR done."
|
---|
444 |
|
---|
445 | Pop $1
|
---|
446 | Pop $0
|
---|
447 |
|
---|
448 | FunctionEnd
|
---|
449 | !macroend
|
---|
450 | !insertmacro StopVBoxMMR ""
|
---|
451 | !insertmacro StopVBoxMMR "un."
|
---|
452 |
|
---|
453 | !macro WriteRegBinR ROOT KEY NAME VALUE
|
---|
454 | WriteRegBin "${ROOT}" "${KEY}" "${NAME}" "${VALUE}"
|
---|
455 | !macroend
|
---|
456 |
|
---|
457 | !macro AbortShutdown un
|
---|
458 | Function ${un}AbortShutdown
|
---|
459 |
|
---|
460 | ${If} ${FileExists} "$g_strSystemDir\shutdown.exe"
|
---|
461 | ; Try to abort the shutdown
|
---|
462 | ${CmdExecute} "$\"$g_strSystemDir\shutdown.exe$\" -a" "true"
|
---|
463 | ${Else}
|
---|
464 | ${LogVerbose} "Shutting down not supported: Binary $\"$g_strSystemDir\shutdown.exe$\" not found"
|
---|
465 | ${EndIf}
|
---|
466 |
|
---|
467 | FunctionEnd
|
---|
468 | !macroend
|
---|
469 | !insertmacro AbortShutdown ""
|
---|
470 | !insertmacro AbortShutdown "un."
|
---|
471 |
|
---|
472 | !macro CheckForCapabilities un
|
---|
473 | Function ${un}CheckForCapabilities
|
---|
474 |
|
---|
475 | Push $0
|
---|
476 |
|
---|
477 | ; Retrieve system mode and store result in
|
---|
478 | System::Call 'user32::GetSystemMetrics(i ${SM_CLEANBOOT}) i .r0'
|
---|
479 | StrCpy $g_iSystemMode $0
|
---|
480 |
|
---|
481 | ; Does the guest have a DLL cache?
|
---|
482 | ${If} $g_strWinVersion == "NT4"
|
---|
483 | ${OrIf} $g_strWinVersion == "2000"
|
---|
484 | ${OrIf} $g_strWinVersion == "XP"
|
---|
485 | StrCpy $g_bCapDllCache "true"
|
---|
486 | ${LogVerbose} "OS has a DLL cache"
|
---|
487 | ${EndIf}
|
---|
488 |
|
---|
489 | ${If} $g_strWinVersion == "2000"
|
---|
490 | ${OrIf} $g_strWinVersion == "XP"
|
---|
491 | ${OrIf} $g_strWinVersion == "2003"
|
---|
492 | ${OrIf} $g_strWinVersion == "Vista"
|
---|
493 | ${OrIf} $g_strWinVersion == "7"
|
---|
494 | StrCpy $g_bCapXPDM "true"
|
---|
495 | ${LogVerbose} "OS is XPDM driver capable"
|
---|
496 | ${EndIf}
|
---|
497 |
|
---|
498 | !if $%VBOX_WITH_WDDM% == "1"
|
---|
499 | ; By default use the WDDM driver on Vista+
|
---|
500 | ${If} $g_strWinVersion == "Vista"
|
---|
501 | ${OrIf} $g_strWinVersion == "7"
|
---|
502 | ${OrIf} $g_strWinVersion == "8"
|
---|
503 | ${OrIf} $g_strWinVersion == "8_1"
|
---|
504 | ${OrIf} $g_strWinVersion == "10"
|
---|
505 | StrCpy $g_bWithWDDM "true"
|
---|
506 | StrCpy $g_bCapWDDM "true"
|
---|
507 | ${LogVerbose} "OS is WDDM driver capable"
|
---|
508 | ${EndIf}
|
---|
509 | !endif
|
---|
510 |
|
---|
511 | Pop $0
|
---|
512 |
|
---|
513 | FunctionEnd
|
---|
514 | !macroend
|
---|
515 | !insertmacro CheckForCapabilities ""
|
---|
516 | !insertmacro CheckForCapabilities "un."
|
---|
517 |
|
---|
518 | ; Switches (back) the path + registry view to
|
---|
519 | ; 32-bit mode (SysWOW64) on 64-bit guests
|
---|
520 | !macro SetAppMode32 un
|
---|
521 | Function ${un}SetAppMode32
|
---|
522 | !if $%KBUILD_TARGET_ARCH% == "amd64"
|
---|
523 | ${EnableX64FSRedirection}
|
---|
524 | SetRegView 32
|
---|
525 | !endif
|
---|
526 | FunctionEnd
|
---|
527 | !macroend
|
---|
528 | !insertmacro SetAppMode32 ""
|
---|
529 | !insertmacro SetAppMode32 "un."
|
---|
530 |
|
---|
531 | ; Because this NSIS installer is always built in 32-bit mode, we have to
|
---|
532 | ; do some tricks for the Windows paths + registry on 64-bit guests
|
---|
533 | !macro SetAppMode64 un
|
---|
534 | Function ${un}SetAppMode64
|
---|
535 | !if $%KBUILD_TARGET_ARCH% == "amd64"
|
---|
536 | ${DisableX64FSRedirection}
|
---|
537 | SetRegView 64
|
---|
538 | !endif
|
---|
539 | FunctionEnd
|
---|
540 | !macroend
|
---|
541 | !insertmacro SetAppMode64 ""
|
---|
542 | !insertmacro SetAppMode64 "un."
|
---|
543 |
|
---|
544 | ;
|
---|
545 | ; Retrieves the vendor ("CompanyName" of FILEINFO structure)
|
---|
546 | ; of a given file.
|
---|
547 | ; @return Stack: Company name, or "" on error/if not found.
|
---|
548 | ; @param Stack: File name to retrieve vendor for.
|
---|
549 | ;
|
---|
550 | !macro GetFileVendor un
|
---|
551 | Function ${un}GetFileVendor
|
---|
552 |
|
---|
553 | ; Preserve values
|
---|
554 | Exch $0 ; Stack: $0 <filename> (Get file name into $0)
|
---|
555 | Push $1
|
---|
556 |
|
---|
557 | IfFileExists "$0" found
|
---|
558 | Goto not_found
|
---|
559 |
|
---|
560 | found:
|
---|
561 |
|
---|
562 | VBoxGuestInstallHelper::FileGetVendor "$0"
|
---|
563 | ; Stack: <vendor> $1 $0
|
---|
564 | Pop $0 ; Get vendor
|
---|
565 | Pop $1 ; Restore $1
|
---|
566 | Exch $0 ; Restore $0, push vendor on top of stack
|
---|
567 | Goto end
|
---|
568 |
|
---|
569 | not_found:
|
---|
570 |
|
---|
571 | Pop $1
|
---|
572 | Pop $0
|
---|
573 | Push "File not found"
|
---|
574 | Goto end
|
---|
575 |
|
---|
576 | end:
|
---|
577 |
|
---|
578 | FunctionEnd
|
---|
579 | !macroend
|
---|
580 | !insertmacro GetFileVendor ""
|
---|
581 | !insertmacro GetFileVendor "un."
|
---|
582 |
|
---|
583 | ;
|
---|
584 | ; Retrieves the architecture of a given file.
|
---|
585 | ; @return Stack: Architecture ("x86", "amd64") or error message.
|
---|
586 | ; @param Stack: File name to retrieve architecture for.
|
---|
587 | ;
|
---|
588 | !macro GetFileArchitecture un
|
---|
589 | Function ${un}GetFileArchitecture
|
---|
590 |
|
---|
591 | ; Preserve values
|
---|
592 | Exch $0 ; Stack: $0 <filename> (Get file name into $0)
|
---|
593 | Push $1
|
---|
594 |
|
---|
595 | IfFileExists "$0" found
|
---|
596 | Goto not_found
|
---|
597 |
|
---|
598 | found:
|
---|
599 |
|
---|
600 | ${LogVerbose} "Getting architecture of file $\"$0$\" ..."
|
---|
601 |
|
---|
602 | VBoxGuestInstallHelper::FileGetArchitecture "$0"
|
---|
603 |
|
---|
604 | ; Stack: <architecture> $1 $0
|
---|
605 | Pop $0 ; Get architecture string
|
---|
606 |
|
---|
607 | ${LogVerbose} "Architecture is: $0"
|
---|
608 |
|
---|
609 | Pop $1 ; Restore $1
|
---|
610 | Exch $0 ; Restore $0, push vendor on top of stack
|
---|
611 | Goto end
|
---|
612 |
|
---|
613 | not_found:
|
---|
614 |
|
---|
615 | Pop $1
|
---|
616 | Pop $0
|
---|
617 | Push "File not found"
|
---|
618 | Goto end
|
---|
619 |
|
---|
620 | end:
|
---|
621 |
|
---|
622 | FunctionEnd
|
---|
623 | !macroend
|
---|
624 | !insertmacro GetFileArchitecture ""
|
---|
625 | !insertmacro GetFileArchitecture "un."
|
---|
626 |
|
---|
627 | ;
|
---|
628 | ; Verifies a given file by checking its file vendor and target
|
---|
629 | ; architecture.
|
---|
630 | ; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
|
---|
631 | ; @param Stack: Architecture ("x86" or "amd64").
|
---|
632 | ; @param Stack: Vendor.
|
---|
633 | ; @param Stack: File name to verify.
|
---|
634 | ;
|
---|
635 | !macro VerifyFile un
|
---|
636 | Function ${un}VerifyFile
|
---|
637 |
|
---|
638 | ; Preserve values
|
---|
639 | Exch $0 ; File; S: old$0 vendor arch
|
---|
640 | Exch ; S: vendor old$0 arch
|
---|
641 | Exch $1 ; Vendor; S: old$1 old$0 arch
|
---|
642 | Exch ; S: old$0 old$1 arch
|
---|
643 | Exch 2 ; S: arch old$1 old$0
|
---|
644 | Exch $2 ; Architecture; S: old$2 old$1 old$0
|
---|
645 | Push $3 ; S: old$3 old$2 old$1 old$0
|
---|
646 |
|
---|
647 | ${LogVerbose} "Verifying file $\"$0$\" (vendor: $1, arch: $2) ..."
|
---|
648 |
|
---|
649 | IfFileExists "$0" check_arch
|
---|
650 | Goto not_found
|
---|
651 |
|
---|
652 | check_arch:
|
---|
653 |
|
---|
654 | ${LogVerbose} "File $\"$0$\" found"
|
---|
655 |
|
---|
656 | Push $0
|
---|
657 | Call ${un}GetFileArchitecture
|
---|
658 | Pop $3
|
---|
659 |
|
---|
660 | ${LogVerbose} "Architecture is: $3"
|
---|
661 |
|
---|
662 | ${If} $3 == $2
|
---|
663 | Goto check_vendor
|
---|
664 | ${EndIf}
|
---|
665 | Goto invalid
|
---|
666 |
|
---|
667 | check_vendor:
|
---|
668 |
|
---|
669 | Push $0
|
---|
670 | Call ${un}GetFileVendor
|
---|
671 | Pop $3
|
---|
672 |
|
---|
673 | ${LogVerbose} "Vendor is: $3"
|
---|
674 |
|
---|
675 | ${If} $3 == $1
|
---|
676 | Goto valid
|
---|
677 | ${EndIf}
|
---|
678 |
|
---|
679 | invalid:
|
---|
680 |
|
---|
681 | ${LogVerbose} "File $\"$0$\" is invalid"
|
---|
682 |
|
---|
683 | StrCpy $3 "1" ; Invalid
|
---|
684 | Goto end
|
---|
685 |
|
---|
686 | valid:
|
---|
687 |
|
---|
688 | ${LogVerbose} "File $\"$0$\" is valid"
|
---|
689 |
|
---|
690 | StrCpy $3 "0" ; Valid
|
---|
691 | Goto end
|
---|
692 |
|
---|
693 | not_found:
|
---|
694 |
|
---|
695 | ${LogVerbose} "File $\"$0$\" was not found"
|
---|
696 |
|
---|
697 | StrCpy $3 "2" ; Not found
|
---|
698 | Goto end
|
---|
699 |
|
---|
700 | end:
|
---|
701 |
|
---|
702 | ; S: old$3 old$2 old$1 old$0
|
---|
703 | Exch $3 ; S: $3 old$2 old$1 old$0
|
---|
704 | Exch ; S: old$2 $3 old$1
|
---|
705 | Pop $2 ; S: $3 old$1 old$0
|
---|
706 | Exch ; S: old$1 $3 old$0
|
---|
707 | Pop $1 ; S: $3 old$0
|
---|
708 | Exch ; S: old$0 $3
|
---|
709 | Pop $0 ; S: $3
|
---|
710 |
|
---|
711 | FunctionEnd
|
---|
712 | !macroend
|
---|
713 | !insertmacro VerifyFile ""
|
---|
714 | !insertmacro VerifyFile "un."
|
---|
715 |
|
---|
716 | ;
|
---|
717 | ; Macro for accessing VerifyFile in a more convenient way by using
|
---|
718 | ; a parameter list.
|
---|
719 | ; @return Stack: "0" if valid, "1" if not, "2" on error / not found.
|
---|
720 | ; @param Un/Installer prefix; either "" or "un".
|
---|
721 | ; @param Name of file to verify.
|
---|
722 | ; @param Vendor to check for.
|
---|
723 | ; @param Architecture ("x86" or "amd64") to check for.
|
---|
724 | ;
|
---|
725 | !macro VerifyFileEx un File Vendor Architecture
|
---|
726 | Push $0
|
---|
727 | Push "${Architecture}"
|
---|
728 | Push "${Vendor}"
|
---|
729 | Push "${File}"
|
---|
730 | Call ${un}VerifyFile
|
---|
731 | Pop $0
|
---|
732 | ${If} $0 == "0"
|
---|
733 | ${LogVerbose} "Verification of file $\"${File}$\" successful (Vendor: ${Vendor}, Architecture: ${Architecture})"
|
---|
734 | ${ElseIf} $0 == "1"
|
---|
735 | ${LogVerbose} "Verification of file $\"${File}$\" failed (not Vendor: ${Vendor}, and/or not Architecture: ${Architecture})"
|
---|
736 | ${Else}
|
---|
737 | ${LogVerbose} "Skipping to file $\"${File}$\"; not found"
|
---|
738 | ${EndIf}
|
---|
739 | ; Push result popped off the stack to stack again
|
---|
740 | Push $0
|
---|
741 | !macroend
|
---|
742 | !define VerifyFileEx "!insertmacro VerifyFileEx"
|
---|
743 |
|
---|
744 | ;
|
---|
745 | ; Macro for copying a file only if the source file is verified
|
---|
746 | ; to be from a certain vendor and architecture.
|
---|
747 | ; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
|
---|
748 | ; @param Un/Installer prefix; either "" or "un".
|
---|
749 | ; @param Name of file to verify and copy to destination.
|
---|
750 | ; @param Destination name to copy verified file to.
|
---|
751 | ; @param Vendor to check for.
|
---|
752 | ; @param Architecture ("x86" or "amd64") to check for.
|
---|
753 | ;
|
---|
754 | !macro CopyFileEx un FileSrc FileDest Vendor Architecture
|
---|
755 | Push $0
|
---|
756 | Push "${Architecture}"
|
---|
757 | Push "${Vendor}"
|
---|
758 | Push "${FileSrc}"
|
---|
759 | Call ${un}VerifyFile
|
---|
760 | Pop $0
|
---|
761 |
|
---|
762 | Push "${Architecture}"
|
---|
763 | Push "Oracle Corporation"
|
---|
764 | Push "${FileDest}"
|
---|
765 | Call ${un}VerifyFile
|
---|
766 | Pop $0
|
---|
767 |
|
---|
768 | ${If} $0 == "0"
|
---|
769 | ${LogVerbose} "Copying verified file $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
|
---|
770 | ClearErrors
|
---|
771 | SetOverwrite on
|
---|
772 | CopyFiles /SILENT "${FileSrc}" "${FileDest}"
|
---|
773 | ${If} ${Errors}
|
---|
774 | CreateDirectory "$TEMP\${PRODUCT_NAME}"
|
---|
775 | ${GetFileName} "${FileSrc}" $0 ; Get the base name
|
---|
776 | CopyFiles /SILENT "${FileSrc}" "$TEMP\${PRODUCT_NAME}\$0"
|
---|
777 | ${LogVerbose} "Immediate installation failed, postponing to next reboot (temporary location is: $\"$TEMP\${PRODUCT_NAME}\$0$\") ..."
|
---|
778 | ;${InstallFileEx} "${un}" "${FileSrc}" "${FileDest}" "$TEMP" ; Only works with compile time files!
|
---|
779 | System::Call "kernel32::MoveFileEx(t '$TEMP\${PRODUCT_NAME}\$0', t '${FileDest}', i 5)"
|
---|
780 | ${EndIf}
|
---|
781 | ${Else}
|
---|
782 | ${LogVerbose} "Skipping to copy file $\"${FileSrc}$\" to $\"${FileDest}$\" (not Vendor: ${Vendor}, Architecture: ${Architecture})"
|
---|
783 | ${EndIf}
|
---|
784 | ; Push result popped off the stack to stack again
|
---|
785 | Push $0
|
---|
786 | !macroend
|
---|
787 | !define CopyFileEx "!insertmacro CopyFileEx"
|
---|
788 |
|
---|
789 | ;
|
---|
790 | ; Macro for installing a library/DLL.
|
---|
791 | ; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
|
---|
792 | ; @param Un/Installer prefix; either "" or "un".
|
---|
793 | ; @param Name of lib/DLL to copy to destination.
|
---|
794 | ; @param Destination name to copy the source file to.
|
---|
795 | ; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
|
---|
796 | ;
|
---|
797 | !macro InstallFileEx un FileSrc FileDest DirTemp
|
---|
798 | ${LogVerbose} "Installing library $\"${FileSrc}$\" to $\"${FileDest}$\" ..."
|
---|
799 | ; Try the gentle way and replace the file instantly
|
---|
800 | !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
|
---|
801 | ; If the above call didn't help, use a (later) reboot to replace the file
|
---|
802 | !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "${FileSrc}" "${FileDest}" "${DirTemp}"
|
---|
803 | !macroend
|
---|
804 | !define InstallFileEx "!insertmacro InstallFileEx"
|
---|
805 |
|
---|
806 | ;
|
---|
807 | ; Macro for installing a library/DLL.
|
---|
808 | ; @return Stack: "0" if copied, "1" if not, "2" on error / not found.
|
---|
809 | ; @param Un/Installer prefix; either "" or "un".
|
---|
810 | ; @param Name of lib/DLL to verify and copy to destination.
|
---|
811 | ; @param Destination name to copy verified file to.
|
---|
812 | ; @param Temporary folder used for exchanging the (locked) lib/DLL after a reboot.
|
---|
813 | ; @param Vendor to check for.
|
---|
814 | ; @param Architecture ("x86" or "amd64") to check for.
|
---|
815 | ;
|
---|
816 | !macro InstallFileVerify un FileSrc FileDest DirTemp Vendor Architecture
|
---|
817 | Push $0
|
---|
818 | Push "${Architecture}"
|
---|
819 | Push "${Vendor}"
|
---|
820 | Push "${FileSrc}"
|
---|
821 | ${LogVerbose} "Verifying library $\"${FileSrc}$\" ..."
|
---|
822 | Call ${un}VerifyFile
|
---|
823 | Pop $0
|
---|
824 | ${If} $0 == "0"
|
---|
825 | ${InstallFileEx} ${un} ${FileSrc} ${FileDest} ${DirTemp}
|
---|
826 | ${Else}
|
---|
827 | ${LogVerbose} "File $\"${FileSrc}$\" did not pass verification (Vendor: ${Vendor}, Architecture: ${Architecture})"
|
---|
828 | ${EndIf}
|
---|
829 | ; Push result popped off the stack to stack again.
|
---|
830 | Push $0
|
---|
831 | !macroend
|
---|
832 | !define InstallFileVerify "!insertmacro InstallFileVerify"
|
---|
833 |
|
---|
834 |
|
---|
835 | ; Note: We don't ship modified Direct3D files anymore, but we need to (try to)
|
---|
836 | ; restore the original (backed up) DLLs when upgrading from an old(er)
|
---|
837 | ; installation.
|
---|
838 | ;
|
---|
839 | ; Restores formerly backed up Direct3D original files, which were replaced by
|
---|
840 | ; a VBox XPDM driver installation before. This might be necessary for upgrading a
|
---|
841 | ; XPDM installation to a WDDM one.
|
---|
842 | ; @return Stack: "0" if files were restored successfully; otherwise "1".
|
---|
843 | ;
|
---|
844 | !macro RestoreFilesDirect3D un
|
---|
845 | Function ${un}RestoreFilesDirect3D
|
---|
846 | ${If} $g_bCapXPDM != "true"
|
---|
847 | ${LogVerbose} "RestoreFilesDirect3D: XPDM is not supported"
|
---|
848 | Return
|
---|
849 | ${EndIf}
|
---|
850 |
|
---|
851 | Push $0
|
---|
852 |
|
---|
853 | ; We need to switch to 64-bit app mode to handle the "real" 64-bit files in
|
---|
854 | ; "system32" on a 64-bit guest
|
---|
855 | Call ${un}SetAppMode64
|
---|
856 |
|
---|
857 | ${LogVerbose} "Restoring original D3D files ..."
|
---|
858 | ${CopyFileEx} "${un}" "$SYSDIR\msd3d8.dll" "$SYSDIR\d3d8.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
|
---|
859 | ${CopyFileEx} "${un}" "$SYSDIR\msd3d9.dll" "$SYSDIR\d3d9.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
|
---|
860 |
|
---|
861 | ${If} $g_bCapDllCache == "true"
|
---|
862 | ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d8.dll" "$SYSDIR\dllcache\d3d8.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
|
---|
863 | ${CopyFileEx} "${un}" "$SYSDIR\dllcache\msd3d9.dll" "$SYSDIR\dllcache\d3d9.dll" "Microsoft Corporation" "$%KBUILD_TARGET_ARCH%"
|
---|
864 | ${EndIf}
|
---|
865 |
|
---|
866 | !if $%KBUILD_TARGET_ARCH% == "amd64"
|
---|
867 | ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d8.dll" "$g_strSysWow64\d3d8.dll" "Microsoft Corporation" "x86"
|
---|
868 | ${CopyFileEx} "${un}" "$g_strSysWow64\msd3d9.dll" "$g_strSysWow64\d3d9.dll" "Microsoft Corporation" "x86"
|
---|
869 |
|
---|
870 | ${If} $g_bCapDllCache == "true"
|
---|
871 | ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "Microsoft Corporation" "x86"
|
---|
872 | ${CopyFileEx} "${un}" "$g_strSysWow64\dllcache\msd3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "Microsoft Corporation" "x86"
|
---|
873 | ${EndIf}
|
---|
874 | !endif
|
---|
875 |
|
---|
876 | Pop $0
|
---|
877 |
|
---|
878 | FunctionEnd
|
---|
879 | !macroend
|
---|
880 | !insertmacro RestoreFilesDirect3D ""
|
---|
881 | !insertmacro RestoreFilesDirect3D "un."
|
---|