ReactOS 0.4.15-dev-7842-g558ab78
smutil.c File Reference
#include "smss.h"
#include <ndk/sefuncs.h>
#include <debug.h>
Include dependency graph for smutil.c:

Go to the source code of this file.

Classes

struct  _SMP_PRIVILEGE_STATE
 

Macros

#define NDEBUG
 
#define VALUE_BUFFER_SIZE   (sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 512)
 

Typedefs

typedef struct _SMP_PRIVILEGE_STATE SMP_PRIVILEGE_STATE
 
typedef struct _SMP_PRIVILEGE_STATEPSMP_PRIVILEGE_STATE
 

Functions

NTSTATUS NTAPI SmpAcquirePrivilege (IN ULONG Privilege, OUT PVOID *PrivilegeState)
 
VOID NTAPI SmpReleasePrivilege (IN PVOID PrivState)
 
NTSTATUS NTAPI SmpParseToken (IN PUNICODE_STRING Input, IN BOOLEAN SecondPass, OUT PUNICODE_STRING Token)
 
NTSTATUS NTAPI SmpParseCommandLine (IN PUNICODE_STRING CommandLine, OUT PULONG Flags, OUT PUNICODE_STRING FileName, OUT PUNICODE_STRING Directory, OUT PUNICODE_STRING Arguments)
 
BOOLEAN NTAPI SmpQueryRegistrySosOption (VOID)
 
BOOLEAN NTAPI SmpSaveAndClearBootStatusData (OUT PBOOLEAN BootOkay, OUT PBOOLEAN ShutdownOkay)
 
VOID NTAPI SmpRestoreBootStatusData (IN BOOLEAN BootOkay, IN BOOLEAN ShutdownOkay)
 

Variables

UNICODE_STRING SmpDebugKeyword
 
UNICODE_STRING SmpASyncKeyword
 
UNICODE_STRING SmpAutoChkKeyword
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file smutil.c.

◆ VALUE_BUFFER_SIZE

#define VALUE_BUFFER_SIZE   (sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 512)

Definition at line 23 of file smutil.c.

Typedef Documentation

◆ PSMP_PRIVILEGE_STATE

◆ SMP_PRIVILEGE_STATE

Function Documentation

◆ SmpAcquirePrivilege()

NTSTATUS NTAPI SmpAcquirePrivilege ( IN ULONG  Privilege,
OUT PVOID PrivilegeState 
)

Definition at line 40 of file smutil.c.

42{
44 ULONG Size;
46
47 /* Assume failure */
48 *PrivilegeState = NULL;
49
50 /* Acquire the state structure to hold everything we need */
52 0,
53 sizeof(SMP_PRIVILEGE_STATE) +
54 sizeof(TOKEN_PRIVILEGES) +
55 sizeof(LUID_AND_ATTRIBUTES));
56 if (!State) return STATUS_NO_MEMORY;
57
58 /* Open our token */
61 &State->TokenHandle);
62 if (!NT_SUCCESS(Status))
63 {
64 /* Fail */
66 return Status;
67 }
68
69 /* Set one privilege in the enabled state */
70 State->NewPrivileges = &State->NewBuffer;
71 State->OldPrivileges = (PTOKEN_PRIVILEGES)&State->OldBuffer;
72 State->NewPrivileges->PrivilegeCount = 1;
73 State->NewPrivileges->Privileges[0].Luid = RtlConvertUlongToLuid(Privilege);
74 State->NewPrivileges->Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
75
76 /* Adjust the privileges in the token */
77 Size = sizeof(State->OldBuffer);
79 FALSE,
80 State->NewPrivileges,
81 Size,
82 State->OldPrivileges,
83 &Size);
85 {
86 /* Our static buffer is not big enough, allocate a bigger one */
87 State->OldPrivileges = RtlAllocateHeap(SmpHeap, 0, Size);
88 if (!State->OldPrivileges)
89 {
90 /* Out of memory, fail */
92 goto Quickie;
93 }
94
95 /* Now try again */
97 FALSE,
98 State->NewPrivileges,
99 Size,
100 State->OldPrivileges,
101 &Size);
102 }
103
104 /* Normalize failure code and check for success */
106 if (NT_SUCCESS(Status))
107 {
108 /* We got the privilege, return */
109 *PrivilegeState = State;
110 return STATUS_SUCCESS;
111 }
112
113Quickie:
114 /* Check if we used a dynamic buffer */
115 if (State->OldPrivileges != (PTOKEN_PRIVILEGES)&State->OldBuffer)
116 {
117 /* Free it */
118 RtlFreeHeap(SmpHeap, 0, State->OldPrivileges);
119 }
120
121 /* Close the token handle and free the state structure */
122 NtClose(State->TokenHandle);
124 return Status;
125}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSTATUS NTAPI NtOpenProcessToken(IN HANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, OUT PHANDLE TokenHandle)
Definition: security.c:350
#define STATUS_NOT_ALL_ASSIGNED
Definition: ntstatus.h:85
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
PVOID SmpHeap
Definition: sminit.c:25
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtAdjustPrivilegesToken(_In_ HANDLE TokenHandle, _In_ BOOLEAN DisableAllPrivileges, _In_opt_ PTOKEN_PRIVILEGES NewState, _In_ ULONG BufferLength, _Out_writes_bytes_to_opt_(BufferLength, *ReturnLength) PTOKEN_PRIVILEGES PreviousState, _When_(PreviousState!=NULL, _Out_) PULONG ReturnLength)
Removes a certain amount of privileges of a token based upon the request by the caller.
Definition: tokenadj.c:451
uint32_t ULONG
Definition: typedefs.h:59
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
FORCEINLINE LUID NTAPI_INLINE RtlConvertUlongToLuid(_In_ ULONG Val)
Definition: rtlfuncs.h:3541
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by _main(), SmpLoadSubSystem(), and SmpLoadSubSystemsForMuSession().

