ReactOS 0.4.15-dev-8052-gc0e3179
rosload.c File Reference
#include "rosload.h"
Include dependency graph for rosload.c:

Go to the source code of this file.

Functions

NTSTATUS OslArchTransferToKernel (_In_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ PVOID KernelEntrypoint)
 
VOID OslFatalErrorEx (_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3)
 
VOID OslAbortBoot (_In_ NTSTATUS Status)
 
NTSTATUS OslBlStatusErrorHandler (_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3, _In_ ULONG_PTR Parameter4)
 
VOID OslpSanitizeLoadOptionsString (_In_ PWCHAR OptionString, _In_ PWCHAR SanitizeString)
 
VOID OslpSanitizeStringOptions (_In_ PBL_BCD_OPTION BcdOptions)
 
NTSTATUS OslpRemoveInternalApplicationOptions (VOID)
 
NTSTATUS OslpCheckForcedFailure (VOID)
 
VOID OslpInitializeBootStatusDataLog (VOID)
 
NTSTATUS OslpReadWriteBootStatusData (_In_ BOOLEAN WriteAccess)
 
NTSTATUS OslpGetSetBootStatusData (_In_ BOOLEAN Read, _In_ RTL_BSD_ITEM_TYPE DataClass, _Out_ PVOID Buffer, _Inout_ PULONG Size)
 
NTSTATUS OslSetBootStatusData (_In_ BOOLEAN LastBootGood, _In_ BOOLEAN LastBootShutdown, _In_ BOOLEAN LastBootCheckpoint, _In_ ULONG UpdateIncrement, _In_ ULONG BootAttemptCount)
 
NTSTATUS OslGetBootStatusData (_Out_ PBOOLEAN LastBootGood, _Out_ PBOOLEAN LastBootShutdown, _Out_ PBOOLEAN LastBootCheckpoint, _Out_ PULONG LastBootId, _Out_ PBOOLEAN BootGood, _Out_ PBOOLEAN BootShutdown)
 
BOOLEAN OslpAdvancedOptionsRequested (VOID)
 
NTSTATUS OslPrepareTarget (_Out_ PULONG ReturnFlags, _Out_ PBOOLEAN Jump)
 
