ReactOS  0.4.13-dev-651-g5dbc677
controlset.c File Reference
#include "services.h"
#include <debug.h>
Include dependency graph for controlset.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static DWORD ScmCopyTree (HKEY hSrcKey, HKEY hDstKey)
 
static DWORD ScmGetControlSetValues (PDWORD pdwCurrentControlSet, PDWORD pdwDefaultControlSet, PDWORD pdwFailedControlSet, PDWORD pdwLastKnownGoodControlSet)
 
static DWORD ScmSetLastKnownGoodControlSet (DWORD dwControlSet)
 
static DWORD ScmGetSetupInProgress (VOID)
 
static DWORD ScmCopyControlSet (DWORD dwSourceControlSet, DWORD dwDestinationControlSet)
 
DWORD ScmCreateLastKnownGoodControlSet (VOID)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file controlset.c.

Function Documentation

◆ ScmCopyControlSet()

static DWORD ScmCopyControlSet ( DWORD  dwSourceControlSet,
DWORD  dwDestinationControlSet 
)
static

Definition at line 398 of file controlset.c.

401 {
402  WCHAR szSourceControlSetName[32];
403  WCHAR szDestinationControlSetName[32];
404  HKEY hSourceControlSetKey = NULL;
405  HKEY hDestinationControlSetKey = NULL;
406  DWORD dwDisposition;
407  DWORD dwError;
408 
409  /* Create the source control set name */
410  swprintf(szSourceControlSetName, L"SYSTEM\\ControlSet%03lu", dwSourceControlSet);
411  DPRINT("Source control set: %S\n", szSourceControlSetName);
412 
413  /* Create the destination control set name */
414  swprintf(szDestinationControlSetName, L"SYSTEM\\ControlSet%03lu", dwDestinationControlSet);
415  DPRINT("Destination control set: %S\n", szDestinationControlSetName);
416 
417  /* Open the source control set key */
419  szSourceControlSetName,
420  0,
421  KEY_READ,
422  &hSourceControlSetKey);
423  if (dwError != ERROR_SUCCESS)
424  goto done;
425 
426  /* Create the destination control set key */
428  szDestinationControlSetName,
429  0,
430  NULL,
432  KEY_WRITE,
433  NULL,
434  &hDestinationControlSetKey,
435  &dwDisposition);
436  if (dwError != ERROR_SUCCESS)
437  goto done;
438 
439  /* Copy the source control set to the destination control set */
440 #if (_WIN32_WINNT >= 0x0600)
441  dwError = RegCopyTreeW(hSourceControlSetKey,
442  NULL,
443  hDestinationControlSetKey);
444 #else
445  dwError = ScmCopyTree(hSourceControlSetKey,
446  hDestinationControlSetKey);
447 #endif
448  if (dwError != ERROR_SUCCESS)
449  goto done;
450 
451  RegFlushKey(hDestinationControlSetKey);
452 
453 done:
454  if (hDestinationControlSetKey != NULL)
455  RegCloseKey(hDestinationControlSetKey);
456 
457  if (hSourceControlSetKey != NULL)
458  RegCloseKey(hSourceControlSetKey);
459 
460  return dwError;
461 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static DWORD ScmCopyTree(HKEY hSrcKey, HKEY hDstKey)
Definition: controlset.c:26
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2974
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LONG WINAPI RegCopyTreeW(IN HKEY hKeySrc, IN LPCWSTR lpSubKey OPTIONAL, IN HKEY hKeyDest)
Definition: reg.c:736
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ScmCreateLastKnownGoodControlSet().

◆ ScmCopyTree()

static DWORD ScmCopyTree ( HKEY  hSrcKey,
HKEY  hDstKey 
)
static

Definition at line 26 of file controlset.c.

