CmpAssignKeySecurity

INT64 __stdcall CmpAssignKeySecurity(_CM_KEY_BODY *KeyBody, PVOID SecurityDescriptor){
  char v4; 
  BOOL v5; 
  _CM_KEY_CONTROL_BLOCK *KeyControlBlock; 
  INT64 KeyHive; 
  int started; 
  INT64 KeyNodeForKcb; 
  POOL_TYPE v10; 
  INT64 v12[2]; 
  __int128 v13; 
  BOOL v14; 
  INT64 v15; 

  v15 = 0xFFFFFFFFi64;
  *(_OWORD *)v12 = 0i64;
  WORD1(v12[0]) = -1;
  v4 = 0;
  v13 = 0i64;
  v14 = CmpAcquireShutdownRundown();
  v5 = v14;
  if( v14 )
  {
    CmpLockRegistry();
    KeyControlBlock = KeyBody->KeyControlBlock;
    v4 = 1;
    KeyHive = (INT64)KeyControlBlock->KeyHash.KeyHive;
    started = CmpStartKcbStackForTopLayerKcb((INT64)v12, (INT64)KeyControlBlock);
    if( started >= 0 )
    {
      CmpLockKcbStackExclusive((INT64)v12);
      started = CmpPerformKeyBodyDeletionCheck(KeyBody, 0i64);
      if( started >= 0 )
      {
        HvLockHiveFlusherShared(KeyHive);
        CmLockHiveSecurityExclusive((_EX_PUSH_LOCK *)KeyHive);
        KeyNodeForKcb = CmpGetKeyNodeForKcb((INT64)KeyControlBlock, (INT64)&v15, 1);
        ObAssignObjectSecurityDescriptor(KeyBody, 0i64, v10);
        if( !KeGetCurrentThread()->PreviousMode
          && (*(_DWORD *)(KeyHive + 4152) & 0x20) != 0
          && *(_DWORD *)(KeyHive + 1864) )
        {
          SecurityDescriptor = (PVOID)(*(_QWORD *)(*(_QWORD *)(KeyHive + 1880) + 8i64) + 32i64);
        }
        started = CmpAssignSecurityDescriptor(
                    (UINT64)KeyControlBlock->KeyHash.KeyHive,
                    KeyControlBlock->KeyHash.KeyCell,
                    KeyNodeForKcb,
                    SecurityDescriptor,
                    0);
        if( started >= 0 )
        {
          CmpAssignSecurityToKcb((UINT64)KeyControlBlock, *(unsigned int *)(KeyNodeForKcb + 44), 0i64, 1, 0);
          started = 0;
        }
        if( KeyNodeForKcb )
          CmpReleaseKeyNodeForKcb((__int64)KeyControlBlock);
        CmUnlockHiveSecurity(KeyHive);
        HvUnlockHiveFlusherShared(KeyHive);
      }
      CmpUnlockKcbStack((INT64)v12);
    }
    v5 = v14;
  }
  else
  {
    started = -1073741431;
  }
  CmpCleanupKcbStack((INT64)v12);
  if( v4 )
    CmpUnlockRegistry();
  if( v5 )
    CmpReleaseShutdownRundown();
  return(unsigned int)started;
}

Referenced by:

CmpSecurityMethod