NTSTATUS OslFwpKernelSetupPhase1 (_In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS OslArchpKernelSetupPhase0 (_In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID ArchRestoreProcessorFeatures (VOID)
 
NTSTATUS OslArchKernelSetup (_In_ ULONG Phase, _In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS OslExecuteTransition (VOID)
 
NTSTATUS OslpMain (_Out_ PULONG ReturnFlags)
 
NTSTATUS NTAPI OslMain (_In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootParameters)
 

Variables

PLOADER_PARAMETER_BLOCK OslLoaderBlock
 
PVOID OslEntryPoint
 
PVOID UserSharedAddress
 
ULONGLONG ArchXCr0BitsToClear
 
ULONGLONG ArchCr4BitsToClear
 
BOOLEAN BdDebugAfterExitBootServices
 
KDESCRIPTOR OslKernelGdt
 
KDESCRIPTOR OslKernelIdt
 
ULONG_PTR OslImcHiveHandle
 
ULONG_PTR OslMachineHiveHandle
 
ULONG_PTR OslElamHiveHandle
 
ULONG_PTR OslSystemHiveHandle
 
PBL_DEVICE_DESCRIPTOR OslLoadDevice
 
PCHAR OslLoadOptions
 
PWCHAR OslSystemRoot
 
LIST_ENTRY OslFreeMemoryDesctiptorsList
 
LIST_ENTRY OslFinalMemoryMap
 
LIST_ENTRY OslCoreExtensionSubGroups [2]
 
LIST_ENTRY OslLoadedFirmwareDriverList
 
BL_BUFFER_DESCRIPTOR OslFinalMemoryMapDescriptorsBuffer
 
GUID OslApplicationIdentifier
 
ULONG OslResetBootStatus
 
BOOLEAN OslImcProcessingValid
 
ULONG OslFreeMemoryDesctiptorsListSize
 
PVOID OslMemoryDescriptorBuffer
 
BcdObjectType BlpSbdiCurrentApplicationType
 
PRTL_BSD_DATA BsdBootStatusData
 
OSL_BSD_ITEM_TABLE_ENTRY OslpBootStatusFields [RtlBsdItemMax]
 
ULONG OslBootAttemptCount
 
ULONG OslBootCountUpdateRequestForAbort
 
ULONG OslBootAttemptMaximum
 
ULONG OslBootCountUpdateIncrement
 
BOOLEAN OslCurrentBootCheckpoint
 
BOOLEAN OslCurrentBootSucceeded
 
BOOLEAN OslCurrentBootShutdown
 

Function Documentation

◆ ArchRestoreProcessorFeatures()

VOID ArchRestoreProcessorFeatures ( VOID  )

Definition at line 877 of file rosload.c.

880{
881 /* Any XCR0 bits to clear? */
883 {
884 /* Clear them */
885#if defined(_MSC_VER) && !defined(__clang__) && !defined(_M_ARM)
886 __xsetbv(0, __xgetbv(0) & ~ArchXCr0BitsToClear);
887#endif
889 }
890
891 /* Any CR4 bits to clear? */
893 {
894 /* Clear them */
895#if !defined(_M_ARM)
897#endif
899 }
900}
__INTRIN_INLINE unsigned long __readcr4(void)
Definition: intrin_x86.h:1825
__INTRIN_INLINE void __writecr4(unsigned int Data)
Definition: intrin_x86.h:1799
ULONGLONG ArchXCr0BitsToClear
Definition: rosload.c:24
ULONGLONG ArchCr4BitsToClear
Definition: rosload.c:25

Referenced by OslArchKernelSetup().

◆ OslAbortBoot()

VOID OslAbortBoot ( _In_ NTSTATUS  Status)

Definition at line 150 of file rosload.c.

153{
154 /* For now just do this */
155 BlStatusPrint(L"BOOT ABORTED: %lx\n", Status);
156}
VOID BlStatusPrint(_In_ PCWCH Format,...)
Definition: debug.c:75
Status
Definition: gdiplustypes.h:25
#define L(x)
Definition: ntvdm.h:50

Referenced by OslPrepareTarget().

◆ OslArchKernelSetup()

NTSTATUS OslArchKernelSetup ( _In_ ULONG  Phase,
_In_ PLOADER_PARAMETER_BLOCK  LoaderBlock 
)

Definition at line 903 of file rosload.c.

907{
908 /* For phase 0, do architectural setup */
909 if (Phase == 0)
910 {
911 return OslArchpKernelSetupPhase0(LoaderBlock);
912 }
913
914 /* Nothing to do for Phase 1 */
915 if (Phase == 1)
916 {
917 return STATUS_SUCCESS;
918 }
919
920 /* Relocate the self map */
922
923 /* Zero out the HAL Heap */
926
927 /* Move shared user data in its place */
930 PAGE_SIZE);
931
932 /* Clear XCR0/CR4 CPU features that should be disabled before boot */
934
935 /* Good to go */
936 return STATUS_SUCCESS;
937}
PBL_MM_RELOCATE_SELF_MAP BlMmRelocateSelfMap
Definition: arch.c:16
PBL_MM_MOVE_VIRTUAL_ADDRESS_RANGE BlMmMoveVirtualAddressRange
Definition: arch.c:17
PBL_MM_ZERO_VIRTUAL_ADDRESS_RANGE BlMmZeroVirtualAddressRange
Definition: arch.c:18
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define MM_HAL_VA_END
Definition: ketypes.h:338
#define MM_HAL_VA_START
Definition: ketypes.h:337
NTSTATUS OslArchpKernelSetupPhase0(_In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: rosload.c:869
VOID ArchRestoreProcessorFeatures(VOID)
Definition: rosload.c:877
PVOID UserSharedAddress
Definition: rosload.c:23
#define KI_USER_SHARED_DATA
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by OslExecuteTransition().

◆ OslArchpKernelSetupPhase0()

NTSTATUS OslArchpKernelSetupPhase0 ( _In_ PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 869 of file rosload.c.

872{
874}
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

Referenced by OslArchKernelSetup().

◆ OslArchTransferToKernel()

NTSTATUS OslArchTransferToKernel ( _In_ PLOADER_PARAMETER_BLOCK  LoaderBlock,
_In_ PVOID  KernelEntrypoint 
)

Referenced by OslExecuteTransition().

◆ OslBlStatusErrorHandler()

NTSTATUS OslBlStatusErrorHandler ( _In_ ULONG  ErrorCode,
_In_ ULONG  Parameter1,
_In_ ULONG_PTR  Parameter2,
_In_ ULONG_PTR  Parameter3,
_In_ ULONG_PTR  Parameter4 
)

Definition at line 159 of file rosload.c.

166{
167 /* We only filter error code 4 */
168 if (ErrorCode != 4)
169 {
171 }
172
173 /* Handle error 4 as a fatal error 3 internally */
174 OslFatalErrorEx(3, Parameter1, Parameter2, Parameter3);
175 return STATUS_SUCCESS;
176}
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
VOID OslFatalErrorEx(_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3)
Definition: rosload.c:138

Referenced by OslPrepareTarget().

◆ OslExecuteTransition()

NTSTATUS OslExecuteTransition ( VOID  )

Definition at line 940 of file rosload.c.

943{
945
946 /* Is the debugger meant to be kept enabled throughout the boot phase? */
948 {
949#ifdef BL_KD_SUPPORT
950 /* No -- disable it */
951 BlBdStop();
952#endif
953 }
954
955 /* Setup Firmware for Phase 1 */
957 if (NT_SUCCESS(Status))
958 {
959 /* Setup kernel for Phase 2 */
961 if (NT_SUCCESS(Status))
962 {
963#ifdef BL_KD_SUPPORT
964 /* Stop the boot debugger */
965 BlBdStop();
966#endif
967 /* Jump to the kernel entrypoint */
969
970 /* Infinite loop if we got here */
971 for (;;);
972 }
973 }
974
975 /* Return back with the failure code */
976 return Status;
977}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS OslArchKernelSetup(_In_ ULONG Phase, _In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: rosload.c:903
PLOADER_PARAMETER_BLOCK OslLoaderBlock
Definition: rosload.c:21
NTSTATUS OslArchTransferToKernel(_In_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ PVOID KernelEntrypoint)
PVOID OslEntryPoint
Definition: rosload.c:22
BOOLEAN BdDebugAfterExitBootServices
Definition: rosload.c:26
NTSTATUS OslFwpKernelSetupPhase1(_In_ PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: rosload.c:861

Referenced by OslpMain().

◆ OslFatalErrorEx()

VOID OslFatalErrorEx ( _In_ ULONG  ErrorCode,
_In_ ULONG  Parameter1,
_In_ ULONG_PTR  Parameter2,
_In_ ULONG_PTR  Parameter3 
)

Definition at line 138 of file rosload.c.

144{
145 /* For now just do this */
146 BlStatusPrint(L"FATAL ERROR IN ROSLOAD: %lx\n", ErrorCode);
147}

Referenced by OslBlStatusErrorHandler(), and OslPrepareTarget().

◆ OslFwpKernelSetupPhase1()

NTSTATUS OslFwpKernelSetupPhase1 ( _In_ PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 861 of file rosload.c.

864{
866}

Referenced by OslExecuteTransition().

◆ OslGetBootStatusData()

NTSTATUS OslGetBootStatusData ( _Out_ PBOOLEAN  LastBootGood,
_Out_ PBOOLEAN  LastBootShutdown,
_Out_ PBOOLEAN  LastBootCheckpoint,
_Out_ PULONG  LastBootId,
_Out_ PBOOLEAN  BootGood,
_Out_ PBOOLEAN  BootShutdown 
)

Definition at line 446 of file rosload.c.

454{
456 ULONG Size;
457 ULONG64 BootStatusPolicy;
458 BOOLEAN localBootShutdown, localBootGood;
459
460 /* Capture the BSD data in our globals, if needed */
462 if (!NT_SUCCESS(Status))
463 {
464 goto Quickie;
465 }
466
467 /* Read the last boot ID */
468 Size = sizeof(*LastBootId);
470 if (!NT_SUCCESS(Status))
471 {
472 /* Set to zero if we couldn't find it */
473 *LastBootId = 0;
474 }
475
476 /* Get the boot status policy */
479 &BootStatusPolicy);
480 if (!NT_SUCCESS(Status))
481 {
482 /* Apply a default if none exists */
483 BootStatusPolicy = IgnoreShutdownFailures;
484 }
485
486 /* Check if this was a good shutdown */
487 Size = sizeof(localBootShutdown);
490 &localBootShutdown,
491 &Size);
492 if (!NT_SUCCESS(Status))
493 {
494 goto Quickie;
495 }
496
497 /* Tell the caller */
498 *BootShutdown = localBootShutdown;
499
500 /* Check if this was a good boot */
501 Size = sizeof(localBootGood);
504 &localBootGood,
505 &Size);
506 if (!NT_SUCCESS(Status))
507 {
508 goto Quickie;
509 }
510
511 /* Tell the caller*/
512 *BootGood = localBootGood;
513
514 /* TODO: Additional logic for checkpoints and such */
516
517Quickie:
518 return Status;
519}
unsigned char BOOLEAN
@ BcdOSLoaderInteger_BootStatusPolicy
Definition: bcd.h:159
@ IgnoreShutdownFailures
Definition: bcd.h:213
BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry
Definition: bootlib.c:19
NTSTATUS BlGetBootOptionInteger(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PULONGLONG Value)
Definition: bcdopt.c:467
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned __int64 ULONG64
Definition: imports.h:198
@ RtlBsdItemBootShutdown
Definition: rtltypes.h:431
@ RtlBsdItemBootGood
Definition: rtltypes.h:430
@ RtlBsdItemBootId
Definition: rtltypes.h:436
NTSTATUS OslpReadWriteBootStatusData(_In_ BOOLEAN WriteAccess)
Definition: rosload.c:283
NTSTATUS OslpGetSetBootStatusData(_In_ BOOLEAN Read, _In_ RTL_BSD_ITEM_TYPE DataClass, _Out_ PVOID Buffer, _Inout_ PULONG Size)
Definition: rosload.c:308
PBL_BCD_OPTION BcdData
Definition: bl.h:867
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by OslPrepareTarget().

◆ OslMain()

Definition at line 1055 of file rosload.c.

1058{
1059 BL_LIBRARY_PARAMETERS LibraryParameters;
1061 PBL_RETURN_ARGUMENTS ReturnArguments;
1062 PBL_APPLICATION_ENTRY AppEntry;
1063 CPU_INFO CpuInfo;
1064 ULONG Flags;
1065
1066 /* Get the return arguments structure, and set our version */
1067 ReturnArguments = (PBL_RETURN_ARGUMENTS)((ULONG_PTR)BootParameters +
1068 BootParameters->ReturnArgumentsOffset);
1069 ReturnArguments->Version = BL_RETURN_ARGUMENTS_VERSION;
1070
1071 /* Get the application entry, and validate it */
1072 AppEntry = (PBL_APPLICATION_ENTRY)((ULONG_PTR)BootParameters +
1073 BootParameters->AppEntryOffset);
1074 if (!RtlEqualMemory(AppEntry->Signature,
1076 sizeof(AppEntry->Signature)))
1077 {
1078 /* Unrecognized, bail out */
1080 goto Quickie;
1081 }
1082
1083#if !defined(_M_ARM)
1084 /* Check if CPUID 01h is supported */
1086 {
1087 /* Query CPU features */
1088 BlArchCpuId(1, 0, &CpuInfo);
1089
1090 /* Check if PAE is supported */
1091 if (CpuInfo.Edx & 0x40)
1092 {
1093 EfiPrintf(L"PAE Supported, but won't be used\r\n");
1094 }
1095 }
1096#endif
1097
1098 /* Setup the boot library parameters for this application */
1099 BlSetupDefaultParameters(&LibraryParameters);
1100 LibraryParameters.TranslationType = BlVirtual;
1103 LibraryParameters.MinimumAllocationCount = 1024;
1104 LibraryParameters.MinimumHeapSize = 2 * 1024 * 1024;
1106 LibraryParameters.FontBaseDirectory = L"\\Reactos\\Boot\\Fonts";
1107 LibraryParameters.DescriptorCount = 512;
1108
1109 /* Initialize the boot library */
1110 Status = BlInitializeLibrary(BootParameters, &LibraryParameters);
1111 if (NT_SUCCESS(Status))
1112 {
1113 /* For testing, draw the logo */
1114 OslDrawLogo();
1115
1116 /* Call the main routine */
1117 Status = OslpMain(&Flags);
1118
1119 /* Return the flags, and destroy the boot library */
1120 ReturnArguments->Flags = Flags;
1122 }
1123
1124Quickie:
1125 /* Return back to boot manager */
1126 ReturnArguments->Status = Status;
1127 return Status;
1128}
NTSTATUS BlInitializeLibrary(_In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters, _In_ PBL_LIBRARY_PARAMETERS LibraryParameters)
Definition: bootlib.c:355
VOID BlArchCpuId(_In_ ULONG Function, _In_ ULONG SubFunction, _Out_ PCPU_INFO Result)
Definition: util.c:924
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
@ BlVirtual
Definition: bl.h:231
struct _BL_RETURN_ARGUMENTS * PBL_RETURN_ARGUMENTS
struct _BL_APPLICATION_ENTRY * PBL_APPLICATION_ENTRY
BOOLEAN BlArchIsCpuIdFunctionSupported(_In_ ULONG Function)
Definition: util.c:856
FORCEINLINE VOID BlSetupDefaultParameters(_Out_ PBL_LIBRARY_PARAMETERS LibraryParameters)
Definition: bl.h:1354
VOID BlDestroyLibrary(VOID)
Definition: bootlib.c:405
#define BL_LIBRARY_FLAG_REINITIALIZE_ALL
Definition: bl.h:129
#define BL_APP_ENTRY_SIGNATURE
Definition: bl.h:53
@ BlMemoryKernelRange
Definition: bl.h:367
#define BL_LIBRARY_FLAG_ZERO_HEAP_ALLOCATIONS_ON_FREE
Definition: bl.h:130
#define BL_RETURN_ARGUMENTS_VERSION
Definition: bl.h:63
#define RtlEqualMemory(a, b, c)
Definition: kdvm.h:18
#define STATUS_INVALID_PARAMETER_9
Definition: ntstatus.h:483
NTSTATUS OslpMain(_Out_ PULONG ReturnFlags)
Definition: rosload.c:980
VOID NTAPI OslDrawLogo(VOID)
Definition: roslogo.c:9767
Definition: bl.h:855
CHAR Signature[8]
Definition: bl.h:856
PWCHAR FontBaseDirectory
Definition: bl.h:764
ULONG MinimumHeapSize
Definition: bl.h:760
ULONG LibraryFlags
Definition: bl.h:757
ULONG HeapAllocationAttributes
Definition: bl.h:761
ULONG DescriptorCount
Definition: bl.h:763
ULONG MinimumAllocationCount
Definition: bl.h:759
ULONG TranslationType
Definition: bl.h:758
ULONG Version
Definition: bl.h:816
NTSTATUS Status
Definition: bl.h:817
uint32_t ULONG_PTR
Definition: typedefs.h:65
ULONG Edx
Definition: ketypes.h:384
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

◆ OslpAdvancedOptionsRequested()

BOOLEAN OslpAdvancedOptionsRequested ( VOID  )

Definition at line 522 of file rosload.c.

525{
526 /* TODO */
527 return FALSE;
528}

Referenced by OslPrepareTarget().

◆ OslpCheckForcedFailure()

NTSTATUS OslpCheckForcedFailure ( VOID  )

Definition at line 249 of file rosload.c.

252{
253 ULONG64 ForceReason;
255
256 /* Read the option */
259 &ForceReason);
260 if (NT_SUCCESS(Status) && (ForceReason < 4))
261 {
262 /* For reasons above 3, don't actually do anything */
263 if (ForceReason > 3)
264 {
265 return STATUS_SUCCESS;
266 }
267 }
268
269 /* If the option isn't there or invalid, always return success */
270 return STATUS_SUCCESS;
271}
@ BcdOSLoaderInteger_ForceFailure
Definition: bcd.h:154

Referenced by OslPrepareTarget().

◆ OslpGetSetBootStatusData()

NTSTATUS OslpGetSetBootStatusData ( _In_ BOOLEAN  Read,
_In_ RTL_BSD_ITEM_TYPE  DataClass,
_Out_ PVOID  Buffer,
_Inout_ PULONG  Size 
)

Definition at line 308 of file rosload.c.

314{
317
318 /* No data has been read yet, fail */
320 {
321 return STATUS_UNSUCCESSFUL;
322 }
323
324 /* Invalid data item, fail */
325 if (DataClass >= RtlBsdItemMax)
326 {
328 }
329
330 /* Capture the length and offset */
331 Length = OslpBootStatusFields[DataClass].Size;
333
334 /* Make sure it doesn't overflow past the structure we've read */
336 {
338 }
339
340 /* Make sure we have enough space */
341 if (*Size >= Length)
342 {
343 /* We do -- is this a read? */
344 if (Read)
345 {
346 /* Yes, copy into the caller's buffer */
349 Length);
350 }
351 else
352 {
353 /* It's a write, copy from caller's buffer */
355 Buffer,
356 Length);
357 }
358
359 /* Set success */
361 }
362 else
363 {
364 /* Return size needed and failure code */
365 *Size = Length;
367 }
368
369 /* All good */
370 return Status;
371}
Definition: bufpool.h:45
@ RtlBsdItemMax
Definition: rtltypes.h:442
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
OSL_BSD_ITEM_TABLE_ENTRY OslpBootStatusFields[RtlBsdItemMax]
Definition: rosload.c:57
PRTL_BSD_DATA BsdBootStatusData
Definition: rosload.c:55
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ BOOLEAN Read
Definition: strmini.h:479
ULONG Offset
Definition: rosload.h:39
ULONG Size
Definition: rosload.h:40
ULONG Version
Definition: rtltypes.h:1334
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by OslGetBootStatusData(), OslPrepareTarget(), and OslSetBootStatusData().

◆ OslpInitializeBootStatusDataLog()

VOID OslpInitializeBootStatusDataLog ( VOID  )

Definition at line 274 of file rosload.c.

277{
278 /* TODO */
279 return;
280}

Referenced by OslPrepareTarget().

◆ OslpMain()

NTSTATUS OslpMain ( _Out_ PULONG  ReturnFlags)

Definition at line 980 of file rosload.c.

983{
985 BOOLEAN ExecuteJump;
986#if !defined(_M_ARM)
987 CPU_INFO CpuInfo;
988 BOOLEAN NxEnabled;
989 LARGE_INTEGER MiscMsr;
990
991 /* Check if the CPU supports NX */
992 BlArchCpuId(0x80000001, 0, &CpuInfo);
993 if (!(CpuInfo.Edx & 0x10000))
994 {
995 /* It doesn't, check if this is Intel */
996 EfiPrintf(L"NX disabled: %lx\r\n", CpuInfo.Edx);
998 {
999 /* Then turn off the MSR disable feature for it, enabling NX */
1001 EfiPrintf(L"NX being turned on: %llx\r\n", MiscMsr.QuadPart);
1002 MiscMsr.HighPart &= MSR_XD_ENABLE_MASK;
1005 NxEnabled = TRUE;
1006 }
1007 }
1008
1009 /* Turn on NX support with the CPU-generic MSR */
1011
1012#endif
1013
1014 /* Load the kernel */
1015 Status = OslPrepareTarget(ReturnFlags, &ExecuteJump);
1016 if (NT_SUCCESS(Status) && (ExecuteJump))
1017 {
1018 /* Jump to the kernel */
1020 }
1021
1022#if !defined(_M_ARM)
1023 /* Retore NX support */
1025
1026 /* Did we manually enable NX? */
1027 if (NxEnabled)
1028 {
1029 /* Turn it back off */
1031 MiscMsr.HighPart |= ~MSR_XD_ENABLE_MASK;
1033 }
1034
1035#endif
1036 /* Go back */
1037 return Status;
1038}
CPU_VENDORS BlArchGetCpuVendor(VOID)
Definition: util.c:937
PPC_QUAL void __writemsr(const unsigned long Value)
Definition: intrin_ppc.h:748
PPC_QUAL unsigned long long __readmsr()
Definition: intrin_ppc.h:741
#define MSR_EFER
Definition: ketypes.h:247
#define MSR_XD_ENABLE_MASK
Definition: ketypes.h:286
@ CPU_INTEL
Definition: ketypes.h:106
#define MSR_IA32_MISC_ENABLE
Definition: ketypes.h:257
#define MSR_NXE
Definition: ketypes.h:279
NTSTATUS OslExecuteTransition(VOID)
Definition: rosload.c:940
NTSTATUS OslPrepareTarget(_Out_ PULONG ReturnFlags, _Out_ PBOOLEAN Jump)
Definition: rosload.c:531
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by OslMain().

◆ OslpReadWriteBootStatusData()

NTSTATUS OslpReadWriteBootStatusData ( _In_ BOOLEAN  WriteAccess)

Definition at line 283 of file rosload.c.

286{
287 /* Are you trying to write? */
288 if (WriteAccess)
289 {
290 /* Have we already read? */
292 {
293 /* No -- fail */
294 return STATUS_UNSUCCESSFUL;
295 }
296 }
297 else if (BsdBootStatusData)
298 {
299 /* No -- you're trying to read and we already have the data: no-op */
300 return STATUS_SUCCESS;
301 }
302
303 /* TODO */
305}
@ WriteAccess
Definition: iotypes.h:425

Referenced by OslGetBootStatusData(), OslPrepareTarget(), and OslSetBootStatusData().

◆ OslpRemoveInternalApplicationOptions()

NTSTATUS OslpRemoveInternalApplicationOptions ( VOID  )

Definition at line 198 of file rosload.c.

201{
204
205 /* Assume success */
207
208 /* Remove attempts to disable integrity checks or ELAM driver load */
213
214 /* Get the command-line parameters, if any */
217 &LoadString);
218 if (NT_SUCCESS(Status))
219 {
220 /* Conver to upper case */
222
223 /* Remove the existing one */
226
227 /* Sanitize strings we don't want */
228 OslpSanitizeLoadOptionsString(LoadString, L"DISABLE_INTEGRITY_CHECKS");
229 OslpSanitizeLoadOptionsString(LoadString, L"NOINTEGRITYCHECKS");
230 OslpSanitizeLoadOptionsString(LoadString, L"DISABLEELAMDRIVERS");
231
232 /* Add the sanitized one back */
235 LoadString);
236
237 /* Free the original BCD one */
239 }
240
241 /* One more pass for secure-boot options */
243
244 /* All good */
245 return Status;
246}
@ BcdOSLoaderBoolean_DisableElamDrivers
Definition: bcd.h:160
@ BcdLibraryString_LoadOptionsString
Definition: bcd.h:80
@ BcdLibraryBoolean_DisableIntegrityChecks
Definition: bcd.h:88
VOID BlRemoveBootOption(_In_ PBL_BCD_OPTION List, _In_ ULONG Type)
Definition: bcdopt.c:801
NTSTATUS BlAppendBootOptionString(_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, _In_ ULONG OptionId, _In_ PWCHAR OptionString)
Definition: bcdopt.c:689
NTSTATUS BlGetBootOptionString(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PWCHAR *Value)
Definition: bcdopt.c:146
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
VOID OslpSanitizeLoadOptionsString(_In_ PWCHAR OptionString, _In_ PWCHAR SanitizeString)
Definition: rosload.c:179
VOID OslpSanitizeStringOptions(_In_ PBL_BCD_OPTION BcdOptions)
Definition: rosload.c:189
_CRTIMP wchar_t *__cdecl _wcsupr(_Inout_z_ wchar_t *_String)
uint16_t * PWCHAR
Definition: typedefs.h:56
#define LoadString
Definition: winuser.h:5819

