mirror of
https://github.com/reactos/reactos.git
synced 2024-09-15 23:28:15 +00:00
- Change CmiInitNonVolatileRegistry hive to use CmpOpenHiveFiles and CmpInitializeHive. Required a lot of hacking to get to work right, but at least it does, and uses our new code paths.
- Update CmpInitializeHive with the HINIT_FILE hack required for current cmlib functionality. svn path=/trunk/; revision=26714
This commit is contained in:
parent
7ae94663c6
commit
ff7c618dd0
|
@ -23,6 +23,19 @@
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
CmpInitializeHive(OUT PEREGISTRY_HIVE *RegistryHive,
|
||||||
|
IN ULONG OperationType,
|
||||||
|
IN ULONG HiveFlags,
|
||||||
|
IN ULONG FileType,
|
||||||
|
IN PVOID HiveData OPTIONAL,
|
||||||
|
IN HANDLE Primary,
|
||||||
|
IN HANDLE Log,
|
||||||
|
IN HANDLE External,
|
||||||
|
IN PUNICODE_STRING FileName OPTIONAL,
|
||||||
|
IN ULONG CheckFlags);
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
CmiCreateNewRegFile(HANDLE FileHandle)
|
CmiCreateNewRegFile(HANDLE FileHandle)
|
||||||
{
|
{
|
||||||
|
@ -57,95 +70,66 @@ CmiCreateNewRegFile(HANDLE FileHandle)
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
CmiInitNonVolatileRegistryHive (PEREGISTRY_HIVE RegistryHive,
|
CmiInitNonVolatileRegistryHive (IN ULONG HiveFlags,
|
||||||
PWSTR Filename)
|
IN PUNICODE_STRING HiveName,
|
||||||
|
OUT PEREGISTRY_HIVE *Hive)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
ULONG CreateDisposition, LogDisposition;
|
||||||
ULONG CreateDisposition;
|
HANDLE FileHandle, LogHandle;
|
||||||
IO_STATUS_BLOCK IoSB;
|
|
||||||
HANDLE FileHandle;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
FILE_STANDARD_INFORMATION FileInformation;
|
//ULONG Operation;
|
||||||
|
PEREGISTRY_HIVE NewHive;
|
||||||
|
|
||||||
DPRINT("CmiInitNonVolatileRegistryHive(%p, %S) called\n",
|
*Hive = NULL;
|
||||||
RegistryHive, Filename);
|
|
||||||
|
|
||||||
/* Duplicate Filename */
|
Status = CmpOpenHiveFiles(HiveName,
|
||||||
Status = RtlCreateUnicodeString(&RegistryHive->HiveFileName,
|
NULL, //L".LOG",
|
||||||
Filename);
|
&FileHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
&LogHandle,
|
||||||
{
|
&CreateDisposition,
|
||||||
DPRINT("RtlCreateUnicodeString() failed (Status %lx)\n", Status);
|
&LogDisposition,
|
||||||
return(Status);
|
TRUE,
|
||||||
}
|
FALSE,
|
||||||
|
TRUE,
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&RegistryHive->HiveFileName,
|
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
NULL);
|
||||||
|
if (CreateDisposition == FILE_CREATED)
|
||||||
CreateDisposition = FILE_OPEN_IF;
|
|
||||||
Status = ZwCreateFile(&FileHandle,
|
|
||||||
FILE_ALL_ACCESS,
|
|
||||||
&ObjectAttributes,
|
|
||||||
&IoSB,
|
|
||||||
NULL,
|
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
|
||||||
0,
|
|
||||||
CreateDisposition,
|
|
||||||
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
|
|
||||||
NULL,
|
|
||||||
0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
RtlFreeUnicodeString(&RegistryHive->HiveFileName);
|
|
||||||
DPRINT("ZwCreateFile() failed (Status %lx)\n", Status);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IoSB.Information != FILE_OPENED)
|
|
||||||
{
|
{
|
||||||
Status = CmiCreateNewRegFile(FileHandle);
|
Status = CmiCreateNewRegFile(FileHandle);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("CmiCreateNewRegFile() failed (Status %lx)\n", Status);
|
DPRINT("CmiCreateNewRegFile() failed (Status %lx)\n", Status);
|
||||||
ZwClose(FileHandle);
|
ZwClose(FileHandle);
|
||||||
RtlFreeUnicodeString(&RegistryHive->HiveFileName);
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegistryHive->HiveHandle = FileHandle;
|
Status = CmpInitializeHive(&NewHive,
|
||||||
|
HINIT_FILE,
|
||||||
/* Check how large the file is */
|
HiveFlags,
|
||||||
ZwQueryInformationFile(FileHandle,
|
HFILE_TYPE_PRIMARY,
|
||||||
&IoSB,
|
NULL,
|
||||||
&FileInformation,
|
FileHandle,
|
||||||
sizeof(FileInformation),
|
NULL,
|
||||||
FileStandardInformation);
|
NULL,
|
||||||
Status = HvInitialize(&RegistryHive->Hive, HINIT_FILE, 0, 0,
|
HiveName,
|
||||||
0, FileInformation.EndOfFile.LowPart,
|
0);
|
||||||
CmpAllocate, CmpFree,
|
|
||||||
CmpFileRead, CmpFileWrite, CmpFileSetSize,
|
|
||||||
CmpFileFlush, NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Failed to open hive\n");
|
DPRINT1("Failed to open hive\n");
|
||||||
RtlFreeUnicodeString(&RegistryHive->HiveFileName);
|
|
||||||
ZwClose(FileHandle);
|
ZwClose(FileHandle);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
CmPrepareHive(&RegistryHive->Hive);
|
CmPrepareHive(&NewHive->Hive);
|
||||||
|
NewHive->Flags = HiveFlags;
|
||||||
|
|
||||||
|
RtlCreateUnicodeString(&NewHive->HiveFileName, HiveName->Buffer);
|
||||||
|
|
||||||
/* Close the hive file */
|
/* Close the hive file */
|
||||||
ZwClose(FileHandle);
|
ZwClose(FileHandle);
|
||||||
|
|
||||||
DPRINT("CmiInitNonVolatileRegistryHive(%p, %S) - Finished.\n",
|
*Hive = NewHive;
|
||||||
RegistryHive, Filename);
|
return Status;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -161,21 +145,9 @@ CmiLoadHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
||||||
if (Flags & ~REG_NO_LAZY_FLUSH)
|
if (Flags & ~REG_NO_LAZY_FLUSH)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
Hive = ExAllocatePool (NonPagedPool,
|
Status = CmiInitNonVolatileRegistryHive ((Flags & REG_NO_LAZY_FLUSH) ? HIVE_NO_SYNCH : 0,
|
||||||
sizeof(EREGISTRY_HIVE));
|
FileName,
|
||||||
if (Hive == NULL)
|
&Hive);
|
||||||
{
|
|
||||||
DPRINT1 ("Failed to allocate hive header.\n");
|
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
}
|
|
||||||
RtlZeroMemory (Hive,
|
|
||||||
sizeof(EREGISTRY_HIVE));
|
|
||||||
|
|
||||||
DPRINT ("Hive 0x%p\n", Hive);
|
|
||||||
Hive->Flags = (Flags & REG_NO_LAZY_FLUSH) ? HIVE_NO_SYNCH : 0;
|
|
||||||
|
|
||||||
Status = CmiInitNonVolatileRegistryHive (Hive,
|
|
||||||
FileName->Buffer);
|
|
||||||
if (!NT_SUCCESS (Status))
|
if (!NT_SUCCESS (Status))
|
||||||
{
|
{
|
||||||
DPRINT1 ("CmiInitNonVolatileRegistryHive() failed (Status %lx)\n", Status);
|
DPRINT1 ("CmiInitNonVolatileRegistryHive() failed (Status %lx)\n", Status);
|
||||||
|
@ -183,12 +155,6 @@ CmiLoadHive(IN POBJECT_ATTRIBUTES KeyObjectAttributes,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the new hive to the hive list */
|
|
||||||
InsertTailList (&CmpHiveListHead,
|
|
||||||
&Hive->HiveList);
|
|
||||||
|
|
||||||
VERIFY_REGISTRY_HIVE(Hive);
|
|
||||||
|
|
||||||
Status = CmiConnectHive (KeyObjectAttributes,
|
Status = CmiConnectHive (KeyObjectAttributes,
|
||||||
Hive);
|
Hive);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -32,6 +32,7 @@ CmpInitializeHive(OUT PCMHIVE *RegistryHive,
|
||||||
PCMHIVE Hive;
|
PCMHIVE Hive;
|
||||||
#else
|
#else
|
||||||
PEREGISTRY_HIVE Hive;
|
PEREGISTRY_HIVE Hive;
|
||||||
|
FILE_STANDARD_INFORMATION FileInformation;
|
||||||
#endif
|
#endif
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
FILE_FS_SIZE_INFORMATION FileSizeInformation;
|
FILE_FS_SIZE_INFORMATION FileSizeInformation;
|
||||||
|
@ -167,6 +168,15 @@ CmpInitializeHive(OUT PCMHIVE *RegistryHive,
|
||||||
|
|
||||||
/* Set flags */
|
/* Set flags */
|
||||||
Hive->Flags = HiveFlags;
|
Hive->Flags = HiveFlags;
|
||||||
|
Hive->HiveHandle = Primary;
|
||||||
|
|
||||||
|
/* Check how large the file is */
|
||||||
|
ZwQueryInformationFile(Primary,
|
||||||
|
&IoStatusBlock,
|
||||||
|
&FileInformation,
|
||||||
|
sizeof(FileInformation),
|
||||||
|
FileStandardInformation);
|
||||||
|
Cluster = FileInformation.EndOfFile.LowPart;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize it */
|
/* Initialize it */
|
||||||
|
|
Loading…
Reference in a new issue