VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsNT4.nsh@ 31634

Last change on this file since 31634 was 31634, checked in by vboxsync, 14 years ago

Windows Additions: export shared folders and installer to OSE

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette