MmManagePartitionNodeInformation

INT64 __fastcall MmManagePartitionNodeInformation(INT64 a1, UINT64 *a2, CHAR a3){
  void *v5; 
  unsigned int v6; 
  __int64 v7; 
  UINT64 v8; 
  void *v9; 
  UINT8 *v10; 
  _QWORD *v11; 
  _QWORD *v12; 
  unsigned int v13; 
  INT64 *v14; 
  _ETHREAD *CurrentThread; 
  __int64 v17; 
  void *v19; 
  v5 = 0i64;
  v19 = 0i64;
  if( *((_DWORD *)a2 + 1) || (v7 = *(unsigned int *)a2, (_DWORD)v7 != (unsigned __int16)KeNumberNodes) )
  {
    v6 = -1073741811;
    goto LABEL_20;
  }
  v8 = 72 * v7;
  v17 = 72 * v7;
  if( a3 )
  {
    LODWORD(v9) = MiAllocatePool((struct _SLIST_ENTRY *)0x40);
    v5 = v9;
    v19 = v9;
    if( !v9 )
    {
      v6 = -1073741670;
      goto LABEL_20;
    }
    v10 = (UINT8 *)v9;
    LODWORD(v7) = *(_DWORD *)a2;
  }
  else
  {
    v10 = (UINT8 *)a2[1];
  }
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  v11 = *(_QWORD **)(*(_QWORD *)a1 + 16i64);
  if( (_DWORD)v7 )
  {
    v12 = v10 + 56;
    v13 = 0;
    do
    {
      memset((INT64)(v12 - 7), 0i64);
      --*((_WORD *)CurrentThread + 243);
      ExAcquirePushLockSharedEx((UINT64)(v11 + 537), 0i64);
      *(v12 - 7) = v11[522];
      *(v12 - 5) = v11[516];
      *(v12 - 6) = v11[517];
      *(v12 - 3) = v11[268];
      *(v12 - 4) = v11[269];
      *(v12 - 1) = v11[134];
      *(v12 - 2) = v11[135];
      v12[1] = *v11;
      *v12 = v11[1];
      v14 = v11 + 537;
      if( _InterlockedCompareExchange64(v11 + 537, 0i64, 17i64) != 17 )
      {
        ExfReleasePushLockShared(v14);
        v14 = v11 + 537;
      }
      KeAbPostRelease(v14);
      KiLeaveGuardedRegionUnsafe((__int64)CurrentThread);
      if( (unsigned __int64)(*(v12 - 5)
                            + ((*v12 + v12[1]) << 18)
                            + *(v12 - 6)
                            + 16 * (*(v12 - 3) + *(v12 - 4) + 32i64 * (*(v12 - 1) + *(v12 - 2)))) <= *(v12 - 7) )
      {
        ++v13;
        v11 += 568;
        v12 += 9;
      }
    }
    while( v13 < *(_DWORD *)a2 );
    v5 = v19;
    v8 = v17;
  }
  if( a3 )
  {
    ProbeForWrite((VOID *)a2[1], v8, 8ui64);
    memmove((UINT8 *)a2[1], v10, v8);
  }
  v6 = 0;
LABEL_20:
  if( v5 )
    ExFreePoolWithTag(v5, 0);
  return v6;
}

Referenced by:

NtManagePartition