Author: gedmurphy
Date: Sat Jan 2 13:10:14 2010
New Revision: 44881
URL:
http://svn.reactos.org/svn/reactos?rev=44881&view=rev
Log:
[SERVMAN]
Quick fix for bug 5076, this should stop if from crashing.
Stopping services is disabled at the moment
Modified:
trunk/reactos/base/applications/mscutils/servman/dependencies_tv2.c
trunk/reactos/base/applications/mscutils/servman/precomp.h
trunk/reactos/base/applications/mscutils/servman/propsheet_depends.c
trunk/reactos/base/applications/mscutils/servman/stop.c
Modified: trunk/reactos/base/applications/mscutils/servman/dependencies_tv2.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/dependencies_tv2.c [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/mscutils/servman/dependencies_tv2.c [iso-8859-1] Sat
Jan 2 13:10:14 2010
@@ -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 @@
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,
Modified: trunk/reactos/base/applications/mscutils/servman/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mscutils/servman/precomp.h [iso-8859-1] Sat Jan 2
13:10:14 2010
@@ -22,6 +22,10 @@
#define LVSTATUS 2
#define LVSTARTUP 3
#define LVLOGONAS 4
+
+#define IMAGE_UNKNOWN 0
+#define IMAGE_SERVICE 1
+#define IMAGE_DRIVER 2
typedef struct _MAIN_WND_INFO
{
@@ -130,6 +134,7 @@
/* 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);
Modified: trunk/reactos/base/applications/mscutils/servman/propsheet_depends.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/propsheet_depends.c [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/mscutils/servman/propsheet_depends.c [iso-8859-1] Sat
Jan 2 13:10:14 2010
@@ -34,19 +34,19 @@
{
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;
}
Modified: trunk/reactos/base/applications/mscutils/servman/stop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/stop.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mscutils/servman/stop.c [iso-8859-1] Sat Jan 2
13:10:14 2010
@@ -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 @@
{
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 @@
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 @@
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;