29 {
30  FILETIME LastWrite;
31  DWORD dwSubKeys;
32  DWORD dwValues;
33  DWORD dwType;
34  DWORD dwMaxSubKeyNameLength;
35  DWORD dwSubKeyNameLength;
36  DWORD dwMaxValueNameLength;
37  DWORD dwValueNameLength;
38  DWORD dwMaxValueLength;
39  DWORD dwValueLength;
40  DWORD dwDisposition;
41  DWORD i;
43  LPBYTE lpDataBuffer;
44  HKEY hDstSubKey;
45  HKEY hSrcSubKey;
46  DWORD dwError;
47 
48  DPRINT("ScmCopyTree()\n");
49 
50  dwError = RegQueryInfoKey(hSrcKey,
51  NULL,
52  NULL,
53  NULL,
54  &dwSubKeys,
55  &dwMaxSubKeyNameLength,
56  NULL,
57  &dwValues,
58  &dwMaxValueNameLength,
59  &dwMaxValueLength,
60  NULL,
61  NULL);
62  if (dwError != ERROR_SUCCESS)
63  {
64  DPRINT1("RegQueryInfoKey() failed (Error %lu)\n", dwError);
65  return dwError;
66  }
67 
68  dwMaxSubKeyNameLength++;
69  dwMaxValueNameLength++;
70 
71  DPRINT("dwSubKeys %lu\n", dwSubKeys);
72  DPRINT("dwMaxSubKeyNameLength %lu\n", dwMaxSubKeyNameLength);
73  DPRINT("dwValues %lu\n", dwValues);
74  DPRINT("dwMaxValueNameLength %lu\n", dwMaxValueNameLength);
75  DPRINT("dwMaxValueLength %lu\n", dwMaxValueLength);
76 
77  /* Copy subkeys */
78  if (dwSubKeys != 0)
79  {
81  0,
82  dwMaxSubKeyNameLength * sizeof(WCHAR));
83  if (lpNameBuffer == NULL)
84  {
85  DPRINT1("Buffer allocation failed\n");
87  }
88 
89  for (i = 0; i < dwSubKeys; i++)
90  {
91  dwSubKeyNameLength = dwMaxSubKeyNameLength;
92  dwError = RegEnumKeyExW(hSrcKey,
93  i,
95  &dwSubKeyNameLength,
96  NULL,
97  NULL,
98  NULL,
99  &LastWrite);
100  if (dwError != ERROR_SUCCESS)
101  {
102  DPRINT1("Subkey enumeration failed (Error %lu)\n", dwError);
104  0,
105  lpNameBuffer);
106  return dwError;
107  }
108 
109  dwError = RegCreateKeyExW(hDstKey,
110  lpNameBuffer,
111  0,
112  NULL,
114  KEY_WRITE,
115  NULL,
116  &hDstSubKey,
117  &dwDisposition);
118  if (dwError != ERROR_SUCCESS)
119  {
120  DPRINT1("Subkey creation failed (Error %lu)\n", dwError);
122  0,
123  lpNameBuffer);
124  return dwError;
125  }
126 
127  dwError = RegOpenKeyExW(hSrcKey,
128  lpNameBuffer,
129  0,
130  KEY_READ,
131  &hSrcSubKey);
132  if (dwError != ERROR_SUCCESS)
133  {
134  DPRINT1("Error: %lu\n", dwError);
135  RegCloseKey(hDstSubKey);
137  0,
138  lpNameBuffer);
139  return dwError;
140  }
141 
142  dwError = ScmCopyTree(hSrcSubKey,
143  hDstSubKey);
144  if (dwError != ERROR_SUCCESS)
145  {
146  DPRINT1("Error: %lu\n", dwError);
147  RegCloseKey (hSrcSubKey);
148  RegCloseKey (hDstSubKey);
150  0,
151  lpNameBuffer);
152  return dwError;
153  }
154 
155  RegCloseKey(hSrcSubKey);
156  RegCloseKey(hDstSubKey);
157  }
158 
160  0,
161  lpNameBuffer);
162  }
163 
164  /* Copy values */
165  if (dwValues != 0)
166  {
168  0,
169  dwMaxValueNameLength * sizeof(WCHAR));
170  if (lpNameBuffer == NULL)
171  {
172  DPRINT1("Buffer allocation failed\n");
174  }
175 
176  lpDataBuffer = HeapAlloc(GetProcessHeap(),
177  0,
178  dwMaxValueLength);
179  if (lpDataBuffer == NULL)
180  {
181  DPRINT1("Buffer allocation failed\n");
183  0,
184  lpNameBuffer);
186  }
187 
188  for (i = 0; i < dwValues; i++)
189  {
190  dwValueNameLength = dwMaxValueNameLength;
191  dwValueLength = dwMaxValueLength;
192  dwError = RegEnumValueW(hSrcKey,
193  i,
194  lpNameBuffer,
195  &dwValueNameLength,
196  NULL,
197  &dwType,
198  lpDataBuffer,
199  &dwValueLength);
200  if (dwError != ERROR_SUCCESS)
201  {
202  DPRINT1("Error: %lu\n", dwError);
204  0,
205  lpDataBuffer);
207  0,
208  lpNameBuffer);
209  return dwError;
210  }
211 
212  dwError = RegSetValueExW(hDstKey,
213  lpNameBuffer,
214  0,
215  dwType,
216  lpDataBuffer,
217  dwValueLength);
218  if (dwError != ERROR_SUCCESS)
219  {
220  DPRINT1("Error: %lu\n", dwError);
222  0,
223  lpDataBuffer);
225  0,
226  lpNameBuffer);
227  return dwError;
228  }
229  }
230 
232  0,
233  lpDataBuffer);
234 
236  0,
237  lpNameBuffer);
238  }
239 
240  DPRINT("ScmCopyTree() done \n");
241 
242  return ERROR_SUCCESS;
243 }
#define RegQueryInfoKey
Definition: winreg.h:521
#define ERROR_SUCCESS
Definition: deptool.c:10
static DWORD ScmCopyTree(HKEY hSrcKey, HKEY hDstKey)
Definition: controlset.c:26
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2853
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static LPSTR lpNameBuffer
Definition: secur32.c:50
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DPRINT1
Definition: precomp.h:8
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by ScmCopyControlSet().

