- Timestamp:
- Sep 25, 2008 12:10:33 PM (16 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxService
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxService.cpp
r11982 r12723 137 137 Log(("VBoxService: Starting services ...\n")); 138 138 139 Assert(pEnv); 139 140 pEnv->hStopEvent = CreateEvent (NULL, TRUE, FALSE, NULL); 140 141 … … 211 212 { 212 213 /* Signal to all threads. */ 214 Assert(pEnv); 215 Assert(pTable); 213 216 if (bAlert && (NULL != pEnv->hStopEvent)) 214 217 { … … 278 281 279 282 /* Start service threads. */ 280 /*gServiceEnv.hInstance = gInstance; 281 gServiceEnv.hDriver = gVBoxDriver;*/ 282 283 int rc = vboxStartServices (&gServiceEnv, vboxServiceTable); 283 int rc = vboxStartServices(&gServiceEnv, vboxServiceTable); 284 284 285 285 /** @todo Add error handling. */ … … 293 293 LPVOID lpContext) 294 294 { 295 DWORD rc = NO_ERROR; 296 295 297 switch (dwControl) 296 298 { 297 299 298 300 case SERVICE_CONTROL_INTERROGATE: 299 SetStatus 301 SetStatus(gvboxServiceStatusCode); 300 302 break; 301 303 … … 303 305 case SERVICE_CONTROL_SHUTDOWN: 304 306 { 305 SetStatus (SERVICE_STOP_PENDING); 306 307 vboxStopServices (TRUE, &gServiceEnv, vboxServiceTable); 308 309 /*CloseHandle(gvboxDriver);*/ 307 SetStatus(SERVICE_STOP_PENDING); 308 309 vboxStopServices(TRUE, &gServiceEnv, vboxServiceTable); 310 311 /* Don't close VBox driver here - the service might be 312 * started again. */ 310 313 CloseHandle(gStopSem); 311 314 312 SetStatus 315 SetStatus(SERVICE_STOPPED); 313 316 } 314 317 break; … … 330 333 331 334 default: 332 /** @todo r=bird: Andy, you should probably return ERROR_CALL_NOT_IMPLEMENTED here. 333 * Whoever omitted the DWORD return here and WINAPI bit here has been very sloppy :-| */ 335 336 Log(("VBoxService: Service control function not implemented: %ld\n", dwControl)); 337 rc = ERROR_CALL_NOT_IMPLEMENTED; 334 338 break; 335 339 } 336 return NO_ERROR;340 return rc; 337 341 } 338 342 … … 355 359 break; 356 360 default: 357 writeLog("VBoxService: Could not register service control handle! Error: % d\n", dwErr);361 writeLog("VBoxService: Could not register service control handle! Error: %ld\n", dwErr); 358 362 break; 359 363 } … … 363 367 vboxServiceStart(); 364 368 365 while (1) {366 Sleep ( 100); /** @todo */369 while (1) { 370 Sleep (100); /** @todo */ 367 371 } 368 372 } … … 387 391 VBOXSERVICE_NAME, VBOXSERVICE_FRIENDLY_NAME, 388 392 SERVICE_ALL_ACCESS, 389 SERVICE_WIN32_OWN_PROCESS |SERVICE_INTERACTIVE_PROCESS,393 SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, 390 394 SERVICE_DEMAND_START,SERVICE_ERROR_NORMAL, 391 395 imagePath, NULL, NULL, NULL, NULL, NULL); … … 393 397 if (NULL == hService) { 394 398 writeLog("VBoxService: Could not create service! Error: %d\n", GetLastError()); 395 CloseServiceHandle 399 CloseServiceHandle(hSCManager); 396 400 return 1; 397 401 } … … 401 405 } 402 406 403 CloseServiceHandle 404 CloseServiceHandle 407 CloseServiceHandle(hService); 408 CloseServiceHandle(hSCManager); 405 409 406 410 return 0; … … 410 414 { 411 415 SC_HANDLE hService, hSCManager; 412 hSCManager = OpenSCManager 416 hSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); 413 417 414 418 writeLog("VBoxService: Uninstalling service ...\n"); … … 435 439 else 436 440 { 437 HKEY hKey ;438 if (RegOpenKeyEx 439 RegDeleteKey 440 RegCloseKey 441 HKEY hKey = NULL; 442 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\System"), 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS) { 443 RegDeleteKey(hKey, VBOXSERVICE_NAME); 444 RegCloseKey(hKey); 441 445 } 442 446 … … 444 448 } 445 449 446 CloseServiceHandle 447 CloseServiceHandle 450 CloseServiceHandle(hService); 451 CloseServiceHandle(hSCManager); 448 452 449 453 return 0; … … 453 457 { 454 458 char szBuffer[1024] = { 0 }; 459 460 Assert(a_pszText); 455 461 456 462 va_list va; … … 466 472 void printHelp (_TCHAR* a_pszName) 467 473 { 474 Assert(a_pszName); 468 475 _tprintf(_T("VBoxService - Guest Additions Helper Service for Windows XP/2K/Vista\n")); 469 476 _tprintf(_T("Version: %d.%d.%d.%d\n\n"), VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV); … … 505 512 static SERVICE_TABLE_ENTRY const s_serviceTable[]= 506 513 { 507 { VBOXSERVICE_NAME, ServiceMain},514 {VBOXSERVICE_NAME, ServiceMain}, 508 515 {NULL,NULL} 509 516 }; … … 527 534 528 535 else { 529 _tprintf 530 _tprintf 536 _tprintf(_T("Invalid command line argument: %ws\n"), argv[1]); 537 _tprintf(_T("Type %s /h to display help.\n"), argv[0]); 531 538 } 532 539 } -
trunk/src/VBox/Additions/WINNT/VBoxService/VBoxService.h
r11982 r12723 24 24 25 25 #include <iprt/alloc.h> 26 #include <iprt/assert.h> 26 27 #include <iprt/initterm.h> 27 28 #include <iprt/string.h>
Note:
See TracChangeset
for help on using the changeset viewer.