ReactOS  0.4.12-dev-685-gf36cbf7
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,
164  LB_ADDSTRING,
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 }
#define LB_ADDSTRING
Definition: winuser.h:1992
LONG_PTR LPARAM
Definition: windef.h:208
#define GetProcessHeap()
Definition: compat.h:395
static const WCHAR L[]
Definition: oid.c:1250
LPQUERY_SERVICE_CONFIG GetServiceConfig(LPWSTR lpServiceName)
Definition: query.c:29
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394

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 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define StringCchCopy
Definition: strsafe.h:139
#define HeapReAlloc
Definition: compat.h:393
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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 }
#define TRUE
Definition: types.h:120
DWORD dwCurrentState
Definition: winsvc.h:100
LPENUM_SERVICE_STATUS TV2_GetDependants(LPWSTR lpServiceName, LPDWORD lpdwCount)
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
#define SERVICE_STOPPED
Definition: winsvc.h:21
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPWSTR AddServiceToList(LPWSTR *lpServiceList, LPWSTR lpServiceToAdd)
SERVICE_STATUS ServiceStatus
Definition: dhcpcsvc.c:18
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define HeapFree(x, y, z)
Definition: compat.h:394

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;
299  INT_PTR Result;
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 }
LPWSTR DisplayName
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define IDD_DLG_DEPEND_STOP
Definition: resource.h:215
int32_t INT_PTR
Definition: typedefs.h:62
HINSTANCE hInstance
Definition: charmap.c:20
LONG_PTR LPARAM
Definition: windef.h:208
_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:426
LPTSTR ServiceName
Definition: ServiceMain.c:15
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
INT_PTR CALLBACK StopDependsDialogProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
LPWSTR ServiceName
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LPWSTR ServiceList

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 }
smooth NULL
Definition: ftsmooth.c:416
static BOOL BuildListOfServicesToStop(LPWSTR *lpServiceList, LPWSTR lpServiceName)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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 */
196  IMAGE_ICON,
199  0);
200  if (hIcon)
201  {
202  /* Set it */
203  SendMessageW(hDlg,
204  WM_SETICON,
205  ICON_SMALL,
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 */
230  SendDlgItemMessageW(hDlg,
232  WM_SETTEXT,
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 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
LPWSTR DisplayName
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define IMAGE_ICON
Definition: winuser.h:212
#define IDC_STOP_DEPENDS_LB
Definition: resource.h:218
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
__wchar_t WCHAR
Definition: xmlstorage.h:180
static INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:60
#define ICON_SMALL
Definition: tnclass.cpp:48
HINSTANCE hInstance
Definition: charmap.c:20
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
LONG_PTR LPARAM
Definition: windef.h:208
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
smooth NULL
Definition: ftsmooth.c:416
#define WM_SETTEXT
Definition: winuser.h:1599
unsigned int BOOL
Definition: ntddk_ex.h:94
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define IDS_STOP_DEPENDS
Definition: resource.h:217
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SM_CXSMICON
Definition: winuser.h:1002
static VOID AddServiceNamesToStop(HWND hServiceListBox, LPWSTR lpServiceList)
HANDLE ProcessHeap
Definition: servman.c:15
struct _STOP_DATA * PSTOP_DATA
HICON hIcon
Definition: msconfig.c:44
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_STOP_DEPENDS
Definition: resource.h:216
#define IDI_SM_ICON
Definition: resource.h:66
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPWSTR ServiceList
LPARAM lParam
Definition: combotst.c:139
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394

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 }
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
CHAR Message[80]
Definition: alive.c:5
#define WM_COMMAND
Definition: winuser.h:1716
static BOOL InitDialog(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by CreateStopDependsDialog().