Referenced by OslPrepareTarget().

◆ OslPrepareTarget()

NTSTATUS OslPrepareTarget ( _Out_ PULONG  ReturnFlags,
_Out_ PBOOLEAN  Jump 
)

Definition at line 531 of file rosload.c.

535{
536 PGUID AppId;
538 PBL_DEVICE_DESCRIPTOR OsDevice;
540 SIZE_T RootLength, RootLengthWithSep;
541 ULONG i;
542 ULONG64 StartPerf, EndPerf;
543 RTL_BSD_DATA_POWER_TRANSITION PowerTransitionData;
545 ULONG OsDeviceHandle;
546 BOOLEAN LastBootGood, LastBootShutdown, LastBootCheckpoint;
547 ULONG BootId;
548 BOOLEAN BootGood, BootShutdown;
549 ULONG BsdSize;
550
551 /* Initialize locals */
552 PowerBuffer = NULL;
553
554 /* Assume no flags */
555 *ReturnFlags = 0;
556
557 /* Make all registry handles invalid */
558 OslImcHiveHandle = -1;
562
563 /* Initialize memory lists */
568 {
570 }
571
572 /* Initialize the memory map descriptor buffer */
575
576 /* Initialize general pointers */
582
583 /* Initialize general variables */
587
588 /* Capture the current TSC */
589 StartPerf = BlArchGetPerformanceCounter();
590
591 /* Set our application type for SecureBoot/TPM purposes */
599
600 /* Register an error handler */
602
603 /* Get the application identifier and save it */
605 if (AppId)
606 {
608 }
609
610 /* Enable tracing */
611#ifdef BL_ETW_SUPPORT
612 TraceLoggingRegister(&TlgOslBootProviderProv);
613#endif
614
615 /* Remove dangerous BCD options */
617 if (!NT_SUCCESS(Status))
618 {
619 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
620 goto Quickie;
621 }
622
623 /* Get the OS device */
626 &OsDevice,
627 0);
628 if (!NT_SUCCESS(Status))
629 {
630 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
631 goto Quickie;
632 }
633
634 /* If the OS device is the boot device, use the one provided by bootlib */
635 if (OsDevice->DeviceType == BootDevice)
636 {
637 OsDevice = BlpBootDevice;
638 }
639
640 /* Save it as a global for later */
641 OslLoadDevice = OsDevice;
642
643 /* Get the system root */
646 &SystemRoot);
647 if (!NT_SUCCESS(Status))
648 {
649 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
650 goto Quickie;
651 }
652
653 EfiPrintf(L"System root: %s\r\n", SystemRoot);
654
655 /* Get the system root length and make sure it's slash-terminated */
656 RootLength = wcslen(SystemRoot);
657 if (SystemRoot[RootLength - 1] == OBJ_NAME_PATH_SEPARATOR)
658 {
659 /* Perfect, set it */
661 }
662 else
663 {
664 /* Allocate a new buffer large enough to contain the slash */
665 RootLengthWithSep = RootLength + sizeof(OBJ_NAME_PATH_SEPARATOR);
666 OslSystemRoot = BlMmAllocateHeap(RootLengthWithSep * sizeof(WCHAR));
667 if (!OslSystemRoot)
668 {
669 /* Bail out if we're out of memory */
671 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
672 goto Quickie;
673 }
674
675 /* Make a copy of the path, adding the separator */
677 wcscat(OslSystemRoot, L"\\");
678
679 /* Free the original one from the BCD library */
681 }
682
683 /* Initialize access to the BSD */
685
686 /* Check if we're supposed to fail on purpose */
688 if (!NT_SUCCESS(Status))
689 {
690 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
691 goto Quickie;
692 }
693
694 /* Always disable VGA mode */
697 TRUE);
698 if (!NT_SUCCESS(Status))
699 {
700 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
701 goto Quickie;
702 }
703
704 /* Get telemetry data from the last boot */
705 Status = OslGetBootStatusData(&LastBootGood,
706 &LastBootShutdown,
707 &LastBootCheckpoint,
708 &BootId,
709 &BootGood,
710 &BootShutdown);
711 if (!NT_SUCCESS(Status))
712 {
713 /* Assume this is the very first boot and everything went well */
714 BootId = 0;
715 LastBootGood = TRUE;
716 LastBootShutdown = TRUE;
717 LastBootCheckpoint = TRUE;
718 BootGood = TRUE;
719 BootShutdown = TRUE;
720
721 /* Set 0 boot attempts */
723 }
724
725 /* Set more attempt variables to their initial state */
728
729 /* Read the current BSD data into the global buffer */
731 if (NT_SUCCESS(Status))
732 {
733 /* Get the power transition buffer from the BSD */
734 BsdSize = sizeof(PowerTransitionData);
737 &PowerTransitionData,
738 &BsdSize);
739 if (NT_SUCCESS(Status))
740 {
741 /* Save the buffer */
742 PowerBuffer = &PowerTransitionData;
743 }
744 }
745
746 /* Check if this is VHD boot, which gets 3 boot attempts instead of 2 */
749
750 /* Check if the user wants to see the advanced menu */
752 {
753 /* The last boot failed more than the maximum */
754 if (!(LastBootGood) &&
756 {
757 /* Return failure due to boot -- launch recovery */
758 *ReturnFlags |= 8;
759
760 /* Update the attempt count and status variables */
762 OslCurrentBootCheckpoint = LastBootCheckpoint;
764 OslCurrentBootShutdown = LastBootShutdown;
765
766 /* Crash with code 15 and abort boot */
767 OslFatalErrorEx(15, 0, 0, 0);
769 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
770 goto Quickie;
771 }
772
773 /* We never made it far enough, more than the maximum */
774 if (!(LastBootCheckpoint) &&
776 {
777 /* Return crash/dirty shutdown during boot attempt */
778 *ReturnFlags |= 0x10;
779
780 /* Update the attempt count and status variables */
782 OslCurrentBootSucceeded = LastBootGood;
783 OslCurrentBootShutdown = LastBootShutdown;
785
786 /* Crash with code 16 and abort boot */
787 OslFatalErrorEx(16, 0, 0, 0);
789 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
790 goto Quickie;
791 }
792
793 /* We failed to shutdown cleanly, and haven't booted yet */
794 if (!(LastBootShutdown) && !(OslBootAttemptCount))
795 {
796 /* Return crash/dirty shutdown */
797 *ReturnFlags |= 0x10;
798
799 /* There's no boot attempt, so only update shutdown variables */
800 OslCurrentBootSucceeded = LastBootGood;
802 OslCurrentBootCheckpoint = LastBootCheckpoint;
803
804 /* Crash with code 16 and abort boot */
805 OslFatalErrorEx(16, 0, 0, 0);
807 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
808 goto Quickie;
809 }
810 }
811
812 /* Officially increment the number of boot attempts */
814
815 /* No success yet, write to boot status file */
820 FALSE,
821 FALSE,
824
825 /* Open the OS Loader Device for Read/Write access */
828 0,
829 &OsDeviceHandle);
830 if (!NT_SUCCESS(Status))
831 {
832 EfiPrintf(L"Fail here: %d\r\n", __LINE__);
833 goto Quickie;
834 }
835
836 /* That's all for now, folks */
839
840 /* Printf perf */
841 EndPerf = BlArchGetPerformanceCounter();
842 EfiPrintf(L"Delta: %lld\r\n", EndPerf - StartPerf);
843
844Quickie:
845#if BL_BITLOCKER_SUPPORT
846 /* Destroy the RNG/AES library for BitLocker */
847 SymCryptRngAesUninstantiate();
848#endif
849
850 /* Abort the boot */
852
853 /* This is a failure path, so never do the jump */
854 *Jump = FALSE;
855
856 /* Return error code */
857 return Status;
858}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
@ BcdOSLoaderDevice_OSDevice
Definition: bcd.h:110
@ BcdOSLoaderString_SystemRoot
Definition: bcd.h:111
@ BcdOSLoaderBoolean_DisableVgaMode
Definition: bcd.h:129
#define BCD_IMAGE_TYPE_BOOT_APP
Definition: bcd.h:30
#define BCD_OBJECT_TYPE_APPLICATION
Definition: bcd.h:44
#define BCD_APPLICATION_TYPE_OSLOADER
Definition: bcd.h:36
BOOLEAN BlDeviceIsVirtualPartitionDevice(_In_ PBL_DEVICE_DESCRIPTOR InputDevice, _Outptr_ PBL_DEVICE_DESCRIPTOR *VirtualDevice)
Definition: device.c:612
#define BL_DEVICE_READ_ACCESS
Definition: bl.h:152
#define BL_DEVICE_WRITE_ACCESS
Definition: bl.h:153
NTSTATUS BlGetBootOptionDevice(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PBL_DEVICE_DESCRIPTOR *Value, _In_opt_ PBL_BCD_OPTION *ExtraOptions)
Definition: bcdopt.c:321
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
NTSTATUS BlpDeviceOpen(_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ ULONG Flags, _In_ ULONG Unknown, _Out_ PULONG DeviceId)
Definition: device.c:2111
PBL_DEVICE_DESCRIPTOR BlpBootDevice
Definition: bootlib.c:16
@ BootDevice
Definition: bl.h:251
PGUID BlGetApplicationIdentifier(VOID)
Definition: bootlib.c:414
ULONGLONG BlArchGetPerformanceCounter(VOID)
Definition: util.c:902
PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler
Definition: debug.c:20
NTSTATUS BlAppendBootOptionBoolean(_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, _In_ ULONG OptionId, _In_ BOOLEAN Value)
Definition: bcdopt.c:625
#define NULL
Definition: types.h:112
static const WCHAR SystemRoot[]
Definition: reg.c:38
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
@ RtlBsdPowerTransition
Definition: rtltypes.h:433
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:319
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
PBL_DEVICE_DESCRIPTOR OslLoadDevice
Definition: rosload.c:35
ULONG OslResetBootStatus
Definition: rosload.c:48
ULONG OslFreeMemoryDesctiptorsListSize
Definition: rosload.c:50
VOID OslpInitializeBootStatusDataLog(VOID)
Definition: rosload.c:274
LIST_ENTRY OslFreeMemoryDesctiptorsList
Definition: rosload.c:39
ULONG_PTR OslMachineHiveHandle
Definition: rosload.c:31
BOOLEAN OslImcProcessingValid
Definition: rosload.c:49
NTSTATUS OslGetBootStatusData(_Out_ PBOOLEAN LastBootGood, _Out_ PBOOLEAN LastBootShutdown, _Out_ PBOOLEAN LastBootCheckpoint, _Out_ PULONG LastBootId, _Out_ PBOOLEAN BootGood, _Out_ PBOOLEAN BootShutdown)
Definition: rosload.c:446
ULONG_PTR OslSystemHiveHandle
Definition: rosload.c:33
LIST_ENTRY OslCoreExtensionSubGroups[2]
Definition: rosload.c:41
NTSTATUS OslSetBootStatusData(_In_ BOOLEAN LastBootGood, _In_ BOOLEAN LastBootShutdown, _In_ BOOLEAN LastBootCheckpoint, _In_ ULONG UpdateIncrement, _In_ ULONG BootAttemptCount)
Definition: rosload.c:374
BOOLEAN OslpAdvancedOptionsRequested(VOID)
Definition: rosload.c:522
NTSTATUS OslpRemoveInternalApplicationOptions(VOID)
Definition: rosload.c:198
GUID OslApplicationIdentifier
Definition: rosload.c:46
ULONG OslBootCountUpdateRequestForAbort
Definition: rosload.c:126
ULONG_PTR OslElamHiveHandle
Definition: rosload.c:32
PVOID OslMemoryDescriptorBuffer
Definition: rosload.c:51
BcdObjectType BlpSbdiCurrentApplicationType
Definition: rosload.c:53
NTSTATUS OslpCheckForcedFailure(VOID)
Definition: rosload.c:249
NTSTATUS OslBlStatusErrorHandler(_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3, _In_ ULONG_PTR Parameter4)
Definition: rosload.c:159
BOOLEAN OslCurrentBootCheckpoint
Definition: rosload.c:131
ULONG OslBootCountUpdateIncrement
Definition: rosload.c:129
PCHAR OslLoadOptions
Definition: rosload.c:36
BOOLEAN OslCurrentBootShutdown
Definition: rosload.c:133
BL_BUFFER_DESCRIPTOR OslFinalMemoryMapDescriptorsBuffer
Definition: rosload.c:44
VOID OslAbortBoot(_In_ NTSTATUS Status)
Definition: rosload.c:150
BOOLEAN OslCurrentBootSucceeded
Definition: rosload.c:132
ULONG OslBootAttemptCount
Definition: rosload.c:125
ULONG_PTR OslImcHiveHandle
Definition: rosload.c:30
LIST_ENTRY OslFinalMemoryMap
Definition: rosload.c:40
PWCHAR OslSystemRoot
Definition: rosload.c:37
ULONG OslBootAttemptMaximum
Definition: rosload.c:127
LIST_ENTRY OslLoadedFirmwareDriverList
Definition: rosload.c:42
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
struct BcdObjectType::@112::@114::@116 Application
DEVICE_TYPE DeviceType
Definition: bl.h:950
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OslpMain().