◆ SmpParseCommandLine()

NTSTATUS NTAPI SmpParseCommandLine ( IN PUNICODE_STRING  CommandLine,
OUT PULONG  Flags,
OUT PUNICODE_STRING  FileName,
OUT PUNICODE_STRING  Directory,
OUT PUNICODE_STRING  Arguments 
)

Definition at line 233 of file smutil.c.

238{
240 UNICODE_STRING EnvString, PathString, CmdLineCopy, Token;
241 WCHAR PathBuffer[MAX_PATH];
242 PWCHAR FilePart;
244 UNICODE_STRING FullPathString;
245
246 /* Initialize output arguments to NULL */
248 RtlInitUnicodeString(Arguments, NULL);
250
251 /* Check if we haven't yet built a full default path or system root yet */
253 {
254 /* Initialize it based on shared user data string */
256
257 /* Allocate an empty string for the path */
259 sizeof(L"\\system32;");
260 RtlInitEmptyUnicodeString(&FullPathString,
262 (USHORT)Length);
263 if (FullPathString.Buffer)
264 {
265 /* Append the root, system32;, and then the current library path */
267 RtlAppendUnicodeToString(&FullPathString, L"\\system32;");
270 SmpDefaultLibPath = FullPathString;
271 }
272 }
273
274 /* Consume the command line */
275 CmdLineCopy = *CommandLine;
276 while (TRUE)
277 {
278 /* Parse the first token and check for modifiers/specifiers */
279 Status = SmpParseToken(&CmdLineCopy, FALSE, &Token);
280 if (!(NT_SUCCESS(Status)) || !(Token.Buffer)) return STATUS_UNSUCCESSFUL;
281 if (!Flags) break;
282
283 /* Debug requested? */
285 {
286 /* Convert into a flag */
288 }
290 {
291 /* Asynch requested, convert into a flag */
293 }
295 {
296 /* Autochk requested, convert into a flag */
298 }
299 else
300 {
301 /* No specifier found, keep going */
302 break;
303 }
304
305 /* Get rid of this token and get the next */
306 RtlFreeHeap(SmpHeap, 0, Token.Buffer);
307 }
308
309 /* Initialize a string to hold the current path */
310 RtlInitUnicodeString(&EnvString, L"Path");
312 RtlInitEmptyUnicodeString(&PathString,
314 (USHORT)Length);
315 if (!PathString.Buffer)
316 {
317 /* Fail if we have no memory for this */
318 RtlFreeHeap(SmpHeap, 0, Token.Buffer);
320 }
321
322 /* Query the path from the environment */
324 &EnvString,
325 &PathString);
327 {
328 /* Our buffer was too small, free it */
329 RtlFreeHeap(SmpHeap, 0, PathString.Buffer);
330
331 /* And allocate one big enough */
332 Length = PathString.Length + sizeof(UNICODE_NULL);
333 RtlInitEmptyUnicodeString(&PathString,
335 (USHORT)Length);
336 if (!PathString.Buffer)
337 {
338 /* Fail if we have no memory for this */
339 RtlFreeHeap(SmpHeap, 0, Token.Buffer);
341 }
342
343 /* Now try again, this should work */
345 &EnvString,
346 &PathString);
347 }
348 if (!NT_SUCCESS(Status))
349 {
350 /* Another failure means that the kernel hasn't passed the path correctly */
351 DPRINT1("SMSS: %wZ environment variable not defined.\n", &EnvString);
353 }
354 else
355 {
356 /* Check if the caller expects any flags out of here */
357 if (Flags)
358 {
359 /* We can return the image not found flag -- so does the image exist */
360 if (!(RtlDosSearchPath_U(PathString.Buffer,
361 Token.Buffer,
362 L".exe",
363 sizeof(PathBuffer),
364 PathBuffer,
365 &FilePart)) &&
367 Token.Buffer,
368 L".exe",
369 sizeof(PathBuffer),
370 PathBuffer,
371 &FilePart)))
372 {
373 /* It doesn't, let the caller know about it and exit */
375 *FileName = Token;
376 RtlFreeHeap(SmpHeap, 0, PathString.Buffer);
377 return STATUS_SUCCESS;
378 }
379 }
380 else
381 {
382 /* Caller doesn't want flags, probably wants the image itself */
383 RtlStringCbCopyW(PathBuffer, sizeof(PathBuffer), Token.Buffer);
384 }
385 }
386
387 /* Free tokens and such, all that's left is to convert the image name */
388 RtlFreeHeap(SmpHeap, 0, Token.Buffer);
389 RtlFreeHeap(SmpHeap, 0, PathString.Buffer);
390 if (!NT_SUCCESS(Status)) return Status;
391
392 /* Convert it and bail out if this failed */
394 {
395 DPRINT1("SMSS: Unable to translate %ws into an NT File Name\n",
396 &PathBuffer);
398 }
399 if (!NT_SUCCESS(Status)) return Status;
400
401 /* Finally, check if the caller also wanted the directory */
402 if (Directory)
403 {
404 /* Is the file a relative name with no directory? */
405 if (FilePart <= PathBuffer)
406 {
407 /* Clear it */
409 }
410 else
411 {
412 /* There is a directory, and a filename -- separate those two */
413 *--FilePart = UNICODE_NULL;
415 }
416 }
417
418 /* We are done -- move on to the second pass to get the arguments */
419 return SmpParseToken(&CmdLineCopy, TRUE, Arguments);
420}
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define TRUE
Definition: types.h:120
#define MAX_PATH
Definition: compat.h:34
#define PAGE_SIZE
Definition: env_spec_w32.h:49
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
NTSYSAPI ULONG NTAPI RtlDosSearchPath_U(_In_ PCWSTR Path, _In_ PCWSTR FileName, _In_ PCWSTR Extension, _In_ ULONG BufferSize, _Out_ PWSTR Buffer, _Out_ PWSTR *PartName)
NTSYSAPI NTSTATUS NTAPI RtlQueryEnvironmentVariable_U(_In_opt_ PWSTR Environment, _In_ PCUNICODE_STRING Name, _Out_ PUNICODE_STRING Value)
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_OBJECT_PATH_INVALID
Definition: ntstatus.h:293
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
#define SharedUserData
ULONG SmBaseTag
Definition: sminit.c:26
UNICODE_STRING SmpDefaultLibPath
Definition: sminit.c:29
PWCHAR SmpDefaultEnvironment
Definition: sminit.c:28
UNICODE_STRING SmpSystemRoot
Definition: smss.c:20
#define SMP_AUTOCHK_FLAG
Definition: smss.h:46
#define SMP_DEBUG_FLAG
Definition: smss.h:44
#define SMP_INVALID_PATH
Definition: smss.h:48
#define SMP_ASYNC_FLAG
Definition: smss.h:45
NTSTATUS NTAPI SmpParseToken(IN PUNICODE_STRING Input, IN BOOLEAN SecondPass, OUT PUNICODE_STRING Token)
Definition: smutil.c:155
UNICODE_STRING SmpAutoChkKeyword
Definition: smutil.c:34
UNICODE_STRING SmpDebugKeyword
Definition: smutil.c:34
UNICODE_STRING SmpASyncKeyword
Definition: smutil.c:34
base for all directory entries
Definition: entries.h:138
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by SmpCreatePagingFileDescriptor(), SmpExecuteCommand(), and SmpExecuteInitialCommand().

