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