◆ OslpSanitizeLoadOptionsString()

VOID OslpSanitizeLoadOptionsString ( _In_ PWCHAR  OptionString,
_In_ PWCHAR  SanitizeString 
)

Definition at line 179 of file rosload.c.

183{
184 /* TODO */
185 return;
186}

Referenced by OslpRemoveInternalApplicationOptions().

◆ OslpSanitizeStringOptions()

VOID OslpSanitizeStringOptions ( _In_ PBL_BCD_OPTION  BcdOptions)

Definition at line 189 of file rosload.c.

192{
193 /* TODO */
194 return;
195}

Referenced by OslpRemoveInternalApplicationOptions().

◆ OslSetBootStatusData()

NTSTATUS OslSetBootStatusData ( _In_ BOOLEAN  LastBootGood,
_In_ BOOLEAN  LastBootShutdown,
_In_ BOOLEAN  LastBootCheckpoint,
_In_ ULONG  UpdateIncrement,
_In_ ULONG  BootAttemptCount 
)

Definition at line 374 of file rosload.c.

381{
383 ULONG Size;
384
385 /* Capture the BSD data in our globals, if needed */
387 if (!NT_SUCCESS(Status))
388 {
389 goto Quickie;
390 }
391
392 /* Write last boot shutdown */
393 Size = sizeof(LastBootShutdown);
396 &LastBootShutdown,
397 &Size);
398 if (!NT_SUCCESS(Status))
399 {
400 goto Quickie;
401 }
402
403 /* Write last boot good */
404 Size = sizeof(LastBootGood);
407 &LastBootGood,
408 &Size);
409 if (!NT_SUCCESS(Status))
410 {
411 goto Quickie;
412 }
413
414 /* Write last boot checkpoint */
415 Size = sizeof(LastBootCheckpoint);
418 &LastBootCheckpoint,
419 &Size);
420 if (!NT_SUCCESS(Status))
421 {
422 goto Quickie;
423 }
424
425 /* Write boot attempt count */
426 Size = sizeof(BootAttemptCount);
429 &BootAttemptCount,
430 &Size);
431 if (!NT_SUCCESS(Status))
432 {
433 goto Quickie;
434 }
435
436 /* TODO: Update Boot ID*/
437
438 /* Now write the data */
440
441Quickie:
442 return Status;
443}
@ RtlBsdItemBootCheckpoint
Definition: rtltypes.h:435
@ RtlBsdItemBootAttemptCount
Definition: rtltypes.h:434

