MiReferenceDataSubsections

NTSTATUS __stdcall MiReferenceDataSubsections(_CONTROL_AREA *ControlArea, UINT64 *a2, UINT64 a3, INT64 a4, INT64 a5){
  UINT64 v6; 
  int v7; 
  int v8; 
  _SUBSECTION *v10; 
  UINT64 v11; 
  unsigned int v12; 
  NTSTATUS v13; 
  int v14; 
  int v15; 
  int v17; 
  unsigned int v18; 
  _SUBSECTION *SubsectionNode; 
  int v20; 
  __int64 v21[6]; 

  v6 = *a2;
  v7 = 0;
  v8 = a4;
  v21[0] = 0i64;
  *(_DWORD *)a5 = 3;
  v20 = 0;
  v10 = MiOffsetToProtos(ControlArea, v6, (UINT64 *)v21);
  if( !v10 )
    return -1073741793;
  v11 = v21[0] + a3;
  if( v8 )
  {
    v12 = 136;
    if( !v21[0] && (a3 & 0x1FF) == 0 )
    {
      if( ControlArea->FilePointer.Value )
      {
        LOBYTE(v17) = MiControlAreaUsingExtents((INT64)ControlArea);
        if( v17 )
        {
          v20 = 1;
          if( a3 == v10->PtesInSubsection && !v10->SubsectionBase )
            v12 = 1160;
        }
      }
    }
  }
  else
  {
    v12 = 264;
  }
  v13 = MiAddViewsForSection(v10, v11, v12);
  v14 = v13;
  if( (v12 & 0x400) == 0 )
    goto LABEL_5;
  if( v13 < 0 )
  {
    v14 = MiAddViewsForSection(v10, v11, v12 & 0xFFFFFBFF);
LABEL_5:
    v15 = 0;
    goto LABEL_6;
  }
  v15 = 1;
LABEL_6:
  if( v14 >= 0 && v20 )
  {
    if( v15 )
    {
      LOBYTE(v7) = (v10->u1.e1._bf_0 & 0xC0000000) == 0x40000000;
      *(_DWORD *)a5 = v7;
    }
    else
    {
      v18 = MiIncrementLargeSubsections((INT64 *)v10, v11);
      if( v18 != -1 )
      {
        do
        {
          if( !(a3 % MiLargePageSizes[v18]) )
            break;
          ++v18;
        }
        while( v18 <= 1 );
        if( v18 > 1 )
        {
          SubsectionNode = MiLocateSubsectionNode(ControlArea, (a3 << 12) + *a2 - 1, 0i64);
          MiDecrementLargeSubsections(&v10->ControlArea, (INT64)SubsectionNode);
        }
        else
        {
          *(_DWORD *)a5 = v18;
        }
      }
    }
  }
  return v14;
}

Referenced by:

MiInsertInSystemSpace