SmcStoreCreate
NTSTATUS __stdcall SmcStoreCreate(
_SMC_CACHE_MANAGER *CacheMgr,
_SM_STORE_MANAGER_TYPE StoreMgrType,
_SM_STORE_BASIC_PARAMS *StoreParams,
UINT64 CacheId,
UINT64 *StoreIdOut){
unsigned int v8;
_PRIVILEGE_SET *v9;
UINT64 v10;
_SMC_CACHE *v11;
int v12;
UINT64 RegionCountMax;
_SMC_STORE_ENTRY *v14;
_SMC_CACHE v15;
_SM_STORE_BASIC_PARAMS v16;
unsigned __int16 v17;
unsigned int v18;
int v19;
unsigned int EncryptionKeySize;
_PRIVILEGE_SET *v21;
__int64 v22;
int v23;
_SMKM_STORE_REG_PARAMS RegParams;
__int128 v26;
INT64 CreateParams[2];
_SMC_CACHE v28;
int v29;
_SMC_CACHE v30;
int v31;
_PRIVILEGE_SET *v32;
unsigned int v33;
int v34;
_OWORD *v35;
_SMC_CACHE *v36;
__int128 *v37;
_OWORD v38[4];
char v39;
v39 = CacheId;
v8 = CacheId;
memset(v38, 0i64, sizeof(v38));
RegParams = 0i64;
v29 = 0;
v26 = 0i64;
v31 = 0;
v9 = 0i64;
v34 = 0;
v11 = SmcCacheReference(CacheMgr, v8);
if( !v11 )
return -1073741672;
RegionCountMax = StoreParams->RegionCountMax;
if( !(_DWORD)RegionCountMax )
{
v12 = -1073741811;
goto LABEL_23;
}
if( v11[6] != StoreParams->RegionSize || (unsigned __int8)StoreParams->StoreFlags != 1 )
{
v12 = -1073741637;
goto LABEL_23;
}
v14 = SmcStoreSlotReserve(v11, v10, RegionCountMax);
if( v14 )
{
v15 = v11[2];
v16 = *StoreParams;
v17 = (unsigned __int16)v11[7] << 13;
*(_SM_STORE_BASIC_PARAMS *)CreateParams = v16;
HIDWORD(CreateParams[1]) = v15;
v18 = v16.StoreFlags ^ (LOWORD(v16.StoreFlags) ^ v17) & 0x6000;
v30 = v11[1];
v28 = v11[8];
v38[2] = 0i64;
v38[0] = *(_OWORD *)(v11 + 10);
v38[1] = *(_OWORD *)(v11 + 14);
*(_QWORD *)&v38[3] = *((_QWORD *)v11 + 11);
*((_QWORD *)&v38[3] + 1) = (unsigned int)v11[24];
v35 = v38;
LODWORD(CreateParams[0]) = v18;
v12 = SmKmRegParamsLoad(&RegParams);
if( v12 >= 0 )
{
if( (v11[7] & 1) == 0 )
{
v19 = RegParams.Crypto._bf_4 & 3;
if( v19 == 2 || v19 == 1 && (v18 & 0x800) != 0 )
{
EncryptionKeySize = 0;
goto LABEL_19;
}
}
EncryptionKeySize = RegParams.Crypto.EncryptionKeySize;
LODWORD(v21) = SSHSupportAllocateNonPaged(RegParams.Crypto.EncryptionKeySize, 0x4B456D73u);
v9 = v21;
if( v21 )
{
v12 = SmKmKeyGenGenerate(CacheMgr + 128, v11 + 138, v21, EncryptionKeySize);
if( v12 >= 0 )
{
LABEL_19:
v22 = *((_QWORD *)v14 + 1);
LODWORD(v26) = v11[2];
v37 = &v26;
*((_QWORD *)&v26 + 1) = v22;
v36 = v11 + 26;
v32 = v9;
v33 = EncryptionKeySize;
SmStoreCreate(StoreMgrType, (INT64)CreateParams);
v12 = v23;
if( v23 >= 0 )
{
SmcStoreSlotCommit(v11, v14, 0i64, StoreMgrType);
v14 = 0i64;
v12 = 0;
*(_DWORD *)StoreIdOut = 0;
}
}
}
else
{
v12 = -1073741670;
}
}
if( v14 )
SmcStoreSlotAbort(v11, v14, 0i64);
goto LABEL_23;
}
v12 = -1073741697;
LABEL_23:
ExReleaseRundownProtection((_EX_RUNDOWN_REF *)&CacheMgr[8 * (v39 & 0xF) + 2]);
if( v9 )
CmSiFreeMemory(v9);
return v12;
}Referenced by:
SmcProcessStoreCreateRequest