MiProcessDereferenceList

VOID __stdcall MiProcessDereferenceList(_MI_PARTITION *Partition){
  int v1; 
  INT64 *v3; 
  KIRQL v4; 
  char *v5; 
  KIRQL v6; 
  __int64 *v7; 
  __int64 v8; 
  __int64 **v9; 
  __int64 *v10; 
  int v11; 
  _QWORD **v12; 
  _QWORD *v13; 
  UINT64 v14; 
  UINT8 v15; 
  UINT8 v16; 
  __int64 *v17; 
  __int64 v18; 
  INT64 v19; 
  __int128 v20; 
  UINT8 v21; 
  __int64 v22; 
  INT64 v23; 
  __int128 v24; 
  int v25; 
  int v26; 
  bool v27; 
  __int64 v28; 
  UINT64 v29; 
  INT64 result[2]; 
  __int128 v31; 
  __int128 v32; 
  __int128 v33; 
  __int128 v34; 
  _QWORD *v35; 
  int v36; 
  int v37; 
  v37 = v1;
  memset((INT64)result, 0i64);
  v36 = 0;
  v3 = (INT64 *)((char *)Partition + 1344);
  v4 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)Partition + 336);
  v5 = (char *)Partition + 1552;
LABEL_2:
  v6 = v4;
  do
  {
    v7 = *(__int64 **)v5;
    if( *(char **)v5 != v5 )
    {
      v8 = *v7;
      if( (char *)v7[1] != v5 || *(__int64 **)(v8 + 8) != v7 )
LABEL_41:
        __fastfail(3u);
      *(_QWORD *)v5 = v8;
      *(_QWORD *)(v8 + 8) = v5;
      if( (unsigned int)ExTryAcquireSpinLockExclusiveAtDpcLevel(v7 + 8) )
      {
        *((_DWORD *)v7 + 12) &= ~0x8000000u;
        v7[1] = (__int64)v7;
        *v7 = (__int64)v7;
        ExReleaseSpinLockExclusiveFromDpcLevel(v3);
        ExReleaseSpinLockExclusiveFromDpcLevel(v7 + 8);
        __writecr8(v6);
        MiSegmentDelete((__int64)(v7 - 1));
      }
      else
      {
        v17 = *(__int64 **)v5;
        if( *(char **)(*(_QWORD *)v5 + 8i64) != v5 )
          goto LABEL_41;
        *v7 = (__int64)v17;
        v7[1] = (__int64)v5;
        v17[1] = (__int64)v7;
        *(_QWORD *)v5 = v7;
        ExReleaseSpinLockExclusiveFromDpcLevel(v3);
        __writecr8(v6);
      }
      v4 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)v3);
      goto LABEL_2;
    }
    v9 = (__int64 **)((char *)Partition + 1584);
    while( 1 )
    {
      v10 = *v9;
      if( *v9 == (__int64 *)v9 )
        break;
      v18 = *v10;
      if( (__int64 **)v10[1] != v9 || *(__int64 **)(v18 + 8) != v10 )
        goto LABEL_41;
      *v9 = (__int64 *)v18;
      v19 = (INT64)(v10 - 1);
      *(_QWORD *)(v18 + 8) = v9;
      if( *(_QWORD *)(v19 + 32) == -1i64 )
      {
        if( ExAcquireRundownProtection((PEX_RUNDOWN_REF)Partition + 119) )
        {
          ExReleaseSpinLockExclusiveFromDpcLevel(v3);
          __writecr8(v6);
          MiAttemptPageFileReduction(v19);
          ExReleaseRundownProtection((PEX_RUNDOWN_REF)Partition + 119);
          v6 = ExAcquireSpinLockExclusive((PEX_SPIN_LOCK)v3);
        }
        if( (*(_BYTE *)(v19 + 79) & 0x10) == 0 )
          KeSetEvent((PRKEVENT)(v19 + 48), 0);
      }
      else
      {
        *(_OWORD *)result = *(_OWORD *)v19;
        v31 = *(_OWORD *)(v19 + 16);
        v32 = *(_OWORD *)(v19 + 32);
        v33 = *(_OWORD *)(v19 + 48);
        v20 = *(_OWORD *)(v19 + 64);
        v35 = (_QWORD *)v19;
        v34 = v20;
        *(_QWORD *)(v19 + 80) = result;
        ExReleaseSpinLockExclusiveFromDpcLevel(v3);
        __writecr8(v6);
        if( ExAcquireRundownProtection((PEX_RUNDOWN_REF)Partition + 119) )
        {
          MiExtendPagingFiles((INT64)result);
          ExReleaseRundownProtection((PEX_RUNDOWN_REF)Partition + 119);
        }
        v21 = MiProcessingPageExtendComplete((INT64)result, v19, (INT64)Partition);
        --*((_DWORD *)Partition + 467);
        v6 = v21;
        if( *((_DWORD *)Partition + 466) )
          KeSetEvent((PRKEVENT)Partition + 78, 0);
      }
    }
    v11 = v37;
    if( v37 )
    {
      v12 = (_QWORD **)((char *)Partition + 1568);
      while( 1 )
      {
        v13 = *v12;
        if( *v12 == v12 )
          break;
        v22 = *v13;
        if( (_QWORD **)v13[1] != v12 || *(_QWORD **)(v22 + 8) != v13 )
          goto LABEL_41;
        *v12 = (_QWORD *)v22;
        v23 = (INT64)(v13 - 1);
        *(_QWORD *)(v22 + 8) = v12;
        *(_OWORD *)result = *(_OWORD *)(v13 - 1);
        v31 = *(_OWORD *)(v13 + 1);
        v32 = *(_OWORD *)(v13 + 3);
        v33 = *(_OWORD *)(v13 + 5);
        v24 = *(_OWORD *)(v13 + 7);
        v35 = v13 - 1;
        v34 = v24;
        v13[9] = result;
        ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)Partition + 168);
        __writecr8(v6);
        MiRemoveUnusedSegments(Partition);
        v25 = v36;
        v27 = v26 == 0;
        v28 = *((_QWORD *)&v32 + 1);
        if( !v27 )
          v25 = 1;
        v36 = v25;
        if( v25 )
          v28 = 1i64;
        *((_QWORD *)&v32 + 1) = v28;
        v6 = MiProcessingPageExtendComplete((INT64)result, v23, (INT64)Partition);
      }
      v11 = v37;
      v3 = (INT64 *)((char *)Partition + 1344);
    }
  }
  while( *(char **)v5 != v5
       || v11 && *((_MI_PARTITION **)Partition + 196) != (_MI_PARTITION *)((char *)Partition + 1568)
       || *v9 != (__int64 *)v9 );
  ExReleaseSpinLockExclusiveFromDpcLevel(v3);
  __writecr8(v6);
  if( *((_DWORD *)Partition + 453) )
  {
    KeResetEvent((char *)Partition + 1808, v14, v15, v16, (IRP *)result[0]);
    MiFreeClonePool(Partition, v29);
  }
}

Referenced by:

MiDereferenceSegmentThread
MiRemoveUnusedSegments