CmpSetKeySecurity
VOID __stdcall CmpSetKeySecurity(
_CM_KEY_BODY *KeyBody,
UINT64 *SecurityInformation,
PVOID SecurityDescriptor,
PVOID *ObjectsSecurityDescriptor,
_POOL_TYPE PoolType,
_GENERIC_MAPPING *GenericMapping){
char v7;
CHAR v8;
char v9;
_CM_KCB_UOW *UoW;
_CM_KEY_CONTROL_BLOCK *KeyControlBlock;
_CM_TRANS *CmTrans;
INT64 p_KCBLock;
CHAR v14;
char v15;
bool v16;
_CM_KCB_UOW *UnitOfWork;
int v18;
_CM_KEY_CONTROL_BLOCK *v19;
UINT8 *v20;
INT64 v21;
INT64 KeyNodeForKcb;
bool v23;
char v24;
char Count[20];
__int128 v26;
UINT64 RetryCount;
VOID **Array;
INT64 v29;
INT64 v30;
LIST_ENTRY v31;
_GENERIC_MAPPING *v32;
void **ObjectsSecurityDescriptora;
void *ModificationDescriptor;
UINT *SecurityInformationa;
struct _SECURITY_SUBJECT_CONTEXT SubjectContext;
KAPC_STATE ApcState;
v32 = GenericMapping;
v29 = 0xFFFFFFFFi64;
*(_OWORD *)&Count[4] = 0i64;
*(_WORD *)&Count[6] = -1;
ObjectsSecurityDescriptora = ObjectsSecurityDescriptor;
ModificationDescriptor = SecurityDescriptor;
v31.Blink = &v31;
v7 = 0;
SecurityInformationa = (UINT *)SecurityInformation;
v31.Flink = &v31;
v8 = 0;
*(_DWORD *)Count = 0;
v9 = 0;
Array = 0i64;
UoW = 0i64;
memset(&SubjectContext, 0, sizeof(SubjectContext));
v30 = 0i64;
v24 = 0;
memset(&ApcState, 0, sizeof(ApcState));
LODWORD(RetryCount) = 0;
v26 = 0i64;
SeCaptureSubjectContext(&SubjectContext);
CmpAttachToRegistryProcess(&ApcState);
while( 1 )
{
v23 = CmpAcquireShutdownRundown();
if( !v23 )
break;
if( v7 )
CmpLockRegistryExclusive();
else
CmpLockRegistry();
KeyControlBlock = KeyBody->KeyControlBlock;
if( (KeyControlBlock->KeyHash.KeyHive->HiveFlags & 0x100000) != 0
|| (int)CmpStartKcbStackForTopLayerKcb((INT64)&Count[4], (INT64)KeyControlBlock) < 0 )
{
goto LABEL_33;
}
if( !v7 )
{
CmpLockKcbStackTopExclusiveRestShared((__int64)&Count[4]);
v9 = 1;
}
if( CmpPerformKeyBodyDeletionCheck((__int64)KeyBody, 0i64) < 0
|| (*(_QWORD *)&KeyBody->Trans.0 || KeyBody->KtmUow)
&& (CmpTransSearchAddTransFromKeyBody(KeyBody, (_CM_TRANS **)&v30) < 0
|| CmpPerformKeyBodyDeletionCheck((__int64)KeyBody, v30) < 0)
|| *((_BYTE *)KeGetCurrentThread() + 562)
&& (KeyControlBlock->KeyHash.KeyHive[2].Storage[1].FreeDisplay[6].RealVectorSize & 0x20) != 0 )
{
goto LABEL_33;
}
if( KeyControlBlock->LayerHeight )
{
if( (unsigned int)CmpGetEffectiveKcbSemantics(KeyControlBlock) || v7 )
{
if( !(unsigned int)CmpGetEffectiveKcbSemantics(v19)
&& ((int)CmpPromoteKey((__int64)&Count[4], 1, 0) < 0 || (int)CmpPartialPromoteSubkeys((__int64)&Count[4]) < 0) )
{
goto LABEL_33;
}
goto LABEL_15;
}
v7 = 1;
v24 = 1;
CmpUnlockKcbStack((__int64)&Count[4]);
v9 = 0;
CmpCleanupKcbStack((INT64)&Count[4]);
*(_OWORD *)&Count[4] = 0i64;
*(_WORD *)&Count[6] = -1;
v26 = 0i64;
CmpUnlockRegistry();
CmpReleaseShutdownRundown();
}
else
{
LABEL_15:
CmTrans = (_CM_TRANS *)v30;
if( v30 )
{
if( (KeyControlBlock->KeyHash.KeyHive->HiveFlags & 2) == 0 )
{
UnitOfWork = CmpAllocateUnitOfWork();
UoW = UnitOfWork;
if( UnitOfWork )
{
CmpTransEnlistUowInKcb(UnitOfWork, KeyControlBlock);
CmpTransEnlistUowInCmTrans(UoW, CmTrans);
if( v18 >= 0
&& CmpLockIXLockExclusive((__int64)&KeyControlBlock->KCBLock, UoW, 0)
&& CmpLockIXLockExclusive((__int64)&KeyControlBlock->KeyLock, UoW, 1) )
{
LABEL_18:
if( !v24 )
{
HvLockHiveFlusherShared((INT64)KeyControlBlock->KeyHash.KeyHive);
v8 = 1;
CmLockHiveSecurityExclusive((_CMHIVE *)KeyControlBlock->KeyHash.KeyHive);
}
v14 = v8;
if( (int)CmpSetSecurityDescriptorInfo(
KeyControlBlock,
SecurityInformationa,
ModificationDescriptor,
ObjectsSecurityDescriptora,
PoolType,
v32,
CmTrans,
UoW) >= 0 )
{
UoW = 0i64;
if( v8 )
{
CmUnlockHiveSecurity((__int64)KeyControlBlock->KeyHash.KeyHive);
v14 = 0;
}
if( KeyControlBlock->LayerHeight && !(unsigned int)CmpGetEffectiveKcbSemantics(KeyControlBlock) )
{
KeyNodeForKcb = CmpGetKeyNodeForKcb(v21, (INT64)&v29, v8);
*(_BYTE *)(KeyNodeForKcb + 13) = *(_BYTE *)(KeyNodeForKcb + 13) & 0xFC | 2;
CmpReleaseKeyNodeForKcb(KeyControlBlock, (_HV_GET_CELL_CONTEXT *)&v29);
KeyControlBlock->LayerSemantics = 2;
}
if( v8 )
{
HvUnlockHiveFlusherShared((INT64)KeyControlBlock->KeyHash.KeyHive);
v8 = 0;
}
CmpReportNotifyForKcbStack((INT64)&Count[4], (INT64)CmTrans, 10i64, &v31);
}
if( v14 )
CmUnlockHiveSecurity((__int64)KeyControlBlock->KeyHash.KeyHive);
if( v8 )
HvUnlockHiveFlusherShared((INT64)KeyControlBlock->KeyHash.KeyHive);
}
if( UoW )
{
CmpRundownUnitOfWork((ULONG_PTR)UoW);
CmpFreeUnitOfWork(UoW);
}
}
}
LABEL_33:
v15 = 1;
goto LABEL_34;
}
p_KCBLock = (INT64)&KeyControlBlock->KCBLock;
if( !KeyControlBlock->KCBLock.OwnerCount )
{
p_KCBLock = (INT64)&KeyControlBlock->KeyLock;
if( !KeyControlBlock->KeyLock.OwnerCount )
goto LABEL_18;
}
v16 = 0;
if( (int)CmpSnapshotTxOwnerArray(p_KCBLock, (UINT64 *)Count, &Array) < 0 )
goto LABEL_33;
if( v9 )
CmpUnlockKcbStack((__int64)&Count[4]);
v9 = 0;
CmpCleanupKcbStack((INT64)&Count[4]);
*(_OWORD *)&Count[4] = 0i64;
*(_WORD *)&Count[6] = -1;
v26 = 0i64;
CmpUnlockRegistry();
v15 = 0;
CmpReleaseShutdownRundown();
if( (int)CmpRollbackTransactionArray(*(unsigned int *)Count, Array, v20, &RetryCount) < 0 )
goto LABEL_35;
v7 = v24;
}
}
v15 = 0;
LABEL_34:
v16 = v23;
LABEL_35:
if( v9 )
CmpUnlockKcbStack((__int64)&Count[4]);
CmpCleanupKcbStack((INT64)&Count[4]);
if( v15 )
CmpUnlockRegistry();
if( v31.Flink != &v31 )
CmpSignalDeferredPosts(&v31);
if( v16 )
CmpReleaseShutdownRundown();
CmpDetachFromRegistryProcess(&ApcState);
SeReleaseSubjectContext(&SubjectContext);
}Referenced by:
CmpSecurityMethod