IoStartDiskIoAttributionForContext

VOID __stdcall IoStartDiskIoAttributionForContext(PVOID Context){
  KIRQL v2; 
  unsigned __int64 v3; 
  unsigned __int64 v4; 
  bool v5; 
  int v6; 
  unsigned __int64 v7; 
  v2 = ExAcquireSpinLockExclusive(&IopDiskIoAttributionLock);
  v3 = (unsigned __int64)IopDiskIoAttributionTree;
  v4 = v2;
  if( (*(_BYTE *)(&IopDiskIoAttributionTree + 1) & 1) != 0 && IopDiskIoAttributionTree )
    v3 = (unsigned __int64)&IopDiskIoAttributionTree ^ (unsigned __int64)IopDiskIoAttributionTree;
  v5 = 0;
  v6 = *(_BYTE *)(&IopDiskIoAttributionTree + 1) & 1;
  if( v3 )
  {
    while( 1 )
    {
      if( (int)IopDiskIoAttributionTreeCompare((char *)Context + 24, (RTL_BALANCED_NODE *)v3) < 0 )
      {
        v7 = *(_QWORD *)v3;
        if( v6 )
        {
          if( !v7 )
            goto LABEL_15;
          v7 ^= v3;
        }
        if( !v7 )
        {
LABEL_15:
          v5 = 0;
          break;
        }
      }
      else
      {
        v7 = *(_QWORD *)(v3 + 8);
        if( v6 )
        {
          if( !v7 )
            goto LABEL_16;
          v7 ^= v3;
        }
        if( !v7 )
        {
LABEL_16:
          v5 = 1;
          break;
        }
      }
      v3 = v7;
    }
  }
  RtlRbInsertNodeEx((unsigned __int64 *)&IopDiskIoAttributionTree, v3, v5, (unsigned __int64)Context);
  ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)&IopDiskIoAttributionLock);
  __writecr8(v4);
}

Referenced by:

PspIoRateEntryActivate
PspSetJobIoAttribution