|
|
Definition at line 1659 of file cmapi.c.
Referenced by NtLoadKeyEx().
{
SECURITY_QUALITY_OF_SERVICE ServiceQos;
SECURITY_CLIENT_CONTEXT ClientSecurityContext;
HANDLE KeyHandle;
BOOLEAN Allocate = TRUE;
PCMHIVE CmHive, LoadedHive;
NTSTATUS Status;
CM_PARSE_CONTEXT ParseContext;
if (KeyBody)
{
DPRINT1("Trusted classes not yet supported\n");
return STATUS_NOT_IMPLEMENTED;
}
ServiceQos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
ServiceQos.ImpersonationLevel = SecurityImpersonation;
ServiceQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
ServiceQos.EffectiveOnly = TRUE;
Status = SeCreateClientSecurity(PsGetCurrentThread(),
&ServiceQos,
FALSE,
&ClientSecurityContext);
if (!NT_SUCCESS(Status))
{
DPRINT1("Security context failed\n");
return Status;
}
#if 0
Status = ZwOpenKey(&KeyHandle, KEY_READ, TargetKey);
#else
RtlZeroMemory(&ParseContext, sizeof(ParseContext));
ParseContext.CreateOperation = FALSE;
Status = ObOpenObjectByName(TargetKey,
CmpKeyObjectType,
KernelMode,
NULL,
KEY_READ,
&ParseContext,
&KeyHandle);
#endif
if (!NT_SUCCESS(Status)) KeyHandle = NULL;
Status = CmpCmdHiveOpen(SourceFile,
&ClientSecurityContext,
&Allocate,
&CmHive,
0);
SeDeleteClientSecurity(&ClientSecurityContext);
if (!NT_SUCCESS(Status))
{
if (KeyHandle)
{
CmpLockRegistryExclusive();
if (CmpIsHiveAlreadyLoaded(KeyHandle, SourceFile, &LoadedHive))
{
ASSERT(LoadedHive);
Status = STATUS_SUCCESS;
}
CmpUnlockRegistry();
}
if (KeyHandle) ZwClose(KeyHandle);
return Status;
}
CmpLockRegistry();
ExAcquirePushLockExclusive(&CmpLoadHiveLock);
CmHive->Hive.HiveFlags |= HIVE_IS_UNLOADING;
CmHive->CreatorOwner = KeGetCurrentThread();
if (Flags & REG_NO_LAZY_FLUSH) CmHive->Hive.HiveFlags |= HIVE_NOLAZYFLUSH;
Status = CmpLinkHiveToMaster(TargetKey->ObjectName,
TargetKey->RootDirectory,
CmHive,
Allocate,
TargetKey->SecurityDescriptor);
if (NT_SUCCESS(Status))
{
CmpAddToHiveFileList(CmHive);
if (Allocate)
{
CmpLockHiveFlusherExclusive(CmHive);
HvSyncHive(&CmHive->Hive);
CmpUnlockHiveFlusher(CmHive);
}
CmHive->Hive.HiveFlags &= ~HIVE_IS_UNLOADING;
CmHive->CreatorOwner = NULL;
ExReleasePushLock(&CmpLoadHiveLock);
}
else
{
DPRINT1("CmpLinkHiveToMaster failed, Status %lx\n", Status);
ASSERT(FALSE);
}
if (!(CmpProfileLoaded) && !(CmpWasSetupBoot))
{
CmpProfileLoaded = TRUE;
CmpSetGlobalQuotaAllowed();
}
CmpUnlockRegistry();
if (KeyHandle) ZwClose(KeyHandle);
return Status;
}
|