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