ReactOS  0.4.12-dev-722-g4ba3c90
srvpage.cpp File Reference
#include "precomp.h"
#include "utils.h"
#include "regutils.h"
#include "stringutils.h"
#include "listview.h"
#include "uxthemesupp.h"
#include <winsvc.h>
#include <atlcoll.h>
#include <atlstr.h>
Include dependency graph for srvpage.cpp:

Go to the source code of this file.

Classes

struct  ServiceItem
 
struct  RegistryDisabledServiceItemParams
 

Macros

#define OP(a, b)   ((a) == (b) ? (a) : 2)
 

Functions

DWORD GetServicesActivation (VOID)
 
BOOL SetServicesActivation (DWORD dwState)
 
static BOOL RegisterNoMsgAnymore (VOID)
 
BOOL HideEssentialServiceWarning (VOID)
 
 QUERY_REGISTRY_VALUES_ROUTINE (GetRegistryValuedDisabledServicesQueryRoutine)
 
 QUERY_REGISTRY_KEYS_ROUTINE (GetRegistryKeyedDisabledServicesQueryRoutine)
 
static void AddService (SC_HANDLE hSCManager, LPENUM_SERVICE_STATUS_PROCESS Service, BOOL bHideOSVendorServices)
 
static void ClearServicesList (void)
 
static void GetServices (BOOL bHideOSVendorServices=FALSE)
 
INT_PTR CALLBACK RequiredServicesDisablingDialogWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
static BOOL ValidateItem (int index, BOOL bNewState, BOOL bDisplayErrors)
 
static void UpdateBtnStates (HWND hDlg)
 
INT_PTR CALLBACK ServicesPageWndProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

static HWND hServicesPage = NULL
 
static HWND hServicesListCtrl = NULL
 
static int iSortedColumn = 0
 
static BOOL bMaskProprietarySvcs = FALSE
 
static CAtlList< CAtlStringWuserModificationsList
 

Macro Definition Documentation

◆ OP

#define OP (   a,
  b 
)    ((a) == (b) ? (a) : 2)

Function Documentation

◆ AddService()

static void AddService ( SC_HANDLE  hSCManager,
LPENUM_SERVICE_STATUS_PROCESS  Service,
BOOL  bHideOSVendorServices 
)
static

Definition at line 195 of file srvpage.cpp.

