1 | ; $Id: VBoxGuestAdditionsNT4.nsh 96605 2022-09-05 19:08:21Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; VBoxGuestAdditionsNT4.nsh - Guest Additions installation for NT4.
|
---|
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 NT4_SetVideoResolution
|
---|
29 |
|
---|
30 | ; Check for all required parameters
|
---|
31 | StrCmp $g_iScreenX "0" missingParms
|
---|
32 | StrCmp $g_iScreenY "0" missingParms
|
---|
33 | StrCmp $g_iScreenBpp "0" missingParms
|
---|
34 | Goto haveParms
|
---|
35 |
|
---|
36 | missingParms:
|
---|
37 |
|
---|
38 | ${LogVerbose} "Missing display parameters for NT4, setting default (640x480, 8 BPP) ..."
|
---|
39 |
|
---|
40 | StrCpy $g_iScreenX '640' ; Default value
|
---|
41 | StrCpy $g_iScreenY '480' ; Default value
|
---|
42 | StrCpy $g_iScreenBpp '8' ; Default value
|
---|
43 |
|
---|
44 | ; Write setting into registry to show the desktop applet on next boot
|
---|
45 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\GraphicsDrivers\NewDisplay" "" ""
|
---|
46 |
|
---|
47 | haveParms:
|
---|
48 |
|
---|
49 | ${LogVerbose} "Setting display parameters for NT4 ($g_iScreenXx$g_iScreenY, $g_iScreenBpp BPP) ..."
|
---|
50 |
|
---|
51 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.BitsPerPel" $g_iScreenBpp
|
---|
52 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.Flags" 0x00000000
|
---|
53 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.VRefresh" 0x00000001
|
---|
54 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.XPanning" 0x00000000
|
---|
55 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.XResolution" $g_iScreenX
|
---|
56 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.YPanning" 0x00000000
|
---|
57 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Hardware Profiles\Current\System\CurrentControlSet\Services\vboxvideo\Device0" "DefaultSettings.YResolution" $g_iScreenY
|
---|
58 |
|
---|
59 | FunctionEnd
|
---|
60 |
|
---|
61 | Function NT4_SaveMouseDriverInfo
|
---|
62 |
|
---|
63 | Push $0
|
---|
64 |
|
---|
65 | ; !!! NOTE !!!
|
---|
66 | ; Due to some re-branding (see functions Uninstall_Sun, Uninstall_Innotek and
|
---|
67 | ; Uninstall_SunXVM) the installer *has* to transport the very first saved i8042prt
|
---|
68 | ; value to the current installer's "uninstall" directory in both mentioned
|
---|
69 | ; functions above, otherwise NT4 will be screwed because it then would store
|
---|
70 | ; "VBoxMouseNT.sys" as the original i8042prt driver which obviously isn't there
|
---|
71 | ; after uninstallation anymore
|
---|
72 | ; !!! NOTE !!!
|
---|
73 |
|
---|
74 | ; Save current mouse driver info so we may restore it on uninstallation
|
---|
75 | ; But first check if we already installed the additions otherwise we will
|
---|
76 | ; overwrite it with the VBoxMouseNT.sys
|
---|
77 | ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
|
---|
78 | StrCmp $0 "" 0 exists
|
---|
79 |
|
---|
80 | ${LogVerbose} "Saving mouse driver info ..."
|
---|
81 | ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath"
|
---|
82 | WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH} $0
|
---|
83 | Goto exit
|
---|
84 |
|
---|
85 | exists:
|
---|
86 |
|
---|
87 | ${LogVerbose} "Mouse driver info already saved."
|
---|
88 | Goto exit
|
---|
89 |
|
---|
90 | exit:
|
---|
91 |
|
---|
92 | !ifdef _DEBUG
|
---|
93 | ${LogVerbose} "Mouse driver info: $0"
|
---|
94 | !endif
|
---|
95 |
|
---|
96 | Pop $0
|
---|
97 |
|
---|
98 | FunctionEnd
|
---|
99 |
|
---|
100 | Function NT4_Prepare
|
---|
101 |
|
---|
102 | ${If} $g_bNoVBoxServiceExit == "false"
|
---|
103 | ; Stop / kill VBoxService
|
---|
104 | Call StopVBoxService
|
---|
105 | ${EndIf}
|
---|
106 |
|
---|
107 | ${If} $g_bNoVBoxTrayExit == "false"
|
---|
108 | ; Stop / kill VBoxTray
|
---|
109 | Call StopVBoxTray
|
---|
110 | ${EndIf}
|
---|
111 |
|
---|
112 | ; Delete VBoxService from registry
|
---|
113 | DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxService"
|
---|
114 |
|
---|
115 | ; Delete old VBoxService.exe from install directory (replaced by VBoxTray.exe)
|
---|
116 | Delete /REBOOTOK "$INSTDIR\VBoxService.exe"
|
---|
117 |
|
---|
118 | FunctionEnd
|
---|
119 |
|
---|
120 | Function NT4_CopyFiles
|
---|
121 |
|
---|
122 | ${LogVerbose} "Copying files for NT4 ..."
|
---|
123 |
|
---|
124 | SetOutPath "$INSTDIR"
|
---|
125 | FILE "$%PATH_OUT%\bin\additions\RegCleanup.exe"
|
---|
126 | AccessControl::SetOnFile "$INSTDIR\RegCleanup.exe" "(BU)" "GenericRead"
|
---|
127 | !ifdef VBOX_WITH_ADDITIONS_SHIPPING_AUDIO_TEST
|
---|
128 | FILE "$%PATH_OUT%\bin\additions\VBoxAudioTest.exe"
|
---|
129 | !endif
|
---|
130 |
|
---|
131 | ; The files to install for NT 4, they go into the system directories
|
---|
132 | SetOutPath "$SYSDIR"
|
---|
133 | FILE "$%PATH_OUT%\bin\additions\VBoxDisp.dll"
|
---|
134 | AccessControl::SetOnFile "$SYSDIR\VBoxDisp.dll" "(BU)" "GenericRead"
|
---|
135 | FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
|
---|
136 | AccessControl::SetOnFile "$SYSDIR\VBoxTray.exe" "(BU)" "GenericRead"
|
---|
137 | FILE "$%PATH_OUT%\bin\additions\VBoxHook.dll"
|
---|
138 | AccessControl::SetOnFile "$SYSDIR\VBoxHook.dll" "(BU)" "GenericRead"
|
---|
139 | FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
|
---|
140 | AccessControl::SetOnFile "$SYSDIR\VBoxControl.exe" "(BU)" "GenericRead"
|
---|
141 |
|
---|
142 | ; VBoxService
|
---|
143 | FILE "$%PATH_OUT%\bin\additions\VBoxService.exe"
|
---|
144 | AccessControl::SetOnFile "$SYSDIR\VBoxService.exe" "(BU)" "GenericRead"
|
---|
145 |
|
---|
146 | ; The drivers into the "drivers" directory
|
---|
147 | SetOutPath "$SYSDIR\drivers"
|
---|
148 | FILE "$%PATH_OUT%\bin\additions\VBoxVideo.sys"
|
---|
149 | AccessControl::SetOnFile "$SYSDIR\drivers\VBoxVideo.sys" "(BU)" "GenericRead"
|
---|
150 | FILE "$%PATH_OUT%\bin\additions\VBoxMouseNT.sys"
|
---|
151 | AccessControl::SetOnFile "$SYSDIR\drivers\VBoxMouseNT.sys" "(BU)" "GenericRead"
|
---|
152 | FILE "$%PATH_OUT%\bin\additions\VBoxGuest.sys"
|
---|
153 | AccessControl::SetOnFile "$SYSDIR\drivers\VBoxGuest.sys" "(BU)" "GenericRead"
|
---|
154 | ;FILE "$%PATH_OUT%\bin\additions\VBoxSFNT.sys" ; Shared Folders not available on NT4!
|
---|
155 | ;AccessControl::SetOnFile "$SYSDIR\drivers\VBoxSFNT.sys" "(BU)" "GenericRead"
|
---|
156 |
|
---|
157 | FunctionEnd
|
---|
158 |
|
---|
159 | Function NT4_InstallFiles
|
---|
160 |
|
---|
161 | ${LogVerbose} "Installing drivers for NT4 ..."
|
---|
162 |
|
---|
163 | ; Install guest driver
|
---|
164 | ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service create $\"VBoxGuest$\" $\"VBoxGuest Support Driver$\" 1 1 $\"$SYSDIR\drivers\VBoxGuest.sys$\" $\"Base$\"" "false"
|
---|
165 |
|
---|
166 | ; Bugfix: Set "Start" to 1, otherwise, VBoxGuest won't start on boot-up!
|
---|
167 | ; Bugfix: Correct invalid "ImagePath" (\??\C:\WINNT\...)
|
---|
168 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\VBoxGuest" "Start" 1
|
---|
169 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxGuest" "ImagePath" "\SystemRoot\System32\DRIVERS\VBoxGuest.sys"
|
---|
170 |
|
---|
171 | ; Run VBoxTray when Windows NT starts
|
---|
172 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray" '"$SYSDIR\VBoxTray.exe"'
|
---|
173 |
|
---|
174 | ; Video driver
|
---|
175 | ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" driver nt4-install-video" "false"
|
---|
176 |
|
---|
177 | ; Create the VBoxService service
|
---|
178 | ; No need to stop/remove the service here! Do this only on uninstallation!
|
---|
179 | ${LogVerbose} "Installing VirtualBox service ..."
|
---|
180 | ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service create $\"VBoxService$\" $\"VirtualBox Guest Additions Service$\" 16 2 $\"%SystemRoot%\system32\VBoxService.exe$\" $\"Base$\"" "false"
|
---|
181 |
|
---|
182 | ; Create the Shared Folders service ...
|
---|
183 | ;nsSCM::Install /NOUNLOAD "VBoxSF" "VirtualBox Shared Folders" 1 1 "$SYSDIR\drivers\VBoxSFNT.sys" "Network" "" "" ""
|
---|
184 | ;Pop $0 ; Ret value
|
---|
185 |
|
---|
186 | !ifdef _DEBUG
|
---|
187 | ;${LogVerbose} "SCM::Install VBoxSFNT.sys: $0"
|
---|
188 | !endif
|
---|
189 |
|
---|
190 | ;IntCmp $0 0 +1 error error ; Check ret value (0=OK, 1=Error)
|
---|
191 |
|
---|
192 | ; ... and the link to the network provider
|
---|
193 | ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "DeviceName" "\Device\VBoxMiniRdr"
|
---|
194 | ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "Name" "VirtualBox Shared Folders"
|
---|
195 | ;WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" "ProviderPath" "$SYSDIR\VBoxMRXNP.dll"
|
---|
196 |
|
---|
197 | ; Add the shared folders network provider
|
---|
198 | ;${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" netprovider add VBoxSF" "false"
|
---|
199 |
|
---|
200 | Goto done
|
---|
201 |
|
---|
202 | error:
|
---|
203 | Abort "ERROR: Could not install files for Windows NT4! Installation aborted."
|
---|
204 |
|
---|
205 | done:
|
---|
206 |
|
---|
207 | FunctionEnd
|
---|
208 |
|
---|
209 | Function NT4_Main
|
---|
210 |
|
---|
211 | SetOutPath "$INSTDIR"
|
---|
212 |
|
---|
213 | Call NT4_Prepare
|
---|
214 | Call NT4_CopyFiles
|
---|
215 |
|
---|
216 | ; This removes the flag "new display driver installed on the next bootup
|
---|
217 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "VBoxGuestInst" '"$INSTDIR\RegCleanup.exe"'
|
---|
218 |
|
---|
219 | Call NT4_SaveMouseDriverInfo
|
---|
220 | Call NT4_InstallFiles
|
---|
221 | Call NT4_SetVideoResolution
|
---|
222 |
|
---|
223 | ; Write mouse driver name to registry overwriting the default name
|
---|
224 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" "\SystemRoot\System32\DRIVERS\VBoxMouseNT.sys"
|
---|
225 |
|
---|
226 | FunctionEnd
|
---|
227 |
|
---|
228 | !macro NT4_UninstallInstDir un
|
---|
229 | Function ${un}NT4_UninstallInstDir
|
---|
230 |
|
---|
231 | ; Delete remaining files
|
---|
232 | Delete /REBOOTOK "$INSTDIR\VBoxGuestDrvInst.exe"
|
---|
233 | Delete /REBOOTOK "$INSTDIR\RegCleanup.exe"
|
---|
234 |
|
---|
235 | FunctionEnd
|
---|
236 | !macroend
|
---|
237 | !insertmacro NT4_UninstallInstDir ""
|
---|
238 | !insertmacro NT4_UninstallInstDir "un."
|
---|
239 |
|
---|
240 | !macro NT4_Uninstall un
|
---|
241 | Function ${un}NT4_Uninstall
|
---|
242 |
|
---|
243 | Push $0
|
---|
244 |
|
---|
245 | ; Remove the guest driver service
|
---|
246 | ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxGuest" "true"
|
---|
247 | Delete /REBOOTOK "$SYSDIR\drivers\VBoxGuest.sys"
|
---|
248 |
|
---|
249 | ; Delete the VBoxService service
|
---|
250 | Call ${un}StopVBoxService
|
---|
251 | ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxService" "true"
|
---|
252 | DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxService"
|
---|
253 | Delete /REBOOTOK "$SYSDIR\VBoxService.exe"
|
---|
254 |
|
---|
255 | ; Delete the VBoxTray app
|
---|
256 | Call ${un}StopVBoxTray
|
---|
257 | DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray"
|
---|
258 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "VBoxTrayDel" "$SYSDIR\cmd.exe /c del /F /Q $SYSDIR\VBoxTray.exe"
|
---|
259 | Delete /REBOOTOK "$SYSDIR\VBoxTray.exe" ; If it can't be removed cause it's running, try next boot with "RunOnce" key above!
|
---|
260 | Delete /REBOOTOK "$SYSDIR\VBoxHook.dll"
|
---|
261 |
|
---|
262 | ; Delete the VBoxControl utility
|
---|
263 | Delete /REBOOTOK "$SYSDIR\VBoxControl.exe"
|
---|
264 |
|
---|
265 | ; Delete the VBoxVideo service
|
---|
266 | ${CmdExecute} "$\"$INSTDIR\VBoxDrvInst.exe$\" service delete VBoxVideo" "true"
|
---|
267 |
|
---|
268 | ; Delete the VBox video driver files
|
---|
269 | Delete /REBOOTOK "$SYSDIR\drivers\VBoxVideo.sys"
|
---|
270 | Delete /REBOOTOK "$SYSDIR\VBoxDisp.dll"
|
---|
271 |
|
---|
272 | ; Get original mouse driver info and restore it
|
---|
273 | ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" ${ORG_MOUSE_PATH}
|
---|
274 | ; If we still got our driver stored in $0 then this will *never* work, so
|
---|
275 | ; warn the user and set it to the default driver to not screw up NT4 here
|
---|
276 | ${If} $0 == "System32\DRIVERS\VBoxMouseNT.sys"
|
---|
277 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" "\SystemRoot\System32\DRIVERS\i8042prt.sys"
|
---|
278 | ${LogVerbose} "Old mouse driver is set to VBoxMouseNT.sys, defaulting to i8042prt.sys ..."
|
---|
279 | ${Else}
|
---|
280 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
|
---|
281 | ${EndIf}
|
---|
282 | Delete /REBOOTOK "$SYSDIR\drivers\VBoxMouseNT.sys"
|
---|
283 |
|
---|
284 | Pop $0
|
---|
285 |
|
---|
286 | FunctionEnd
|
---|
287 | !macroend
|
---|
288 | !insertmacro NT4_Uninstall ""
|
---|
289 | !insertmacro NT4_Uninstall "un."
|
---|