1 | /* $Id: VBoxService-win.cpp 36331 2011-03-21 19:17:12Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxService - Guest Additions Service Skeleton, Windows Specific Parts.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2010 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 | #include <iprt/assert.h>
|
---|
23 | #include <iprt/err.h>
|
---|
24 | #include <VBox/VBoxGuestLib.h>
|
---|
25 | #include "VBoxServiceInternal.h"
|
---|
26 |
|
---|
27 | #include <Windows.h>
|
---|
28 | #include <process.h>
|
---|
29 | #include <aclapi.h>
|
---|
30 |
|
---|
31 |
|
---|
32 | /*******************************************************************************
|
---|
33 | * Internal Functions *
|
---|
34 | *******************************************************************************/
|
---|
35 | static void WINAPI vboxServiceWinMain(DWORD argc, LPTSTR *argv);
|
---|
36 |
|
---|
37 |
|
---|
38 | /*******************************************************************************
|
---|
39 | * Global Variables *
|
---|
40 | *******************************************************************************/
|
---|
41 | static DWORD g_dwWinServiceLastStatus = 0;
|
---|
42 | SERVICE_STATUS_HANDLE g_hWinServiceStatus = NULL;
|
---|
43 | /** The semaphore for the dummy Windows service. */
|
---|
44 | static RTSEMEVENT g_WindowsEvent = NIL_RTSEMEVENT;
|
---|
45 |
|
---|
46 | static SERVICE_TABLE_ENTRY const g_aServiceTable[] =
|
---|
47 | {
|
---|
48 | { VBOXSERVICE_NAME, vboxServiceWinMain },
|
---|
49 | { NULL, NULL}
|
---|
50 | };
|
---|
51 |
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * @todo Format code style.
|
---|
55 | * @todo Add full unicode support.
|
---|
56 | * @todo Add event log capabilities / check return values.
|
---|
57 | */
|
---|
58 | static DWORD vboxServiceWinAddAceToObjectsSecurityDescriptor(LPTSTR pszObjName,
|
---|
59 | SE_OBJECT_TYPE ObjectType,
|
---|
60 | LPTSTR pszTrustee,
|
---|
61 | TRUSTEE_FORM TrusteeForm,
|
---|
62 | DWORD dwAccessRights,
|
---|
63 | ACCESS_MODE AccessMode,
|
---|
64 | DWORD dwInheritance)
|
---|
65 | {
|
---|
66 | DWORD dwRes = 0;
|
---|
67 | PACL pOldDACL = NULL, pNewDACL = NULL;
|
---|
68 | PSECURITY_DESCRIPTOR pSD = NULL;
|
---|
69 | EXPLICIT_ACCESS ea;
|
---|
70 |
|
---|
71 | if (NULL == pszObjName)
|
---|
72 | return ERROR_INVALID_PARAMETER;
|
---|
73 |
|
---|
74 | /* Get a pointer to the existing DACL. */
|
---|
75 | dwRes = GetNamedSecurityInfo(pszObjName, ObjectType,
|
---|
76 | DACL_SECURITY_INFORMATION,
|
---|
77 | NULL, NULL, &pOldDACL, NULL, &pSD);
|
---|
78 | if (ERROR_SUCCESS != dwRes)
|
---|
79 | {
|
---|
80 | if (dwRes == ERROR_FILE_NOT_FOUND)
|
---|
81 | VBoxServiceError("AddAceToObjectsSecurityDescriptor: Object not found/installed: %s\n", pszObjName);
|
---|
82 | else
|
---|
83 | VBoxServiceError("AddAceToObjectsSecurityDescriptor: GetNamedSecurityInfo: Error %u\n", dwRes);
|
---|
84 | goto l_Cleanup;
|
---|
85 | }
|
---|
86 |
|
---|
87 | /* Initialize an EXPLICIT_ACCESS structure for the new ACE. */
|
---|
88 | ZeroMemory(&ea, sizeof(EXPLICIT_ACCESS));
|
---|
89 | ea.grfAccessPermissions = dwAccessRights;
|
---|
90 | ea.grfAccessMode = AccessMode;
|
---|
91 | ea.grfInheritance= dwInheritance;
|
---|
92 | ea.Trustee.TrusteeForm = TrusteeForm;
|
---|
93 | ea.Trustee.ptstrName = pszTrustee;
|
---|
94 |
|
---|
95 | /* Create a new ACL that merges the new ACE into the existing DACL. */
|
---|
96 | dwRes = SetEntriesInAcl(1, &ea, pOldDACL, &pNewDACL);
|
---|
97 | if (ERROR_SUCCESS != dwRes)
|
---|
98 | {
|
---|
99 | VBoxServiceError("AddAceToObjectsSecurityDescriptor: SetEntriesInAcl: Error %u\n", dwRes);
|
---|
100 | goto l_Cleanup;
|
---|
101 | }
|
---|
102 |
|
---|
103 | /* Attach the new ACL as the object's DACL. */
|
---|
104 | dwRes = SetNamedSecurityInfo(pszObjName, ObjectType,
|
---|
105 | DACL_SECURITY_INFORMATION,
|
---|
106 | NULL, NULL, pNewDACL, NULL);
|
---|
107 | if (ERROR_SUCCESS != dwRes)
|
---|
108 | {
|
---|
109 | VBoxServiceError("AddAceToObjectsSecurityDescriptor: SetNamedSecurityInfo: Error %u\n", dwRes);
|
---|
110 | goto l_Cleanup;
|
---|
111 | }
|
---|
112 |
|
---|
113 | /** @todo get rid of that spaghetti jump ... */
|
---|
114 | l_Cleanup:
|
---|
115 |
|
---|
116 | if(pSD != NULL)
|
---|
117 | LocalFree((HLOCAL) pSD);
|
---|
118 | if(pNewDACL != NULL)
|
---|
119 | LocalFree((HLOCAL) pNewDACL);
|
---|
120 |
|
---|
121 | return dwRes;
|
---|
122 | }
|
---|
123 |
|
---|
124 |
|
---|
125 | /** Reports our current status to the SCM. */
|
---|
126 | static BOOL vboxServiceWinSetStatus(DWORD dwStatus, DWORD dwCheckPoint)
|
---|
127 | {
|
---|
128 | if (g_hWinServiceStatus == NULL) /* Program could be in testing mode, so no service environment available. */
|
---|
129 | return FALSE;
|
---|
130 |
|
---|
131 | VBoxServiceVerbose(2, "Setting service status to: %ld\n", dwStatus);
|
---|
132 | g_dwWinServiceLastStatus = dwStatus;
|
---|
133 |
|
---|
134 | SERVICE_STATUS ss;
|
---|
135 | ss.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
---|
136 | ss.dwCurrentState = dwStatus;
|
---|
137 | ss.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
|
---|
138 | ss.dwWin32ExitCode = NO_ERROR;
|
---|
139 | ss.dwServiceSpecificExitCode = 0; /* Not used */
|
---|
140 | ss.dwCheckPoint = dwCheckPoint;
|
---|
141 | ss.dwWaitHint = 3000;
|
---|
142 |
|
---|
143 | return SetServiceStatus(g_hWinServiceStatus, &ss);
|
---|
144 | }
|
---|
145 |
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * Reports SERVICE_STOP_PENDING to SCM.
|
---|
149 | *
|
---|
150 | * @param uCheckPoint Some number.
|
---|
151 | */
|
---|
152 | void VBoxServiceWinSetStopPendingStatus(uint32_t uCheckPoint)
|
---|
153 | {
|
---|
154 | vboxServiceWinSetStatus(SERVICE_STOP_PENDING, uCheckPoint);
|
---|
155 | }
|
---|
156 |
|
---|
157 |
|
---|
158 | static RTEXITCODE vboxServiceWinSetDesc(SC_HANDLE hService)
|
---|
159 | {
|
---|
160 | #ifndef TARGET_NT4
|
---|
161 | /* On W2K+ there's ChangeServiceConfig2() which lets us set some fields
|
---|
162 | like a longer service description. */
|
---|
163 | /** @todo On Vista+ SERVICE_DESCRIPTION also supports localized strings! */
|
---|
164 | SERVICE_DESCRIPTION desc;
|
---|
165 | desc.lpDescription = VBOXSERVICE_DESCRIPTION;
|
---|
166 | if (!ChangeServiceConfig2(hService,
|
---|
167 | SERVICE_CONFIG_DESCRIPTION, /* Service info level */
|
---|
168 | &desc))
|
---|
169 | {
|
---|
170 | VBoxServiceError("Cannot set the service description! Error: %ld\n", GetLastError());
|
---|
171 | return RTEXITCODE_FAILURE;
|
---|
172 | }
|
---|
173 | #endif
|
---|
174 | return RTEXITCODE_SUCCESS;
|
---|
175 | }
|
---|
176 |
|
---|
177 |
|
---|
178 | /**
|
---|
179 | * Installs the service.
|
---|
180 | */
|
---|
181 | RTEXITCODE VBoxServiceWinInstall(void)
|
---|
182 | {
|
---|
183 | VBoxServiceVerbose(1, "Installing service ...\n");
|
---|
184 |
|
---|
185 | TCHAR imagePath[MAX_PATH] = { 0 };
|
---|
186 | GetModuleFileName(NULL, imagePath, sizeof(imagePath));
|
---|
187 |
|
---|
188 | SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
---|
189 | if (hSCManager == NULL)
|
---|
190 | {
|
---|
191 | VBoxServiceError("Could not open SCM! Error: %ld\n", GetLastError());
|
---|
192 | return RTEXITCODE_FAILURE;
|
---|
193 | }
|
---|
194 |
|
---|
195 | RTEXITCODE rc = RTEXITCODE_SUCCESS;
|
---|
196 | SC_HANDLE hService = CreateService(hSCManager,
|
---|
197 | VBOXSERVICE_NAME, VBOXSERVICE_FRIENDLY_NAME,
|
---|
198 | SERVICE_ALL_ACCESS,
|
---|
199 | SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
|
---|
200 | SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
|
---|
201 | imagePath, NULL, NULL, NULL, NULL, NULL);
|
---|
202 | if (hService != NULL)
|
---|
203 | VBoxServiceVerbose(0, "Service successfully installed!\n");
|
---|
204 | else
|
---|
205 | {
|
---|
206 | DWORD dwErr = GetLastError();
|
---|
207 | switch (dwErr)
|
---|
208 | {
|
---|
209 | case ERROR_SERVICE_EXISTS:
|
---|
210 | VBoxServiceVerbose(1, "Service already exists, just updating the service config.\n");
|
---|
211 | hService = OpenService(hSCManager, VBOXSERVICE_NAME, SERVICE_ALL_ACCESS);
|
---|
212 | if (hService)
|
---|
213 | {
|
---|
214 | if (ChangeServiceConfig (hService,
|
---|
215 | SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
|
---|
216 | SERVICE_DEMAND_START,
|
---|
217 | SERVICE_ERROR_NORMAL,
|
---|
218 | imagePath,
|
---|
219 | NULL,
|
---|
220 | NULL,
|
---|
221 | NULL,
|
---|
222 | NULL,
|
---|
223 | NULL,
|
---|
224 | VBOXSERVICE_FRIENDLY_NAME))
|
---|
225 | VBoxServiceVerbose(1, "The service config has been successfully updated.\n");
|
---|
226 | else
|
---|
227 | rc = VBoxServiceError("Could not change service config! Error: %ld\n", GetLastError());
|
---|
228 | }
|
---|
229 | else
|
---|
230 | rc = VBoxServiceError("Could not open service! Error: %ld\n", GetLastError());
|
---|
231 | break;
|
---|
232 |
|
---|
233 | default:
|
---|
234 | rc = VBoxServiceError("Could not create service! Error: %ld\n", dwErr);
|
---|
235 | break;
|
---|
236 | }
|
---|
237 | }
|
---|
238 |
|
---|
239 | if (rc == RTEXITCODE_SUCCESS)
|
---|
240 | rc = vboxServiceWinSetDesc(hService);
|
---|
241 |
|
---|
242 | CloseServiceHandle(hService);
|
---|
243 | CloseServiceHandle(hSCManager);
|
---|
244 | return rc;
|
---|
245 | }
|
---|
246 |
|
---|
247 | /**
|
---|
248 | * Uninstalls the service.
|
---|
249 | */
|
---|
250 | RTEXITCODE VBoxServiceWinUninstall(void)
|
---|
251 | {
|
---|
252 | VBoxServiceVerbose(1, "Uninstalling service ...\n");
|
---|
253 |
|
---|
254 | SC_HANDLE hSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
|
---|
255 | if (hSCManager == NULL)
|
---|
256 | {
|
---|
257 | VBoxServiceError("Could not open SCM! Error: %d\n", GetLastError());
|
---|
258 | return RTEXITCODE_FAILURE;
|
---|
259 | }
|
---|
260 |
|
---|
261 | RTEXITCODE rcExit;
|
---|
262 | SC_HANDLE hService = OpenService(hSCManager, VBOXSERVICE_NAME, SERVICE_ALL_ACCESS );
|
---|
263 | if (hService != NULL)
|
---|
264 | {
|
---|
265 | if (DeleteService(hService))
|
---|
266 | {
|
---|
267 | /*
|
---|
268 | * ???
|
---|
269 | */
|
---|
270 | HKEY hKey = NULL;
|
---|
271 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
---|
272 | "SYSTEM\\CurrentControlSet\\Services\\EventLog\\System",
|
---|
273 | 0,
|
---|
274 | KEY_ALL_ACCESS,
|
---|
275 | &hKey)
|
---|
276 | == ERROR_SUCCESS)
|
---|
277 | {
|
---|
278 | RegDeleteKey(hKey, VBOXSERVICE_NAME);
|
---|
279 | RegCloseKey(hKey);
|
---|
280 | }
|
---|
281 |
|
---|
282 | VBoxServiceVerbose(0, "Service successfully uninstalled!\n");
|
---|
283 | rcExit = RTEXITCODE_SUCCESS;
|
---|
284 | }
|
---|
285 | else
|
---|
286 | rcExit = VBoxServiceError("Could not remove service! Error: %d\n", GetLastError());
|
---|
287 | CloseServiceHandle(hService);
|
---|
288 | }
|
---|
289 | else
|
---|
290 | rcExit = VBoxServiceError("Could not open service! Error: %d\n", GetLastError());
|
---|
291 | CloseServiceHandle(hSCManager);
|
---|
292 |
|
---|
293 | return rcExit;
|
---|
294 | }
|
---|
295 |
|
---|
296 |
|
---|
297 | static int vboxServiceWinStart(void)
|
---|
298 | {
|
---|
299 | int rc = VINF_SUCCESS;
|
---|
300 |
|
---|
301 | #ifndef TARGET_NT4
|
---|
302 | /* Create a well-known SID for the "Builtin Users" group. */
|
---|
303 | PSID pBuiltinUsersSID = NULL;
|
---|
304 | SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_LOCAL_SID_AUTHORITY;
|
---|
305 |
|
---|
306 | if (!AllocateAndInitializeSid(&SIDAuthWorld, 1,
|
---|
307 | SECURITY_LOCAL_RID,
|
---|
308 | 0, 0, 0, 0, 0, 0, 0,
|
---|
309 | &pBuiltinUsersSID))
|
---|
310 | {
|
---|
311 | /**@todo r=bird: rc = RTErrConvertFromWin32(GetLastError()); ?*/
|
---|
312 | VBoxServiceError("AllocateAndInitializeSid: Error %u\n", GetLastError());
|
---|
313 | }
|
---|
314 | else
|
---|
315 | {
|
---|
316 | DWORD dwRes = vboxServiceWinAddAceToObjectsSecurityDescriptor(TEXT("\\\\.\\VBoxMiniRdrDN"),
|
---|
317 | SE_FILE_OBJECT,
|
---|
318 | (LPTSTR)pBuiltinUsersSID,
|
---|
319 | TRUSTEE_IS_SID,
|
---|
320 | FILE_GENERIC_READ | FILE_GENERIC_WRITE,
|
---|
321 | SET_ACCESS,
|
---|
322 | NO_INHERITANCE);
|
---|
323 | if (dwRes != ERROR_SUCCESS)
|
---|
324 | {
|
---|
325 | if (dwRes == ERROR_FILE_NOT_FOUND)
|
---|
326 | {
|
---|
327 | /* If we don't find our "VBoxMiniRdrDN" (for Shared Folders) object above,
|
---|
328 | don't report an error; it just might be not installed. Otherwise this
|
---|
329 | would cause the SCM to hang on starting up the service. */
|
---|
330 | rc = VINF_SUCCESS;
|
---|
331 | }
|
---|
332 | else
|
---|
333 | rc = RTErrConvertFromWin32(dwRes);
|
---|
334 | }
|
---|
335 | }
|
---|
336 | #endif
|
---|
337 |
|
---|
338 | if (RT_SUCCESS(rc))
|
---|
339 | {
|
---|
340 | rc = VBoxServiceStartServices();
|
---|
341 | if (RT_SUCCESS(rc))
|
---|
342 | {
|
---|
343 | vboxServiceWinSetStatus(SERVICE_RUNNING, 0);
|
---|
344 | VBoxServiceMainWait();
|
---|
345 | }
|
---|
346 | else
|
---|
347 | {
|
---|
348 | vboxServiceWinSetStatus(SERVICE_STOPPED, 0);
|
---|
349 | #if 0 /** @todo r=bird: Enable this if SERVICE_CONTROL_STOP isn't triggered automatically */
|
---|
350 | VBoxServiceStopServices();
|
---|
351 | #endif
|
---|
352 | }
|
---|
353 | }
|
---|
354 | /**@todo r=bird: else vboxServiceWinSetStatus(SERVICE_STOPPED, 0); ? */
|
---|
355 |
|
---|
356 | if (RT_FAILURE(rc))
|
---|
357 | VBoxServiceError("Service failed to start with rc=%Rrc!\n", rc);
|
---|
358 |
|
---|
359 | return rc;
|
---|
360 | }
|
---|
361 |
|
---|
362 |
|
---|
363 | /**
|
---|
364 | * Call StartServiceCtrlDispatcher.
|
---|
365 | *
|
---|
366 | * The main() thread invokes this when not started in foreground mode. It
|
---|
367 | * won't return till the service is being shutdown (unless start up fails).
|
---|
368 | *
|
---|
369 | * @returns RTEXITCODE_SUCCESS on normal return after service shutdown.
|
---|
370 | * Something else on failure, error will have been reported.
|
---|
371 | */
|
---|
372 | RTEXITCODE VBoxServiceWinEnterCtrlDispatcher(void)
|
---|
373 | {
|
---|
374 | if (!StartServiceCtrlDispatcher(&g_aServiceTable[0]))
|
---|
375 | return VBoxServiceError("StartServiceCtrlDispatcher: %u. Please start %s with option -f (foreground)!\n",
|
---|
376 | GetLastError(), g_pszProgName);
|
---|
377 | return RTEXITCODE_SUCCESS;
|
---|
378 | }
|
---|
379 |
|
---|
380 |
|
---|
381 | #ifdef TARGET_NT4
|
---|
382 | static VOID WINAPI vboxServiceWinCtrlHandler(DWORD dwControl)
|
---|
383 | #else
|
---|
384 | static DWORD WINAPI vboxServiceWinCtrlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
|
---|
385 | #endif
|
---|
386 | {
|
---|
387 | DWORD rcRet = NO_ERROR;
|
---|
388 |
|
---|
389 | #ifdef TARGET_NT4
|
---|
390 | VBoxServiceVerbose(2, "Control handler: Control=%#x\n", dwControl);
|
---|
391 | #else
|
---|
392 | VBoxServiceVerbose(2, "Control handler: Control=%#x EventType=%#x\n", dwControl, dwEventType);
|
---|
393 | #endif
|
---|
394 |
|
---|
395 | switch (dwControl)
|
---|
396 | {
|
---|
397 | case SERVICE_CONTROL_INTERROGATE:
|
---|
398 | vboxServiceWinSetStatus(g_dwWinServiceLastStatus, 0);
|
---|
399 | break;
|
---|
400 |
|
---|
401 | case SERVICE_CONTROL_STOP:
|
---|
402 | case SERVICE_CONTROL_SHUTDOWN:
|
---|
403 | {
|
---|
404 | vboxServiceWinSetStatus(SERVICE_STOP_PENDING, 0);
|
---|
405 |
|
---|
406 | int rc2 = VBoxServiceStopServices();
|
---|
407 | if (RT_FAILURE(rc2))
|
---|
408 | rcRet = ERROR_GEN_FAILURE;
|
---|
409 |
|
---|
410 | vboxServiceWinSetStatus(SERVICE_STOPPED, 0);
|
---|
411 | break;
|
---|
412 | }
|
---|
413 |
|
---|
414 | case SERVICE_CONTROL_SESSIONCHANGE: /* Only Win XP and up. */
|
---|
415 | #ifndef TARGET_NT4
|
---|
416 | # if 0
|
---|
417 | switch (dwEventType)
|
---|
418 | {
|
---|
419 | case WTS_SESSION_LOGON:
|
---|
420 | VBoxServiceVerbose(2, "A user has logged on to the session.\n");
|
---|
421 | break;
|
---|
422 |
|
---|
423 | case WTS_SESSION_LOGOFF:
|
---|
424 | VBoxServiceVerbose(2, "A user has logged off from the session.\n");
|
---|
425 | break;
|
---|
426 | default:
|
---|
427 | break;
|
---|
428 | }
|
---|
429 | # endif
|
---|
430 | #endif /* !TARGET_NT4 */
|
---|
431 | break;
|
---|
432 |
|
---|
433 | default:
|
---|
434 | VBoxServiceVerbose(1, "Service control function not implemented: %#x\n", dwControl);
|
---|
435 | rcRet = ERROR_CALL_NOT_IMPLEMENTED;
|
---|
436 | break;
|
---|
437 | }
|
---|
438 |
|
---|
439 | #ifndef TARGET_NT4
|
---|
440 | return rcRet;
|
---|
441 | #endif
|
---|
442 | }
|
---|
443 |
|
---|
444 |
|
---|
445 | static void WINAPI vboxServiceWinMain(DWORD argc, LPTSTR *argv)
|
---|
446 | {
|
---|
447 | VBoxServiceVerbose(2, "Registering service control handler ...\n");
|
---|
448 | #ifdef TARGET_NT4
|
---|
449 | g_hWinServiceStatus = RegisterServiceCtrlHandler(VBOXSERVICE_NAME, vboxServiceWinCtrlHandler);
|
---|
450 | #else
|
---|
451 | g_hWinServiceStatus = RegisterServiceCtrlHandlerEx(VBOXSERVICE_NAME, vboxServiceWinCtrlHandler, NULL);
|
---|
452 | #endif
|
---|
453 | if (g_hWinServiceStatus != NULL)
|
---|
454 | {
|
---|
455 | VBoxServiceVerbose(2, "Service control handler registered.\n");
|
---|
456 | vboxServiceWinStart();
|
---|
457 | }
|
---|
458 | else
|
---|
459 | {
|
---|
460 | DWORD dwErr = GetLastError();
|
---|
461 | switch (dwErr)
|
---|
462 | {
|
---|
463 | case ERROR_INVALID_NAME:
|
---|
464 | VBoxServiceError("Invalid service name!\n");
|
---|
465 | break;
|
---|
466 | case ERROR_SERVICE_DOES_NOT_EXIST:
|
---|
467 | VBoxServiceError("Service does not exist!\n");
|
---|
468 | break;
|
---|
469 | default:
|
---|
470 | VBoxServiceError("Could not register service control handle! Error: %ld\n", dwErr);
|
---|
471 | break;
|
---|
472 | }
|
---|
473 | }
|
---|
474 | }
|
---|
475 |
|
---|