Changeset 108456 in vbox
- Timestamp:
- Mar 5, 2025 4:45:41 PM (2 months ago)
- svn:sync-xref-src-repo-rev:
- 167830
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp ¶
r108455 r108456 2699 2699 UINT __stdcall UninstallVBoxDrv(MSIHANDLE hModule) 2700 2700 { 2701 /* 2702 * Try open the service. 2703 */ 2704 SC_HANDLE hSMgr = OpenSCManager(NULL, NULL, SERVICE_CHANGE_CONFIG | SERVICE_STOP | SERVICE_QUERY_STATUS); 2705 if (hSMgr) 2706 { 2707 SC_HANDLE hService = OpenServiceW(hSMgr, L"VBoxDrv", DELETE | SERVICE_STOP | SERVICE_QUERY_STATUS); 2708 if (hService) 2709 { 2710 /* 2711 * Try stop it before we delete it. 2712 */ 2713 SERVICE_STATUS Status = { 0, 0, 0, 0, 0, 0, 0 }; 2714 QueryServiceStatus(hService, &Status); 2715 if (Status.dwCurrentState == SERVICE_STOPPED) 2716 logStringF(hModule, "VBoxDrv: The service old service was already stopped"); 2717 else 2718 { 2719 logStringF(hModule, "VBoxDrv: Stopping the service (state %u)", Status.dwCurrentState); 2720 if (ControlService(hService, SERVICE_CONTROL_STOP, &Status)) 2721 { 2722 /* waiting for it to stop: */ 2723 int iWait = 100; 2724 while (Status.dwCurrentState == SERVICE_STOP_PENDING && iWait-- > 0) 2725 { 2726 Sleep(100); 2727 QueryServiceStatus(hService, &Status); 2728 } 2729 2730 if (Status.dwCurrentState == SERVICE_STOPPED) 2731 logStringF(hModule, "VBoxDrv: Stopped service"); 2732 else 2733 logStringF(hModule, "VBoxDrv: Failed to stop the service, status: %u", Status.dwCurrentState); 2734 } 2735 else 2736 { 2737 DWORD const dwErr = GetLastError(); 2738 if ( Status.dwCurrentState == SERVICE_STOP_PENDING 2739 && dwErr == ERROR_SERVICE_CANNOT_ACCEPT_CTRL) 2740 logStringF(hModule, "VBoxDrv: Failed to stop the service: stop pending, not accepting control messages"); 2741 else 2742 logStringF(hModule, "VBoxDrv: Failed to stop the service: dwErr=%u status=%u", dwErr, Status.dwCurrentState); 2743 } 2744 } 2745 2746 /* 2747 * Delete the service, or at least mark it for deletion. 2748 */ 2749 if (DeleteService(hService)) 2750 logStringF(hModule, "VBoxDrv: Successfully delete service"); 2751 else 2752 logStringF(hModule, "VBoxDrv: Failed to delete the service: %u", GetLastError()); 2753 2754 CloseServiceHandle(hService); 2755 } 2756 else 2757 { 2758 DWORD const dwErr = GetLastError(); 2759 if (dwErr == ERROR_SERVICE_DOES_NOT_EXIST) 2760 logStringF(hModule, "VBoxDrv: Nothing to do, the old service does not exist"); 2761 else 2762 logStringF(hModule, "VBoxDrv: Failed to open the service: %u", dwErr); 2763 } 2764 2765 CloseServiceHandle(hSMgr); 2766 } 2767 else 2768 logStringF(hModule, "VBoxDrv: Failed to open service manager (%u).", GetLastError()); 2701 VBOXWINDRVINST hWinDrvInst; 2702 int rc = VBoxWinDrvInstCreateEx(&hWinDrvInst, 1 /* uVerbostiy */, &vboxWinDrvInstLogCallback, &hModule /* pvUser */); 2703 if (RT_SUCCESS(rc)) 2704 { 2705 /* 2706 * Try stop it before we delete it. 2707 */ 2708 /* ignore rc */ VBoxWinDrvInstControlServiceEx(hWinDrvInst, "VBoxDrv", 2709 VBOXWINDRVSVCFN_STOP, VBOXWINDRVSVCFN_F_WAIT, RT_MS_10SEC); 2710 2711 /* 2712 * Delete the service, or at least mark it for deletion. 2713 */ 2714 /* ignore rc */ VBoxWinDrvInstControlService(hWinDrvInst, "VBoxDrv", VBOXWINDRVSVCFN_DELETE); 2715 2716 VBoxWinDrvInstDestroy(hWinDrvInst); 2717 } 2769 2718 2770 2719 return ERROR_SUCCESS; 2771 2720 } 2721
Note:
See TracChangeset
for help on using the changeset viewer.