MiInsertClone

VOID __stdcall MiInsertClone(_EPROCESS *CurrentProcess, _MMCLONE_DESCRIPTOR *Clone){
  int v2; 
  BOOL v3; 
  _RTL_BALANCED_NODE *Root; 
  _RTL_BALANCED_NODE *v7; 

  v3 = 0;
  if( v2 )
    MiDeleteCloneZombies((INT64)CurrentProcess, 1i64);
  Root = CurrentProcess->CloneRoot.Root;
  if( Root )
  {
    while( 1 )
    {
      if( Clone->StartingCloneBlock > (_MMCLONE_BLOCK *)Root[1].Children[1]
        || Clone->EndingCloneBlock >= (_MMCLONE_BLOCK *)Root[1].Children[0] )
      {
        v7 = Root->Children[1];
        if( !v7 )
        {
          v3 = 1;
          break;
        }
      }
      else
      {
        v7 = Root->Children[0];
        if( !Root->Children[0] )
          break;
      }
      Root = v7;
    }
  }
  RtlAvlInsertNodeEx(&CurrentProcess->CloneRoot.Root, (UINT64)Root, v3, &Clone->CloneNode);
}

Referenced by:

MiCloneProcessAddressSpace
MiCloneVads