MiAddSecureEntry

_DWORD *__fastcall MiAddSecureEntry(_MI_PARTITION *Partition, __int64 a2, __int64 a3, int a4, int a5){
  int v9; 
  _DWORD *PoolMm; 
  _DWORD *v11; 

  if( ((__int64)Partition->Core.PfnUnmapWorkItem.List.Flink & 8) != 0
    && ((a5 & 1) != 0 || MiLocateExclusiveSecure((__int64)Partition)) )
  {
    return 0i64;
  }
  LOWORD(v9) = MmGetCurrentProcessorColor();
  PoolMm = ExAllocatePoolMm(64i64, 0x48ui64, 0x65536D4Dui64, v9 | 0x80000000);
  v11 = PoolMm;
  if( !PoolMm )
    return 0i64;
  PoolMm[16] = 2;
  *((_QWORD *)PoolMm + 1) = a2;
  *((_QWORD *)PoolMm + 2) = a3;
  if( (a4 & 1) != 0 )
  {
    LODWORD(a2) = a2 | 8;
    goto LABEL_8;
  }
  if( (a4 & 4) != 0 )
  {
    LODWORD(a2) = a2 | 0xA;
    goto LABEL_8;
  }
  if( (a4 & 2) != 0 )
  {
    LODWORD(a2) = a2 | 9;
LABEL_8:
    PoolMm[2] = a2;
  }
  if( (a5 & 1) != 0 )
  {
    LODWORD(a2) = a2 | 0x20;
    PoolMm[2] = a2;
  }
  if( (a5 & 4) != 0 )
  {
    LODWORD(a2) = a2 | 0x40;
    PoolMm[2] = a2;
  }
  if( (a5 & 8) != 0 )
  {
    LODWORD(a2) = a2 | 0x80;
    PoolMm[2] = a2;
  }
  if( a4 < 0 )
  {
    LODWORD(a2) = a2 | 4;
    PoolMm[2] = a2;
  }
  if( (a4 & 0x40000000) != 0 )
  {
    LODWORD(a2) = a2 | 0x10;
    PoolMm[2] = a2;
  }
  if( (a4 & 0x20000000) != 0 )
    PoolMm[2] = a2 | 0x100;
  MiInsertVadEvent((__int64)Partition, PoolMm, 1);
  MiSetVadFlags(Partition, 1ui64, 1);
  return v11;
}

Referenced by:

MiAllocateNewSubAllocatedRegion
MiAllocateVad
MiCloneNoChange
MiMapLockedPagesInUserSpace
MiMapViewOfDataSection
MiMapViewOfImageSection
MiReserveUserMemory
MiSecureVad
MmSecureVirtualMemoryAgainstWrites