◆ SmpParseToken()

NTSTATUS NTAPI SmpParseToken ( IN PUNICODE_STRING  Input,
IN BOOLEAN  SecondPass,
OUT PUNICODE_STRING  Token 
)

Definition at line 155 of file smutil.c.

158{
159 PWCHAR p, pp;
160 ULONG Length, TokenLength, InputLength;
161
162 /* Initialize to NULL to start with */
164
165 /* Save the input length */
166 InputLength = Input->Length;
167
168 /* If the input string is empty, just return */
169 if (InputLength == 0) return STATUS_SUCCESS;
170
171 /* Parse the buffer until the first character */
172 p = Input->Buffer;
173 Length = 0;
174 while (Length < InputLength)
175 {
176 if (*p > L' ') break;
177 ++p;
178 Length += sizeof(WCHAR);
179 }
180
181 /* Are we being called for argument pick-up? */
182 if (SecondPass)
183 {
184 /* Then assume everything else is an argument */
185 TokenLength = InputLength - Length * sizeof(WCHAR);
186 pp = (PWSTR)((ULONG_PTR)p + TokenLength);
187 }
188 else
189 {
190 /* No -- so loop until the next space */
191 pp = p;
192 while (Length < InputLength)
193 {
194 if (*pp <= L' ') break;
195 ++pp;
196 Length += sizeof(WCHAR);
197 }
198
199 /* Now compute how long this token is, and loop until the next char */
201 while (Length < InputLength)
202 {
203 if (*pp > L' ') break;
204 ++pp;
205 Length += sizeof(WCHAR);
206 }
207 }
208
209 /* Did we find a token? */
210 if (TokenLength)
211 {
212 /* Allocate a buffer for it */
213 Token->Buffer = RtlAllocateHeap(SmpHeap,
214 SmBaseTag,
215 TokenLength + sizeof(UNICODE_NULL));
216 if (!Token->Buffer) return STATUS_NO_MEMORY;
217
218 /* Fill in the unicode string to hold it */
219 Token->MaximumLength = (USHORT)(TokenLength + sizeof(UNICODE_NULL));
220 Token->Length = (USHORT)TokenLength;
221 RtlCopyMemory(Token->Buffer, p, TokenLength);
222 Token->Buffer[TokenLength / sizeof(WCHAR)] = UNICODE_NULL;
223 }
224
225 /* Modify the input string with the position of where the next token begins */
226 Input->Length -= (USHORT)((ULONG_PTR)pp - (ULONG_PTR)Input->Buffer);
227 Input->Buffer = pp;
228 return STATUS_SUCCESS;
229}
#define ULONG_PTR
Definition: config.h:101
GLfloat GLfloat p
Definition: glext.h:8902
@ Input
Definition: arc.h:84
int TokenLength(const char *pc)
Definition: spec2def.c:191
uint16_t * PWSTR
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by SmpParseCommandLine().