◆ ScmCreateLastKnownGoodControlSet()

DWORD ScmCreateLastKnownGoodControlSet ( VOID  )

Definition at line 465 of file controlset.c.

466 {
467  DWORD dwCurrentControlSet, dwDefaultControlSet;
468  DWORD dwFailedControlSet, dwLastKnownGoodControlSet;
469  DWORD dwNewControlSet;
470  DWORD dwError;
471 
472  /* Get the control set values */
473  dwError = ScmGetControlSetValues(&dwCurrentControlSet,
474  &dwDefaultControlSet,
475  &dwFailedControlSet,
476  &dwLastKnownGoodControlSet);
477  if (dwError != ERROR_SUCCESS)
478  return dwError;
479 
480  /* First boot after setup? */
481  if ((ScmGetSetupInProgress() == 0) &&
482  (dwCurrentControlSet == dwLastKnownGoodControlSet))
483  {
484  DPRINT("First boot after setup!\n");
485 
486  /* Search for a new control set number */
487  for (dwNewControlSet = 1; dwNewControlSet < 1000; dwNewControlSet++)
488  {
489  if ((dwNewControlSet != dwCurrentControlSet) &&
490  (dwNewControlSet != dwDefaultControlSet) &&
491  (dwNewControlSet != dwFailedControlSet) &&
492  (dwNewControlSet != dwLastKnownGoodControlSet))
493  break;
494  }
495 
496  /* Fail if we did not find an unused control set!*/
497  if (dwNewControlSet >= 1000)
498  {
499  DPRINT1("Too many control sets!\n");
500  return ERROR_NO_MORE_ITEMS;
501  }
502 
503  /* Copy the current control set */
504  dwError = ScmCopyControlSet(dwCurrentControlSet,
505  dwNewControlSet);
506  if (dwError != ERROR_SUCCESS)
507  return dwError;
508 
509  /* Set the new 'LastKnownGood' control set */
510  dwError = ScmSetLastKnownGoodControlSet(dwNewControlSet);
511  }
512 
513  return dwError;
514 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static DWORD ScmGetSetupInProgress(VOID)
Definition: controlset.c:362
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
static DWORD ScmCopyControlSet(DWORD dwSourceControlSet, DWORD dwDestinationControlSet)
Definition: controlset.c:398
static DWORD ScmSetLastKnownGoodControlSet(DWORD dwControlSet)
Definition: controlset.c:332
void DPRINT(...)
Definition: polytest.cpp:61
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DPRINT1
Definition: precomp.h:8
static DWORD ScmGetControlSetValues(PDWORD pdwCurrentControlSet, PDWORD pdwDefaultControlSet, PDWORD pdwFailedControlSet, PDWORD pdwLastKnownGoodControlSet)
Definition: controlset.c:249

Referenced by wWinMain().

◆ ScmGetControlSetValues()

static DWORD ScmGetControlSetValues ( PDWORD  pdwCurrentControlSet,
PDWORD  pdwDefaultControlSet,
PDWORD  pdwFailedControlSet,
PDWORD  pdwLastKnownGoodControlSet 
)
static

Definition at line 249 of file controlset.c.

254 {
255  HKEY hSelectKey;
256  DWORD dwType;
257  DWORD dwSize;
258  DWORD dwError;
259 
260  DPRINT("ScmGetControlSetValues() called\n");
261 
263  L"System\\Select",
264  0,
265  KEY_READ,
266  &hSelectKey);
267  if (dwError != ERROR_SUCCESS)
268  return dwError;
269 
270  dwSize = sizeof(DWORD);
271  dwError = RegQueryValueExW(hSelectKey,
272  L"Current",
273  0,
274  &dwType,
275  (LPBYTE)pdwCurrentControlSet,
276  &dwSize);
277  if (dwError != ERROR_SUCCESS)
278  {
279  *pdwCurrentControlSet = 0;
280  }
281 
282  dwSize = sizeof(DWORD);
283  dwError = RegQueryValueExW(hSelectKey,
284  L"Default",
285  0,
286  &dwType,
287  (LPBYTE)pdwDefaultControlSet,
288  &dwSize);
289  if (dwError != ERROR_SUCCESS)
290  {
291  *pdwDefaultControlSet = 0;
292  }
293 
294  dwSize = sizeof(DWORD);
295  dwError = RegQueryValueExW(hSelectKey,
296  L"Failed",
297  0,
298  &dwType,
299  (LPBYTE)pdwFailedControlSet,
300  &dwSize);
301  if (dwError != ERROR_SUCCESS)
302  {
303  *pdwFailedControlSet = 0;
304  }
305 
306  dwSize = sizeof(DWORD);
307  dwError = RegQueryValueExW(hSelectKey,
308  L"LastKnownGood",
309  0,
310  &dwType,
311  (LPBYTE)pdwLastKnownGoodControlSet,
312  &dwSize);
313  if (dwError != ERROR_SUCCESS)
314  {
315  *pdwLastKnownGoodControlSet = 0;
316  }
317 
318  RegCloseKey(hSelectKey);
319 
320  DPRINT("ControlSets:\n");
321  DPRINT("Current: %lu\n", *pdwCurrentControlSet);
322  DPRINT("Default: %lu\n", *pdwDefaultControlSet);
323  DPRINT("Failed: %lu\n", *pdwFailedControlSet);
324  DPRINT("LastKnownGood: %lu\n", *pdwLastKnownGoodControlSet);
325 
326  return dwError;
327 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
void DPRINT(...)
Definition: polytest.cpp:61
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ScmCreateLastKnownGoodControlSet().

◆ ScmGetSetupInProgress()

static DWORD ScmGetSetupInProgress ( VOID  )
static

Definition at line 362 of file controlset.c.

363 {
364  DWORD dwError;
365  HKEY hKey;
366  DWORD dwType;
367  DWORD dwSize;
368  DWORD dwSetupInProgress = (DWORD)-1;
369 
370  DPRINT("ScmGetSetupInProgress()\n");
371 
372  /* Open key */
374  L"SYSTEM\\Setup",
375  0,
377  &hKey);
378  if (dwError == ERROR_SUCCESS)
379  {
380  /* Read key */
381  dwSize = sizeof(DWORD);
382  RegQueryValueExW(hKey,
383  L"SystemSetupInProgress",
384  NULL,
385  &dwType,
386  (LPBYTE)&dwSetupInProgress,
387  &dwSize);
388  RegCloseKey(hKey);
389  }
390 
391  DPRINT("SetupInProgress: %lu\n", dwSetupInProgress);
392  return dwSetupInProgress;
393 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ScmCreateLastKnownGoodControlSet().

◆ ScmSetLastKnownGoodControlSet()

static DWORD ScmSetLastKnownGoodControlSet ( DWORD  dwControlSet)
static

Definition at line 332 of file controlset.c.

334 {
335  HKEY hSelectKey;
336  DWORD dwError;
337 
339  L"System\\Select",
340  0,
341  KEY_WRITE,
342  &hSelectKey);
343  if (dwError != ERROR_SUCCESS)
344  return dwError;
345 
346  dwError = RegSetValueExW(hSelectKey,
347  L"LastKnownGood",
348  0,
349  REG_DWORD,
350  (LPBYTE)&dwControlSet,
351  sizeof(dwControlSet));
352 
353  RegFlushKey(hSelectKey);
354  RegCloseKey(hSelectKey);
355 
356  return dwError;
357 }
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2974
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define REG_DWORD
Definition: sdbapi.c:596
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ScmCreateLastKnownGoodControlSet().