[SERVMAN]

Quick fix for bug 5076, this should stop if from crashing.
Stopping services is disabled at the moment

svn path=/trunk/; revision=44881
This commit is contained in:
Ged Murphy 2010-01-02 12:10:14 +00:00
parent 2c793a902d
commit 53281cd601
4 changed files with 40 additions and 55 deletions

View file

@ -10,8 +10,8 @@
#include "precomp.h"
static BOOL
HasDependantServices(LPWSTR lpServiceName)
BOOL
TV2_HasDependantServices(LPWSTR lpServiceName)
{
HANDLE hSCManager;
HANDLE hService;
@ -136,7 +136,7 @@ TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
for (i = 0; i < count; i++)
{
/* Does this item need a +/- box? */
bHasChildren = HasDependantServices(lpServiceStatus[i].lpServiceName);
bHasChildren = TV2_HasDependantServices(lpServiceStatus[i].lpServiceName);
/* Add it */
AddItemToTreeView(pDlgInfo->hDependsTreeView2,

View file

@ -23,6 +23,10 @@
#define LVSTARTUP 3
#define LVLOGONAS 4
#define IMAGE_UNKNOWN 0
#define IMAGE_SERVICE 1
#define IMAGE_DRIVER 2
typedef struct _MAIN_WND_INFO
{
HWND hMainWnd;
@ -130,6 +134,7 @@ VOID TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, HTREEITEM hParent, LPTS
/* tv2_dependencies */
BOOL TV2_Initialize(PSERVICEPROPSHEET pDlgInfo, LPTSTR lpServiceName);
VOID TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, HTREEITEM hParent, LPTSTR lpServiceName);
BOOL TV2_HasDependantServices(LPWSTR lpServiceName);
LONG APIENTRY OpenPropSheet(PMAIN_WND_INFO Info);

View file

@ -34,19 +34,19 @@ AddItemToTreeView(HWND hTreeView,
{
case SERVICE_WIN32_OWN_PROCESS:
case SERVICE_WIN32_SHARE_PROCESS:
tvi.iImage = 1;
tvi.iSelectedImage = 1;
tvi.iImage = IMAGE_SERVICE;
tvi.iSelectedImage = IMAGE_SERVICE;
break;
case SERVICE_KERNEL_DRIVER:
case SERVICE_FILE_SYSTEM_DRIVER:
tvi.iImage = 2;
tvi.iSelectedImage = 2;
tvi.iImage = IMAGE_DRIVER;
tvi.iSelectedImage = IMAGE_DRIVER;
break;
default:
tvi.iImage = 0;
tvi.iSelectedImage = 0;
tvi.iImage = IMAGE_UNKNOWN;
tvi.iSelectedImage = IMAGE_UNKNOWN;
break;
}

View file

@ -11,16 +11,16 @@
static BOOL
StopService(PSTOP_INFO pStopInfo,
SC_HANDLE hService)
StopService(PMAIN_WND_INFO pInfo,
LPWSTR lpServiceName)
{
SERVICE_STATUS_PROCESS ServiceStatus;
DWORD dwBytesNeeded;
DWORD dwStartTime;
DWORD dwTimeout;
HWND hProgDlg;
//SERVICE_STATUS_PROCESS ServiceStatus;
//DWORD dwBytesNeeded;
//DWORD dwStartTime;
// DWORD dwTimeout;
//HWND hProgDlg;
BOOL bRet = FALSE;
/*
dwStartTime = GetTickCount();
dwTimeout = 30000; // 30 secs
@ -47,7 +47,7 @@ StopService(PSTOP_INFO pStopInfo,
{
if (GetTickCount() - dwStartTime > dwTimeout)
{
/* We exceeded our max wait time, give up */
We exceeded our max wait time, give up
break;
}
}
@ -63,13 +63,13 @@ StopService(PSTOP_INFO pStopInfo,
Sleep(500);
DestroyWindow(hProgDlg);
}
*/
return bRet;
}
static BOOL
StopDependentServices(PSTOP_INFO pStopInfo,
SC_HANDLE hService)
StopDependantServices(PMAIN_WND_INFO pInfo,
LPWSTR lpServiceName)
{
//LPENUM_SERVICE_STATUS lpDependencies;
//SC_HANDLE hDepService;
@ -118,53 +118,33 @@ StopDependentServices(PSTOP_INFO pStopInfo,
BOOL
DoStop(PMAIN_WND_INFO pInfo)
{
STOP_INFO stopInfo;
//SC_HANDLE hSCManager;
SC_HANDLE hService = NULL;
BOOL bRet = FALSE;
if (pInfo)
{
//stopInfo.pInfo = pInfo;
if (TRUE /*HasDependentServices(pInfo->pCurrentService->lpServiceName)*/)
/* Does this service have anything which depends on it? */
if (TV2_HasDependantServices(pInfo->pCurrentService->lpServiceName))
{
INT ret = DialogBoxParam(hInstance,
MAKEINTRESOURCE(IDD_DLG_DEPEND_STOP),
pInfo->hMainWnd,
StopDependsDialogProc,
(LPARAM)&stopInfo);
if (ret == IDOK)
/* It does, list them and ask the user if they want to stop them as well */
if (DialogBoxParam(hInstance,
MAKEINTRESOURCE(IDD_DLG_DEPEND_STOP),
pInfo->hMainWnd,
StopDependsDialogProc,
(LPARAM)&pInfo) == IDOK)
{
if (StopDependentServices(&stopInfo, hService))
/* Stop all the dependany services */
if (StopDependantServices(pInfo, pInfo->pCurrentService->lpServiceName))
{
bRet = StopService(&stopInfo, hService);
/* Finally stop the requested service */
bRet = StopService(pInfo, pInfo->pCurrentService->lpServiceName);
}
}
}
else
{
bRet = StopService(&stopInfo, hService);
/* No dependants, just stop the service */
bRet = StopService(pInfo, pInfo->pCurrentService->lpServiceName);
}
/*
hSCManager = OpenSCManager(NULL,
NULL,
SC_MANAGER_ALL_ACCESS);
if (hSCManager)
{
hService = OpenService(hSCManager,
pInfo->pCurrentService->lpServiceName,
SERVICE_STOP | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS);
if (hService)
{
stopInfo.hSCManager = hSCManager;
stopInfo.hMainService = hService;
CloseServiceHandle(hService);
}
CloseServiceHandle(hSCManager);
}*/
}
return bRet;