yangzhengbao
03-30-2006, 08:26 AM
ntos\boot\bldr\regboot.c
BOOLEAN
BlInitializeHive(
IN PVOID HiveImage,
IN PCMHIVE Hive,
IN BOOLEAN IsAlternate
)
/*++
Routine Description:
Initializes the hive data structure based on the in-memory hive image.
Arguments:
HiveImage - Supplies a pointer to the in-memory hive image.
Hive - Supplies the CMHIVE structure to be filled in.
IsAlternate - Supplies whether or not the hive is the alternate hive,
which indicates that the primary hive is corrupt and should be
rewritten by the system.
Return Value:
TRUE - Hive successfully initialized.
FALSE - Hive is corrupt.
--*/
{
NTSTATUS status;
ULONG HiveCheckCode;
status = HvInitializeHive(
&Hive->Hive,
HINIT_MEMORY_INPLACE,
FALSE,
IsAlternate ? HFILE_TYPE_ALTERNATE : HFILE_TYPE_PRIMARY,
HiveImage,
(PALLOCATE_ROUTINE)BlpHiveAllocate, // allocate
NULL, // free
NULL, // setsize
NULL, // write
NULL, // read
NULL, // flush
1, // cluster
NULL
);
if (!NT_SUCCESS(status)) {
return FALSE;
}
HiveCheckCode = CmCheckRegistry(Hive,TRUE);
if (HiveCheckCode != 0) {
return(FALSE);
} else {
return TRUE;
}
}
BOOLEAN
BlInitializeHive(
IN PVOID HiveImage,
IN PCMHIVE Hive,
IN BOOLEAN IsAlternate
)
/*++
Routine Description:
Initializes the hive data structure based on the in-memory hive image.
Arguments:
HiveImage - Supplies a pointer to the in-memory hive image.
Hive - Supplies the CMHIVE structure to be filled in.
IsAlternate - Supplies whether or not the hive is the alternate hive,
which indicates that the primary hive is corrupt and should be
rewritten by the system.
Return Value:
TRUE - Hive successfully initialized.
FALSE - Hive is corrupt.
--*/
{
NTSTATUS status;
ULONG HiveCheckCode;
status = HvInitializeHive(
&Hive->Hive,
HINIT_MEMORY_INPLACE,
FALSE,
IsAlternate ? HFILE_TYPE_ALTERNATE : HFILE_TYPE_PRIMARY,
HiveImage,
(PALLOCATE_ROUTINE)BlpHiveAllocate, // allocate
NULL, // free
NULL, // setsize
NULL, // write
NULL, // read
NULL, // flush
1, // cluster
NULL
);
if (!NT_SUCCESS(status)) {
return FALSE;
}
HiveCheckCode = CmCheckRegistry(Hive,TRUE);
if (HiveCheckCode != 0) {
return(FALSE);
} else {
return TRUE;
}
}