◆ SmpQueryRegistrySosOption()

BOOLEAN NTAPI SmpQueryRegistrySosOption ( VOID  )

Definition at line 424 of file smutil.c.

425{
431 WCHAR ValueBuffer[VALUE_BUFFER_SIZE];
432 PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)ValueBuffer;
433
434 /* Open the key */
436 L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
438 &KeyName,
440 NULL,
441 NULL);
443 if (!NT_SUCCESS(Status))
444 {
445 DPRINT1("SMSS: Cannot open control key (Status 0x%x)\n", Status);
446 return FALSE;
447 }
448
449 /* Query the value */
450 RtlInitUnicodeString(&ValueName, L"SystemStartOptions");
452 &ValueName,
454 PartialInfo,
455 sizeof(ValueBuffer),
456 &Length);
459 if (!NT_SUCCESS(Status) ||
460 ((PartialInfo->Type != REG_SZ) && (PartialInfo->Type != REG_EXPAND_SZ)))
461 {
462 DPRINT1("SMSS: Cannot query value key (Type %lu, Status 0x%x)\n",
463 PartialInfo->Type, Status);
464 return FALSE;
465 }
466
467 /* Check if it's set to SOS or sos */
468 if (!(wcsstr((PWCHAR)PartialInfo->Data, L"SOS")) ||
469 (wcsstr((PWCHAR)PartialInfo->Data, L"sos")))
470 {
471 /* It's not set, return FALSE */
472 return FALSE;
473 }
474
475 /* It's set, return TRUE */
476 return TRUE;
477}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define REG_SZ
Definition: layer.c:22
#define ASSERT(a)
Definition: mode.c:44
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
@ KeyValuePartialInformation
Definition: nt_native.h:1182
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define VALUE_BUFFER_SIZE
Definition: smutil.c:23
void * PVOID
Definition: typedefs.h:50
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

Referenced by SmpInvokeAutoChk().

◆ SmpReleasePrivilege()

VOID NTAPI SmpReleasePrivilege ( IN PVOID  PrivState)

Definition at line 129 of file smutil.c.

