1 | ; $Id: VBoxGuestAdditionsNT4.nsh 108773 2025-03-27 15:45:34Z 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 | ;;
|
---|
142 | ; Callback function for extracting files for NT4 guests.
|
---|
143 | ;
|
---|
144 | ; Input:
|
---|
145 | ; None
|
---|
146 | ; Output:
|
---|
147 | ; None
|
---|
148 | ;
|
---|
149 | Function NT4_CallbackExtractFiles
|
---|
150 |
|
---|
151 | ${LogVerbose} "Extracting for NT4 ..."
|
---|
152 | ; Nothing to do here.
|
---|
153 |
|
---|
154 | FunctionEnd
|
---|
155 |
|
---|
156 |
|
---|
157 | ;;
|
---|
158 | ; Callback function for installation for Windows NT4 guests.
|
---|
159 | ;
|
---|
160 | ; Input:
|
---|
161 | ; None
|
---|
162 | ; Output:
|
---|
163 | ; None
|
---|
164 | ;
|
---|
165 | Function NT4_CallbackInstall
|
---|
166 |
|
---|
167 | SetOutPath "$INSTDIR"
|
---|
168 |
|
---|
169 | Call NT4_SaveMouseDriverInfo
|
---|
170 |
|
---|
171 | ${LogVerbose} "Installing for NT4 ..."
|
---|
172 |
|
---|
173 | ; The files to install for NT 4, they go into the system directories.
|
---|
174 | SetOutPath "$SYSDIR"
|
---|
175 | FILE "$%PATH_OUT%\bin\additions\VBoxDisp.dll"
|
---|
176 | AccessControl::SetOnFile "$SYSDIR\VBoxDisp.dll" "(BU)" "GenericRead"
|
---|
177 | FILE "$%PATH_OUT%\bin\additions\VBoxTray.exe"
|
---|
178 | AccessControl::SetOnFile "$SYSDIR\VBoxTray.exe" "(BU)" "GenericRead"
|
---|
179 | FILE "$%PATH_OUT%\bin\additions\VBoxHook.dll"
|
---|
180 | AccessControl::SetOnFile "$SYSDIR\VBoxHook.dll" "(BU)" "GenericRead"
|
---|
181 | FILE "$%PATH_OUT%\bin\additions\VBoxControl.exe"
|
---|
182 | AccessControl::SetOnFile "$SYSDIR\VBoxControl.exe" "(BU)" "GenericRead"
|
---|
183 | FILE "$%PATH_OUT%\bin\additions\VBoxService.exe"
|
---|
184 | AccessControl::SetOnFile "$SYSDIR\VBoxService.exe" "(BU)" "GenericRead"
|
---|
185 |
|
---|
186 | ; The drivers into the "drivers" directory.
|
---|
187 | SetOutPath "$SYSDIR\drivers"
|
---|
188 | FILE "$%PATH_OUT%\bin\additions\VBoxVideo.sys"
|
---|
189 | AccessControl::SetOnFile "$SYSDIR\drivers\VBoxVideo.sys" "(BU)" "GenericRead"
|
---|
190 | FILE "$%PATH_OUT%\bin\additions\VBoxMouseNT.sys"
|
---|
191 | AccessControl::SetOnFile "$SYSDIR\drivers\VBoxMouseNT.sys" "(BU)" "GenericRead"
|
---|
192 | FILE "$%PATH_OUT%\bin\additions\VBoxGuest.sys"
|
---|
193 | AccessControl::SetOnFile "$SYSDIR\drivers\VBoxGuest.sys" "(BU)" "GenericRead"
|
---|
194 |
|
---|
195 | ; Note: Shared Folders not available on NT4!
|
---|
196 |
|
---|
197 | ; Install guest driver.
|
---|
198 | ${CmdExecute} "$\"$INSTDIR\Tools\VBoxGuestInstallHelper.exe$\" service create \
|
---|
199 | $\"VBoxGuest$\" $\"VBoxGuest Support Driver$\" 1 1 $\"$SYSDIR\drivers\VBoxGuest.sys$\" $\"Base$\"" 'non-zero-exitcode=abort'
|
---|
200 |
|
---|
201 | ; Bugfix: Set "Start" to 1, otherwise, VBoxGuest won't start on boot-up!
|
---|
202 | ; Bugfix: Correct invalid "ImagePath" (\??\C:\WINNT\...)
|
---|
203 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\VBoxGuest" "Start" 1
|
---|
204 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\VBoxGuest" "ImagePath" "\SystemRoot\System32\DRIVERS\VBoxGuest.sys"
|
---|
205 |
|
---|
206 | ; Run VBoxTray when Windows NT starts.
|
---|
207 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray" '"$SYSDIR\VBoxTray.exe"'
|
---|
208 |
|
---|
209 | ; Video driver
|
---|
210 | ${CmdExecute} "$\"$INSTDIR\Tools\VBoxGuestInstallHelper.exe$\" driver nt4-install-video $\"$INSTDIR\VBoxVideo$\"" 'non-zero-exitcode=abort'
|
---|
211 |
|
---|
212 | ; Create the VBoxService service.
|
---|
213 | ; No need to stop/remove the service here! Do this only on uninstallation!
|
---|
214 | ${LogVerbose} "Installing VirtualBox service ..."
|
---|
215 | ${CmdExecute} "$\"$INSTDIR\Tools\VBoxGuestInstallHelper.exe$\" service create \
|
---|
216 | $\"VBoxService$\" $\"VirtualBox Guest Additions Service$\" 16 2 $\"%SystemRoot%\system32\VBoxService.exe$\" $\"Base$\"" 'non-zero-exitcode=abort'
|
---|
217 |
|
---|
218 | ; Note: Shared Folders not available on NT4!
|
---|
219 |
|
---|
220 | Call NT4_SetVideoResolution
|
---|
221 |
|
---|
222 | ; Write mouse driver name to registry overwriting the default name.
|
---|
223 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" "\SystemRoot\System32\DRIVERS\VBoxMouseNT.sys"
|
---|
224 |
|
---|
225 | ; This removes the flag "new display driver installed on the next bootup.
|
---|
226 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "VBoxGuestPostInstCleanup" '"$INSTDIR\Tools\VBoxGuestInstallHelper.exe" nt4 installcleanup'
|
---|
227 |
|
---|
228 | FunctionEnd
|
---|
229 |
|
---|
230 |
|
---|
231 | !macro NT4_CallbackDeleteFiles un
|
---|
232 | ;;
|
---|
233 | ; Callback function for deleting files for Windows NT4 guests.
|
---|
234 | ;
|
---|
235 | ; Input:
|
---|
236 | ; None
|
---|
237 | ; Output:
|
---|
238 | ; None
|
---|
239 | ;
|
---|
240 | Function ${un}NT4_CallbackDeleteFiles
|
---|
241 |
|
---|
242 | ; Nothing to do here.
|
---|
243 | ${LogVerbose} "Deleting files for NT4 ..."
|
---|
244 |
|
---|
245 | FunctionEnd
|
---|
246 | !macroend
|
---|
247 | !insertmacro NT4_CallbackDeleteFiles "un."
|
---|
248 |
|
---|
249 |
|
---|
250 | !macro NT4_CallbackUninstall un
|
---|
251 | ;;
|
---|
252 | ; Callback function for uninstallation for Windows NT4 guests.
|
---|
253 | ;
|
---|
254 | ; Input:
|
---|
255 | ; None
|
---|
256 | ; Output:
|
---|
257 | ; None
|
---|
258 | ;
|
---|
259 | Function ${un}NT4_CallbackUninstall
|
---|
260 |
|
---|
261 | Push $0
|
---|
262 |
|
---|
263 | ${LogVerbose} "Uninstalling for NT4 ..."
|
---|
264 |
|
---|
265 | ; Remove the guest driver service.
|
---|
266 | ${CmdExecute} "$\"$INSTDIR\Tools\VBoxGuestInstallHelper.exe$\" service delete VBoxGuest" 'non-zero-exitcode=log'
|
---|
267 | Delete /REBOOTOK "$SYSDIR\drivers\VBoxGuest.sys"
|
---|
268 |
|
---|
269 | ; Delete the VBoxService service.
|
---|
270 | Call ${un}StopVBoxService
|
---|
271 | ${CmdExecute} "$\"$INSTDIR\Tools\VBoxGuestInstallHelper.exe$\" service delete VBoxService" 'non-zero-exitcode=log'
|
---|
272 | DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxService"
|
---|
273 | Delete /REBOOTOK "$SYSDIR\VBoxService.exe"
|
---|
274 |
|
---|
275 | ; Delete the VBoxTray app.
|
---|
276 | Call ${un}StopVBoxTray
|
---|
277 | DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "VBoxTray"
|
---|
278 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "VBoxTrayDel" "$SYSDIR\cmd.exe /c del /F /Q $SYSDIR\VBoxTray.exe"
|
---|
279 | Delete /REBOOTOK "$SYSDIR\VBoxTray.exe" ; If it can't be removed cause it's running, try next boot with "RunOnce" key above!
|
---|
280 | Delete /REBOOTOK "$SYSDIR\VBoxHook.dll"
|
---|
281 |
|
---|
282 | ; Delete the VBoxControl utility.
|
---|
283 | Delete /REBOOTOK "$SYSDIR\VBoxControl.exe"
|
---|
284 |
|
---|
285 | ; Delete the VBoxVideo service.
|
---|
286 | ${CmdExecute} "$\"$INSTDIR\Tools\VBoxGuestInstallHelper.exe$\" service delete VBoxVideo" 'non-zero-exitcode=log'
|
---|
287 |
|
---|
288 | ; Delete the VBox video driver files.
|
---|
289 | Delete /REBOOTOK "$SYSDIR\drivers\VBoxVideo.sys"
|
---|
290 | Delete /REBOOTOK "$SYSDIR\VBoxDisp.dll"
|
---|
291 |
|
---|
292 | ; Get original mouse driver info and restore it.
|
---|
293 | ReadRegStr $0 "${REGISTRY_KEY_UNINST_ROOT}" "${REGISTRY_KEY_UNINST_PRODUCT}" ${REGISTRY_VAL_ORG_MOUSE_PATH}
|
---|
294 | ; If we still got our driver stored in $0 then this will *never* work, so
|
---|
295 | ; warn the user and set it to the default driver to not screw up NT4 here.
|
---|
296 | ${If} $0 == "System32\DRIVERS\VBoxMouseNT.sys"
|
---|
297 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" "\SystemRoot\System32\DRIVERS\i8042prt.sys"
|
---|
298 | ${LogVerbose} "Old mouse driver is set to VBoxMouseNT.sys, defaulting to i8042prt.sys ..."
|
---|
299 | ${Else}
|
---|
300 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\i8042prt" "ImagePath" $0
|
---|
301 | ${EndIf}
|
---|
302 | Delete /REBOOTOK "$SYSDIR\drivers\VBoxMouseNT.sys"
|
---|
303 |
|
---|
304 | ; Remove any pending post-installation steps from the registy.
|
---|
305 | DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "VBoxGuestPostInstCleanup"
|
---|
306 |
|
---|
307 | Pop $0
|
---|
308 |
|
---|
309 | FunctionEnd
|
---|
310 | !macroend
|
---|
311 | !ifndef UNINSTALLER_ONLY
|
---|
312 | !insertmacro NT4_CallbackUninstall ""
|
---|
313 | !endif
|
---|
314 | !insertmacro NT4_CallbackUninstall "un."
|
---|