Referenced by OslPrepareTarget().

Variable Documentation

◆ ArchCr4BitsToClear

ULONGLONG ArchCr4BitsToClear

Definition at line 25 of file rosload.c.

Referenced by ArchRestoreProcessorFeatures().

◆ ArchXCr0BitsToClear

ULONGLONG ArchXCr0BitsToClear

Definition at line 24 of file rosload.c.

Referenced by ArchRestoreProcessorFeatures().

◆ BdDebugAfterExitBootServices

BOOLEAN BdDebugAfterExitBootServices

Definition at line 26 of file rosload.c.

Referenced by OslExecuteTransition().

◆ BlpSbdiCurrentApplicationType

BcdObjectType BlpSbdiCurrentApplicationType

Definition at line 53 of file rosload.c.

Referenced by OslPrepareTarget().

◆ BsdBootStatusData

PRTL_BSD_DATA BsdBootStatusData

Definition at line 55 of file rosload.c.

Referenced by OslpGetSetBootStatusData(), and OslpReadWriteBootStatusData().

◆ OslApplicationIdentifier

GUID OslApplicationIdentifier

Definition at line 46 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslBootAttemptCount

ULONG OslBootAttemptCount

Definition at line 125 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslBootAttemptMaximum

ULONG OslBootAttemptMaximum

