ReactOS 0.4.15-dev-7924-g5949c20
stop_dependencies.c File Reference
#include "precomp.h"
Include dependency graph for stop_dependencies.c:

Go to the source code of this file.

Classes

struct  _STOP_DATA
 

Typedefs

typedef struct _STOP_DATA STOP_DATA
 
typedef struct _STOP_DATAPSTOP_DATA
 

Functions

static LPWSTR AddServiceToList (LPWSTR *lpServiceList, LPWSTR lpServiceToAdd)
 
static BOOL BuildListOfServicesToStop (LPWSTR *lpServiceList, LPWSTR lpServiceName)
 
LPWSTR GetListOfServicesToStop (LPWSTR lpServiceName)
 
static VOID AddServiceNamesToStop (HWND hServiceListBox, LPWSTR lpServiceList)
 
static BOOL InitDialog (HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK StopDependsDialogProc (HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 
BOOL CreateStopDependsDialog (HWND hParent, LPWSTR ServiceName, LPWSTR DisplayName, LPWSTR ServiceList)
 

Typedef Documentation

◆ PSTOP_DATA

◆ STOP_DATA

Function Documentation

◆ AddServiceNamesToStop()

static VOID AddServiceNamesToStop ( HWND  hServiceListBox,
LPWSTR  lpServiceList 
)
static

Definition at line 138 of file stop_dependencies.c.

140{
141 LPQUERY_SERVICE_CONFIG lpServiceConfig;
142 LPWSTR lpStr;
143
144 lpStr = lpServiceList;
145
146 /* Loop through all the services in the list */
147 for (;;)
148 {
149 /* Break when we hit the double null */
150 if (*lpStr == L'\0' && *(lpStr + 1) == L'\0')
151 break;
152
153 /* If this isn't our first time in the loop we'll
154 have been left on a null char */
155 if (*lpStr == L'\0')
156 lpStr++;
157
158 /* Get the service's display name */
159 lpServiceConfig = GetServiceConfig(lpStr);
160 if (lpServiceConfig)
161 {
162 /* Add the service to the listbox */
163 SendMessageW(hServiceListBox,
165 0,
166 (LPARAM)lpServiceConfig->lpDisplayName);
167
168 HeapFree(GetProcessHeap(), 0, lpServiceConfig);
169 }
170
171 /* Move onto the next string */
172 while (*lpStr != L'\0')
173 lpStr++;
174 }
175}
LPQUERY_SERVICE_CONFIG GetServiceConfig(LPWSTR lpServiceName)
Definition: query.c:29
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
#define L(x)
Definition: ntvdm.h:50
LONG_PTR LPARAM
Definition: windef.h:208
#define LB_ADDSTRING
Definition: winuser.h:2031
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by InitDialog().

◆ AddServiceToList()

static LPWSTR AddServiceToList ( LPWSTR lpServiceList,
LPWSTR  lpServiceToAdd 
)
static

Definition at line 21 of file stop_dependencies.c.

23{
24 LPWSTR lpNewList = NULL;
25 LPWSTR ptr;
26 DWORD dwToAddSize;
27 DWORD dwCurSize;
28
29 dwToAddSize = wcslen(lpServiceToAdd) + 1;
30
31 /* Is this is the first in the list? */
32 if (!*lpServiceList)
33 {
34 /* Add another char for double null */
35 dwToAddSize++;
36
37 lpNewList = HeapAlloc(GetProcessHeap(),
38 0,
39 dwToAddSize * sizeof(WCHAR));
40 if (lpNewList)
41 {
42 /* Copy the service name */
43 StringCchCopy(lpNewList,
44 dwToAddSize,
45 lpServiceToAdd);
46
47 /* Add the double null char */
48 lpNewList[dwToAddSize - 1] = L'\0';
49 }
50 }
51 else
52 {
53 ptr = *lpServiceList;
54 dwCurSize = 0;
55
56 /* Get the list size */
57 for (;;)
58 {
59 /* Break when we hit the double null */
60 if (*ptr == L'\0' && *(ptr + 1) == L'\0')
61 break;
62
63 ptr++;
64 dwCurSize++;
65 }
66 dwCurSize++;
67
68 /* Add another char for double null */
69 dwCurSize++;
70
71 /* Extend the list size */
72 lpNewList = HeapReAlloc(GetProcessHeap(),
73 0,
74 *lpServiceList,
75 (dwCurSize + dwToAddSize) * sizeof(WCHAR));
76 if (lpNewList)
77 {
78 /* Copy the service name */
79 StringCchCopy(&lpNewList[dwCurSize - 1],
80 dwToAddSize,
81 lpServiceToAdd);
82
83 /* Add the double null char */
84 lpNewList[dwCurSize + dwToAddSize - 1] = L'\0';
85 }
86 }
87
88 return lpNewList;
89}
#define NULL
Definition: types.h:112
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static PVOID ptr
Definition: dispmode.c:27
#define StringCchCopy
Definition: strsafe.h:139
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by BuildListOfServicesToStop().

◆ BuildListOfServicesToStop()

static BOOL BuildListOfServicesToStop ( LPWSTR lpServiceList,
LPWSTR  lpServiceName 
)
static

Definition at line 92 of file stop_dependencies.c.

94{
95 LPENUM_SERVICE_STATUS lpServiceStatus;
96 DWORD dwCount, i;
97 BOOL bRet = FALSE;
98
99 /* Get a list of service dependents */
100 lpServiceStatus = TV2_GetDependants(lpServiceName, &dwCount);
101 if (lpServiceStatus)
102 {
103 for (i = 0; i < dwCount; i++)
104 {
105 /* Does this service need stopping? */
106 if (lpServiceStatus[i].ServiceStatus.dwCurrentState != SERVICE_STOPPED &&
107 lpServiceStatus[i].ServiceStatus.dwCurrentState != SERVICE_STOP_PENDING)
108 {
109 /* Add the service to the list */
110 *lpServiceList = AddServiceToList(lpServiceList, lpServiceStatus[i].lpServiceName);
111
112 /* We've got one */
113 bRet = TRUE;
114 }
115 }
116
118 0,
119 lpServiceStatus);
120 }
121
122 return bRet;
123}
static SERVICE_STATUS ServiceStatus
Definition: browser.c:22
LPENUM_SERVICE_STATUS TV2_GetDependants(LPWSTR lpServiceName, LPDWORD lpdwCount)
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static LPWSTR AddServiceToList(LPWSTR *lpServiceList, LPWSTR lpServiceToAdd)
DWORD dwCurrentState
Definition: winsvc.h:100
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23

Referenced by GetListOfServicesToStop().

◆ CreateStopDependsDialog()

BOOL CreateStopDependsDialog ( HWND  hParent,
LPWSTR  ServiceName,
LPWSTR  DisplayName,
LPWSTR  ServiceList 
)

Definition at line 293 of file stop_dependencies.c.

297{
298 STOP_DATA StopData;
300
301 StopData.ServiceName = ServiceName;
302 StopData.DisplayName = DisplayName;
303 StopData.ServiceList = ServiceList;
304
307 hParent,
309 (LPARAM)&StopData);
310 if (Result == IDOK)
311 return TRUE;
312
313 return FALSE;
314}
#define IDD_DLG_DEPEND_STOP
Definition: resource.h:213
static WCHAR ServiceName[]
Definition: browser.c:19
HINSTANCE hInstance
Definition: charmap.c:19
INT_PTR CALLBACK StopDependsDialogProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
LPWSTR ServiceName
LPWSTR DisplayName
LPWSTR ServiceList
int32_t INT_PTR
Definition: typedefs.h:64
#define IDOK
Definition: winuser.h:830
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by RunActionWithProgress().

