CmpFindMatchingDescriptorCell

UINT8 __stdcall CmpFindMatchingDescriptorCell(
        CMHIVE *CmHive,
        VOID *SecurityDescriptor,
        UINT64 Type,
        UINT64 *MatchingCell,
        CM_KEY_SECURITY_CACHE **CachedSecurityPointer){
  UINT64 v8; 
  UINT64 *v9; 
  int v10; 
  _LIST_ENTRY *v11; 
  _LIST_ENTRY *i; 
  CM_KEY_SECURITY_CACHE *p_Blink; 
  unsigned int Cell; 
  int v16; 

  v16 = Type;
  v8 = (unsigned int)RtlLengthSecurityDescriptorStrict(SecurityDescriptor);
  v10 = CmpSecConvKey(v8, v9);
  v11 = &CmHive->SecurityHash[v10 & 0x3F];
  for( i = v11->Flink; ; i = i->Flink )
  {
    if( i == v11 )
      return 0;
    p_Blink = (CM_KEY_SECURITY_CACHE *)&i[-1].Blink;
    if( HIDWORD(i[-1].Blink) == v10 )
    {
      Cell = p_Blink->Cell;
      if( v16 == p_Blink->Cell >> 31
        && (_DWORD)v8 == p_Blink->DescriptorLength
        && !memcmp(SecurityDescriptor, &p_Blink->Descriptor, v8) )
      {
        break;
      }
    }
  }
  *(_DWORD *)MatchingCell = Cell;
  if( CachedSecurityPointer )
    *CachedSecurityPointer = p_Blink;
  return 1;
}

Referenced by:

CmpGetSecurityDescriptorNode
CmpSetSecurityDescriptorInfo