- Timestamp:
- Jan 30, 2025 10:25:17 AM (3 months ago)
- svn:sync-xref-src-repo-rev:
- 167250
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/installation/VBoxWinDrvInst.cpp
r107985 r107987 123 123 typedef BOOL(WINAPI* PFNSETUPUNINSTALLOEMINFW) (PCWSTR InfFileName, DWORD Flags, PVOID Reserved); 124 124 typedef BOOL(WINAPI *PFNSETUPSETNONINTERACTIVEMODE) (BOOL NonInteractiveFlag); 125 /* advapi32.dll: */ 126 typedef BOOL(WINAPI *PFNQUERYSERVICESTATUSEX) (SC_HANDLE, SC_STATUS_TYPE, LPBYTE, DWORD, LPDWORD); 125 127 126 128 /** Function pointer for a general try INF section callback. */ … … 146 148 DECL_HIDDEN_DATA(PFNSETUPUNINSTALLOEMINFW) g_pfnSetupUninstallOEMInfW = NULL; /* For XP+. */ 147 149 DECL_HIDDEN_DATA(PFNSETUPSETNONINTERACTIVEMODE) g_pfnSetupSetNonInteractiveMode = NULL; /* For W2K+. */ 150 /* advapi32.dll: */ 151 DECL_HIDDEN_DATA(PFNQUERYSERVICESTATUSEX) g_pfnQueryServiceStatusEx = NULL; /* For W2K+. */ 148 152 149 153 /** … … 223 227 }; 224 228 229 /* newdev.dll: */ 230 static VBOXWINDRVINSTIMPORTSYMBOL s_aAdvApi32Imports[] = 231 { 232 /* Only for Windows 2000 and up. */ 233 { "QueryServiceStatusEx", (void **)&g_pfnQueryServiceStatusEx } 234 }; 235 225 236 226 237 /********************************************************************************************************************************* … … 525 536 /* rc ignored, keep going */ vboxWinDrvInstResolveMod(pCtx, "newdev.dll", 526 537 s_aNewDevImports, RT_ELEMENTS(s_aNewDevImports)); 527 538 /* rc ignored, keep going */ vboxWinDrvInstResolveMod(pCtx, "advapi32.dll", 539 s_aAdvApi32Imports, RT_ELEMENTS(s_aAdvApi32Imports)); 528 540 return VINF_SUCCESS; 529 541 } … … 2387 2399 rc = VERR_NO_CHANGE; /* No change yet. */ 2388 2400 2389 vboxWinDrvInstLogInfo(pCtx, "Waiting for status change of service '%s' ...", pszService); 2390 for (;;) 2391 { 2392 DWORD dwBytes; 2393 if (!QueryServiceStatusEx(hSvc, 2394 SC_STATUS_PROCESS_INFO, 2395 (LPBYTE)&enmSvcSts, 2396 sizeof(SERVICE_STATUS_PROCESS), 2397 &dwBytes)) 2401 if (!g_pfnQueryServiceStatusEx) 2402 { 2403 vboxWinDrvInstLogWarn(pCtx, "Waiting for status change of service '%s' not supported on this OS, skipping", 2404 pszService); 2405 rc = VINF_SUCCESS; 2406 } 2407 else 2408 { 2409 vboxWinDrvInstLogInfo(pCtx, "Waiting for status change of service '%s' ...", pszService); 2410 for (;;) 2398 2411 { 2399 rc = vboxWinDrvInstLogLastError(pCtx, "Failed to query service status"); 2400 break; 2401 } 2402 2403 if ((RTTimeMilliTS() - msStartTS) % RT_MS_1SEC == 0) /* Don't spam. */ 2404 vboxWinDrvInstLogVerbose(pCtx, 3, "Service '%s' status is %#x: %u", 2405 pszService, enmSvcSts.dwCurrentState, (RTTimeMilliTS() - msStartTS) % 100 == 0); 2406 2407 switch (enmSvcSts.dwCurrentState) 2408 { 2409 case SERVICE_STOP_PENDING: 2410 case SERVICE_START_PENDING: 2411 RTThreadSleep(100); /* Wait a bit before retrying. */ 2412 break; 2413 2414 case SERVICE_RUNNING: 2412 DWORD dwBytes; 2413 if (!g_pfnQueryServiceStatusEx(hSvc, 2414 SC_STATUS_PROCESS_INFO, 2415 (LPBYTE)&enmSvcSts, 2416 sizeof(SERVICE_STATUS_PROCESS), 2417 &dwBytes)) 2415 2418 { 2416 if (enmFn == VBOXWINDRVSVCFN_START) 2417 rc = VINF_SUCCESS; 2419 rc = vboxWinDrvInstLogLastError(pCtx, "Failed to query service status"); 2418 2420 break; 2419 2421 } 2420 2422 2421 case SERVICE_STOPPED: 2423 if ((RTTimeMilliTS() - msStartTS) % RT_MS_1SEC == 0) /* Don't spam. */ 2424 vboxWinDrvInstLogVerbose(pCtx, 3, "Service '%s' status is %#x: %u", 2425 pszService, enmSvcSts.dwCurrentState, (RTTimeMilliTS() - msStartTS) % 100 == 0); 2426 2427 switch (enmSvcSts.dwCurrentState) 2422 2428 { 2423 if (enmFn == VBOXWINDRVSVCFN_START) 2429 case SERVICE_STOP_PENDING: 2430 case SERVICE_START_PENDING: 2431 RTThreadSleep(100); /* Wait a bit before retrying. */ 2432 break; 2433 2434 case SERVICE_RUNNING: 2424 2435 { 2425 vboxWinDrvInstLogError(pCtx, "Service '%s' stopped unexpectedly", pszService); 2436 if (enmFn == VBOXWINDRVSVCFN_START) 2437 rc = VINF_SUCCESS; 2438 break; 2439 } 2440 2441 case SERVICE_STOPPED: 2442 { 2443 if (enmFn == VBOXWINDRVSVCFN_START) 2444 { 2445 vboxWinDrvInstLogError(pCtx, "Service '%s' stopped unexpectedly", pszService); 2446 rc = VERR_INVALID_STATE; 2447 } 2448 else 2449 rc = VINF_SUCCESS; 2450 break; 2451 } 2452 2453 default: 2454 { 2455 vboxWinDrvInstLogError(pCtx, "Service '%s' reported an unexpected state (%#x)", 2456 pszService, enmSvcSts.dwCurrentState); 2426 2457 rc = VERR_INVALID_STATE; 2427 2458 } 2428 else 2429 rc = VINF_SUCCESS; 2459 } 2460 2461 if ( RT_FAILURE(rc) 2462 && rc != VERR_NO_CHANGE) 2463 break; 2464 2465 if (RT_SUCCESS(rc)) 2466 break; 2467 2468 if (RTTimeMilliTS() - msStartTS >= msTimeout) 2469 { 2470 vboxWinDrvInstLogError(pCtx, "Waiting for service '%s' timed out (%ums)", pszService, msTimeout); 2471 rc = VERR_TIMEOUT; 2430 2472 break; 2431 2473 } 2432 2433 default:2434 {2435 vboxWinDrvInstLogError(pCtx, "Service '%s' reported an unexpected state (%#x)",2436 pszService, enmSvcSts.dwCurrentState);2437 rc = VERR_INVALID_STATE;2438 }2439 }2440 2441 if ( RT_FAILURE(rc)2442 && rc != VERR_NO_CHANGE)2443 break;2444 2445 if (RT_SUCCESS(rc))2446 break;2447 2448 if (RTTimeMilliTS() - msStartTS >= msTimeout)2449 {2450 vboxWinDrvInstLogError(pCtx, "Waiting for service '%s' timed out (%ums)", pszService, msTimeout);2451 rc = VERR_TIMEOUT;2452 break;2453 2474 } 2454 2475 }
Note:
See TracChangeset
for help on using the changeset viewer.