Author: ekohl
Date: Fri Apr 6 18:25:18 2012
New Revision: 56332
URL:
http://svn.reactos.org/svn/reactos?rev=56332&view=rev
Log:
[RTL]
Implement RtlCreateBootStatusDataFile, RtlGetSetBootStatusData, RtlLockBootStatusData and
RtlUnlockBootStatusData.
[SYSSETUP]
Call RtlCreateBootStatusDataFile as part of the install process.
Modified:
trunk/reactos/dll/win32/syssetup/wizard.c
trunk/reactos/lib/rtl/bootdata.c
Modified: trunk/reactos/dll/win32/syssetup/wizard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/wizard.…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] Fri Apr 6 18:25:18 2012
@@ -1750,6 +1750,9 @@
SetupTermDefaultQueueCallback(RegistrationData->DefaultContext);
HeapFree(GetProcessHeap(), 0, RegistrationData);
+ // FIXME: Move this call to a separate cleanup page!
+ RtlCreateBootStatusDataFile();
+
return 0;
}
@@ -2051,6 +2054,8 @@
return FALSE;
}
+
+
BOOL
ProcessUnattendInf(HINF hUnattendedInf)
{
@@ -2260,8 +2265,9 @@
return FALSE;
}
+
VOID
-ProcessUnattendSetup()
+ProcessUnattendSetup(VOID)
{
WCHAR szPath[MAX_PATH];
HINF hUnattendedInf;
@@ -2311,7 +2317,6 @@
ZeroMemory(&SetupData, sizeof(SETUPDATA));
ProcessUnattendSetup();
-
/* Create the Welcome page */
psp.dwSize = sizeof(PROPSHEETPAGE);
Modified: trunk/reactos/lib/rtl/bootdata.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/bootdata.c?rev=563…
==============================================================================
--- trunk/reactos/lib/rtl/bootdata.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/bootdata.c [iso-8859-1] Fri Apr 6 18:25:18 2012
@@ -12,9 +12,17 @@
#define NDEBUG
#include <debug.h>
+typedef struct _RTL_BSD_ITEM
+{
+ ULONG Offset;
+ ULONG Size;
+} RTL_BSD_ITEM, *PRTL_BSD_ITEM;
+
/* FUNCTIONS *****************************************************************/
static SID_IDENTIFIER_AUTHORITY LocalSystemAuthority = {SECURITY_NT_AUTHORITY};
+
+static RTL_BSD_ITEM BsdItemTable[6] = {{0, 4}, {4, 4,}, {8, 1}, {9, 1}, {10, 1}, {11,
1}};
static NTSTATUS
RtlpSysVolCreateSecurityDescriptor(OUT PISECURITY_DESCRIPTOR *SecurityDescriptor,
@@ -671,52 +679,187 @@
}
/*
-* @unimplemented
+* @implemented
*/
NTSTATUS
NTAPI
RtlCreateBootStatusDataFile(VOID)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK IoStatusBlock;
+ LARGE_INTEGER AllocationSize;
+ LARGE_INTEGER ByteOffset;
+ UNICODE_STRING FileName;
+ HANDLE FileHandle;
+ NTSTATUS Status;
+
+ /* Initialize the file name */
+ RtlInitUnicodeString(&FileName,
+ L"\\SystemRoot\\bootstat.dat");
+
+ /* Initialize the object attributes */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &FileName,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ AllocationSize.QuadPart = 0x800;
+
+ /* Create the boot status data file */
+ Status = ZwCreateFile(&FileHandle,
+ FILE_GENERIC_READ | FILE_GENERIC_WRITE,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ NULL, //&AllocationSize,
+ FILE_ATTRIBUTE_SYSTEM,
+ 0,
+ FILE_CREATE,
+ FILE_SYNCHRONOUS_IO_NONALERT,
+ NULL,
+ 0);
+ if (NT_SUCCESS(Status))
+ {
+ // FIXME: Initialize the buffer in a better way.
+ UCHAR Buffer[12] = {0xC,0,0,0, 1,0,0,0, 1, 0x1e, 1, 0};
+
+ ByteOffset.QuadPart = 0;
+ Status = ZwWriteFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatusBlock,
+ &Buffer,
+ 12, //BufferSize,
+ &ByteOffset,
+ NULL);
+ }
+
+ /* Close the file */
+ ZwClose(FileHandle);
+
+ return Status;
}
/*
-* @unimplemented
+* @implemented
*/
NTSTATUS
NTAPI
-RtlGetSetBootStatusData(IN HANDLE Filehandle,
+RtlGetSetBootStatusData(IN HANDLE FileHandle,
IN BOOLEAN WriteMode,
IN RTL_BSD_ITEM_TYPE DataClass,
IN PVOID Buffer,
IN ULONG BufferSize,
OUT PULONG ReturnLength)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ IO_STATUS_BLOCK IoStatusBlock;
+ LARGE_INTEGER ByteOffset;
+ NTSTATUS Status;
+
+ DPRINT("RtlGetSetBootStatusData (%p %u %u %p %lu %p)\n",
+ FileHandle, WriteMode, DataClass, Buffer, BufferSize, ReturnLength);
+
+ if (DataClass >= RtlBsdItemMax)
+ return STATUS_INVALID_PARAMETER;
+
+ if (BufferSize > BsdItemTable[DataClass].Size)
+ return STATUS_BUFFER_TOO_SMALL;
+
+ ByteOffset.HighPart = 0;
+ ByteOffset.LowPart = BsdItemTable[DataClass].Offset;
+
+ if (WriteMode)
+ {
+ Status = ZwReadFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatusBlock,
+ Buffer,
+ BufferSize,
+ &ByteOffset,
+ NULL);
+ }
+ else
+ {
+ Status = ZwWriteFile(FileHandle,
+ NULL,
+ NULL,
+ NULL,
+ &IoStatusBlock,
+ Buffer,
+ BufferSize,
+ &ByteOffset,
+ NULL);
+ }
+
+ if (NT_SUCCESS(Status))
+ {
+ if (ReturnLength)
+ *ReturnLength = BsdItemTable[DataClass].Size;
+ }
+
+ return Status;
}
/*
-* @unimplemented
+* @implemented
*/
NTSTATUS
NTAPI
-RtlLockBootStatusData(OUT PHANDLE Filehandle)
+RtlLockBootStatusData(OUT PHANDLE FileHandle)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK IoStatusBlock;
+ UNICODE_STRING FileName;
+ HANDLE LocalFileHandle;
+ NTSTATUS Status;
+
+ /* Intialize the file handle */
+ *FileHandle = NULL;
+
+ /* Initialize the file name */
+ RtlInitUnicodeString(&FileName,
+ L"\\SystemRoot\\bootstat.dat");
+
+ /* Initialize the object attributes */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &FileName,
+ 0,
+ NULL,
+ NULL);
+
+ /* Open the boot status data file */
+ Status = ZwOpenFile(&LocalFileHandle,
+ FILE_ALL_ACCESS,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ 0,
+ FILE_SYNCHRONOUS_IO_NONALERT);
+ if (NT_SUCCESS(Status))
+ {
+ /* Return the file handle */
+ *FileHandle = LocalFileHandle;
+ }
+
+ return Status;
}
/*
-* @unimplemented
+* @implemented
*/
NTSTATUS
NTAPI
-RtlUnlockBootStatusData(IN HANDLE Filehandle)
+RtlUnlockBootStatusData(IN HANDLE FileHandle)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ IO_STATUS_BLOCK IoStatusBlock;
+
+ /* Flush the file and close it */
+ ZwFlushBuffersFile(FileHandle,
+ &IoStatusBlock);
+
+ return ZwClose(FileHandle);
}
/* EOF */