130{
132
133 /* Adjust the privileges in the token */
134 NtAdjustPrivilegesToken(State->TokenHandle,
135 FALSE,
136 State->OldPrivileges,
137 0,
138 NULL,
139 NULL);
140
141 /* Check if we used a dynamic buffer */
142 if (State->OldPrivileges != (PTOKEN_PRIVILEGES)&State->OldBuffer)
143 {
144 /* Free it */
145 RtlFreeHeap(SmpHeap, 0, State->OldPrivileges);
146 }
147
148 /* Close the token handle and free the state structure */
149 NtClose(State->TokenHandle);
151}
struct _SMP_PRIVILEGE_STATE * PSMP_PRIVILEGE_STATE

Referenced by _main(), SmpLoadSubSystem(), and SmpLoadSubSystemsForMuSession().

◆ SmpRestoreBootStatusData()

VOID NTAPI SmpRestoreBootStatusData ( IN BOOLEAN  BootOkay,
IN BOOLEAN  ShutdownOkay 
)

Definition at line 531 of file smutil.c.

533{
535 PVOID BootState;
536
537 /* Lock the BSD */
538 Status = RtlLockBootStatusData(&BootState);
539 if (NT_SUCCESS(Status))
540 {
541 /* Write the bootokay and bootshutdown values */
542 RtlGetSetBootStatusData(BootState,
543 FALSE,
545 &BootOkay,
546 sizeof(BootOkay),
547 NULL);
548 RtlGetSetBootStatusData(BootState,
549 FALSE,
551 &ShutdownOkay,
552 sizeof(ShutdownOkay),
553 NULL);
554
555 /* Unlock the BSD and return */
556 RtlUnlockBootStatusData(BootState);
557 }
558}
@ RtlBsdItemBootShutdown
Definition: rtltypes.h:431
@ RtlBsdItemBootGood
Definition: rtltypes.h:430
NTSTATUS NTAPI RtlLockBootStatusData(_Out_ PHANDLE FileHandle)
Definition: bootdata.c:231
NTSTATUS NTAPI RtlGetSetBootStatusData(_In_ HANDLE FileHandle, _In_ BOOLEAN Read, _In_ RTL_BSD_ITEM_TYPE DataClass, _In_ PVOID Buffer, _In_ ULONG BufferSize, _Out_opt_ PULONG ReturnLength)
Definition: bootdata.c:161
NTSTATUS NTAPI RtlUnlockBootStatusData(_In_ HANDLE FileHandle)
Definition: bootdata.c:267

Referenced by SmpInvokeAutoChk().

◆ SmpSaveAndClearBootStatusData()

BOOLEAN NTAPI SmpSaveAndClearBootStatusData ( OUT PBOOLEAN  BootOkay,
OUT PBOOLEAN  ShutdownOkay 
)

Definition at line 481 of file smutil.c.

483{
486 PVOID BootStatusDataHandle;
487
488 /* Assume failure */
489 *BootOkay = FALSE;
490 *ShutdownOkay = FALSE;
491
492 /* Lock the BSD and fail if we couldn't */
493 Status = RtlLockBootStatusData(&BootStatusDataHandle);
494 if (!NT_SUCCESS(Status)) return FALSE;
495
496 /* Read the old settings */
497 RtlGetSetBootStatusData(BootStatusDataHandle,
498 TRUE,
500 BootOkay,
501 sizeof(BOOLEAN),
502 NULL);
503 RtlGetSetBootStatusData(BootStatusDataHandle,
504 TRUE,
506 ShutdownOkay,
507 sizeof(BOOLEAN),
508 NULL);
509
510 /* Set new ones indicating we got at least this far */
511 RtlGetSetBootStatusData(BootStatusDataHandle,
512 FALSE,
514 &Value,
515 sizeof(Value),
516 NULL);
517 RtlGetSetBootStatusData(BootStatusDataHandle,
518 FALSE,
520 &Value,
521 sizeof(Value),
522 NULL);
523
524 /* Unlock the BSD and return */
525 RtlUnlockBootStatusData(BootStatusDataHandle);
526 return TRUE;
527}
unsigned char BOOLEAN
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by SmpInvokeAutoChk().

Variable Documentation

◆ SmpASyncKeyword

UNICODE_STRING SmpASyncKeyword

Definition at line 34 of file smutil.c.

Referenced by SmpParseCommandLine().

◆ SmpAutoChkKeyword

UNICODE_STRING SmpAutoChkKeyword

Definition at line 34 of file smutil.c.

Referenced by SmpParseCommandLine().

◆ SmpDebugKeyword

UNICODE_STRING SmpDebugKeyword

Definition at line 34 of file smutil.c.

Referenced by SmpLoadDataFromRegistry(), and SmpParseCommandLine().