ReactOS 0.4.15-dev-5672-gf73ac17
bootdata.c File Reference
#include <rtl.h>
#include <debug.h>
Include dependency graph for bootdata.c:

Go to the source code of this file.

Classes

struct  _RTL_BSD_ITEM_TABLE_ENTRY
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _RTL_BSD_ITEM_TABLE_ENTRY RTL_BSD_ITEM_TABLE_ENTRY
 

Functions

NTSTATUS NTAPI RtlCreateBootStatusDataFile (VOID)
 
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)
 
NTSTATUS NTAPI RtlLockBootStatusData (_Out_ PHANDLE FileHandle)
 
NTSTATUS NTAPI RtlUnlockBootStatusData (_In_ HANDLE FileHandle)
 

Variables

PRTL_BSD_DATA DummyBsd
 
RTL_BSD_ITEM_TABLE_ENTRY BsdItemTable [RtlBsdItemMax]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file bootdata.c.

Typedef Documentation

◆ RTL_BSD_ITEM_TABLE_ENTRY

Function Documentation

◆ RtlCreateBootStatusDataFile()

NTSTATUS NTAPI RtlCreateBootStatusDataFile ( VOID  )

Definition at line 98 of file bootdata.c.

101{
106 RTL_CONSTANT_STRING(L"\\SystemRoot\\bootstat.dat");
111 RTL_BSD_DATA InitialBsd;
112
113 /* Create the boot status data file */
114 AllocationSize.QuadPart = 0x800;
116 Status = ZwCreateFile(&FileHandle,
120 NULL, //&AllocationSize,
122 0,
125 NULL,
126 0);
127 if (NT_SUCCESS(Status))
128 {
129 /* Setup a sane looking initial BSD */
130 RtlZeroMemory(&InitialBsd, sizeof(InitialBsd));
131 InitialBsd.Version = sizeof(InitialBsd);
132 InitialBsd.ProductType = NtProductWinNt;
133 InitialBsd.AabEnabled = 1;
134 InitialBsd.AabTimeout = 30;
135 InitialBsd.LastBootSucceeded = TRUE;
136
137 /* Write it to disk */
138 ByteOffset.QuadPart = 0;
139 Status = ZwWriteFile(FileHandle,
140 NULL,
141 NULL,
142 NULL,
144 &InitialBsd,
145 sizeof(InitialBsd),
146 &ByteOffset,
147 NULL);
148 }
149
150 /* Close the file */
152
153 return Status;
154}
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
@ NtProductWinNt
Definition: shellpath.c:64
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:731
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:322
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_CREATE
Definition: from_kernel.h:55
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_GENERIC_READ
Definition: nt_native.h:653
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:319
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
#define L(x)
Definition: ntvdm.h:50
UCHAR AabTimeout
Definition: rtltypes.h:1337
ULONG ProductType
Definition: rtltypes.h:1335
BOOLEAN LastBootSucceeded
Definition: rtltypes.h:1338
BOOLEAN AabEnabled
Definition: rtltypes.h:1336
ULONG Version
Definition: rtltypes.h:1334
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by ItemCompletionThread().

◆ RtlGetSetBootStatusData()

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 at line 161 of file bootdata.c.

169{
173
174 DPRINT("RtlGetSetBootStatusData (%p %u %d %p %lu %p)\n",
176
177 if (DataClass >= RtlBsdItemMax)
178 {
180 }
181
182 if (BufferSize > BsdItemTable[DataClass].Size)
183 {
185 }
186
187 ByteOffset.HighPart = 0;
188 ByteOffset.LowPart = BsdItemTable[DataClass].Offset;
189
190 if (Read)
191 {
192 Status = ZwReadFile(FileHandle,
193 NULL,
194 NULL,
195 NULL,
197 Buffer,
199 &ByteOffset,
200 NULL);
201 }
202 else
203 {
204 Status = ZwWriteFile(FileHandle,
205 NULL,
206 NULL,
207 NULL,
209 Buffer,
211 &ByteOffset,
212 NULL);
213 }
214
215 if (NT_SUCCESS(Status))
216 {
217 if (ReturnLength)
218 {
219 *ReturnLength = BsdItemTable[DataClass].Size;
220 }
221 }
222
223 return Status;
224}
Definition: bufpool.h:45
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
@ RtlBsdItemMax
Definition: rtltypes.h:442
RTL_BSD_ITEM_TABLE_ENTRY BsdItemTable[RtlBsdItemMax]
Definition: bootdata.c:25
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define DPRINT
Definition: sndvol32.h:71
_In_ BOOLEAN Read
Definition: strmini.h:479
UCHAR Size
Definition: bootdata.c:19
UCHAR Offset
Definition: bootdata.c:18
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by SmpRestoreBootStatusData(), and SmpSaveAndClearBootStatusData().

◆ RtlLockBootStatusData()

NTSTATUS NTAPI RtlLockBootStatusData ( _Out_ PHANDLE  FileHandle)

Definition at line 231 of file bootdata.c.

234{
236 RTL_CONSTANT_STRING(L"\\SystemRoot\\bootstat.dat");
239 HANDLE LocalFileHandle;
242
243 /* Intialize the file handle */
244 *FileHandle = NULL;
245
246 /* Open the boot status data file */
247 Status = ZwOpenFile(&LocalFileHandle,
251 0,
253 if (NT_SUCCESS(Status))
254 {
255 /* Return the file handle */
256 *FileHandle = LocalFileHandle;
257 }
258
259 return Status;
260}
NTSYSAPI NTSTATUS NTAPI ZwOpenFile(_Out_ PHANDLE FileHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes, _Out_ PIO_STATUS_BLOCK IoStatusBlock, _In_ ULONG ShareAccess, _In_ ULONG OpenOptions)
#define FILE_ALL_ACCESS
Definition: nt_native.h:651

Referenced by SmpRestoreBootStatusData(), and SmpSaveAndClearBootStatusData().

◆ RtlUnlockBootStatusData()

NTSTATUS NTAPI RtlUnlockBootStatusData ( _In_ HANDLE  FileHandle)

Definition at line 267 of file bootdata.c.

270{
272
273 /* Flush the file and close it */
275 return ZwClose(FileHandle);
276}
NTSYSAPI NTSTATUS NTAPI ZwFlushBuffersFile(_In_ HANDLE FileHandle, _Out_ PIO_STATUS_BLOCK IoStatusBlock)

Referenced by SmpRestoreBootStatusData(), and SmpSaveAndClearBootStatusData().

Variable Documentation

◆ BsdItemTable

Definition at line 25 of file bootdata.c.

Referenced by RtlGetSetBootStatusData().

◆ DummyBsd

PRTL_BSD_DATA DummyBsd

Definition at line 24 of file bootdata.c.