MiInsertSubsectionNode

VOID __stdcall MiInsertSubsectionNode(_CONTROL_AREA *ControlArea, _MSUBSECTION *Subsection, UINT64 LockHeld){
  unsigned __int64 *v3; 
  KIRQL v6; 
  _QWORD *v7; 
  bool v8; 
  unsigned __int64 v9; 
  unsigned __int64 v10; 
  unsigned __int64 v11; 
  _QWORD *v12; 
  v3 = (unsigned __int64 *)((char *)ControlArea + 272);
  if( (_DWORD)LockHeld )
    v6 = 17;
  else
    v6 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)ControlArea + 18);
  v7 = (_QWORD *)*v3;
  v8 = 0;
  if( !*v3 )
    goto LABEL_14;
  v9 = *((unsigned int *)Subsection + 9) | ((unsigned __int64)(*((_WORD *)Subsection + 16) & 0xFFC0) << 26);
  while( 1 )
  {
    v10 = *((unsigned int *)v7 - 5) | ((unsigned __int64)(*(_WORD *)(v7 - 3) & 0xFFC0) << 26);
    v11 = v10 + *((unsigned int *)v7 - 4);
    if( *((_WORD *)v7 - 11) < 0x10u )
      --v11;
    if( v9 <= v11 && v9 < v10 )
      break;
    v12 = (_QWORD *)v7[1];
    if( !v12 )
    {
      v8 = 1;
      goto LABEL_14;
    }
LABEL_12:
    v7 = v12;
  }
  v12 = (_QWORD *)*v7;
  if( *v7 )
    goto LABEL_12;
  v8 = 0;
LABEL_14:
  RtlAvlInsertNodeEx(v3, (__int64)v7, v8, (_QWORD *)Subsection + 7);
  ++v3[1];
  v3[2] = (unsigned __int64)Subsection;
  if( v6 != 17 )
  {
    ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)ControlArea + 9);
    __writecr8(v6);
  }
}

Referenced by:

MiAppendSubsectionChain
MiCreateDataFileMap