CmpAddSecurityCellToCache
INT64 __stdcall CmpAddSecurityCellToCache(CMHIVE *CmHive, UINT64 SecurityCell, UINT8 BuildUp){
__int64 v3;
unsigned int v5;
unsigned int SecurityCacheSize;
_CELL_DATA *v8;
_CELL_DATA *v9;
__int64 v10;
_CM_KEY_SECURITY_CACHE *v11;
_CM_KEY_SECURITY_CACHE *v12;
unsigned int Parent;
unsigned int v14;
__int64 v15;
_LIST_ENTRY *p_List;
_LIST_ENTRY *v17;
_LIST_ENTRY *Blink;
__int64 v19;
unsigned int v20;
__int64 v21;
_CM_KEY_SECURITY_CACHE_ENTRY *SecurityCache;
unsigned int v24;
int v25;
unsigned int v26;
void *(__fastcall *Allocate)(unsigned int, unsigned __int8, unsigned int);
_CM_KEY_SECURITY_CACHE_ENTRY *v28;
unsigned int SecurityCount;
_DWORD v30[10];
UINT64 Index;
HIDWORD(Index) = HIDWORD(v3);
v30[0] = -1;
LODWORD(Index) = 0;
v5 = SecurityCell;
v30[1] = 0;
if( CmpFindSecurityCellCacheIndex(CmHive, SecurityCell, &Index) == 1 )
return 0i64;
SecurityCacheSize = CmHive->SecurityCacheSize;
if( CmHive->SecurityCount == SecurityCacheSize )
{
SecurityCache = CmHive->SecurityCache;
v24 = 16 * SecurityCacheSize;
v25 = 256;
if( BuildUp != 1 )
v25 = 16;
v26 = SecurityCacheSize + v25;
Allocate = CmHive->Hive.Allocate;
CmHive->SecurityCacheSize = v26;
v28 = (_CM_KEY_SECURITY_CACHE_ENTRY *)Allocate(16 * v26, 0, 1666403651u);
SecurityCount = CmHive->SecurityCount;
CmHive->SecurityCache = v28;
if( !v28 )
{
CmHive->SecurityCache = SecurityCache;
CmHive->SecurityCacheSize = SecurityCount;
return 3221225626i64;
}
memmove(v28, SecurityCache, 16 * SecurityCount);
if( SecurityCache )
CmHive->Hive.Free(SecurityCache, v24);
}
v8 = CmHive->Hive.GetCellRoutine(CmHive, v5, v30);
v9 = v8;
if( v8 )
{
v10 = v8->u.KeyNode.Parent + 32;
if( v8->u.KeyNode.Parent < 0xFFFFFFE0 && (_DWORD)v10 != 32 )
{
v11 = (_CM_KEY_SECURITY_CACHE *)CmHive->Hive.Allocate(v10, 0i64, 1666403651i64);
v12 = v11;
if( v11 )
{
memmove(&v11->Descriptor, &v9->u.KeyString[10], v9->u.KeyNode.Parent);
v12->Cell = v5;
Parent = v9->u.KeyNode.Parent;
v12->RealRefCount = 0;
v12->DescriptorLength = Parent;
v14 = CmpSecConvKey(v9->u.KeyNode.Parent, (UINT64 *)&v9->u.KeyString[10]);
v12->ConvKey = v14;
v15 = v14 & 0x3F;
p_List = &v12->List;
v17 = &CmHive->SecurityHash[v15];
Blink = v17->Blink;
if( Blink->Flink != v17 )
__fastfail(3u);
v19 = (unsigned int)Index;
p_List->Flink = v17;
v12->List.Blink = Blink;
Blink->Flink = p_List;
v17->Blink = p_List;
v20 = CmHive->SecurityCount;
if( (unsigned int)v19 < v20 )
memmove(
&CmHive->SecurityCache[(unsigned int)(v19 + 1)],
&CmHive->SecurityCache[(unsigned int)v19],
16 * (v20 - v19));
v21 = v19;
CmHive->SecurityCache[v21].Cell = v5;
CmHive->SecurityCache[v21].CachedSecurity = v12;
++CmHive->SecurityCount;
CmHive->Hive.ReleaseCellRoutine((_HHIVE *)CmHive, (_HV_GET_CELL_CONTEXT *)v30);
return 0i64;
}
}
CmHive->Hive.ReleaseCellRoutine((_HHIVE *)CmHive, (_HV_GET_CELL_CONTEXT *)v30);
}
return 3221225626i64;
}Referenced by:
CmpInsertSecurityCellList
CmpSetSecurityDescriptorInfo
CmpValidateHiveSecurityDescriptors