ReactOS  0.4.14-dev-98-gb0d4763
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,
119  &IoStatusBlock,
120  NULL, //&AllocationSize,
122  0,
123  FILE_CREATE,
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,
143  &IoStatusBlock,
144  &InitialBsd,
145  sizeof(InitialBsd),
146  &ByteOffset,
147  NULL);
148  }
149 
150  /* Close the file */
152 
153  return Status;
154 }
#define FILE_GENERIC_READ
Definition: nt_native.h:653
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_CREATE
Definition: from_kernel.h:55
ULONG Version
Definition: rtltypes.h:1328
HANDLE FileHandle
Definition: stats.c:38
smooth NULL
Definition: ftsmooth.c:416
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:326
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN AabEnabled
Definition: rtltypes.h:1330
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN LastBootSucceeded
Definition: rtltypes.h:1332
Status
Definition: gdiplustypes.h:24
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:310
UCHAR AabTimeout
Definition: rtltypes.h:1331
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG ProductType
Definition: rtltypes.h:1329
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:716
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by RegistrationProc().

◆ 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",
175  FileHandle, Read, DataClass, Buffer, BufferSize, ReturnLength);
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,
196  &IoStatusBlock,
197  Buffer,
198  BufferSize,
199  &ByteOffset,
200  NULL);
201  }
202  else
203  {
204  Status = ZwWriteFile(FileHandle,
205  NULL,
206  NULL,
207  NULL,
208  &IoStatusBlock,
209  Buffer,
210  BufferSize,
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 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
_In_ BOOLEAN Read
Definition: strmini.h:479
UCHAR Offset
Definition: bootdata.c:18
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
HANDLE FileHandle
Definition: stats.c:38
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define BufferSize
Definition: classpnp.h:419
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
UCHAR Size
Definition: bootdata.c:19
RTL_BSD_ITEM_TABLE_ENTRY BsdItemTable[RtlBsdItemMax]
Definition: bootdata.c:25
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:716

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,
250  &IoStatusBlock,
251  0,
253  if (NT_SUCCESS(Status))
254  {
255  /* Return the file handle */
256  *FileHandle = LocalFileHandle;
257  }
258 
259  return Status;
260 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define FILE_ALL_ACCESS
Definition: nt_native.h:651
LONG NTSTATUS
Definition: precomp.h:26
HANDLE FileHandle
Definition: stats.c:38
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
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)
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define RTL_CONSTANT_OBJECT_ATTRIBUTES(n, a)
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

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)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
HANDLE FileHandle
Definition: stats.c:38
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75

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.