1 | /* $Id: VBoxDrvInst.cpp 46593 2013-06-17 14:32:51Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxDrvInst - Driver and service installation helper for Windows guests.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2013 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 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 | #ifndef UNICODE
|
---|
23 | # define UNICODE
|
---|
24 | #endif
|
---|
25 |
|
---|
26 | #include <VBox/version.h>
|
---|
27 |
|
---|
28 | #include <Windows.h>
|
---|
29 | #include <setupapi.h>
|
---|
30 | #include <stdio.h>
|
---|
31 | #include <tchar.h>
|
---|
32 |
|
---|
33 | /*******************************************************************************
|
---|
34 | * Defines *
|
---|
35 | *******************************************************************************/
|
---|
36 |
|
---|
37 | /* Exit codes */
|
---|
38 | #define EXIT_OK (0)
|
---|
39 | #define EXIT_REBOOT (1)
|
---|
40 | #define EXIT_FAIL (2)
|
---|
41 | #define EXIT_USAGE (3)
|
---|
42 |
|
---|
43 | /* Prototypes */
|
---|
44 | typedef struct {
|
---|
45 | PWSTR pApplicationId;
|
---|
46 | PWSTR pDisplayName;
|
---|
47 | PWSTR pProductName;
|
---|
48 | PWSTR pMfgName;
|
---|
49 | } INSTALLERINFO, *PINSTALLERINFO;
|
---|
50 | typedef const PINSTALLERINFO PCINSTALLERINFO;
|
---|
51 |
|
---|
52 | typedef enum {
|
---|
53 | DIFXAPI_SUCCESS,
|
---|
54 | DIFXAPI_INFO,
|
---|
55 | DIFXAPI_WARNING,
|
---|
56 | DIFXAPI_ERROR
|
---|
57 | } DIFXAPI_LOG;
|
---|
58 |
|
---|
59 | typedef void (WINAPI * DIFXLOGCALLBACK_W)( DIFXAPI_LOG Event, DWORD Error, PCWSTR EventDescription, PVOID CallbackContext);
|
---|
60 | typedef void ( __cdecl* DIFXAPILOGCALLBACK_W)( DIFXAPI_LOG Event, DWORD Error, PCWSTR EventDescription, PVOID CallbackContext);
|
---|
61 |
|
---|
62 | typedef DWORD (WINAPI *fnDriverPackageInstall) (PCTSTR DriverPackageInfPath, DWORD Flags, PCINSTALLERINFO pInstallerInfo, BOOL *pNeedReboot);
|
---|
63 | fnDriverPackageInstall g_pfnDriverPackageInstall = NULL;
|
---|
64 |
|
---|
65 | typedef DWORD (WINAPI *fnDriverPackageUninstall) (PCTSTR DriverPackageInfPath, DWORD Flags, PCINSTALLERINFO pInstallerInfo, BOOL *pNeedReboot);
|
---|
66 | fnDriverPackageUninstall g_pfnDriverPackageUninstall = NULL;
|
---|
67 |
|
---|
68 | typedef VOID (WINAPI *fnDIFXAPISetLogCallback) (DIFXAPILOGCALLBACK_W LogCallback, PVOID CallbackContext);
|
---|
69 | fnDIFXAPISetLogCallback g_pfnDIFXAPISetLogCallback = NULL;
|
---|
70 |
|
---|
71 | /* Defines */
|
---|
72 | #define DRIVER_PACKAGE_REPAIR 0x00000001
|
---|
73 | #define DRIVER_PACKAGE_SILENT 0x00000002
|
---|
74 | #define DRIVER_PACKAGE_FORCE 0x00000004
|
---|
75 | #define DRIVER_PACKAGE_ONLY_IF_DEVICE_PRESENT 0x00000008
|
---|
76 | #define DRIVER_PACKAGE_LEGACY_MODE 0x00000010
|
---|
77 | #define DRIVER_PACKAGE_DELETE_FILES 0x00000020
|
---|
78 |
|
---|
79 | /* DIFx error codes */
|
---|
80 | /** @todo any reason why we're not using difxapi.h instead of these redefinitions? */
|
---|
81 | #ifndef ERROR_DRIVER_STORE_ADD_FAILED
|
---|
82 | # define ERROR_DRIVER_STORE_ADD_FAILED \
|
---|
83 | (APPLICATION_ERROR_MASK | ERROR_SEVERITY_ERROR | 0x0247L)
|
---|
84 | #endif
|
---|
85 | #define ERROR_DEPENDENT_APPLICATIONS_EXIST \
|
---|
86 | (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x300)
|
---|
87 | #define ERROR_DRIVER_PACKAGE_NOT_IN_STORE \
|
---|
88 | (APPLICATION_ERROR_MASK|ERROR_SEVERITY_ERROR|0x302)
|
---|
89 |
|
---|
90 | /* Registry string list flags */
|
---|
91 | #define VBOX_REG_STRINGLIST_NONE 0x00000000 /* No flags set. */
|
---|
92 | #define VBOX_REG_STRINGLIST_ALLOW_DUPLICATES 0x00000001 /* Allows duplicates in list when adding a value. */
|
---|
93 |
|
---|
94 | #ifdef DEBUG
|
---|
95 | # define VBOX_DRVINST_LOGFILE "C:\\Temp\\VBoxDrvInstDIFx.log"
|
---|
96 | #endif
|
---|
97 |
|
---|
98 | bool GetErrorMsg(DWORD dwLastError, _TCHAR *pszMsg, DWORD dwBufSize)
|
---|
99 | {
|
---|
100 | if (::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwLastError, 0, pszMsg, dwBufSize / sizeof(TCHAR), NULL) == 0)
|
---|
101 | {
|
---|
102 | _sntprintf(pszMsg, dwBufSize / sizeof(TCHAR), _T("Unknown error!\n"), dwLastError);
|
---|
103 | return false;
|
---|
104 | }
|
---|
105 | else
|
---|
106 | {
|
---|
107 | _TCHAR *p = _tcschr(pszMsg, _T('\r'));
|
---|
108 | if (p != NULL)
|
---|
109 | *p = _T('\0');
|
---|
110 | }
|
---|
111 |
|
---|
112 | return true;
|
---|
113 | }
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Log callback for DIFxAPI calls.
|
---|
117 | *
|
---|
118 | * @param Event The event's structure to log.
|
---|
119 | * @param dwError The event's error level.
|
---|
120 | * @param pEventDescription The event's text description.
|
---|
121 | * @param pCallbackContext User-supplied callback context.
|
---|
122 | */
|
---|
123 | void LogCallback(DIFXAPI_LOG Event, DWORD dwError, PCWSTR pEventDescription, PVOID pCallbackContext)
|
---|
124 | {
|
---|
125 | if (dwError == 0)
|
---|
126 | _tprintf(_T("(%u) %ws\n"), Event, pEventDescription);
|
---|
127 | else
|
---|
128 | _tprintf(_T("(%u) ERROR: %u - %ws\n"), Event, dwError, pEventDescription);
|
---|
129 |
|
---|
130 | if (pCallbackContext)
|
---|
131 | fwprintf((FILE*)pCallbackContext, _T("(%u) %u - %s\n"), Event, dwError, pEventDescription);
|
---|
132 | }
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Loads a system DLL.
|
---|
136 | *
|
---|
137 | * @returns Module handle or NULL
|
---|
138 | * @param pszName The DLL name.
|
---|
139 | */
|
---|
140 | static HMODULE loadSystemDll(const char *pszName)
|
---|
141 | {
|
---|
142 | char szPath[MAX_PATH];
|
---|
143 | UINT cchPath = GetSystemDirectoryA(szPath, sizeof(szPath));
|
---|
144 | size_t cbName = strlen(pszName) + 1;
|
---|
145 | if (cchPath + 1 + cbName > sizeof(szPath))
|
---|
146 | return NULL;
|
---|
147 | szPath[cchPath] = '\\';
|
---|
148 | memcpy(&szPath[cchPath + 1], pszName, cbName);
|
---|
149 | return LoadLibraryA(szPath);
|
---|
150 | }
|
---|
151 |
|
---|
152 | /**
|
---|
153 | * (Un)Installs a driver from/to the system.
|
---|
154 | *
|
---|
155 | * @return Exit code (EXIT_OK, EXIT_FAIL)
|
---|
156 | * @param fInstall Flag indicating whether to install (TRUE) or uninstall (FALSE) a driver.
|
---|
157 | * @param pszDriverPath Pointer to full qualified path to the driver's .INF file (+ driver files).
|
---|
158 | * @param fSilent Flag indicating a silent installation (TRUE) or not (FALSE).
|
---|
159 | * @param pszLogFile Pointer to full qualified path to log file to be written during installation.
|
---|
160 | * Optional.
|
---|
161 | */
|
---|
162 | int VBoxInstallDriver(const BOOL fInstall, const _TCHAR *pszDriverPath, BOOL fSilent,
|
---|
163 | const _TCHAR *pszLogFile)
|
---|
164 | {
|
---|
165 | HRESULT hr = S_OK;
|
---|
166 | HMODULE hDIFxAPI = loadSystemDll("DIFxAPI.dll");
|
---|
167 | if (NULL == hDIFxAPI)
|
---|
168 | {
|
---|
169 | _tprintf(_T("ERROR: Unable to locate DIFxAPI.dll!\n"));
|
---|
170 | hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
|
---|
171 | }
|
---|
172 | else
|
---|
173 | {
|
---|
174 | if (fInstall)
|
---|
175 | {
|
---|
176 | g_pfnDriverPackageInstall = (fnDriverPackageInstall)GetProcAddress(hDIFxAPI, "DriverPackageInstallW");
|
---|
177 | if (g_pfnDriverPackageInstall == NULL)
|
---|
178 | {
|
---|
179 | _tprintf(_T("ERROR: Unable to retrieve entry point for DriverPackageInstallW!\n"));
|
---|
180 | hr = HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND);
|
---|
181 | }
|
---|
182 | }
|
---|
183 | else
|
---|
184 | {
|
---|
185 | g_pfnDriverPackageUninstall = (fnDriverPackageUninstall)GetProcAddress(hDIFxAPI, "DriverPackageUninstallW");
|
---|
186 | if (g_pfnDriverPackageUninstall == NULL)
|
---|
187 | {
|
---|
188 | _tprintf(_T("ERROR: Unable to retrieve entry point for DriverPackageUninstallW!\n"));
|
---|
189 | hr = HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND);
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 | if (SUCCEEDED(hr))
|
---|
194 | {
|
---|
195 | g_pfnDIFXAPISetLogCallback = (fnDIFXAPISetLogCallback)GetProcAddress(hDIFxAPI, "DIFXAPISetLogCallbackW");
|
---|
196 | if (g_pfnDIFXAPISetLogCallback == NULL)
|
---|
197 | {
|
---|
198 | _tprintf(_T("ERROR: Unable to retrieve entry point for DIFXAPISetLogCallbackW!\n"));
|
---|
199 | hr = HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND);
|
---|
200 | }
|
---|
201 | }
|
---|
202 | }
|
---|
203 |
|
---|
204 | if (SUCCEEDED(hr))
|
---|
205 | {
|
---|
206 | FILE *phFile = NULL;
|
---|
207 | if (pszLogFile)
|
---|
208 | {
|
---|
209 | phFile = _wfopen(pszLogFile, _T("a"));
|
---|
210 | if (!phFile)
|
---|
211 | _tprintf(_T("ERROR: Unable to create log file!\n"));
|
---|
212 | g_pfnDIFXAPISetLogCallback(LogCallback, phFile);
|
---|
213 | }
|
---|
214 |
|
---|
215 | INSTALLERINFO instInfo =
|
---|
216 | {
|
---|
217 | TEXT("{7d2c708d-c202-40ab-b3e8-de21da1dc629}"), /* Our GUID for representing this installation tool. */
|
---|
218 | TEXT("VirtualBox Guest Additions Install Helper"),
|
---|
219 | TEXT("VirtualBox Guest Additions"), /** @todo Add version! */
|
---|
220 | TEXT("Oracle Corporation")
|
---|
221 | };
|
---|
222 |
|
---|
223 | _TCHAR szDriverInf[MAX_PATH + 1];
|
---|
224 | if (0 == GetFullPathNameW(pszDriverPath, MAX_PATH, szDriverInf, NULL))
|
---|
225 | {
|
---|
226 | _tprintf(_T("ERROR: INF-Path too long / could not be retrieved!\n"));
|
---|
227 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
|
---|
228 | }
|
---|
229 | else
|
---|
230 | {
|
---|
231 | if (fInstall)
|
---|
232 | _tprintf(_T("Installing driver ...\n"));
|
---|
233 | else
|
---|
234 | _tprintf(_T("Uninstalling driver ...\n"));
|
---|
235 | _tprintf(_T("INF-File: %ws\n"), szDriverInf);
|
---|
236 |
|
---|
237 | DWORD dwFlags = DRIVER_PACKAGE_FORCE;
|
---|
238 | if (!fInstall)
|
---|
239 | dwFlags |= DRIVER_PACKAGE_DELETE_FILES;
|
---|
240 |
|
---|
241 | OSVERSIONINFO osi;
|
---|
242 | memset(&osi, 0, sizeof(OSVERSIONINFO));
|
---|
243 | osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
---|
244 | if ( (GetVersionEx(&osi) != 0)
|
---|
245 | && (osi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
---|
246 | && (osi.dwMajorVersion < 6))
|
---|
247 | {
|
---|
248 | if (fInstall)
|
---|
249 | {
|
---|
250 | _tprintf(_T("Using legacy mode for install ...\n"));
|
---|
251 | dwFlags |= DRIVER_PACKAGE_LEGACY_MODE;
|
---|
252 | }
|
---|
253 | }
|
---|
254 |
|
---|
255 | if (fSilent)
|
---|
256 | {
|
---|
257 | _tprintf(_T("Installation is silent ...\n"));
|
---|
258 | /*
|
---|
259 | * Don't add DRIVER_PACKAGE_SILENT to dwFlags here, otherwise
|
---|
260 | * installation will fail because we (still) don't have WHQL certified
|
---|
261 | * drivers. See CERT_E_WRONG_USAGE on MSDN for more information.
|
---|
262 | */
|
---|
263 | }
|
---|
264 |
|
---|
265 | BOOL fReboot;
|
---|
266 | DWORD dwRet = fInstall ?
|
---|
267 | g_pfnDriverPackageInstall(szDriverInf, dwFlags, &instInfo, &fReboot)
|
---|
268 | : g_pfnDriverPackageUninstall(szDriverInf, dwFlags, &instInfo, &fReboot);
|
---|
269 | if (dwRet != ERROR_SUCCESS)
|
---|
270 | {
|
---|
271 | switch (dwRet)
|
---|
272 | {
|
---|
273 | case CRYPT_E_FILE_ERROR:
|
---|
274 | _tprintf(_T("ERROR: The catalog file for the specified driver package was not found!\n"));
|
---|
275 | break;
|
---|
276 |
|
---|
277 | case ERROR_ACCESS_DENIED:
|
---|
278 | _tprintf(_T("ERROR: Caller is not in Administrators group to (un)install this driver package!\n"));
|
---|
279 | break;
|
---|
280 |
|
---|
281 | case ERROR_BAD_ENVIRONMENT:
|
---|
282 | _tprintf(_T("ERROR: The current Microsoft Windows version does not support this operation!\n"));
|
---|
283 | break;
|
---|
284 |
|
---|
285 | case ERROR_CANT_ACCESS_FILE:
|
---|
286 | _tprintf(_T("ERROR: The driver package files could not be accessed!\n"));
|
---|
287 | break;
|
---|
288 |
|
---|
289 | case ERROR_DEPENDENT_APPLICATIONS_EXIST:
|
---|
290 | _tprintf(_T("ERROR: DriverPackageUninstall removed an association between the driver package and the specified application but the function did not uninstall the driver package because other applications are associated with the driver package!\n"));
|
---|
291 | break;
|
---|
292 |
|
---|
293 | case ERROR_DRIVER_PACKAGE_NOT_IN_STORE:
|
---|
294 | _tprintf(_T("ERROR: There is no INF file in the DIFx driver store that corresponds to the INF file %ws!\n"), szDriverInf);
|
---|
295 | break;
|
---|
296 |
|
---|
297 | case ERROR_FILE_NOT_FOUND:
|
---|
298 | _tprintf(_T("ERROR: File not found! File = %ws\n"), szDriverInf);
|
---|
299 | break;
|
---|
300 |
|
---|
301 | case ERROR_IN_WOW64:
|
---|
302 | _tprintf(_T("ERROR: The calling application is a 32-bit application attempting to execute in a 64-bit environment, which is not allowed!\n"));
|
---|
303 | break;
|
---|
304 |
|
---|
305 | case ERROR_INVALID_FLAGS:
|
---|
306 | _tprintf(_T("ERROR: The flags specified are invalid!\n"));
|
---|
307 | break;
|
---|
308 |
|
---|
309 | case ERROR_INSTALL_FAILURE:
|
---|
310 | _tprintf(_T("ERROR: The (un)install operation failed! Consult the Setup API logs for more information.\n"));
|
---|
311 | break;
|
---|
312 |
|
---|
313 | case ERROR_NO_MORE_ITEMS:
|
---|
314 | _tprintf(
|
---|
315 | _T(
|
---|
316 | "ERROR: The function found a match for the HardwareId value, but the specified driver was not a better match than the current driver and the caller did not specify the INSTALLFLAG_FORCE flag!\n"));
|
---|
317 | break;
|
---|
318 |
|
---|
319 | case ERROR_NO_DRIVER_SELECTED:
|
---|
320 | _tprintf(_T("ERROR: No driver in .INF-file selected!\n"));
|
---|
321 | break;
|
---|
322 |
|
---|
323 | case ERROR_SECTION_NOT_FOUND:
|
---|
324 | _tprintf(_T("ERROR: Section in .INF-file was not found!\n"));
|
---|
325 | break;
|
---|
326 |
|
---|
327 | case ERROR_SHARING_VIOLATION:
|
---|
328 | _tprintf(_T("ERROR: A component of the driver package in the DIFx driver store is locked by a thread or process\n"));
|
---|
329 | break;
|
---|
330 |
|
---|
331 | /*
|
---|
332 | * ! sig: Verifying file against specific Authenticode(tm) catalog failed! (0x800b0109)
|
---|
333 | * ! sig: Error 0x800b0109: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
|
---|
334 | * !!! sto: No error message will be displayed as client is running in non-interactive mode.
|
---|
335 | * !!! ndv: Driver package failed signature validation. Error = 0xE0000247
|
---|
336 | */
|
---|
337 | case ERROR_DRIVER_STORE_ADD_FAILED:
|
---|
338 | _tprintf(_T("ERROR: Adding driver to the driver store failed!!\n"));
|
---|
339 | break;
|
---|
340 |
|
---|
341 | case ERROR_UNSUPPORTED_TYPE:
|
---|
342 | _tprintf(_T("ERROR: The driver package type is not supported of INF %ws!\n"), szDriverInf);
|
---|
343 | break;
|
---|
344 |
|
---|
345 | default:
|
---|
346 | {
|
---|
347 | /* Try error lookup with GetErrorMsg(). */
|
---|
348 | TCHAR szErrMsg[1024];
|
---|
349 | GetErrorMsg(dwRet, szErrMsg, sizeof(szErrMsg));
|
---|
350 | _tprintf(_T("ERROR (%08x): %ws\n"), dwRet, szErrMsg);
|
---|
351 | break;
|
---|
352 | }
|
---|
353 | }
|
---|
354 | hr = HRESULT_FROM_WIN32(dwRet);
|
---|
355 | }
|
---|
356 | g_pfnDIFXAPISetLogCallback(NULL, NULL);
|
---|
357 | if (phFile)
|
---|
358 | fclose(phFile);
|
---|
359 | if (SUCCEEDED(hr))
|
---|
360 | {
|
---|
361 | _tprintf(_T("Driver was installed successfully!\n"));
|
---|
362 | if (fReboot)
|
---|
363 | _tprintf(_T("A reboot is needed to complete the driver (un)installation!\n"));
|
---|
364 | }
|
---|
365 | }
|
---|
366 | }
|
---|
367 |
|
---|
368 | if (NULL != hDIFxAPI)
|
---|
369 | FreeLibrary(hDIFxAPI);
|
---|
370 |
|
---|
371 | return SUCCEEDED(hr) ? EXIT_OK : EXIT_FAIL;
|
---|
372 | }
|
---|
373 |
|
---|
374 | static UINT WINAPI vboxDrvInstExecuteInfFileCallback(PVOID Context,
|
---|
375 | UINT Notification,
|
---|
376 | UINT_PTR Param1,
|
---|
377 | UINT_PTR Param2)
|
---|
378 | {
|
---|
379 | #ifdef DEBUG
|
---|
380 | _tprintf (_T( "Got installation notification %u\n"), Notification);
|
---|
381 | #endif
|
---|
382 |
|
---|
383 | switch (Notification)
|
---|
384 | {
|
---|
385 | case SPFILENOTIFY_NEEDMEDIA:
|
---|
386 | _tprintf (_T( "Requesting installation media ...\n"));
|
---|
387 | break;
|
---|
388 |
|
---|
389 | case SPFILENOTIFY_STARTCOPY:
|
---|
390 | _tprintf (_T( "Copying driver files to destination ...\n"));
|
---|
391 | break;
|
---|
392 |
|
---|
393 | case SPFILENOTIFY_TARGETNEWER:
|
---|
394 | case SPFILENOTIFY_TARGETEXISTS:
|
---|
395 | return TRUE;
|
---|
396 | }
|
---|
397 |
|
---|
398 | return SetupDefaultQueueCallback(Context, Notification, Param1, Param2);
|
---|
399 | }
|
---|
400 |
|
---|
401 | /**
|
---|
402 | * Executes a sepcified .INF section to install/uninstall drivers and/or services.
|
---|
403 | *
|
---|
404 | * @return Exit code (EXIT_OK, EXIT_FAIL)
|
---|
405 | * @param pszSection Section to execute; usually it's "DefaultInstall".
|
---|
406 | * @param iMode Execution mode to use (see MSDN).
|
---|
407 | * @param pszInf Full qualified path of the .INF file to use.
|
---|
408 | */
|
---|
409 | int ExecuteInfFile(const _TCHAR *pszSection, int iMode, const _TCHAR *pszInf)
|
---|
410 | {
|
---|
411 | _tprintf(_T("Installing from INF-File: %ws (Section: %ws) ...\n"),
|
---|
412 | pszInf, pszSection);
|
---|
413 |
|
---|
414 | UINT uErrorLine = 0;
|
---|
415 | HINF hINF = SetupOpenInfFile(pszInf, NULL, INF_STYLE_WIN4, &uErrorLine);
|
---|
416 | if (hINF != INVALID_HANDLE_VALUE)
|
---|
417 | {
|
---|
418 | PVOID pvQueue = SetupInitDefaultQueueCallback(NULL);
|
---|
419 |
|
---|
420 | BOOL fSuccess = SetupInstallFromInfSection(NULL,
|
---|
421 | hINF,
|
---|
422 | pszSection,
|
---|
423 | SPINST_ALL,
|
---|
424 | HKEY_LOCAL_MACHINE,
|
---|
425 | NULL,
|
---|
426 | SP_COPY_NEWER_OR_SAME | SP_COPY_NOSKIP,
|
---|
427 | vboxDrvInstExecuteInfFileCallback,
|
---|
428 | pvQueue,
|
---|
429 | NULL,
|
---|
430 | NULL
|
---|
431 | );
|
---|
432 | if (fSuccess)
|
---|
433 | {
|
---|
434 | _tprintf (_T( "File installation stage successful\n"));
|
---|
435 |
|
---|
436 | fSuccess = SetupInstallServicesFromInfSection(hINF,
|
---|
437 | L"DefaultInstall.Services",
|
---|
438 | 0 /* Flags */);
|
---|
439 | if (fSuccess)
|
---|
440 | {
|
---|
441 | _tprintf (_T( "Service installation stage successful. Installation completed\n"));
|
---|
442 | }
|
---|
443 | else
|
---|
444 | {
|
---|
445 | DWORD dwErr = GetLastError();
|
---|
446 | switch (dwErr)
|
---|
447 | {
|
---|
448 | case ERROR_SUCCESS_REBOOT_REQUIRED:
|
---|
449 | _tprintf (_T( "A reboot is required to complete the installation\n"));
|
---|
450 | break;
|
---|
451 |
|
---|
452 | case ERROR_SECTION_NOT_FOUND:
|
---|
453 | break;
|
---|
454 |
|
---|
455 | default:
|
---|
456 | _tprintf (_T( "Error %ld while installing service\n"), dwErr);
|
---|
457 | break;
|
---|
458 | }
|
---|
459 | }
|
---|
460 | }
|
---|
461 | else
|
---|
462 | _tprintf (_T( "Error %ld while installing files\n"), GetLastError());
|
---|
463 |
|
---|
464 | if (pvQueue)
|
---|
465 | SetupTermDefaultQueueCallback(pvQueue);
|
---|
466 |
|
---|
467 | SetupCloseInfFile(hINF);
|
---|
468 | }
|
---|
469 | else
|
---|
470 | _tprintf (_T( "Unable to open %ws: %ld (error line %u)\n"),
|
---|
471 | pszInf, GetLastError(), uErrorLine);
|
---|
472 |
|
---|
473 | return EXIT_OK;
|
---|
474 | }
|
---|
475 |
|
---|
476 | /**
|
---|
477 | * Adds a string entry to a MULTI_SZ registry list.
|
---|
478 | *
|
---|
479 | * @return Exit code (EXIT_OK, EXIT_FAIL)
|
---|
480 | * @param pszSubKey Sub key containing the list.
|
---|
481 | * @param pszKeyValue The actual key name of the list.
|
---|
482 | * @param pszValueToRemove The value to add to the list.
|
---|
483 | * @param uiOrder Position (zero-based) of where to add the value to the list.
|
---|
484 | */
|
---|
485 | int RegistryAddStringToMultiSZ(const TCHAR *pszSubKey, const TCHAR *pszKeyValue, const TCHAR *pszValueToAdd, unsigned int uiOrder)
|
---|
486 | {
|
---|
487 | #ifdef DEBUG
|
---|
488 | _tprintf(_T("AddStringToMultiSZ: Adding MULTI_SZ string %ws to %ws\\%ws (Order = %d)\n"), pszValueToAdd, pszSubKey, pszKeyValue, uiOrder);
|
---|
489 | #endif
|
---|
490 |
|
---|
491 | HKEY hKey = NULL;
|
---|
492 | DWORD disp, dwType;
|
---|
493 | LONG lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, pszSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &hKey, &disp);
|
---|
494 | if (lRet != ERROR_SUCCESS)
|
---|
495 | _tprintf(_T("AddStringToMultiSZ: RegCreateKeyEx %ts failed with error %ld!\n"), pszSubKey, lRet);
|
---|
496 |
|
---|
497 | if (lRet == ERROR_SUCCESS)
|
---|
498 | {
|
---|
499 | TCHAR szKeyValue[512] = { 0 };
|
---|
500 | TCHAR szNewKeyValue[512] = { 0 };
|
---|
501 | DWORD cbKeyValue = sizeof(szKeyValue);
|
---|
502 |
|
---|
503 | lRet = RegQueryValueEx(hKey, pszKeyValue, NULL, &dwType, (LPBYTE)szKeyValue, &cbKeyValue);
|
---|
504 | if ( lRet != ERROR_SUCCESS
|
---|
505 | || dwType != REG_MULTI_SZ)
|
---|
506 | {
|
---|
507 | _tprintf(_T("AddStringToMultiSZ: RegQueryValueEx failed with error %ld, key type = 0x%x!\n"), lRet, dwType);
|
---|
508 | }
|
---|
509 | else
|
---|
510 | {
|
---|
511 |
|
---|
512 | /* Look if the network provider is already in the list. */
|
---|
513 | int iPos = 0;
|
---|
514 | size_t cb = 0;
|
---|
515 |
|
---|
516 | /* Replace delimiting "\0"'s with "," to make tokenizing work. */
|
---|
517 | for (int i = 0; i < cbKeyValue / sizeof(TCHAR); i++)
|
---|
518 | if (szKeyValue[i] == '\0') szKeyValue[i] = ',';
|
---|
519 |
|
---|
520 | TCHAR *pszToken = wcstok(szKeyValue, _T(","));
|
---|
521 | TCHAR *pszNewToken = NULL;
|
---|
522 | TCHAR *pNewKeyValuePos = szNewKeyValue;
|
---|
523 | while (pszToken != NULL)
|
---|
524 | {
|
---|
525 | pszNewToken = wcstok(NULL, _T(","));
|
---|
526 |
|
---|
527 | /* Append new value (at beginning if iOrder=0). */
|
---|
528 | if (iPos == uiOrder)
|
---|
529 | {
|
---|
530 | memcpy(pNewKeyValuePos, pszValueToAdd, wcslen(pszValueToAdd)*sizeof(TCHAR));
|
---|
531 |
|
---|
532 | cb += (wcslen(pszValueToAdd) + 1) * sizeof(TCHAR); /* Add trailing zero as well. */
|
---|
533 | pNewKeyValuePos += wcslen(pszValueToAdd) + 1;
|
---|
534 | iPos++;
|
---|
535 | }
|
---|
536 |
|
---|
537 | if (0 != wcsicmp(pszToken, pszValueToAdd))
|
---|
538 | {
|
---|
539 | memcpy(pNewKeyValuePos, pszToken, wcslen(pszToken)*sizeof(TCHAR));
|
---|
540 | cb += (wcslen(pszToken) + 1) * sizeof(TCHAR); /* Add trailing zero as well. */
|
---|
541 | pNewKeyValuePos += wcslen(pszToken) + 1;
|
---|
542 | iPos++;
|
---|
543 | }
|
---|
544 |
|
---|
545 | pszToken = pszNewToken;
|
---|
546 | }
|
---|
547 |
|
---|
548 | /* Append as last item if needed. */
|
---|
549 | if (uiOrder >= iPos)
|
---|
550 | {
|
---|
551 | memcpy(pNewKeyValuePos, pszValueToAdd, wcslen(pszValueToAdd)*sizeof(TCHAR));
|
---|
552 | cb += wcslen(pszValueToAdd) * sizeof(TCHAR); /* Add trailing zero as well. */
|
---|
553 | }
|
---|
554 |
|
---|
555 | lRet = RegSetValueExW(hKey, pszKeyValue, 0, REG_MULTI_SZ, (LPBYTE)szNewKeyValue, (DWORD)cb);
|
---|
556 | if (lRet != ERROR_SUCCESS)
|
---|
557 | _tprintf(_T("AddStringToMultiSZ: RegSetValueEx failed with error %ld!\n"), lRet);
|
---|
558 | }
|
---|
559 |
|
---|
560 | RegCloseKey(hKey);
|
---|
561 | #ifdef DEBUG
|
---|
562 | if (lRet == ERROR_SUCCESS)
|
---|
563 | _tprintf(_T("AddStringToMultiSZ: Value %ws successfully written!\n"), pszValueToAdd);
|
---|
564 | #endif
|
---|
565 | }
|
---|
566 |
|
---|
567 | return (lRet == ERROR_SUCCESS) ? EXIT_OK : EXIT_FAIL;
|
---|
568 | }
|
---|
569 |
|
---|
570 | /**
|
---|
571 | * Removes a string entry from a MULTI_SZ registry list.
|
---|
572 | *
|
---|
573 | * @return Exit code (EXIT_OK, EXIT_FAIL)
|
---|
574 | * @param pszSubKey Sub key containing the list.
|
---|
575 | * @param pszKeyValue The actual key name of the list.
|
---|
576 | * @param pszValueToRemove The value to remove from the list.
|
---|
577 | */
|
---|
578 | int RegistryRemoveStringFromMultiSZ(const TCHAR *pszSubKey, const TCHAR *pszKeyValue, const TCHAR *pszValueToRemove)
|
---|
579 | {
|
---|
580 | // @todo Make string sizes dynamically allocated!
|
---|
581 |
|
---|
582 | const TCHAR *pszKey = pszSubKey;
|
---|
583 | #ifdef DEBUG
|
---|
584 | _tprintf(_T("RemoveStringFromMultiSZ: Removing MULTI_SZ string: %ws from %ws\\%ws ...\n"), pszValueToRemove, pszSubKey, pszKeyValue);
|
---|
585 | #endif
|
---|
586 |
|
---|
587 | HKEY hkey;
|
---|
588 | DWORD disp, dwType;
|
---|
589 | LONG lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, pszKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &hkey, &disp);
|
---|
590 | if (lRet != ERROR_SUCCESS)
|
---|
591 | _tprintf(_T("RemoveStringFromMultiSZ: RegCreateKeyEx %ts failed with error %ld!\n"), pszKey, lRet);
|
---|
592 |
|
---|
593 | if (lRet == ERROR_SUCCESS)
|
---|
594 | {
|
---|
595 | TCHAR szKeyValue[1024];
|
---|
596 | DWORD cbKeyValue = sizeof(szKeyValue);
|
---|
597 |
|
---|
598 | lRet = RegQueryValueEx(hkey, pszKeyValue, NULL, &dwType, (LPBYTE)szKeyValue, &cbKeyValue);
|
---|
599 | if ( lRet != ERROR_SUCCESS
|
---|
600 | || dwType != REG_MULTI_SZ)
|
---|
601 | {
|
---|
602 | _tprintf(_T("RemoveStringFromMultiSZ: RegQueryValueEx failed with %d, key type = 0x%x!\n"), lRet, dwType);
|
---|
603 | }
|
---|
604 | else
|
---|
605 | {
|
---|
606 | #ifdef DEBUG
|
---|
607 | _tprintf(_T("RemoveStringFromMultiSZ: Current key len: %ld\n"), cbKeyValue);
|
---|
608 | #endif
|
---|
609 |
|
---|
610 | TCHAR szCurString[1024] = { 0 };
|
---|
611 | TCHAR szFinalString[1024] = { 0 };
|
---|
612 | int iIndex = 0;
|
---|
613 | int iNewIndex = 0;
|
---|
614 | for (int i = 0; i < cbKeyValue / sizeof(TCHAR); i++)
|
---|
615 | {
|
---|
616 | if (szKeyValue[i] != _T('\0'))
|
---|
617 | szCurString[iIndex++] = szKeyValue[i];
|
---|
618 |
|
---|
619 | if ( (!szKeyValue[i] == _T('\0'))
|
---|
620 | && (szKeyValue[i + 1] == _T('\0')))
|
---|
621 | {
|
---|
622 | if (NULL == wcsstr(szCurString, pszValueToRemove))
|
---|
623 | {
|
---|
624 | wcscat(&szFinalString[iNewIndex], szCurString);
|
---|
625 |
|
---|
626 | if (iNewIndex == 0)
|
---|
627 | iNewIndex = iIndex;
|
---|
628 | else iNewIndex += iIndex;
|
---|
629 |
|
---|
630 | szFinalString[++iNewIndex] = _T('\0');
|
---|
631 | }
|
---|
632 |
|
---|
633 | iIndex = 0;
|
---|
634 | ZeroMemory(szCurString, sizeof(szCurString));
|
---|
635 | }
|
---|
636 | }
|
---|
637 | szFinalString[++iNewIndex] = _T('\0');
|
---|
638 | #ifdef DEBUG
|
---|
639 | _tprintf(_T("RemoveStringFromMultiSZ: New key value: %ws (%u bytes)\n"),
|
---|
640 | szFinalString, iNewIndex * sizeof(TCHAR));
|
---|
641 | #endif
|
---|
642 |
|
---|
643 | lRet = RegSetValueExW(hkey, pszKeyValue, 0, REG_MULTI_SZ, (LPBYTE)szFinalString, iNewIndex * sizeof(TCHAR));
|
---|
644 | if (lRet != ERROR_SUCCESS)
|
---|
645 | _tprintf(_T("RemoveStringFromMultiSZ: RegSetValueEx failed with %d!\n"), lRet);
|
---|
646 | }
|
---|
647 |
|
---|
648 | RegCloseKey(hkey);
|
---|
649 | #ifdef DEBUG
|
---|
650 | if (lRet == ERROR_SUCCESS)
|
---|
651 | _tprintf(_T("RemoveStringFromMultiSZ: Value %ws successfully removed!\n"), pszValueToRemove);
|
---|
652 | #endif
|
---|
653 | }
|
---|
654 |
|
---|
655 | return (lRet == ERROR_SUCCESS) ? EXIT_OK : EXIT_FAIL;
|
---|
656 | }
|
---|
657 |
|
---|
658 | /**
|
---|
659 | * Adds a string to a registry string list (STRING_SZ).
|
---|
660 | * Only operates in HKLM for now, needs to be extended later for
|
---|
661 | * using other hives. Only processes lists with a "," separator
|
---|
662 | * at the moment.
|
---|
663 | *
|
---|
664 | * @return Exit code (EXIT_OK, EXIT_FAIL)
|
---|
665 | * @param pszSubKey Sub key containing the list.
|
---|
666 | * @param pszKeyValue The actual key name of the list.
|
---|
667 | * @param pszValueToAdd The value to add to the list.
|
---|
668 | * @param uiOrder Position (zero-based) of where to add the value to the list.
|
---|
669 | * @param dwFlags Flags.
|
---|
670 | */
|
---|
671 | int RegistryAddStringToList(const TCHAR *pszSubKey, const TCHAR *pszKeyValue, const TCHAR *pszValueToAdd,
|
---|
672 | unsigned int uiOrder, DWORD dwFlags)
|
---|
673 | {
|
---|
674 | HKEY hKey = NULL;
|
---|
675 | DWORD disp, dwType;
|
---|
676 | LONG lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, pszSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &hKey, &disp);
|
---|
677 | if (lRet != ERROR_SUCCESS)
|
---|
678 | _tprintf(_T("RegistryAddStringToList: RegCreateKeyEx %ts failed with error %ld!\n"), pszSubKey, lRet);
|
---|
679 |
|
---|
680 | TCHAR szKeyValue[512] = { 0 };
|
---|
681 | TCHAR szNewKeyValue[512] = { 0 };
|
---|
682 | DWORD cbKeyValue = sizeof(szKeyValue);
|
---|
683 |
|
---|
684 | lRet = RegQueryValueEx(hKey, pszKeyValue, NULL, &dwType, (LPBYTE)szKeyValue, &cbKeyValue);
|
---|
685 | if ( lRet != ERROR_SUCCESS
|
---|
686 | || dwType != REG_SZ)
|
---|
687 | {
|
---|
688 | _tprintf(_T("RegistryAddStringToList: RegQueryValueEx failed with %d, key type = 0x%x!\n"), lRet, dwType);
|
---|
689 | }
|
---|
690 |
|
---|
691 | if (lRet == ERROR_SUCCESS)
|
---|
692 | {
|
---|
693 | #ifdef DEBUG
|
---|
694 | _tprintf(_T("RegistryAddStringToList: Key value: %ws\n"), szKeyValue);
|
---|
695 | #endif
|
---|
696 |
|
---|
697 | /* Create entire new list. */
|
---|
698 | unsigned int iPos = 0;
|
---|
699 | TCHAR *pszToken = wcstok(szKeyValue, _T(","));
|
---|
700 | TCHAR *pszNewToken = NULL;
|
---|
701 | while (pszToken != NULL)
|
---|
702 | {
|
---|
703 | pszNewToken = wcstok(NULL, _T(","));
|
---|
704 |
|
---|
705 | /* Append new provider name (at beginning if iOrder=0). */
|
---|
706 | if (iPos == uiOrder)
|
---|
707 | {
|
---|
708 | wcscat(szNewKeyValue, pszValueToAdd);
|
---|
709 | wcscat(szNewKeyValue, _T(","));
|
---|
710 | iPos++;
|
---|
711 | }
|
---|
712 |
|
---|
713 | BOOL fAddToList = FALSE;
|
---|
714 | if ( !wcsicmp(pszToken, pszValueToAdd)
|
---|
715 | && (dwFlags & VBOX_REG_STRINGLIST_ALLOW_DUPLICATES))
|
---|
716 | fAddToList = TRUE;
|
---|
717 | else if (wcsicmp(pszToken, pszValueToAdd))
|
---|
718 | fAddToList = TRUE;
|
---|
719 |
|
---|
720 | if (fAddToList)
|
---|
721 | {
|
---|
722 | wcscat(szNewKeyValue, pszToken);
|
---|
723 | wcscat(szNewKeyValue, _T(","));
|
---|
724 | iPos++;
|
---|
725 | }
|
---|
726 |
|
---|
727 | #ifdef DEBUG
|
---|
728 | _tprintf (_T("RegistryAddStringToList: Temp new key value: %ws\n"), szNewKeyValue);
|
---|
729 | #endif
|
---|
730 | pszToken = pszNewToken;
|
---|
731 | }
|
---|
732 |
|
---|
733 | /* Append as last item if needed. */
|
---|
734 | if (uiOrder >= iPos)
|
---|
735 | wcscat(szNewKeyValue, pszValueToAdd);
|
---|
736 |
|
---|
737 | /* Last char a delimiter? Cut off ... */
|
---|
738 | if (szNewKeyValue[wcslen(szNewKeyValue) - 1] == ',')
|
---|
739 | szNewKeyValue[wcslen(szNewKeyValue) - 1] = '\0';
|
---|
740 |
|
---|
741 | size_t iNewLen = (wcslen(szNewKeyValue) * sizeof(WCHAR)) + sizeof(WCHAR);
|
---|
742 |
|
---|
743 | #ifdef DEBUG
|
---|
744 | _tprintf(_T("RegistryAddStringToList: New provider list: %ws (%u bytes)\n"), szNewKeyValue, iNewLen);
|
---|
745 | #endif
|
---|
746 |
|
---|
747 | lRet = RegSetValueExW(hKey, pszKeyValue, 0, REG_SZ, (LPBYTE)szNewKeyValue, (DWORD)iNewLen);
|
---|
748 | if (lRet != ERROR_SUCCESS)
|
---|
749 | _tprintf(_T("RegistryAddStringToList: RegSetValueEx failed with %ld!\n"), lRet);
|
---|
750 | }
|
---|
751 |
|
---|
752 | RegCloseKey(hKey);
|
---|
753 | return (lRet == ERROR_SUCCESS) ? EXIT_OK : EXIT_FAIL;
|
---|
754 | }
|
---|
755 |
|
---|
756 | /**
|
---|
757 | * Removes a string from a registry string list (STRING_SZ).
|
---|
758 | * Only operates in HKLM for now, needs to be extended later for
|
---|
759 | * using other hives. Only processes lists with a "," separator
|
---|
760 | * at the moment.
|
---|
761 | *
|
---|
762 | * @return Exit code (EXIT_OK, EXIT_FAIL)
|
---|
763 | * @param pszSubKey Sub key containing the list.
|
---|
764 | * @param pszKeyValue The actual key name of the list.
|
---|
765 | * @param pszValueToRemove The value to remove from the list.
|
---|
766 | */
|
---|
767 | int RegistryRemoveStringFromList(const TCHAR *pszSubKey, const TCHAR *pszKeyValue, const TCHAR *pszValueToRemove)
|
---|
768 | {
|
---|
769 | HKEY hKey = NULL;
|
---|
770 | DWORD disp, dwType;
|
---|
771 | LONG lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, pszSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &hKey, &disp);
|
---|
772 | if (lRet != ERROR_SUCCESS)
|
---|
773 | _tprintf(_T("RegistryRemoveStringFromList: RegCreateKeyEx %ts failed with error %ld!\n"), pszSubKey, lRet);
|
---|
774 |
|
---|
775 | TCHAR szKeyValue[512] = { 0 };
|
---|
776 | TCHAR szNewKeyValue[512] = { 0 };
|
---|
777 | DWORD cbKeyValue = sizeof(szKeyValue);
|
---|
778 |
|
---|
779 | lRet = RegQueryValueEx(hKey, pszKeyValue, NULL, &dwType, (LPBYTE)szKeyValue, &cbKeyValue);
|
---|
780 | if ( lRet != ERROR_SUCCESS
|
---|
781 | || dwType != REG_SZ)
|
---|
782 | {
|
---|
783 | _tprintf(_T("RegistryRemoveStringFromList: RegQueryValueEx failed with %d, key type = 0x%x!\n"), lRet, dwType);
|
---|
784 | }
|
---|
785 |
|
---|
786 | if (lRet == ERROR_SUCCESS)
|
---|
787 | {
|
---|
788 | #ifdef DEBUG
|
---|
789 | _tprintf(_T("RegistryRemoveStringFromList: Key value: %ws\n"), szKeyValue);
|
---|
790 | #endif
|
---|
791 |
|
---|
792 | /* Create entire new list. */
|
---|
793 | int iPos = 0;
|
---|
794 |
|
---|
795 | TCHAR *pszToken = wcstok(szKeyValue, _T(","));
|
---|
796 | TCHAR *pszNewToken = NULL;
|
---|
797 | while (pszToken != NULL)
|
---|
798 | {
|
---|
799 | pszNewToken = wcstok(NULL, _T(","));
|
---|
800 |
|
---|
801 | /* Append all list values as long as it's not the
|
---|
802 | * value we want to remove. */
|
---|
803 | if (wcsicmp(pszToken, pszValueToRemove))
|
---|
804 | {
|
---|
805 | wcscat(szNewKeyValue, pszToken);
|
---|
806 | wcscat(szNewKeyValue, _T(","));
|
---|
807 | iPos++;
|
---|
808 | }
|
---|
809 |
|
---|
810 | #ifdef DEBUG
|
---|
811 | _tprintf (_T("RegistryRemoveStringFromList: Temp new key value: %ws\n"), szNewKeyValue);
|
---|
812 | #endif
|
---|
813 | pszToken = pszNewToken;
|
---|
814 | }
|
---|
815 |
|
---|
816 | /* Last char a delimiter? Cut off ... */
|
---|
817 | if (szNewKeyValue[wcslen(szNewKeyValue) - 1] == ',')
|
---|
818 | szNewKeyValue[wcslen(szNewKeyValue) - 1] = '\0';
|
---|
819 |
|
---|
820 | size_t iNewLen = (wcslen(szNewKeyValue) * sizeof(WCHAR)) + sizeof(WCHAR);
|
---|
821 |
|
---|
822 | #ifdef DEBUG
|
---|
823 | _tprintf(_T("RegistryRemoveStringFromList: New provider list: %ws (%u bytes)\n"), szNewKeyValue, iNewLen);
|
---|
824 | #endif
|
---|
825 |
|
---|
826 | lRet = RegSetValueExW(hKey, pszKeyValue, 0, REG_SZ, (LPBYTE)szNewKeyValue, (DWORD)iNewLen);
|
---|
827 | if (lRet != ERROR_SUCCESS)
|
---|
828 | _tprintf(_T("RegistryRemoveStringFromList: RegSetValueEx failed with %ld!\n"), lRet);
|
---|
829 | }
|
---|
830 |
|
---|
831 | RegCloseKey(hKey);
|
---|
832 | return (lRet == ERROR_SUCCESS) ? EXIT_OK : EXIT_FAIL;
|
---|
833 | }
|
---|
834 |
|
---|
835 | /**
|
---|
836 | * Adds a network provider with a specified order to the system.
|
---|
837 | *
|
---|
838 | * @return Exit code (EXIT_OK, EXIT_FAIL)
|
---|
839 | * @param pszProvider Name of network provider to add.
|
---|
840 | * @param uiOrder Position in list (zero-based) of where to add.
|
---|
841 | */
|
---|
842 | int AddNetworkProvider(const TCHAR *pszProvider, unsigned int uiOrder)
|
---|
843 | {
|
---|
844 | _tprintf(_T("Adding network provider \"%ws\" (Order = %u) ...\n"), pszProvider, uiOrder);
|
---|
845 | int rc = RegistryAddStringToList(_T("System\\CurrentControlSet\\Control\\NetworkProvider\\Order"),
|
---|
846 | _T("ProviderOrder"),
|
---|
847 | pszProvider, uiOrder, VBOX_REG_STRINGLIST_NONE /* No flags set */);
|
---|
848 | if (rc == EXIT_OK)
|
---|
849 | _tprintf(_T("Network provider successfully added!\n"));
|
---|
850 | return rc;
|
---|
851 | }
|
---|
852 |
|
---|
853 | /**
|
---|
854 | * Removes a network provider from the system.
|
---|
855 | *
|
---|
856 | * @return Exit code (EXIT_OK, EXIT_FAIL)
|
---|
857 | * @param pszProvider Name of network provider to remove.
|
---|
858 | */
|
---|
859 | int RemoveNetworkProvider(const TCHAR *pszProvider)
|
---|
860 | {
|
---|
861 | _tprintf(_T("Removing network provider \"%ws\" ...\n"), pszProvider);
|
---|
862 | int rc = RegistryRemoveStringFromList(_T("System\\CurrentControlSet\\Control\\NetworkProvider\\Order"),
|
---|
863 | _T("ProviderOrder"),
|
---|
864 | pszProvider);
|
---|
865 | if (rc == EXIT_OK)
|
---|
866 | _tprintf(_T("Network provider successfully removed!\n"));
|
---|
867 | return rc;
|
---|
868 | }
|
---|
869 |
|
---|
870 | int CreateService(const TCHAR *pszStartStopName,
|
---|
871 | const TCHAR *pszDisplayName,
|
---|
872 | int iServiceType,
|
---|
873 | int iStartType,
|
---|
874 | const TCHAR *pszBinPath,
|
---|
875 | const TCHAR *pszLoadOrderGroup,
|
---|
876 | const TCHAR *pszDependencies,
|
---|
877 | const TCHAR *pszLogonUser,
|
---|
878 | const TCHAR *pszLogonPassword)
|
---|
879 | {
|
---|
880 | int rc = ERROR_SUCCESS;
|
---|
881 |
|
---|
882 | _tprintf(_T("Installing service %ws (%ws) ...\n"), pszDisplayName, pszStartStopName);
|
---|
883 |
|
---|
884 | SC_HANDLE hSCManager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
---|
885 | if (hSCManager == NULL)
|
---|
886 | {
|
---|
887 | _tprintf(_T("Could not get handle to SCM! Error: %ld\n"), GetLastError());
|
---|
888 | return EXIT_FAIL;
|
---|
889 | }
|
---|
890 |
|
---|
891 | /* Fixup end of multistring. */
|
---|
892 | TCHAR szDepend[ _MAX_PATH ] = { 0 }; /* @todo Use dynamically allocated string here! */
|
---|
893 | if (pszDependencies != NULL)
|
---|
894 | {
|
---|
895 | _tcsnccpy (szDepend, pszDependencies, wcslen(pszDependencies));
|
---|
896 | DWORD len = (DWORD)wcslen (szDepend);
|
---|
897 | szDepend [len + 1] = 0;
|
---|
898 |
|
---|
899 | /* Replace comma separator on null separator. */
|
---|
900 | for (DWORD i = 0; i < len; i++)
|
---|
901 | {
|
---|
902 | if (',' == szDepend [i])
|
---|
903 | szDepend [i] = 0;
|
---|
904 | }
|
---|
905 | }
|
---|
906 |
|
---|
907 | DWORD dwTag = 0xDEADBEAF;
|
---|
908 | SC_HANDLE hService = CreateService (hSCManager, /* SCManager database handle. */
|
---|
909 | pszStartStopName, /* Name of service. */
|
---|
910 | pszDisplayName, /* Name to display. */
|
---|
911 | SERVICE_ALL_ACCESS, /* Desired access. */
|
---|
912 | iServiceType, /* Service type. */
|
---|
913 | iStartType, /* Start type. */
|
---|
914 | SERVICE_ERROR_NORMAL, /* Error control type. */
|
---|
915 | pszBinPath, /* Service's binary. */
|
---|
916 | pszLoadOrderGroup, /* Ordering group. */
|
---|
917 | (pszLoadOrderGroup != NULL) ? &dwTag : NULL, /* Tag identifier. */
|
---|
918 | (pszDependencies != NULL) ? szDepend : NULL, /* Dependencies. */
|
---|
919 | (pszLogonUser != NULL) ? pszLogonUser: NULL, /* Account. */
|
---|
920 | (pszLogonPassword != NULL) ? pszLogonPassword : NULL); /* Password. */
|
---|
921 | if (NULL == hService)
|
---|
922 | {
|
---|
923 | DWORD dwErr = GetLastError();
|
---|
924 | switch (dwErr)
|
---|
925 | {
|
---|
926 |
|
---|
927 | case ERROR_SERVICE_EXISTS:
|
---|
928 | {
|
---|
929 | _tprintf(_T("Service already exists. No installation required. Updating the service config.\n"));
|
---|
930 |
|
---|
931 | hService = OpenService (hSCManager, /* SCManager database handle. */
|
---|
932 | pszStartStopName, /* Name of service. */
|
---|
933 | SERVICE_ALL_ACCESS); /* Desired access. */
|
---|
934 | if (NULL == hService)
|
---|
935 | {
|
---|
936 | dwErr = GetLastError();
|
---|
937 | _tprintf(_T("Could not open service! Error: %ld\n"), dwErr);
|
---|
938 | }
|
---|
939 | else
|
---|
940 | {
|
---|
941 | BOOL fResult = ChangeServiceConfig (hService, /* Service handle. */
|
---|
942 | iServiceType, /* Service type. */
|
---|
943 | iStartType, /* Start type. */
|
---|
944 | SERVICE_ERROR_NORMAL, /* Error control type. */
|
---|
945 | pszBinPath, /* Service's binary. */
|
---|
946 | pszLoadOrderGroup, /* Ordering group. */
|
---|
947 | (pszLoadOrderGroup != NULL) ? &dwTag : NULL, /* Tag identifier. */
|
---|
948 | (pszDependencies != NULL) ? szDepend : NULL, /* Dependencies. */
|
---|
949 | (pszLogonUser != NULL) ? pszLogonUser: NULL, /* Account. */
|
---|
950 | (pszLogonPassword != NULL) ? pszLogonPassword : NULL, /* Password. */
|
---|
951 | pszDisplayName); /* Name to display. */
|
---|
952 | if (fResult)
|
---|
953 | _tprintf(_T("The service config has been successfully updated.\n"));
|
---|
954 | else
|
---|
955 | {
|
---|
956 | dwErr = GetLastError();
|
---|
957 | _tprintf(_T("Could not change service config! Error: %ld\n"), dwErr);
|
---|
958 | }
|
---|
959 | CloseServiceHandle(hService);
|
---|
960 | }
|
---|
961 |
|
---|
962 | /*
|
---|
963 | * This entire branch do not return an error to avoid installations failures,
|
---|
964 | * if updating service parameters. Better to have a running system with old
|
---|
965 | * parameters and the failure information in the installation log.
|
---|
966 | */
|
---|
967 | break;
|
---|
968 | }
|
---|
969 |
|
---|
970 | case ERROR_INVALID_PARAMETER:
|
---|
971 |
|
---|
972 | _tprintf(_T("Invalid parameter specified!\n"));
|
---|
973 | rc = EXIT_FAIL;
|
---|
974 | break;
|
---|
975 |
|
---|
976 | default:
|
---|
977 |
|
---|
978 | _tprintf(_T("Could not create service! Error: %ld\n"), dwErr);
|
---|
979 | rc = EXIT_FAIL;
|
---|
980 | break;
|
---|
981 | }
|
---|
982 |
|
---|
983 | if (rc == EXIT_FAIL)
|
---|
984 | goto cleanup;
|
---|
985 | }
|
---|
986 | else
|
---|
987 | {
|
---|
988 | CloseServiceHandle (hService);
|
---|
989 | _tprintf(_T("Installation of service successful!\n"));
|
---|
990 | }
|
---|
991 |
|
---|
992 | cleanup:
|
---|
993 |
|
---|
994 | if (hSCManager != NULL)
|
---|
995 | CloseServiceHandle (hSCManager);
|
---|
996 |
|
---|
997 | return rc;
|
---|
998 | }
|
---|
999 |
|
---|
1000 | int DelService(const TCHAR *pszStartStopName)
|
---|
1001 | {
|
---|
1002 | int rc = ERROR_SUCCESS;
|
---|
1003 |
|
---|
1004 | _tprintf(_T("Deleting service '%ws' ...\n"), pszStartStopName);
|
---|
1005 |
|
---|
1006 | SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
---|
1007 | SC_HANDLE hService = NULL;
|
---|
1008 | if (hSCManager == NULL)
|
---|
1009 | {
|
---|
1010 | _tprintf(_T("Could not get handle to SCM! Error: %ld\n"), GetLastError());
|
---|
1011 | rc = EXIT_FAIL;
|
---|
1012 | }
|
---|
1013 | else
|
---|
1014 | {
|
---|
1015 | hService = OpenService(hSCManager, pszStartStopName, SERVICE_ALL_ACCESS);
|
---|
1016 | if (NULL == hService)
|
---|
1017 | {
|
---|
1018 | _tprintf(_T("Could not open service '%ws'! Error: %ld\n"), pszStartStopName, GetLastError());
|
---|
1019 | rc = EXIT_FAIL;
|
---|
1020 | }
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | if (hService != NULL)
|
---|
1024 | {
|
---|
1025 | if (LockServiceDatabase(hSCManager))
|
---|
1026 | {
|
---|
1027 | if (FALSE == DeleteService(hService))
|
---|
1028 | {
|
---|
1029 | DWORD dwErr = GetLastError();
|
---|
1030 | switch (dwErr)
|
---|
1031 | {
|
---|
1032 |
|
---|
1033 | case ERROR_SERVICE_MARKED_FOR_DELETE:
|
---|
1034 |
|
---|
1035 | _tprintf(_T("Service '%ws' already marked for deletion.\n"), pszStartStopName);
|
---|
1036 | break;
|
---|
1037 |
|
---|
1038 | default:
|
---|
1039 |
|
---|
1040 | _tprintf(_T("Could not delete service '%ws'! Error: %ld\n"), pszStartStopName, GetLastError());
|
---|
1041 | rc = EXIT_FAIL;
|
---|
1042 | break;
|
---|
1043 | }
|
---|
1044 | }
|
---|
1045 | else
|
---|
1046 | {
|
---|
1047 | _tprintf(_T("Service '%ws' successfully removed!\n"), pszStartStopName);
|
---|
1048 | }
|
---|
1049 | UnlockServiceDatabase(hSCManager);
|
---|
1050 | }
|
---|
1051 | else
|
---|
1052 | {
|
---|
1053 | _tprintf(_T("Unable to lock service database! Error: %ld\n"), GetLastError());
|
---|
1054 | rc = EXIT_FAIL;
|
---|
1055 | }
|
---|
1056 | CloseServiceHandle(hService);
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | if (hSCManager != NULL)
|
---|
1060 | CloseServiceHandle(hSCManager);
|
---|
1061 |
|
---|
1062 | return rc;
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 | DWORD RegistryWrite(HKEY hRootKey,
|
---|
1066 | const _TCHAR *pszSubKey,
|
---|
1067 | const _TCHAR *pszValueName,
|
---|
1068 | DWORD dwType,
|
---|
1069 | const BYTE *pbData,
|
---|
1070 | DWORD cbData)
|
---|
1071 | {
|
---|
1072 | DWORD lRet;
|
---|
1073 | HKEY hKey;
|
---|
1074 | lRet = RegCreateKeyEx (hRootKey,
|
---|
1075 | pszSubKey,
|
---|
1076 | 0, /* Reserved */
|
---|
1077 | NULL, /* lpClass [in, optional] */
|
---|
1078 | 0, /* dwOptions [in] */
|
---|
1079 | KEY_WRITE,
|
---|
1080 | NULL, /* lpSecurityAttributes [in, optional] */
|
---|
1081 | &hKey,
|
---|
1082 | NULL); /* lpdwDisposition [out, optional] */
|
---|
1083 | if (lRet != ERROR_SUCCESS)
|
---|
1084 | {
|
---|
1085 | _tprintf(_T("Could not open registry key! Error: %ld\n"), GetLastError());
|
---|
1086 | }
|
---|
1087 | else
|
---|
1088 | {
|
---|
1089 | lRet = RegSetValueEx(hKey, pszValueName, 0, dwType, (BYTE*)pbData, cbData);
|
---|
1090 | if (lRet != ERROR_SUCCESS)
|
---|
1091 | _tprintf(_T("Could not write to registry! Error: %ld\n"), GetLastError());
|
---|
1092 | RegCloseKey(hKey);
|
---|
1093 |
|
---|
1094 | }
|
---|
1095 | return lRet;
|
---|
1096 | }
|
---|
1097 |
|
---|
1098 | void PrintHelp(void)
|
---|
1099 | {
|
---|
1100 | _tprintf(_T("VirtualBox Guest Additions Installation Helper for Windows\n"));
|
---|
1101 | _tprintf(_T("Version: %d.%d.%d.%d\n\n"), VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV);
|
---|
1102 | _tprintf(_T("Syntax:\n"));
|
---|
1103 | _tprintf(_T("\n"));
|
---|
1104 | _tprintf(_T("Drivers:\n"));
|
---|
1105 | _tprintf(_T("\tVBoxDrvInst driver install <inf-file> [log file]\n"));
|
---|
1106 | _tprintf(_T("\tVBoxDrvInst driver uninstall <inf-file> [log file]\n"));
|
---|
1107 | _tprintf(_T("\tVBoxDrvInst driver executeinf <inf-file>\n"));
|
---|
1108 | _tprintf(_T("\n"));
|
---|
1109 | _tprintf(_T("Network Provider:\n"));
|
---|
1110 | _tprintf(_T("\tVBoxDrvInst netprovider add <name> [order]\n"));
|
---|
1111 | _tprintf(_T("\tVBoxDrvInst netprovider remove <name>\n"));
|
---|
1112 | _tprintf(_T("\n"));
|
---|
1113 | _tprintf(_T("Registry:\n"));
|
---|
1114 | _tprintf(_T("\tVBoxDrvInst registry write <root> <sub key>\n")
|
---|
1115 | _T("\t <key name> <key type> <value>\n")
|
---|
1116 | _T("\t [type] [size]\n"));
|
---|
1117 | _tprintf(_T("\tVBoxDrvInst registry addmultisz <root> <sub key>\n")
|
---|
1118 | _T("\t <value> [order]\n"));
|
---|
1119 | _tprintf(_T("\tVBoxDrvInst registry delmultisz <root> <sub key>\n")
|
---|
1120 | _T("\t <key name> <value to remove>\n"));
|
---|
1121 | /** @todo Add "service" category! */
|
---|
1122 | _tprintf(_T("\n"));
|
---|
1123 | }
|
---|
1124 |
|
---|
1125 | int __cdecl _tmain(int argc, _TCHAR *argv[])
|
---|
1126 | {
|
---|
1127 | int rc = EXIT_USAGE;
|
---|
1128 |
|
---|
1129 | OSVERSIONINFO OSinfo;
|
---|
1130 | OSinfo.dwOSVersionInfoSize = sizeof(OSinfo);
|
---|
1131 | GetVersionEx(&OSinfo);
|
---|
1132 |
|
---|
1133 | if (argc >= 2)
|
---|
1134 | {
|
---|
1135 | if ( !_tcsicmp(argv[1], _T("driver"))
|
---|
1136 | && argc >= 3)
|
---|
1137 | {
|
---|
1138 | _TCHAR szINF[_MAX_PATH] = { 0 }; /* Complete path to INF file.*/
|
---|
1139 | if ( ( !_tcsicmp(argv[2], _T("install"))
|
---|
1140 | || !_tcsicmp(argv[2], _T("uninstall")))
|
---|
1141 | && argc >= 4)
|
---|
1142 | {
|
---|
1143 | if (OSinfo.dwMajorVersion < 5)
|
---|
1144 | {
|
---|
1145 | _tprintf(_T("ERROR: Platform not supported for driver (un)installation!\n"));
|
---|
1146 | rc = EXIT_FAIL;
|
---|
1147 | }
|
---|
1148 | else
|
---|
1149 | {
|
---|
1150 | _sntprintf(szINF, sizeof(szINF) / sizeof(TCHAR), _T("%ws"), argv[3]);
|
---|
1151 |
|
---|
1152 | _TCHAR szLogFile[_MAX_PATH] = { 0 };
|
---|
1153 | if (argc > 4)
|
---|
1154 | _sntprintf(szLogFile, sizeof(szLogFile) / sizeof(TCHAR), _T("%ws"), argv[4]);
|
---|
1155 | rc = VBoxInstallDriver(!_tcsicmp(argv[2], _T("install")) ? TRUE : FALSE, szINF,
|
---|
1156 | FALSE /* Not silent */, szLogFile[0] != NULL ? szLogFile : NULL);
|
---|
1157 | }
|
---|
1158 | }
|
---|
1159 | else if ( !_tcsicmp(argv[2], _T("executeinf"))
|
---|
1160 | && argc == 4)
|
---|
1161 | {
|
---|
1162 | _sntprintf(szINF, sizeof(szINF) / sizeof(TCHAR), _T("%ws"), argv[3]);
|
---|
1163 | rc = ExecuteInfFile(_T("DefaultInstall"), 132, szINF);
|
---|
1164 | }
|
---|
1165 | }
|
---|
1166 | else if ( !_tcsicmp(argv[1], _T("netprovider"))
|
---|
1167 | && argc >= 3)
|
---|
1168 | {
|
---|
1169 | _TCHAR szProvider[_MAX_PATH] = { 0 }; /* The network provider name for the registry. */
|
---|
1170 | if ( !_tcsicmp(argv[2], _T("add"))
|
---|
1171 | && argc >= 4)
|
---|
1172 | {
|
---|
1173 | int iOrder = 0;
|
---|
1174 | if (argc > 4)
|
---|
1175 | iOrder = _ttoi(argv[4]);
|
---|
1176 | _sntprintf(szProvider, sizeof(szProvider) / sizeof(TCHAR), _T("%ws"), argv[3]);
|
---|
1177 | rc = AddNetworkProvider(szProvider, iOrder);
|
---|
1178 | }
|
---|
1179 | else if ( !_tcsicmp(argv[2], _T("remove"))
|
---|
1180 | && argc >= 4)
|
---|
1181 | {
|
---|
1182 | _sntprintf(szProvider, sizeof(szProvider) / sizeof(TCHAR), _T("%ws"), argv[3]);
|
---|
1183 | rc = RemoveNetworkProvider(szProvider);
|
---|
1184 | }
|
---|
1185 | }
|
---|
1186 | else if ( !_tcsicmp(argv[1], _T("service"))
|
---|
1187 | && argc >= 3)
|
---|
1188 | {
|
---|
1189 | if ( !_tcsicmp(argv[2], _T("create"))
|
---|
1190 | && argc >= 8)
|
---|
1191 | {
|
---|
1192 | rc = CreateService(argv[3],
|
---|
1193 | argv[4],
|
---|
1194 | _ttoi(argv[5]),
|
---|
1195 | _ttoi(argv[6]),
|
---|
1196 | argv[7],
|
---|
1197 | (argc > 8) ? argv[8] : NULL,
|
---|
1198 | (argc > 9) ? argv[9] : NULL,
|
---|
1199 | (argc > 10) ? argv[10] : NULL,
|
---|
1200 | (argc > 11) ? argv[11] : NULL);
|
---|
1201 | }
|
---|
1202 | else if ( !_tcsicmp(argv[2], _T("delete"))
|
---|
1203 | && argc == 4)
|
---|
1204 | {
|
---|
1205 | rc = DelService(argv[3]);
|
---|
1206 | }
|
---|
1207 | }
|
---|
1208 | else if ( !_tcsicmp(argv[1], _T("registry"))
|
---|
1209 | && argc >= 3)
|
---|
1210 | {
|
---|
1211 | /** @todo add a handleRegistry(argc, argv) method to keep things cleaner */
|
---|
1212 | if ( !_tcsicmp(argv[2], _T("addmultisz"))
|
---|
1213 | && argc == 7)
|
---|
1214 | {
|
---|
1215 | rc = RegistryAddStringToMultiSZ(argv[3], argv[4], argv[5], _ttoi(argv[6]));
|
---|
1216 | }
|
---|
1217 | else if ( !_tcsicmp(argv[2], _T("delmultisz"))
|
---|
1218 | && argc == 6)
|
---|
1219 | {
|
---|
1220 | rc = RegistryRemoveStringFromMultiSZ(argv[3], argv[4], argv[5]);
|
---|
1221 | }
|
---|
1222 | else if ( !_tcsicmp(argv[2], _T("write"))
|
---|
1223 | && argc >= 8)
|
---|
1224 | {
|
---|
1225 | HKEY hRootKey = HKEY_LOCAL_MACHINE; /** @todo needs to be expanded (argv[3]) */
|
---|
1226 | DWORD dwValSize;
|
---|
1227 | BYTE *pbVal = NULL;
|
---|
1228 | DWORD dwVal;
|
---|
1229 |
|
---|
1230 | if (argc > 8)
|
---|
1231 | {
|
---|
1232 | if (!_tcsicmp(argv[8], _T("dword")))
|
---|
1233 | {
|
---|
1234 | dwVal = _ttol(argv[7]);
|
---|
1235 | pbVal = (BYTE*)&dwVal;
|
---|
1236 | dwValSize = sizeof(DWORD);
|
---|
1237 | }
|
---|
1238 | }
|
---|
1239 | if (pbVal == NULL) /* By default interpret value as string */
|
---|
1240 | {
|
---|
1241 | pbVal = (BYTE*)argv[7];
|
---|
1242 | dwValSize = _tcslen(argv[7]);
|
---|
1243 | }
|
---|
1244 | if (argc > 9)
|
---|
1245 | dwValSize = _ttol(argv[9]); /* Get the size in bytes of the value we want to write */
|
---|
1246 | rc = RegistryWrite(hRootKey,
|
---|
1247 | argv[4], /* Sub key */
|
---|
1248 | argv[5], /* Value name */
|
---|
1249 | REG_BINARY, /** @todo needs to be expanded (argv[6]) */
|
---|
1250 | pbVal, /* The value itself */
|
---|
1251 | dwValSize); /* Size of the value */
|
---|
1252 | }
|
---|
1253 | #if 0
|
---|
1254 | else if (!_tcsicmp(argv[2], _T("read")))
|
---|
1255 | {
|
---|
1256 | }
|
---|
1257 | else if (!_tcsicmp(argv[2], _T("del")))
|
---|
1258 | {
|
---|
1259 | }
|
---|
1260 | #endif
|
---|
1261 | }
|
---|
1262 | else if (!_tcsicmp(argv[1], _T("--version")))
|
---|
1263 | {
|
---|
1264 | _tprintf(_T("%d.%d.%d.%d\n"), VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV);
|
---|
1265 | rc = EXIT_OK;
|
---|
1266 | }
|
---|
1267 | else if ( !_tcsicmp(argv[1], _T("--help"))
|
---|
1268 | || !_tcsicmp(argv[1], _T("/help"))
|
---|
1269 | || !_tcsicmp(argv[1], _T("/h"))
|
---|
1270 | || !_tcsicmp(argv[1], _T("/?")))
|
---|
1271 | {
|
---|
1272 | PrintHelp();
|
---|
1273 | rc = EXIT_OK;
|
---|
1274 | }
|
---|
1275 | }
|
---|
1276 |
|
---|
1277 | if (rc == EXIT_USAGE)
|
---|
1278 | _tprintf(_T("No or wrong parameters given! Please consult the help (\"--help\" or \"/?\") for more information.\n"));
|
---|
1279 |
|
---|
1280 | return rc;
|
---|
1281 | }
|
---|
1282 |
|
---|