MiTrimSharedPage

__int64 __fastcall MiTrimSharedPage(__int64 a1, unsigned __int8 a2, unsigned int a3){
  __int64 v3; 
  unsigned __int64 v4; 
  _MMPTE *v6; 
  unsigned int v7; 
  char v8; 
  char v9; 
  char v10; 
  unsigned int v11; 
  char v12; 
  __int64 v13; 
  __int64 v14; 
  __int64 v15; 
  _QWORD *v16; 
  _SUBSECTION *v18; 
  _QWORD *v19; 
  __int64 v20[5]; 
  int v21; 
  int v22; 
  INT64 *v23; 
  ULONG_PTR BugCheckParameter2; 
  v3 = *(_QWORD *)(a1 + 8);
  v4 = a2;
  v22 = 0;
  v6 = (_MMPTE *)(v3 | 0x8000000000000000ui64);
  v23 = 0i64;
  BugCheckParameter2 = 0i64;
  v7 = (a3 >> 18) & 1 | 2;
  if( (a3 & 0x80000) == 0 )
    v7 = (a3 >> 18) & 1;
  v8 = v7 | 4;
  if( (a3 & 0x20000) == 0 )
    v8 = v7;
  v9 = v8 | 8;
  if( (a3 & 0x10000000) == 0 )
    v9 = v8;
  v10 = v9 | 0x10;
  v11 = a3 & 0x800000;
  if( (a3 & 0x800000) == 0 )
    v10 = v9;
  v12 = v10 | 0x40;
  if( (a3 & 0x3000000) == 0 )
    v12 = v10;
  if( (*(_DWORD *)(a1 + 16) & 0x400i64) == 0 )
  {
    _InterlockedAnd64((volatile signed __int64 *)(a1 + 24), 0x7FFFFFFFFFFFFFFFui64);
    __writecr8(v4);
    v18 = MiReferencePfBackedSection(v6);
    v15 = (__int64)v18;
    if( v18 )
    {
      v13 = *(_QWORD *)v18;
      if( !v11 || *(int *)(v13 + 56) >= 0 || (unsigned int)MiClusterVadFull((_MMPFN *)a1, v18) != 1 )
        goto LABEL_17;
      MiDecrementModifiedWriteCount((_CONTROL_AREA *)v13, 0i64);
      if( v19 )
        MiReleaseControlAreaWaiters(v19);
    }
    MiLockPageInline(a1);
    return 0i64;
  }
  v13 = MiPreventControlAreaDeletion(a1, 0i64, (INT64 *)&BugCheckParameter2, &v23);
  if( !v13 )
    return 0i64;
  v14 = *(_QWORD *)(a1 + 16);
  if( qword_140C4DC80 && (v14 & 0x10) == 0 )
    v14 &= ~qword_140C4DC80;
  v15 = v14 >> 16;
  _InterlockedAnd64((volatile signed __int64 *)(a1 + 24), 0x7FFFFFFFFFFFFFFFui64);
  __writecr8(v4);
  MiReleaseControlAreaWaiters(v23);
LABEL_17:
  v21 = 0;
  v20[0] = v13;
  v20[1] = (__int64)v6;
  v20[2] = (__int64)v6;
  v20[3] = v15;
  v20[4] = v15;
  if( (unsigned int)MiTrimSection(v20, 1, v12) || (*(_BYTE *)(a1 + 34) & 7) == 6 )
    MiTrimSection(v20, 1, v12);
  if( BugCheckParameter2 )
    MiDecrementSubsection((PVOID)BugCheckParameter2);
  MiDecrementModifiedWriteCount((_CONTROL_AREA *)v13, 0i64);
  if( v16 )
    MiReleaseControlAreaWaiters(v16);
  MiLockPageInline(a1);
  if( (*(_BYTE *)(a1 + 34) & 7) != 6 )
    return 2i64;
  return 0i64;
}

Referenced by:

MiMarkFileOnlyPfnBad
MiTradePage
MiWalkEntireImage