mirror of
https://github.com/reactos/reactos.git
synced 2025-06-29 17:31:21 +00:00
[NTOS] Do not perform hive write operations when we are not supposed to.
- When we are in LiveCD mode (more generally, when hives are shared), load the system hives as volatile. - Ignore hive write operations when everything operates in read-only mode and just return success instead. - Just return success on hive file I/O if no file is associated with a given hive. This happens when e.g. a CM hive has a primary but no log.
This commit is contained in:
parent
5f255827d3
commit
da8134527b
2 changed files with 30 additions and 2 deletions
|
@ -900,7 +900,7 @@ CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
/* We imported, no need to create a new hive */
|
/* We imported, no need to create a new hive */
|
||||||
Allocate = FALSE;
|
Allocate = FALSE;
|
||||||
|
|
||||||
/* Manually set the hive as volatile, if in Live CD mode */
|
/* Manually set the hive as volatile, if in LiveCD mode */
|
||||||
if (CmpShareSystemHives) SystemHive->Hive.HiveFlags = HIVE_VOLATILE;
|
if (CmpShareSystemHives) SystemHive->Hive.HiveFlags = HIVE_VOLATILE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1433,9 +1433,13 @@ CmpInitializeHiveList(IN USHORT Flag)
|
||||||
/* Loop every hive we care about */
|
/* Loop every hive we care about */
|
||||||
for (i = 0; i < CM_NUMBER_OF_MACHINE_HIVES; i++)
|
for (i = 0; i < CM_NUMBER_OF_MACHINE_HIVES; i++)
|
||||||
{
|
{
|
||||||
/* Make sure the list is setup */
|
/* Make sure the list is set up */
|
||||||
ASSERT(CmpMachineHiveList[i].Name != NULL);
|
ASSERT(CmpMachineHiveList[i].Name != NULL);
|
||||||
|
|
||||||
|
/* Load the hive as volatile, if in LiveCD mode */
|
||||||
|
if (CmpShareSystemHives)
|
||||||
|
CmpMachineHiveList[i].HHiveFlags |= HIVE_VOLATILE;
|
||||||
|
|
||||||
/* Create a thread to handle this hive */
|
/* Create a thread to handle this hive */
|
||||||
Status = PsCreateSystemThread(&Thread,
|
Status = PsCreateSystemThread(&Thread,
|
||||||
THREAD_ALL_ACCESS,
|
THREAD_ALL_ACCESS,
|
||||||
|
|
|
@ -82,6 +82,10 @@ CmpFileRead(IN PHHIVE RegistryHive,
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Just return success if no file is associated with this hive */
|
||||||
|
if (HiveHandle == NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
_FileOffset.QuadPart = *FileOffset;
|
_FileOffset.QuadPart = *FileOffset;
|
||||||
Status = ZwReadFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
|
Status = ZwReadFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
|
||||||
Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
|
Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
|
||||||
|
@ -102,6 +106,14 @@ CmpFileWrite(IN PHHIVE RegistryHive,
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Just return success if no file is associated with this hive */
|
||||||
|
if (HiveHandle == NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* Don't do anything if we're not supposed to */
|
||||||
|
if (CmpNoWrite)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
_FileOffset.QuadPart = *FileOffset;
|
_FileOffset.QuadPart = *FileOffset;
|
||||||
Status = ZwWriteFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
|
Status = ZwWriteFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
|
||||||
Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
|
Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
|
||||||
|
@ -122,6 +134,10 @@ CmpFileSetSize(IN PHHIVE RegistryHive,
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Just return success if no file is associated with this hive */
|
||||||
|
if (HiveHandle == NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
EndOfFileInfo.EndOfFile.QuadPart = FileSize;
|
EndOfFileInfo.EndOfFile.QuadPart = FileSize;
|
||||||
Status = ZwSetInformationFile(HiveHandle,
|
Status = ZwSetInformationFile(HiveHandle,
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
|
@ -153,6 +169,14 @@ CmpFileFlush(IN PHHIVE RegistryHive,
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Just return success if no file is associated with this hive */
|
||||||
|
if (HiveHandle == NULL)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* Don't do anything if we're not supposed to */
|
||||||
|
if (CmpNoWrite)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
Status = ZwFlushBuffersFile(HiveHandle, &IoStatusBlock);
|
Status = ZwFlushBuffersFile(HiveHandle, &IoStatusBlock);
|
||||||
return NT_SUCCESS(Status) ? TRUE : FALSE;
|
return NT_SUCCESS(Status) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue