MiCreateKernelStackNode

_RTL_BALANCED_NODE *__fastcall MiCreateKernelStackNode(_WORD *a1, _QWORD *a2){
  _RTL_BALANCED_NODE *result; 
  _RTL_BALANCED_NODE *v5; 
  unsigned __int8 v6; 
  _QWORD *v7; 
  BOOL v8; 
  unsigned __int64 v9; 
  _RTL_BALANCED_NODE *v10; 
  _QWORD *v11; 

  result = (_RTL_BALANCED_NODE *)MiAllocatePool(64i64, 0x30ui64, 0x734B694Dui64);
  v5 = result;
  if( !result )
    return result;
  result[1].Children[0] = (_RTL_BALANCED_NODE *)(*a2 - 1i64);
  result[1].Children[1] = (_RTL_BALANCED_NODE *)a2[1];
  *(_WORD *)&result[1]._bf_0 = *a1;
  v6 = ExAcquireSpinLockExclusive((INT64 *)&stru_140C4DB30 + 446);
  v7 = (_QWORD *)*(&stru_140C4DB30 + 445);
  v8 = 0;
  v9 = v6;
  if( !*(&stru_140C4DB30 + 445) )
    goto LABEL_11;
  v10 = v5[1].Children[0];
  while( (unsigned __int64)v10 <= v7[3] && (unsigned __int64)v10 < v7[4] )
  {
    v11 = (_QWORD *)*v7;
    if( !*v7 )
      goto LABEL_11;
LABEL_9:
    v7 = v11;
  }
  v11 = (_QWORD *)v7[1];
  if( v11 )
    goto LABEL_9;
  v8 = 1;
LABEL_11:
  RtlAvlInsertNodeEx((_RTL_BALANCED_NODE **)&stru_140C4DB30 + 445, (UINT64)v7, v8, v5);
  ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)&stru_140C4DB30 + 446);
  __writecr8(v9);
  return v5;
}

Referenced by:

MiOutPageSingleKernelStack