Definition at line 127 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslBootCountUpdateIncrement

ULONG OslBootCountUpdateIncrement

Definition at line 129 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslBootCountUpdateRequestForAbort

ULONG OslBootCountUpdateRequestForAbort

Definition at line 126 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslCoreExtensionSubGroups

LIST_ENTRY OslCoreExtensionSubGroups[2]

Definition at line 41 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslCurrentBootCheckpoint

BOOLEAN OslCurrentBootCheckpoint

Definition at line 131 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslCurrentBootShutdown

BOOLEAN OslCurrentBootShutdown

Definition at line 133 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslCurrentBootSucceeded

BOOLEAN OslCurrentBootSucceeded

Definition at line 132 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslElamHiveHandle

ULONG_PTR OslElamHiveHandle

Definition at line 32 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslEntryPoint

PVOID OslEntryPoint

Definition at line 22 of file rosload.c.

Referenced by OslExecuteTransition().

◆ OslFinalMemoryMap

LIST_ENTRY OslFinalMemoryMap

Definition at line 40 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslFinalMemoryMapDescriptorsBuffer

BL_BUFFER_DESCRIPTOR OslFinalMemoryMapDescriptorsBuffer

Definition at line 44 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslFreeMemoryDesctiptorsList

LIST_ENTRY OslFreeMemoryDesctiptorsList