◆ GetListOfServicesToStop()

LPWSTR GetListOfServicesToStop ( LPWSTR  lpServiceName)

Definition at line 126 of file stop_dependencies.c.

127{
128 LPWSTR lpServiceList = NULL;
129
130 /* Call recursive function to get our list */
131 if (BuildListOfServicesToStop(&lpServiceList, lpServiceName))
132 return lpServiceList;
133 else
134 return NULL;
135}
static BOOL BuildListOfServicesToStop(LPWSTR *lpServiceList, LPWSTR lpServiceName)

Referenced by RunActionWithProgress().

◆ InitDialog()

static BOOL InitDialog ( HWND  hDlg,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 178 of file stop_dependencies.c.

182{
183 PSTOP_DATA StopData;
184 HWND hServiceListBox;
185 LPWSTR lpPartialStr, lpStr;
186 DWORD fullLen;
187 HICON hIcon = NULL;
188 BOOL bRet = FALSE;
189
190 StopData = (PSTOP_DATA)lParam;
191
192
193 /* Load the icon for the window */
199 0);
200 if (hIcon)
201 {
202 /* Set it */
203 SendMessageW(hDlg,
204 WM_SETICON,
206 (LPARAM)hIcon);
208 }
209
210 /* Load the stop depends note */
211 if (AllocAndLoadString(&lpPartialStr,
212 hInstance,
214 {
215 /* Get the length required */
216 fullLen = wcslen(lpPartialStr) + wcslen(StopData->DisplayName) + 1;
217
218 lpStr = HeapAlloc(ProcessHeap,
219 0,
220 fullLen * sizeof(WCHAR));
221 if (lpStr)
222 {
223 /* Add the service name to the depends note */
224 _snwprintf(lpStr,
225 fullLen,
226 lpPartialStr,
227 StopData->DisplayName);
228
229 /* Add the string to the dialog */
233 0,
234 (LPARAM)lpStr);
235
237 0,
238 lpStr);
239
240 bRet = TRUE;
241 }
242
243 LocalFree(lpPartialStr);
244 }
245
246 /* Display the list of services which need stopping */
247 hServiceListBox = GetDlgItem(hDlg, IDC_STOP_DEPENDS_LB);
248 if (hServiceListBox)
249 {
250 AddServiceNamesToStop(hServiceListBox,
251 (LPWSTR)StopData->ServiceList);
252 }
253
254 return bRet;
255}
INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:59
HANDLE ProcessHeap
Definition: servman.c:15
#define IDS_STOP_DEPENDS
Definition: resource.h:215
#define IDC_STOP_DEPENDS
Definition: resource.h:214
#define IDI_SM_ICON
Definition: resource.h:64
#define IDC_STOP_DEPENDS_LB
Definition: resource.h:216
LPARAM lParam
Definition: combotst.c:139
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
static VOID AddServiceNamesToStop(HWND hServiceListBox, LPWSTR lpServiceList)
struct _STOP_DATA * PSTOP_DATA
#define ICON_SMALL
Definition: tnclass.cpp:48
#define IMAGE_ICON
Definition: winuser.h:212
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2203
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETTEXT
Definition: winuser.h:1617
#define SM_CXSMICON
Definition: winuser.h:1012
#define MAKEINTRESOURCE
Definition: winuser.h:591
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2053

Referenced by StopDependsDialogProc().

◆ StopDependsDialogProc()

INT_PTR CALLBACK StopDependsDialogProc ( HWND  hDlg,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 258 of file stop_dependencies.c.

262{
263
264 switch (Message)
265 {
266 case WM_INITDIALOG:
267 {
268 return InitDialog(hDlg,
269 Message,
270 wParam,
271 lParam);
272 }
273
274 case WM_COMMAND:
275 {
276 switch (LOWORD(wParam))
277 {
278 case IDOK:
279 case IDCANCEL:
280 {
281 EndDialog(hDlg,
282 LOWORD(wParam));
283 return TRUE;
284 }
285 }
286 }
287 }
288
289 return FALSE;
290}
WPARAM wParam
Definition: combotst.c:138
static const WCHAR Message[]
Definition: register.c:74
#define LOWORD(l)
Definition: pedump.c:82
static BOOL InitDialog(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by CreateStopDependsDialog().