196 {
197  //
198  // Retrieve a handle to the service.
199  //
200  SC_HANDLE hService = OpenServiceW(hSCManager, Service->lpServiceName, SERVICE_QUERY_CONFIG);
201  if (hService == NULL)
202  return;
203 
204  DWORD dwBytesNeeded = 0;
205  QueryServiceConfigW(hService, NULL, 0, &dwBytesNeeded);
206  // if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
207 
208  LPQUERY_SERVICE_CONFIG lpServiceConfig = (LPQUERY_SERVICE_CONFIG)MemAlloc(0, dwBytesNeeded);
209  if (!lpServiceConfig)
210  {
211  CloseServiceHandle(hService);
212  return;
213  }
214  QueryServiceConfigW(hService, lpServiceConfig, dwBytesNeeded, &dwBytesNeeded);
215 
216  //
217  // Get the service's vendor...
218  //
219  LPWSTR lpszVendor = NULL;
220  {
221  // Isolate only the executable path, without any arguments.
222  // TODO: Correct at the level of CmdLineToArgv the potential bug when lpszFilename == NULL.
223 #if 0 // Disabled until CmdLineToArgv is included
224  unsigned int argc = 0;
225  LPWSTR* argv = NULL;
226  CmdLineToArgv(lpServiceConfig->lpBinaryPathName, &argc, &argv, L" \t");
227  if (argc >= 1 && argv[0])
228  lpszVendor = GetExecutableVendor(argv[0]);
229 #else
230  // Hackish solution taken from the original srvpage.c.
231  // Will be removed after CmdLineToArgv is introduced.
233  memset(&FileName, 0, sizeof(FileName));
234  if (wcscspn(lpServiceConfig->lpBinaryPathName, L"\""))
235  {
236  wcsncpy(FileName, lpServiceConfig->lpBinaryPathName, wcscspn(lpServiceConfig->lpBinaryPathName, L" ") );
237  }
238  else
239  {
240  wcscpy(FileName, lpServiceConfig->lpBinaryPathName);
241  }
242  lpszVendor = GetExecutableVendor(FileName);
243 #endif
244  if (!lpszVendor)
245  lpszVendor = LoadResourceString(hInst, IDS_UNKNOWN);
246 #if 0
247  MemFree(argv);
248 #endif
249  }
250 
251  // ...and display or not the Microsoft / ReactOS services.
252  BOOL bContinue = TRUE;
253  if (bHideOSVendorServices)
254  {
255  if (FindSubStrI(lpszVendor, bIsWindows ? IDS_MICROSOFT : IDS_REACTOS))
256  bContinue = FALSE;
257  }
258 
259  if (bContinue)
260  {
261  BOOL bIsServiceEnabled = (lpServiceConfig->dwStartType != SERVICE_DISABLED);
262  BOOL bAddServiceToList = FALSE;
263  BOOL bIsModifiedService = FALSE;
265 
266  //
267  // Try to look into the user modifications list...
268  //
269  POSITION it = userModificationsList.Find(Service->lpServiceName);
270  if (it)
271  {
272  bAddServiceToList = TRUE;
273  bIsModifiedService = TRUE;
274  }
275 
276  //
277  // ...if not found, try to find if the disabled service is in the registry.
278  //
279  if (!bAddServiceToList)
280  {
281  if (!bIsServiceEnabled)
282  {
283  QUERY_REGISTRY_KEYS_TABLE KeysQueryTable[2] = {};
284  KeysQueryTable[0].QueryRoutine = GetRegistryKeyedDisabledServicesQueryRoutine;
285  KeysQueryTable[0].EntryContext = &params;
286  RegQueryRegistryKeys(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", KeysQueryTable, Service->lpServiceName);
287 
288  bAddServiceToList = params.bIsPresent;
289 
290  if (bIsWindows && bIsPreVistaOSVersion && !bAddServiceToList)
291  {
292  QUERY_REGISTRY_VALUES_TABLE ValuesQueryTable[2] = {};
293  ValuesQueryTable[0].QueryRoutine = GetRegistryValuedDisabledServicesQueryRoutine;
294  ValuesQueryTable[0].EntryContext = &params;
295  RegQueryRegistryValues(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", ValuesQueryTable, Service->lpServiceName);
296 
297  bAddServiceToList = params.bIsPresent;
298  }
299  }
300  else
301  {
302  bAddServiceToList = TRUE;
303  }
304  }
305 
306  if (bAddServiceToList)
307  {
308  //
309  // Check if service is required by the system.
310  //
311  BOOL bIsRequired = FALSE;
312 
313  dwBytesNeeded = 0;
314  QueryServiceConfig2(hService, SERVICE_CONFIG_FAILURE_ACTIONS, NULL, 0, &dwBytesNeeded);
315  // if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
316 
317  LPSERVICE_FAILURE_ACTIONS lpServiceFailureActions = (LPSERVICE_FAILURE_ACTIONS)MemAlloc(0, dwBytesNeeded);
318  if (!lpServiceFailureActions)
319  {
320  MemFree(lpszVendor);
321  MemFree(lpServiceConfig);
322  CloseServiceHandle(hService);
323  return;
324  }
325 
326  QueryServiceConfig2(hService, SERVICE_CONFIG_FAILURE_ACTIONS, (LPBYTE)lpServiceFailureActions, dwBytesNeeded, &dwBytesNeeded);
327 
328  // In Microsoft's MSConfig, things are done just like that!! (extracted string values from msconfig.exe)
329  if ( ( wcsicmp(Service->lpServiceName, L"rpcss" ) == 0 ||
330  wcsicmp(Service->lpServiceName, L"rpclocator") == 0 ||
331  wcsicmp(Service->lpServiceName, L"dcomlaunch") == 0 ) ||
332  ( lpServiceFailureActions &&
333  (lpServiceFailureActions->cActions >= 1) &&
334  (lpServiceFailureActions->lpsaActions[0].Type == SC_ACTION_REBOOT) ) ) // We add also this test, which corresponds to real life.
335  {
336  bIsRequired = TRUE;
337  }
338  MemFree(lpServiceFailureActions);
339 
340  //
341  // Add the service into the list.
342  //
343  LVITEM item = {};
344  item.mask = LVIF_TEXT | LVIF_PARAM;
345  item.pszText = Service->lpDisplayName;
346  item.lParam = reinterpret_cast<LPARAM>(new ServiceItem(Service->lpServiceName, bIsServiceEnabled, bIsRequired));
348 
349  if (bIsRequired)
350  {
352  ListView_SetItemText(hServicesListCtrl, item.iItem, 1, lpszYes);
353  MemFree(lpszYes);
354  }
355 
356  ListView_SetItemText(hServicesListCtrl, item.iItem, 2, lpszVendor);
357 
358  LPWSTR lpszStatus = LoadResourceString(hInst, ((Service->ServiceStatusProcess.dwCurrentState == SERVICE_STOPPED) ? IDS_SERVICES_STATUS_STOPPED : IDS_SERVICES_STATUS_RUNNING));
359  ListView_SetItemText(hServicesListCtrl, item.iItem, 3, lpszStatus);
360  MemFree(lpszStatus);
361 
362  if (!bIsServiceEnabled)
363  {
364  LPWSTR lpszUnknown = LoadResourceString(hInst, IDS_UNKNOWN);
365 
366  LPWSTR lpszDisableDate = FormatDateTime(&params.time);
367  ListView_SetItemText(hServicesListCtrl, item.iItem, 4, (lpszDisableDate ? lpszDisableDate : lpszUnknown));
368  FreeDateTime(lpszDisableDate);
369 
370  MemFree(lpszUnknown);
371  }
372 
373  ListView_SetCheckState(hServicesListCtrl, item.iItem, (!bIsModifiedService ? bIsServiceEnabled : !bIsServiceEnabled));
374  }
375  }
376 
377  MemFree(lpszVendor);
378  MemFree(lpServiceConfig);
379  CloseServiceHandle(hService);
380 
381  return;
382 }
LPWSTR GetExecutableVendor(IN LPCWSTR lpszFilename)
Definition: utils.c:288
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
QUERY_SERVICE_CONFIGA * LPQUERY_SERVICE_CONFIG
Definition: winsvc.h:550
BOOL MemFree(IN PVOID lpMem)
Definition: utils.c:26
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI QueryServiceConfigW(SC_HANDLE hService, LPQUERY_SERVICE_CONFIGW lpServiceConfig, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2234
SC_ACTION_TYPE Type
Definition: winsvc.h:205
PVOID MemAlloc(IN DWORD dwFlags, IN DWORD dwBytes)
Definition: utils.c:33
LRESULT RegQueryRegistryKeys(IN HKEY hRootKey, IN LPCWSTR KeyName, IN PQUERY_REGISTRY_KEYS_TABLE QueryTable, IN PVOID Context)
Definition: regutils.c:6
_Check_return_ _CRTIMP size_t __cdecl wcscspn(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
static CAtlList< CAtlStringW > userModificationsList
Definition: srvpage.cpp:92
BOOL bIsWindows
Definition: msconfig.c:31
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2380
#define argv
Definition: mplay32.c:18
#define IDS_REACTOS
Definition: resource.h:9
#define IDS_YES
Definition: resource.h:16
#define LVIF_TEXT
Definition: commctrl.h:2281
#define SERVICE_DISABLED
Definition: cmtypes.h:977
BOOL bIsPreVistaOSVersion
Definition: msconfig.c:32
#define SERVICE_STOPPED
Definition: winsvc.h:21
unsigned char * LPBYTE
Definition: typedefs.h:52
GLenum const GLfloat * params
Definition: glext.h:5645
#define IDS_SERVICES_STATUS_STOPPED
Definition: resource.h:109
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2103
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
smooth NULL
Definition: ftsmooth.c:416
#define QueryServiceConfig2
Definition: winsvc.h:581
#define IDS_UNKNOWN
Definition: resource.h:7
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2663
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID LoadResourceString(UINT ResourceId, LPVOID Buffer, UINT ccount, LPVOID DefaultString, BOOL bUnicode)
Definition: enum.c:13
PQUERY_REGISTRY_VALUES_ROUTINE QueryRoutine
Definition: regutils.h:63
const LPCWSTR IDS_MICROSOFT
Definition: msconfig.c:36
#define MAX_PATH
Definition: compat.h:26
#define SERVICE_CONFIG_FAILURE_ACTIONS
Definition: winsvc.h:66
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT RegQueryRegistryValues(IN HKEY hRootKey, IN LPCWSTR KeyName, IN PQUERY_REGISTRY_VALUES_TABLE QueryTable, IN PVOID Context)
Definition: regutils.c:51
VOID FreeDateTime(IN LPWSTR lpszDateTime)
Definition: utils.c:84
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
SC_HANDLE hSCManager
Definition: sc.c:12
#define wcsicmp
Definition: string.h:1152
#define IDS_SERVICES_STATUS_RUNNING
Definition: resource.h:110
SC_ACTION * lpsaActions
Definition: winsvc.h:213
LPSERVICE_FAILURE_ACTIONSA LPSERVICE_FAILURE_ACTIONS
Definition: winsvc.h:557
PQUERY_REGISTRY_KEYS_ROUTINE QueryRoutine
Definition: regutils.h:29
HINSTANCE hInst
Definition: dxdiag.c:13
static ATOM item
Definition: dde.c:856
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
LPTSTR FindSubStrI(LPCTSTR str, LPCTSTR strSearch)
Definition: stringutils.c:183
#define ListView_SetCheckState(hwndLV, i, fCheck)
Definition: commctrl.h:2646
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVITEM
Definition: commctrl.h:2347
#define SERVICE_QUERY_CONFIG
Definition: winsvc.h:53
LPWSTR FormatDateTime(IN LPSYSTEMTIME pDateTime)
Definition: utils.c:41
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39
static HWND hServicesListCtrl
Definition: srvpage.cpp:26
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by GetServices().

◆ ClearServicesList()

static void ClearServicesList ( void  )
static

Definition at line 384 of file srvpage.cpp.

385 {
386  LVITEM lvitem = {};
387  lvitem.mask = LVIF_PARAM;
388  lvitem.iItem = -1; // From the beginning.
389 
390  while ((lvitem.iItem = ListView_GetNextItem(hServicesListCtrl, lvitem.iItem, LVNI_ALL)) != -1)
391  {
393 
394  delete reinterpret_cast<ServiceItem*>(lvitem.lParam);
395  lvitem.lParam = NULL;
396  }
398 
399  return;
400 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2406
smooth NULL
Definition: ftsmooth.c:416
#define LVNI_ALL
Definition: commctrl.h:2394
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2366
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVITEM
Definition: commctrl.h:2347
static HWND hServicesListCtrl
Definition: srvpage.cpp:26
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2386

Referenced by GetServices(), and ServicesPageWndProc().

◆ GetServices()

static void GetServices ( BOOL  bHideOSVendorServices = FALSE)
static

Definition at line 402 of file srvpage.cpp.

403 {
404  //
405  // First of all, clear the list.
406  //
408 
409  //
410  // Now, we can list the services.
411  //
412 
413  // Open the Service Control Manager.
415  if (hSCManager == NULL)
416  return;
417 
418  // Enumerate all the Win32 services.
419  DWORD dwBytesNeeded = 0;
420  DWORD dwNumServices = 0;
421  // DWORD dwResumeHandle = 0;
422  EnumServicesStatusExW(hSCManager, SC_ENUM_PROCESS_INFO, SERVICE_WIN32, SERVICE_STATE_ALL, NULL, 0, &dwBytesNeeded, &dwNumServices, NULL /* &dwResumeHandle */, NULL);
423  // if (GetLastError() == ERROR_MORE_DATA)
424 
426  if (!lpServices)
427  {
429  return;
430  }
431  EnumServicesStatusExW(hSCManager, SC_ENUM_PROCESS_INFO, SERVICE_WIN32, SERVICE_STATE_ALL, (LPBYTE)lpServices, dwBytesNeeded, &dwBytesNeeded, &dwNumServices, NULL /* &dwResumeHandle */, NULL);
432 
433  // Add them into the list.
434  for (DWORD i = 0 ; i < dwNumServices ; ++i)
435  {
436  AddService(hSCManager, lpServices + i, bHideOSVendorServices);
437  }
438 
439  // Cleaning.
440  MemFree(lpServices);
442 
443  return;
444 }
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16
BOOL MemFree(IN PVOID lpMem)
Definition: utils.c:26
PVOID MemAlloc(IN DWORD dwFlags, IN DWORD dwBytes)
Definition: utils.c:33
#define SERVICE_STATE_ALL
Definition: winsvc.h:52
LPENUM_SERVICE_STATUS_PROCESSA LPENUM_SERVICE_STATUS_PROCESS
Definition: winsvc.h:549
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
unsigned char * LPBYTE
Definition: typedefs.h:52
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
smooth NULL
Definition: ftsmooth.c:416
static void ClearServicesList(void)
Definition: srvpage.cpp:384
unsigned long DWORD
Definition: ntddk_ex.h:95
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2011
SC_HANDLE hSCManager
Definition: sc.c:12
#define SERVICE_WIN32
Definition: cmtypes.h:962
static void AddService(SC_HANDLE hSCManager, LPENUM_SERVICE_STATUS_PROCESS Service, BOOL bHideOSVendorServices)
Definition: srvpage.cpp:195
BOOL WINAPI EnumServicesStatusExW(SC_HANDLE hSCManager, SC_ENUM_TYPE InfoLevel, DWORD dwServiceType, DWORD dwServiceState, LPBYTE lpServices, DWORD cbBufSize, LPDWORD pcbBytesNeeded, LPDWORD lpServicesReturned, LPDWORD lpResumeHandle, LPCWSTR pszGroupName)
Definition: scm.c:1513

Referenced by ServicesPageWndProc().

◆ GetServicesActivation()

DWORD GetServicesActivation ( VOID  )

Definition at line 30 of file srvpage.cpp.

31 {
32  DWORD dwServices = 0;
33  RegGetDWORDValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\state", L"services", &dwServices);
34  return dwServices;
35 }
LONG RegGetDWORDValue(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValue OPTIONAL, OUT LPDWORD lpData OPTIONAL)
Definition: regutils.c:95
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ HideEssentialServiceWarning()

BOOL HideEssentialServiceWarning ( VOID  )

Definition at line 52 of file srvpage.cpp.

53 {
54  BOOL bRetVal = FALSE;
55  DWORD dwValue = 0;
56 
57  bRetVal = ( (RegGetDWORDValue(HKEY_CURRENT_USER /* HKEY_LOCAL_MACHINE ?? */,
58  L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig",
59  L"HideEssentialServiceWarning",
60  &dwValue) == ERROR_SUCCESS) &&
61  (dwValue == 1) );
62 
63  return bRetVal;
64 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG RegGetDWORDValue(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValue OPTIONAL, OUT LPDWORD lpData OPTIONAL)
Definition: regutils.c:95
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250

Referenced by ServicesPageWndProc().

◆ QUERY_REGISTRY_KEYS_ROUTINE()

QUERY_REGISTRY_KEYS_ROUTINE ( GetRegistryKeyedDisabledServicesQueryRoutine  )

Definition at line 126 of file srvpage.cpp.

127 {
128  UNREFERENCED_PARAMETER(hRootKey);
130 
131  if (!EntryContext)
132  return ERROR_SUCCESS;
133 
135  if (pContextParams->bIsPresent)
136  return ERROR_SUCCESS;
137 
138  DWORD dwType = 0, dwBufSize = 0;
139 
140  // Be careful, the order of the operations in the comparison is very important.
141  if ( (wcsicmp((LPCWSTR)Context, SubKeyName) == 0) &&
142  (RegQueryValueEx(hOpenedSubKey, /* ValueName == */ SubKeyName, NULL, &dwType, NULL, &dwBufSize) == ERROR_SUCCESS) &&
143  (dwType == REG_DWORD) && (dwBufSize == sizeof(DWORD)) )
144  {
145 #if 1 // DisableDate
146  SYSTEMTIME disableDate = {};
147  DWORD dwRegData = 0;
148 
149  dwRegData = 0;
150  RegGetDWORDValue(hOpenedSubKey, NULL, L"DAY", &dwRegData);
151  disableDate.wDay = LOWORD(dwRegData);
152 
153  dwRegData = 0;
154  RegGetDWORDValue(hOpenedSubKey, NULL, L"HOUR", &dwRegData);
155  disableDate.wHour = LOWORD(dwRegData);
156 
157  dwRegData = 0;
158  RegGetDWORDValue(hOpenedSubKey, NULL, L"MINUTE", &dwRegData);
159  disableDate.wMinute = LOWORD(dwRegData);
160 
161  dwRegData = 0;
162  RegGetDWORDValue(hOpenedSubKey, NULL, L"MONTH", &dwRegData);
163  disableDate.wMonth = LOWORD(dwRegData);
164 
165  dwRegData = 0;
166  RegGetDWORDValue(hOpenedSubKey, NULL, L"SECOND", &dwRegData);
167  disableDate.wSecond = LOWORD(dwRegData);
168 
169  dwRegData = 0;
170  RegGetDWORDValue(hOpenedSubKey, NULL, L"YEAR", &dwRegData);
171  disableDate.wYear = LOWORD(dwRegData);
172 #endif
173 
174  DWORD dwStartType = 0;
175  RegGetDWORDValue(hOpenedSubKey, NULL, SubKeyName /* Service name */, &dwStartType);
176 
177  pContextParams->bIsPresent = TRUE;
178  pContextParams->bIsKeyed = TRUE;
179  pContextParams->dwStartType = dwStartType;
180  pContextParams->time = disableDate;
181  }
182  else
183  {
184  pContextParams->bIsPresent = FALSE;
185  pContextParams->bIsKeyed = TRUE;
186  pContextParams->dwStartType = 0;
187  // pContextParams->time = {};
188  }
189 
190  return ERROR_SUCCESS;
191 }
#define RegQueryValueEx
Definition: winreg.h:524
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4705
WORD wMonth
Definition: winbase.h:871
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define DWORD
Definition: msvc.h:34
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WORD wYear
Definition: winbase.h:870
WORD wMinute
Definition: winbase.h:875
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:3988
smooth NULL
Definition: ftsmooth.c:416
LONG RegGetDWORDValue(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValue OPTIONAL, OUT LPDWORD lpData OPTIONAL)
Definition: regutils.c:95
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD wSecond
Definition: winbase.h:876
static const WCHAR L[]
Definition: oid.c:1250
#define wcsicmp
Definition: string.h:1152
WORD wDay
Definition: winbase.h:873
WORD wHour
Definition: winbase.h:874
#define REG_DWORD
Definition: sdbapi.c:539
#define LOWORD(l)
Definition: pedump.c:82

◆ QUERY_REGISTRY_VALUES_ROUTINE()

QUERY_REGISTRY_VALUES_ROUTINE ( GetRegistryValuedDisabledServicesQueryRoutine  )

Definition at line 94 of file srvpage.cpp.

95 {
99 
100  if (!EntryContext)
101  return ERROR_SUCCESS;
102 
104  if (pContextParams->bIsPresent)
105  return ERROR_SUCCESS;
106 
107  if ( (hRootKey == HKEY_LOCAL_MACHINE) && (ValueType == REG_DWORD) && (ValueLength == sizeof(DWORD)) &&
108  (wcsicmp((LPCWSTR)Context, ValueName) == 0) )
109  {
110  pContextParams->bIsPresent = TRUE;
111  pContextParams->bIsKeyed = FALSE;
112  pContextParams->dwStartType = *(DWORD*)ValueData;
113  // pContextParams->time = {};
114  }
115  else
116  {
117  pContextParams->bIsPresent = FALSE;
118  pContextParams->bIsKeyed = FALSE;
119  pContextParams->dwStartType = 0;
120  // pContextParams->time = {};
121  }
122 
123  return ERROR_SUCCESS;
124 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4000
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:3988
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ GUID _In_ PVOID _In_ ULONG ValueLength
Definition: hubbusif.h:311
#define wcsicmp
Definition: string.h:1152
#define REG_DWORD
Definition: sdbapi.c:539
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ RegisterNoMsgAnymore()

static BOOL RegisterNoMsgAnymore ( VOID  )
static

Definition at line 43 of file srvpage.cpp.

44 {
45  return (RegSetDWORDValue(HKEY_CURRENT_USER /* HKEY_LOCAL_MACHINE ?? */,
46  L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig",
47  L"HideEssentialServiceWarning",
48  TRUE, 1) == ERROR_SUCCESS);
49 }
#define TRUE
Definition: types.h:120
LONG RegSetDWORDValue(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValue OPTIONAL, IN BOOL bCreateKeyIfDoesntExist, IN DWORD dwData)
Definition: regutils.c:162
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static const WCHAR L[]
Definition: oid.c:1250

Referenced by RequiredServicesDisablingDialogWndProc().

◆ RequiredServicesDisablingDialogWndProc()

INT_PTR CALLBACK RequiredServicesDisablingDialogWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 447 of file srvpage.cpp.

451 {
453 
454  switch (message)
455  {
456  case WM_INITDIALOG:
457  {
458  /* Correctly display message strings */
459  LPCWSTR szOSVendor;
460  size_t itemLength = 0;
461  LPWSTR szItem = NULL, szNewItem = NULL;
462 
463  szOSVendor = (bIsWindows ? IDS_WINDOWS : IDS_REACTOS);
464 
466  szItem = (LPWSTR)MemAlloc(0, itemLength * sizeof(WCHAR));
467  GetDlgItemText(hDlg, IDC_STATIC_REQSVCSDIS_INFO, szItem, (int)itemLength);
468  szNewItem = FormatString(szItem, szOSVendor);
469  SetDlgItemText(hDlg, IDC_STATIC_REQSVCSDIS_INFO, szNewItem);
470  MemFree(szNewItem);
471  MemFree(szItem);
472 
473  return TRUE;
474  }
475 
476  case WM_COMMAND:
477  {
478  switch (LOWORD(wParam))
479  {
480  case IDOK:
481  {
484 
485  EndDialog(hDlg, LOWORD(wParam));
486  return TRUE;
487  }
488 
489  case IDCANCEL:
490  EndDialog(hDlg, LOWORD(wParam));
491  return TRUE;
492 
493  default:
494  //break;
495  return FALSE;
496  }
497  }
498  }
499 
500  return FALSE;
501 }
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL MemFree(IN PVOID lpMem)
Definition: utils.c:26
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
PVOID MemAlloc(IN DWORD dwFlags, IN DWORD dwBytes)
Definition: utils.c:33
BOOL bIsWindows
Definition: msconfig.c:31
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static BOOL RegisterNoMsgAnymore(VOID)
Definition: srvpage.cpp:43
DWORD FormatString(DWORD dwFlags, HINSTANCE hInstance, DWORD dwStringId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments)
Definition: fontview.c:48
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define IDS_REACTOS
Definition: resource.h:9
smooth NULL
Definition: ftsmooth.c:416
#define IDC_CBX_REQSVCSDIS_NO_MSG_ANYMORE
Definition: resource.h:108
#define GetDlgItemText
Definition: winuser.h:5651
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define Button_GetCheck(hwndCtl)
Definition: windowsx.h:6
#define SetDlgItemText
Definition: winuser.h:5715
#define WM_COMMAND
Definition: winuser.h:1716
#define BST_CHECKED
Definition: winuser.h:197
#define IDC_STATIC_REQSVCSDIS_INFO
Definition: resource.h:109
#define GetWindowTextLength
Definition: winuser.h:5665
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
const LPCWSTR IDS_WINDOWS
Definition: msconfig.c:37
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by ValidateItem().

◆ ServicesPageWndProc()

INT_PTR CALLBACK ServicesPageWndProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 629 of file srvpage.cpp.

630 {
633 
634  switch (message)
635  {
636  case WM_INITDIALOG:
637  {
638  hServicesPage = hDlg;
640 
641  //
642  // Correctly display message strings.
643  //
644  LPCWSTR szOSVendor = (bIsWindows ? IDS_MICROSOFT : IDS_REACTOS);
645 
646  size_t itemLength = 0;
647  LPWSTR szItem = NULL, szNewItem = NULL;
648 
650  szItem = (LPWSTR)MemAlloc(0, itemLength * sizeof(WCHAR));
651  GetDlgItemText(hServicesPage, IDC_STATIC_SERVICES_WARNING, szItem, (int)itemLength);
652  szNewItem = FormatString(szItem, szOSVendor);
654  MemFree(szNewItem);
655  MemFree(szItem);
656 
658  szItem = (LPWSTR)MemAlloc(0, itemLength * sizeof(WCHAR));
660  szNewItem = FormatString(szItem, szOSVendor);
662  MemFree(szNewItem);
663  MemFree(szItem);
664 
665  //
666  // Initialize the styles.
667  //
670  SetWindowTheme(hServicesListCtrl, L"Explorer", NULL);
671 
672  //
673  // Initialize the application page's controls.
674  //
675  LVCOLUMN column = {};
676 
677  // First column : Service's name.
678  column.mask = LVCF_TEXT | LVCF_WIDTH;
680  column.cx = 150;
682  MemFree(column.pszText);
683 
684  // Second column : Whether the service is required or not.
685  column.mask = LVCF_TEXT | LVCF_WIDTH;
687  column.cx = 60;
689  MemFree(column.pszText);
690 
691  // Third column : Service's vendor.
692  column.mask = LVCF_TEXT | LVCF_WIDTH;
694  column.cx = 150;
696  MemFree(column.pszText);
697 
698  // Fourth column : Service's status.
699  column.mask = LVCF_TEXT | LVCF_WIDTH;
701  column.cx = 60;
703  MemFree(column.pszText);
704 
705  // Fifth column : Service's disabled date.
706  column.mask = LVCF_TEXT | LVCF_WIDTH;
708  column.cx = 120;
710  MemFree(column.pszText);
711 
712  //
713  // Populate and sort the list.
714  //
715  GetServices();
717  UpdateBtnStates(hDlg);
718 
719  // Select the first item.
721 
722  return TRUE;
723  }
724 
725  case WM_DESTROY:
726  {
728  userModificationsList.RemoveAll();
729  return 0;
730  }
731 
732  case WM_COMMAND:
733  {
734  switch (LOWORD(wParam))
735  {
737  {
738  BOOL bAreThereMods = FALSE;
739 
740  int index = -1; // From the beginning.
742  {
743  bAreThereMods = ValidateItem(index, TRUE, FALSE) || bAreThereMods; // The order is verrrrrry important !!!!
744  }
745 
746  if (bAreThereMods)
747  {
748  UpdateBtnStates(hDlg);
750  }
751 
752  return TRUE;
753  }
754 
756  {
757  BOOL bAreThereMods = FALSE;
758 
759  int index = -1; // From the beginning.
761  {
762  bAreThereMods = ValidateItem(index, FALSE, FALSE) || bAreThereMods; // The order is verrrrrry important !!!!
763  }
764 
765  if (bAreThereMods)
766  {
767  UpdateBtnStates(hDlg);
769  }
770 
771  return TRUE;
772  }
773 
775  {
778  UpdateBtnStates(hDlg);
779 
780  return TRUE;
781  }
782 
783  default:
784  return FALSE;
785  }
786  return FALSE;
787  }
788 
789  case UM_CHECKSTATECHANGE:
790  {
791  BOOL bNewCheckState = !!((ListView_GetCheckState(hServicesListCtrl, int(lParam)) + 1) % 2);
792 
793  if (ValidateItem(/*reinterpret_cast<int>*/ int(lParam), bNewCheckState, !HideEssentialServiceWarning()))
794  {
795  UpdateBtnStates(hDlg);
797  }
798 
799  return TRUE;
800  }
801 
802  case WM_NOTIFY:
803  {
804  if (reinterpret_cast<LPNMHDR>(lParam)->hwndFrom == hServicesListCtrl)
805  {
806  switch (reinterpret_cast<LPNMHDR>(lParam)->code)
807  {
808  case NM_CLICK:
809  case NM_RCLICK:
810  {
811  DWORD dwpos = GetMessagePos();
812  LVHITTESTINFO ht = {};
813  ht.pt.x = GET_X_LPARAM(dwpos);
814  ht.pt.y = GET_Y_LPARAM(dwpos);
816 
817  /*
818  * We use ListView_SubItemHitTest(...) and not ListView_HitTest(...)
819  * because ListView_HitTest(...) returns bad flags when one clicks
820  * on a sub-item different from 0. The flags then contain LVHT_ONITEMSTATEICON
821  * which must not be obviously present in this case.
822  */
824 
825  if (LVHT_ONITEMSTATEICON & ht.flags)
826  {
827  PostMessage(hDlg, UM_CHECKSTATECHANGE, 0, (LPARAM)ht.iItem);
828 
829  // Disable default behaviour. Needed for the UM_CHECKSTATECHANGE
830  // custom notification to work as expected.
832  }
833 
834  return TRUE;
835  }
836 
837  case NM_DBLCLK:
838  case NM_RDBLCLK:
839  {
840  // We deactivate double-clicks.
842  return TRUE;
843  }
844 
845  case LVN_KEYDOWN:
846  {
847  if (reinterpret_cast<LPNMLVKEYDOWN>(lParam)->wVKey == VK_SPACE)
848  {
850  PostMessage(hDlg, UM_CHECKSTATECHANGE, 0, (LPARAM)iItem);
851 
852  // Disable default behaviour. Needed for the UM_CHECKSTATECHANGE
853  // custom notification to work as expected.
855  }
856 
857  return TRUE;
858  }
859 
860  case LVN_COLUMNCLICK:
861  {
862  int iSortingColumn = reinterpret_cast<LPNMLISTVIEW>(lParam)->iSubItem;
863 
865  iSortedColumn = iSortingColumn;
866 
867  return TRUE;
868  }
869  }
870  }
871  else
872  {
873  switch (reinterpret_cast<LPNMHDR>(lParam)->code)
874  {
875  case PSN_APPLY:
876  {
877  // Try to apply the modifications to the system.
878  MessageBox(NULL, _T("In Services page: PSN_APPLY"), _T("Info"), MB_ICONINFORMATION);
879 
880  /*
881  //
882  // Move this away...
883  //
884  int iRetVal = MessageBox(NULL, _T("Would you really want to modify the configuration of your system ?"), _T("Warning"), MB_ICONWARNING | MB_YESNOCANCEL);
885 
886  if (iRetVal == IDYES /\* modifications are OK *\/)
887  SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_NOERROR);
888  else if (iRetVal == IDNO /\* modifications are not OK *\/)
889  SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_NOERROR);
890  else // if (iRetVal == IDCANCEL) // There was an error...
891  SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_INVALID);
892  */
893 
894  //
895  // We modify the services which are stored in the user modification list.
896  //
897 
898  // 1- Open the Service Control Manager for modifications.
900  if (hSCManager != NULL)
901  {
902  LPCWSTR svcName;
903 
904  for (POSITION it = userModificationsList.GetHeadPosition(); it; userModificationsList.GetNext(it))
905  {
906  svcName = userModificationsList.GetAt(it);
907 
908  // 2- Retrieve a handle to the service.
909  SC_HANDLE hService = OpenServiceW(hSCManager, svcName, SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG);
910  if (hService == NULL)
911  {
912  // TODO : Show a message box.
913  continue;
914  }
915 
916  DWORD dwBytesNeeded = 0;
917  QueryServiceConfigW(hService, NULL, 0, &dwBytesNeeded);
918  // if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
919 
920  LPQUERY_SERVICE_CONFIG lpServiceConfig = (LPQUERY_SERVICE_CONFIG)MemAlloc(0, dwBytesNeeded);
921  if (!lpServiceConfig)
922  {
923  CloseServiceHandle(hService);
924  continue; // TODO ? Show a message box...
925  }
926  QueryServiceConfigW(hService, lpServiceConfig, dwBytesNeeded, &dwBytesNeeded);
927 
928  if (lpServiceConfig->dwStartType == SERVICE_DISABLED) // We have a disabled service which is becoming to be enabled.
929  {
930  // 3a- Retrieve the properties of the disabled service from the registry.
932 
933  QUERY_REGISTRY_KEYS_TABLE KeysQueryTable[2] = {};
934  KeysQueryTable[0].QueryRoutine = GetRegistryKeyedDisabledServicesQueryRoutine;
935  KeysQueryTable[0].EntryContext = &params;
936  RegQueryRegistryKeys(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", KeysQueryTable, (PVOID)svcName);
937 
938  if (bIsWindows && bIsPreVistaOSVersion && !params.bIsPresent)
939  {
940  QUERY_REGISTRY_VALUES_TABLE ValuesQueryTable[2] = {};
941  ValuesQueryTable[0].QueryRoutine = GetRegistryValuedDisabledServicesQueryRoutine;
942  ValuesQueryTable[0].EntryContext = &params;
943  RegQueryRegistryValues(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", ValuesQueryTable, (PVOID)svcName);
944  }
945 
946  if (params.bIsPresent)
947  {
948  // 4a- Modify the service.
950 
951  // 5a- Remove the registry entry of the service.
952  if (params.bIsKeyed)
953  {
954  CAtlStringW serviceRegKey(L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services\\");
955  serviceRegKey += svcName;
956  RegDeleteKeyW(HKEY_LOCAL_MACHINE, serviceRegKey);
957 
958  /***** HACK for Windows < Vista (e.g. 2000, Xp, 2003...) *****/
959  //
960  // Delete also the valued-entry of the service.
961  //
963  {
964  HKEY hSubKey = NULL;
965  if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", 0, KEY_SET_VALUE /*KEY_READ*/, &hSubKey) == ERROR_SUCCESS)
966  {
967  RegDeleteValue(hSubKey, svcName);
968  RegCloseKey(hSubKey);
969  }
970  }
971  /*************************************************************/
972  }
973  else
974  {
975  HKEY hSubKey = NULL;
976  if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", 0, KEY_SET_VALUE /*KEY_READ*/, &hSubKey) == ERROR_SUCCESS)
977  {
978  RegDeleteValue(hSubKey, svcName);
979  RegCloseKey(hSubKey);
980  }
981  }
982 
984  // userModificationsList.RemoveAt(it);
985  }
986  else
987  {
988  // Ohoh !! We have a very big problem.
989  MessageBox(NULL, _T("WTF ??"), _T("FATAL ERROR !!!!"), MB_ICONERROR);
990  }
991  }
992  else // We have an enabled service which is becoming to be disabled.
993  {
994  // 3b- Retrieve the local time of disabling.
995  SYSTEMTIME disableDate = {};
996  GetLocalTime(&disableDate);
997 
998  // 4b- Modify the service.
1000 
1001  // 5b- Register the service into the registry.
1002  CAtlStringW serviceRegKey(L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services\\");
1003  serviceRegKey += svcName;
1004  HKEY hSubKey = NULL;
1006  {
1007  RegSetDWORDValue(hSubKey, NULL, svcName, FALSE, lpServiceConfig->dwStartType);
1008 
1009  #if 1 // DisableDate
1010  RegSetDWORDValue(hSubKey, NULL, L"DAY" , FALSE, disableDate.wDay );
1011  RegSetDWORDValue(hSubKey, NULL, L"HOUR" , FALSE, disableDate.wHour );
1012  RegSetDWORDValue(hSubKey, NULL, L"MINUTE", FALSE, disableDate.wMinute);
1013  RegSetDWORDValue(hSubKey, NULL, L"MONTH" , FALSE, disableDate.wMonth );
1014  RegSetDWORDValue(hSubKey, NULL, L"SECOND", FALSE, disableDate.wSecond);
1015  RegSetDWORDValue(hSubKey, NULL, L"YEAR" , FALSE, disableDate.wYear );
1016  #endif
1017 
1018  RegCloseKey(hSubKey);
1019  }
1020 
1021  /***** HACK for Windows < Vista (e.g. 2000, Xp, 2003...) *****/
1022  //
1023  // Save also a valued-entry for the service.
1024  //
1026  {
1027  RegSetDWORDValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", svcName, TRUE, lpServiceConfig->dwStartType);
1028  }
1029  /*************************************************************/
1030 
1032  // userModificationsList.RemoveAt(it);
1033  }
1034 
1035  MemFree(lpServiceConfig);
1036  CloseServiceHandle(hService);
1037  }
1038 
1040  userModificationsList.RemoveAll();
1042 
1044 
1045 
1048 
1049  /* Modifications are OK */
1051  }
1052  else
1053  {
1054  MessageBox(hDlg, _T("Impossible to open the SC manager..."), _T("Error"), MB_ICONERROR);
1055 
1056  // There was an error...
1058  }
1059 
1061  UpdateBtnStates(hDlg);
1062 
1063  return TRUE;
1064  }
1065 
1066  case PSN_HELP:
1067  {
1068  MessageBox(hServicesPage, _T("Help not implemented yet!"), _T("Help"), MB_ICONINFORMATION | MB_OK);
1069  return TRUE;
1070  }
1071 
1072  case PSN_KILLACTIVE: // Is going to lose activation.
1073  {
1074  // Changes are always valid of course.
1076  return TRUE;
1077  }
1078 
1079  case PSN_QUERYCANCEL:
1080  {
1081  // RefreshStartupList();
1082 
1083  // Allows cancellation.
1085 
1086  return TRUE;
1087  }
1088 
1089  case PSN_QUERYINITIALFOCUS:
1090  {
1091  // Give the focus on and select the first item.
1093 
1095  return TRUE;
1096  }
1097 
1098  //
1099  // DO NOT TOUCH THESE NEXT MESSAGES, THEY ARE OK LIKE THIS...
1100  //
1101  case PSN_RESET: // Perform final cleaning, called before WM_DESTROY.
1102  return TRUE;
1103 
1104  case PSN_SETACTIVE: // Is going to gain activation.
1105  {
1107  return TRUE;
1108  }
1109 
1110  default:
1111  break;
1112  }
1113  }
1114  }
1115 
1116  default:
1117  return FALSE;
1118  }
1119 
1120  return FALSE;
1121 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2406
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
LONG RegSetDWORDValue(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValue OPTIONAL, IN BOOL bCreateKeyIfDoesntExist, IN DWORD dwData)
Definition: regutils.c:162
#define LVCF_WIDTH
Definition: commctrl.h:2559
QUERY_SERVICE_CONFIGA * LPQUERY_SERVICE_CONFIG
Definition: winsvc.h:550
BOOL MemFree(IN PVOID lpMem)
Definition: utils.c:26
#define ERROR_SUCCESS
Definition: deptool.c:10
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define IDC_SERVICES_LIST
Definition: resource.h:17
#define LVCF_TEXT
Definition: commctrl.h:2560
WORD wMonth
Definition: winbase.h:871
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define PSN_HELP
Definition: prsht.h:119
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI QueryServiceConfigW(SC_HANDLE hService, LPQUERY_SERVICE_CONFIGW lpServiceConfig, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2234
PVOID MemAlloc(IN DWORD dwFlags, IN DWORD dwBytes)
Definition: utils.c:33
LRESULT RegQueryRegistryKeys(IN HKEY hRootKey, IN LPCWSTR KeyName, IN PQUERY_REGISTRY_KEYS_TABLE QueryTable, IN PVOID Context)
Definition: regutils.c:6
#define IDS_SERVICES_COLUMN_REQ
Definition: resource.h:82
#define ListView_SubItemHitTest(hwnd, plvhti)
Definition: commctrl.h:2737
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1240
#define PropSheet_CancelToClose(d)
Definition: prsht.h:325
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2706
static CAtlList< CAtlStringW > userModificationsList
Definition: srvpage.cpp:92
BOOL bIsWindows
Definition: msconfig.c:31
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ListView_Sort(hListView, iSortingColumn)
Definition: listview.h:32
#define UM_CHECKSTATECHANGE
Definition: comctl32supp.h:16
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1326
#define PSN_APPLY
Definition: prsht.h:117
DWORD FormatString(DWORD dwFlags, HINSTANCE hInstance, DWORD dwStringId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments)
Definition: fontview.c:48
#define PSN_SETACTIVE
Definition: prsht.h:115
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
#define DWLP_MSGRESULT
Definition: winuser.h:864
#define IDS_REACTOS
Definition: resource.h:9
#define SERVICE_NO_CHANGE
Definition: winsvc.h:20
#define PSN_QUERYCANCEL
Definition: prsht.h:123
#define SERVICE_DISABLED
Definition: cmtypes.h:977
WORD wYear
Definition: winbase.h:870
BOOL bIsPreVistaOSVersion
Definition: msconfig.c:32
#define LVCOLUMN
Definition: commctrl.h:2553
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2608
#define NM_RDBLCLK
Definition: commctrl.h:134
#define LVN_KEYDOWN
Definition: commctrl.h:3156
#define IDC_BTN_SERVICES_DEACTIVATE
Definition: resource.h:21
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define PSN_KILLACTIVE
Definition: prsht.h:116
GLenum const GLfloat * params
Definition: glext.h:5645
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2645
#define ListView_GetExtendedListViewStyle(hwndLV)
Definition: commctrl.h:2700
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI ChangeServiceConfigW(SC_HANDLE hService, DWORD dwServiceType, DWORD dwStartType, DWORD dwErrorControl, LPCWSTR lpBinaryPathName, LPCWSTR lpLoadOrderGroup, LPDWORD lpdwTagId, LPCWSTR lpDependencies, LPCWSTR lpServiceStartName, LPCWSTR lpPassword, LPCWSTR lpDisplayName)
Definition: scm.c:480
static int iSortedColumn
Definition: srvpage.cpp:27
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2103
HRESULT WINAPI SetWindowTheme(_In_ HWND hwnd, _In_ LPCWSTR pszSubAppName, _In_ LPCWSTR pszSubIdList)
Definition: uxthemesupp.c:69
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
WORD wMinute
Definition: winbase.h:875
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2291
static void UpdateBtnStates(HWND hDlg)
Definition: srvpage.cpp:585
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:276
GLuint index
Definition: glext.h:6031
static BOOL bMaskProprietarySvcs
Definition: srvpage.cpp:28
#define IDS_SERVICES_COLUMN_DATEDISABLED
Definition: resource.h:136
#define IDS_SERVICES_COLUMN_STATUS
Definition: resource.h:84
#define WM_DESTROY
Definition: winuser.h:1591
#define PostMessage
Definition: winuser.h:5698
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define RegDeleteValue
Definition: winreg.h:508
static void ClearServicesList(void)
Definition: srvpage.cpp:384
#define _T(x)
Definition: vfdio.h:22
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID LoadResourceString(UINT ResourceId, LPVOID Buffer, UINT ccount, LPVOID DefaultString, BOOL bUnicode)
Definition: enum.c:13
#define GetDlgItemText
Definition: winuser.h:5651
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
PQUERY_REGISTRY_VALUES_ROUTINE QueryRoutine
Definition: regutils.h:63
#define IDC_CBX_SERVICES_MASK_PROPRIETARY_SVCS
Definition: resource.h:73
const LPCWSTR IDS_MICROSOFT
Definition: msconfig.c:36
#define SERVICE_CHANGE_CONFIG
Definition: winsvc.h:54
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT RegQueryRegistryValues(IN HKEY hRootKey, IN LPCWSTR KeyName, IN PQUERY_REGISTRY_VALUES_TABLE QueryTable, IN PVOID Context)
Definition: regutils.c:51
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2697
#define SetDlgItemText
Definition: winuser.h:5715
WORD wSecond
Definition: winbase.h:876
#define PSNRET_NOERROR
Definition: prsht.h:129
#define MB_ICONINFORMATION
Definition: winuser.h:796
static const WCHAR L[]
Definition: oid.c:1250
#define LVS_EX_CHECKBOXES
Definition: commctrl.h:2703
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2011
#define MB_ICONERROR
Definition: winuser.h:781
static void GetServices(BOOL bHideOSVendorServices=FALSE)
Definition: srvpage.cpp:402
static HWND hServicesPage
Definition: srvpage.cpp:25
#define MessageBox
Definition: winuser.h:5688
#define WM_COMMAND
Definition: winuser.h:1716
#define NM_CLICK
Definition: commctrl.h:130
SC_HANDLE hSCManager
Definition: sc.c:12
#define LVNI_ALL
Definition: commctrl.h:2394
#define IDC_STATIC_SERVICES_WARNING
Definition: resource.h:74
WORD wDay
Definition: winbase.h:873
HWND WINAPI GetParent(_In_ HWND)
PQUERY_REGISTRY_KEYS_ROUTINE QueryRoutine
Definition: regutils.h:29
BOOL ListView_SortEx(HWND hListView, int iSortingColumn, int iSortedColumn)
Definition: listview.c:43
#define RegOpenKeyEx
Definition: winreg.h:520
HINSTANCE hInst
Definition: dxdiag.c:13
#define PSNRET_INVALID
Definition: prsht.h:130
#define ListView_GetCheckState(hwndLV, i)
Definition: commctrl.h:2649
#define NM_DBLCLK
Definition: commctrl.h:131
#define PSN_RESET
Definition: prsht.h:118
#define NM_RCLICK
Definition: commctrl.h:133
WORD wHour
Definition: winbase.h:874
static const struct newhuff ht[]
Definition: huffman.h:296
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define HWND_DESKTOP
Definition: winuser.h:1195
#define VK_SPACE
Definition: winuser.h:2173
#define MB_OK
Definition: winuser.h:784
#define LVN_COLUMNCLICK
Definition: commctrl.h:3111
#define SC_MANAGER_ALL_ACCESS
Definition: winsvc.h:13
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
#define LVHT_ONITEMSTATEICON
Definition: commctrl.h:2468
static BOOL ValidateItem(int index, BOOL bNewState, BOOL bDisplayErrors)
Definition: srvpage.cpp:503
#define GetWindowTextLength
Definition: winuser.h:5665
#define SERVICE_QUERY_CONFIG
Definition: winsvc.h:53
#define IDS_SERVICES_COLUMN_SERVICE
Definition: resource.h:81
#define ListView_GetSelectionMark(hwnd)
Definition: commctrl.h:2761
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDS_SERVICES_COLUMN_VENDOR
Definition: resource.h:83
#define IDC_BTN_SERVICES_ACTIVATE
Definition: resource.h:20
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
BOOL HideEssentialServiceWarning(VOID)
Definition: srvpage.cpp:52
#define LOWORD(l)
Definition: pedump.c:82
#define PSN_QUERYINITIALFOCUS
Definition: settings.cpp:98
static HWND hServicesListCtrl
Definition: srvpage.cpp:26
#define RegCreateKeyEx
Definition: winreg.h:501
#define LVIS_FOCUSED
Definition: commctrl.h:2290
#define WM_NOTIFY
Definition: richedit.h:61
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ SetServicesActivation()

BOOL SetServicesActivation ( DWORD  dwState)

Definition at line 37 of file srvpage.cpp.

38 {
39  return (RegSetDWORDValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\state", L"services", TRUE, dwState) == ERROR_SUCCESS);
40 }
#define TRUE
Definition: types.h:120
LONG RegSetDWORDValue(IN HKEY hKey, IN LPCWSTR lpSubKey OPTIONAL, IN LPCWSTR lpValue OPTIONAL, IN BOOL bCreateKeyIfDoesntExist, IN DWORD dwData)
Definition: regutils.c:162
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR L[]
Definition: oid.c:1250
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ UpdateBtnStates()

static void UpdateBtnStates ( HWND  hDlg)
static

Definition at line 585 of file srvpage.cpp.

586 {
587  // HWND hTree = GetDlgItem(hDlg, IDC_SYSTEM_TREE);
588 
589  //
590  // "Enable all" / "Disable all" buttons.
591  //
592  // UINT uRootCheckState = TreeView_GetRealSubtreeState(hTree, TVI_ROOT);
593  UINT uRootCheckState = ListView_GetCheckState(hServicesListCtrl, 0);
594 #define OP(a, b) ((a) == (b) ? (a) : 2)
595  int index = 0; // -1 // From the beginning + 1.
597  {
599  uRootCheckState = OP(uRootCheckState, temp);
600  }
601 
602  if (uRootCheckState == 0)
603  {
606  }
607  else if (uRootCheckState == 1)
608  {
611  }
612  else if (uRootCheckState == 2)
613  {
616  }
617  else
618  {
621  }
622 
623  return;
624 }
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2406
#define TRUE
Definition: types.h:120
#define IDC_BTN_SERVICES_DEACTIVATE
Definition: resource.h:21
GLuint index
Definition: glext.h:6031
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
unsigned int UINT
Definition: ndis.h:50
static stack_node_t temp
Definition: rpn.c:18
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define LVNI_ALL
Definition: commctrl.h:2394
#define ListView_GetCheckState(hwndLV, i)
Definition: commctrl.h:2649
#define OP(a, b)
#define IDC_BTN_SERVICES_ACTIVATE
Definition: resource.h:20
static HWND hServicesListCtrl
Definition: srvpage.cpp:26

Referenced by ServicesPageWndProc().

◆ ValidateItem()

static BOOL ValidateItem ( int  index,
BOOL  bNewState,
BOOL  bDisplayErrors 
)
static

Definition at line 503 of file srvpage.cpp.

504 {
505  ServiceItem* pSvcItem = NULL;
506 
507  LVITEM truc = {};
508  truc.mask = LVIF_PARAM;
509  truc.iItem = index;
511 
512  // The lParam member must be valid.
513  pSvcItem = reinterpret_cast<ServiceItem*>(truc.lParam);
514  if (!pSvcItem)
515  return FALSE;
516 
517  //
518  // Allow modifications only if the service is not a required service for the system,
519  // or allow only the activation of a disabled required service.
520  //
521  BOOL bOldState = !!(ListView_GetCheckState(hServicesListCtrl, truc.iItem /* == index */) % 2);
522 
523  if ( !pSvcItem->m_bIsRequired ||
524  (pSvcItem->m_bIsRequired && !pSvcItem->m_bIsEnabled && bOldState == FALSE && bNewState == TRUE) )
525  {
526  if (bOldState == bNewState)
527  return FALSE;
528 
530 
531  if (pSvcItem->m_bIsEnabled) // Enabled service.
532  {
533  if (bNewState == FALSE) // To be deactivated.
534  {
535  userModificationsList.AddTail(pSvcItem->m_lpszSvcName);
536  }
537  else if (bNewState == TRUE) // To be reactivated
538  {
539  POSITION it = userModificationsList.Find(pSvcItem->m_lpszSvcName);
540  if (it)
541  {
542  userModificationsList.RemoveAt(it);
543  }
544  else
545  {
546  OutputDebugString(_T("(1) \"WTF: What The Fukhurmajalmahamadahaldeliya ?!\" (The Dictator, Sacha Baron Cohen)\n"));
547  }
548  }
549  }
550  else // Disabled service.
551  {
552  if (bNewState == TRUE) // To be activated.
553  {
554  userModificationsList.AddTail(pSvcItem->m_lpszSvcName);
555  }
556  else if (bNewState == FALSE) // To be redeactivated
557  {
558  POSITION it = userModificationsList.Find(pSvcItem->m_lpszSvcName);
559  if (it)
560  {
561  userModificationsList.RemoveAt(it);
562  }
563  else
564  {
565  OutputDebugString(_T("(2) \"WTF: What The Fukhurmajalmahamadahaldeliya ?!\" (The Dictator, Sacha Baron Cohen)\n"));
566  }
567  }
568  }
569 
570  return TRUE;
571  }
572  else
573  {
574  if (bDisplayErrors)
575  {
577  }
578 
579  return FALSE;
580  }
581 }
#define TRUE
Definition: types.h:120
INT_PTR CALLBACK RequiredServicesDisablingDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: srvpage.cpp:447
static CAtlList< CAtlStringW > userModificationsList
Definition: srvpage.cpp:92
BOOL m_bIsEnabled
Definition: srvpage.cpp:80
#define OutputDebugString
Definition: winbase.h:3704
BOOL m_bIsRequired
Definition: srvpage.cpp:81
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4268
#define _T(x)
Definition: vfdio.h:22
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IDD_REQUIRED_SERVICES_DISABLING_DIALOG
Definition: resource.h:19
#define index(s, c)
Definition: various.h:29
static HWND hServicesPage
Definition: srvpage.cpp:25
HINSTANCE hInst
Definition: dxdiag.c:13
#define ListView_GetCheckState(hwndLV, i)
Definition: commctrl.h:2649
#define ListView_SetCheckState(hwndLV, i, fCheck)
Definition: commctrl.h:2646
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2366
#define LVIF_PARAM
Definition: commctrl.h:2283
#define LVITEM
Definition: commctrl.h:2347
CAtlStringW m_lpszSvcName
Definition: srvpage.cpp:79
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static HWND hServicesListCtrl
Definition: srvpage.cpp:26

Referenced by ServicesPageWndProc().

Variable Documentation

◆ bMaskProprietarySvcs

BOOL bMaskProprietarySvcs = FALSE
static

Definition at line 28 of file srvpage.cpp.

Referenced by ServicesPageWndProc().

◆ hServicesListCtrl

HWND hServicesListCtrl = NULL
static

◆ hServicesPage

HWND hServicesPage = NULL
static

Definition at line 25 of file srvpage.cpp.

Referenced by ServicesPageWndProc(), and ValidateItem().

◆ iSortedColumn

int iSortedColumn = 0
static

Definition at line 27 of file srvpage.cpp.

Referenced by ListView_Sort(), ListView_SortEx(), and ServicesPageWndProc().

◆ userModificationsList

CAtlList<CAtlStringW> userModificationsList
static

Definition at line 92 of file srvpage.cpp.

Referenced by AddService(), ServicesPageWndProc(), and ValidateItem().