CmpCreateHiveRootCell
INT64 __fastcall CmpCreateHiveRootCell(UINT64 a1, INT64 a2, _UNICODE_STRING *a3, INT64 a4, UINT64 *a5){
unsigned int v9;
ULONG_PTR v10;
size_t v11;
_WORD *v12;
VOID *v13;
unsigned __int16 v14;
NTSTATUS v15;
int v16;
PVOID v17;
__int64 v19;
void *v20;
INT64 v21;
INT64 v22;
VOID *CellAddress;
_HV_GET_CELL_CONTEXT CellAddressContext;
PVOID NewDescriptor;
*((_WORD *)&CellAddressContext.BinContext + 1) = 0;
CellAddress = 0i64;
NewDescriptor = 0i64;
CellAddressContext.Cell = -1;
CellAddressContext.BinContext = 0;
HvLockHiveFlusherShared(a1);
v9 = CmpNameSize(a3) + 76;
v10 = HvAllocateCell(a1, v9, 0, &CellAddress, &CellAddressContext);
if( v10 == -1 )
{
v16 = -1073741670;
CmpRecordParseFailure(a4, 196864i64, 3221225626i64);
v13 = CellAddress;
goto LABEL_9;
}
v11 = v9;
v12 = CellAddress;
memset(CellAddress, 0i64, v11);
*(_DWORD *)v12 = 813934;
v13 = CellAddress;
*(_QWORD *)((char *)CellAddress + 4) = *(_QWORD *)&KUSER_SHARED_DATA.SystemTime.LowPart;
*((_DWORD *)v13 + 4) = -1;
*((_DWORD *)v13 + 7) = -1;
*((_DWORD *)v13 + 8) = -1;
*((_DWORD *)v13 + 10) = -1;
*((_DWORD *)v13 + 11) = -1;
*((_DWORD *)v13 + 12) = -1;
v14 = CmpCopyName((PWCHAR)v13 + 38, a3);
*((_WORD *)v13 + 36) = v14;
if( v14 < a3->Length )
v12[1] |= 0x20u;
if( (*(_DWORD *)(a1 + 4152) & 0x20) != 0 )
{
NewDescriptor = CmpGenerateAppHiveSecurityDescriptor();
if( NewDescriptor )
{
LABEL_6:
CmLockHiveSecurityExclusive((_EX_PUSH_LOCK *)a1);
v16 = CmpAssignSecurityDescriptor(a1, v10, (INT64)v13, NewDescriptor, 0);
CmUnlockHiveSecurity(a1);
if( v16 < 0 )
{
v21 = (unsigned int)v16;
v22 = 197632i64;
}
else
{
HvLockHiveWriter(*(_QWORD *)(a4 + 48));
HvMarkBaseBlockDirty(*(_HHIVE **)(a4 + 48));
v16 = HvCheckAndUpdateHiveBackupTimeStamp(*(_HHIVE **)(a4 + 48));
HvUnlockHiveWriter(*(_QWORD *)(a4 + 48));
if( v16 >= 0 )
{
*(_DWORD *)(*(_QWORD *)(a1 + 64) + 36i64) = v10;
*(_DWORD *)a5 = v10;
v10 = -1;
v16 = 0;
goto LABEL_9;
}
v21 = (unsigned int)v16;
v22 = 197888i64;
}
goto LABEL_26;
}
v21 = 3221225626i64;
v22 = 197120i64;
v16 = -1073741670;
}
else
{
v15 = SeAssignSecurity(
0i64,
*(VOID **)(a2 + 64),
&NewDescriptor,
1u,
(_SECURITY_SUBJECT_CONTEXT *)(a2 + 32),
(_GENERIC_MAPPING *)((char *)CmKeyObjectType + 76),
*((POOL_TYPE *)CmKeyObjectType + 25));
v16 = v15;
if( v15 >= 0 )
goto LABEL_6;
v21 = (unsigned int)v15;
v22 = 197376i64;
}
LABEL_26:
CmpRecordParseFailure(a4, v22, v21);
LABEL_9:
v17 = NewDescriptor;
if( NewDescriptor )
{
if( (*(_DWORD *)(a1 + 4152) & 0x20) != 0 )
{
ExFreePoolWithTag(NewDescriptor, 0);
}
else if( (*(_DWORD *)a4 & 1) != 0 && (*(_DWORD *)(a4 + 24) & 4) != 0 )
{
SeDeassignSecurity(&NewDescriptor);
}
else
{
v19 = *(_QWORD *)(a2 + 72);
v20 = *(void **)(v19 + 48);
if( v20 )
ExFreePoolWithTag(v20, 0);
*(_QWORD *)(v19 + 48) = v17;
}
}
if( v13 )
(*(void(__fastcall **)(UINT64, _HV_GET_CELL_CONTEXT *))(a1 + 16))(a1, &CellAddressContext);
if( v10 != -1 )
HvFreeCell(a1, v10);
HvUnlockHiveFlusherShared(a1);
return(unsigned int)v16;
}Referenced by:
CmpDoParseKey