PspIumAllocatePartitionState

NTSTATUS __stdcall PspIumAllocatePartitionState(INT64 a1){
  void *v2; 
  VOID **PoolWithTag; 
  VOID **v4; 
  unsigned int v6; 
  VOID *v7; 
  INT64 v8; 
  INT64 v9; 
  int v10; 
  VOID **v11; 

  v10 = 0;
  v2 = *(void **)(a1 + 16);
  PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0xA8ui64, 1884321097i64);
  v4 = PoolWithTag;
  v11 = PoolWithTag;
  if( !PoolWithTag )
    return -1073741670;
  *(_DWORD *)PoolWithTag = 0;
  *((_DWORD *)PoolWithTag + 22) = 0;
  *((_DWORD *)PoolWithTag + 1) = 0;
  PoolWithTag[1] = v2;
  PoolWithTag[2] = 0i64;
  v6 = *(_DWORD *)(a1 + 24);
  if( v6 < 8 )
    v6 = 8;
  *((_DWORD *)v4 + 38) = v6;
  v4[12] = 0i64;
  *((_WORD *)v4 + 52) = 8 * ((((unsigned __int64)((unsigned __int16)v4 & 0xFFF) + 4263) >> 12) + 6);
  *((_WORD *)v4 + 53) = 0;
  v4[16] = (VOID *)((unsigned __int64)v4 & 0xFFFFFFFFFFFFF000ui64);
  *((_DWORD *)v4 + 35) = (unsigned __int16)v4 & 0xFFF;
  *((_DWORD *)v4 + 34) = 168;
  MiProbeAndLockPages((INT64)(v4 + 12), 0, 1i64);
  LODWORD(v7) = MmAllocateSecureKernelPages(v2, *((unsigned int *)v4 + 38), 1u, 1, &v10);
  v4[20] = v7;
  if( v7 )
  {
    *((_DWORD *)v4 + 39) = *((_DWORD *)v4 + 38);
    if( v2 )
      ObfReferenceObjectWithTag(v2, 0x746C6644ui64);
    *(_QWORD *)(a1 + 16) = v4;
    *(_QWORD *)(a1 + 24) = v4[18];
    return 0;
  }
  else
  {
    if( (*((_BYTE *)v4 + 106) & 2) != 0 )
      MmUnlockPages((INT64)(v4 + 12), v8, v9);
    ExFreePoolWithTag(v4, 0);
    return -1073741670;
  }
}

Referenced by:

PsDispatchIumService