Definition at line 39 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslFreeMemoryDesctiptorsListSize

ULONG OslFreeMemoryDesctiptorsListSize

Definition at line 50 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslImcHiveHandle

ULONG_PTR OslImcHiveHandle

Definition at line 30 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslImcProcessingValid

BOOLEAN OslImcProcessingValid

Definition at line 49 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslKernelGdt

KDESCRIPTOR OslKernelGdt

Definition at line 27 of file rosload.c.

◆ OslKernelIdt

KDESCRIPTOR OslKernelIdt

Definition at line 28 of file rosload.c.

◆ OslLoadDevice

PBL_DEVICE_DESCRIPTOR OslLoadDevice

Definition at line 35 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslLoadedFirmwareDriverList

LIST_ENTRY OslLoadedFirmwareDriverList

Definition at line 42 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslLoaderBlock

PLOADER_PARAMETER_BLOCK OslLoaderBlock

Definition at line 21 of file rosload.c.

Referenced by OslExecuteTransition(), and OslPrepareTarget().

◆ OslLoadOptions

PCHAR OslLoadOptions

Definition at line 36 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslMachineHiveHandle

ULONG_PTR OslMachineHiveHandle

Definition at line 31 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslMemoryDescriptorBuffer

PVOID OslMemoryDescriptorBuffer

Definition at line 51 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslpBootStatusFields

OSL_BSD_ITEM_TABLE_ENTRY OslpBootStatusFields[RtlBsdItemMax]

Definition at line 57 of file rosload.c.

Referenced by OslpGetSetBootStatusData().

◆ OslResetBootStatus

ULONG OslResetBootStatus

Definition at line 48 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslSystemHiveHandle

ULONG_PTR OslSystemHiveHandle

Definition at line 33 of file rosload.c.

Referenced by OslPrepareTarget().

◆ OslSystemRoot

PWCHAR OslSystemRoot

Definition at line 37 of file rosload.c.

Referenced by OslPrepareTarget().

◆ UserSharedAddress

PVOID UserSharedAddress

Definition at line 23 of file rosload.c.

Referenced by OslArchKernelSetup().