MiEnablePartitionMappedWrites

NTSTATUS __stdcall MiEnablePartitionMappedWrites(_MI_PARTITION *Partition){
  int *v1; 
  unsigned int i; 
  _ETHREAD *CurrentThread; 
  _EPARTITION *PartitionObject; 
  NTSTATUS MappedWriterMdls; 
  unsigned int v8; 
  __int64 *v9; 
  int *v10; 
  __int64 v11; 
  __int64 v12[9]; 
  int v13; 
  int v14; 
  void *v15; 
  VOID *SystemProcessHandle; 

  v13 = 3;
  v12[0] = (__int64)MiDereferenceSegmentThread;
  v1 = &v13;
  v14 = 5;
  v12[1] = (__int64)MiMappedPageWriter;
  for( i = 0; i < 2; ++i )
  {
    if( !Partition->Core.SystemThreadHandles[*v1] )
      break;
    ++v1;
  }
  if( i == 2 )
    return 0;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  PartitionObject = Partition->Core.PartitionObject;
  v15 = 0i64;
  MappedWriterMdls = 0;
  SystemProcessHandle = PartitionObject->SystemProcessHandle;
  MiLockPartitionSystemThreads((INT64)Partition, (INT64)CurrentThread);
  v8 = 0;
  v9 = v12;
  v10 = &v13;
  while( 1 )
  {
    v11 = (unsigned int)*v10;
    if( Partition->Core.SystemThreadHandles[v11] )
      goto LABEL_13;
    if( (_DWORD)v11 == 5 )
    {
      MappedWriterMdls = MiAllocateMappedWriterMdls(Partition);
      if( MappedWriterMdls < 0 )
        goto LABEL_14;
    }
    if( !MiMakePartitionActive(Partition) )
      break;
    MappedWriterMdls = PsCreateSystemThreadEx(
                         (__int64)&v15,
                         0x1FFFFF,
                         0i64,
                         SystemProcessHandle,
                         0i64,
                         (VOID *)*v9,
                         (INT64)Partition,
                         0i64,
                         0i64);
    if( MappedWriterMdls < 0 )
      goto LABEL_16;
    Partition->Core.SystemThreadHandles[v11] = v15;
LABEL_13:
    ++v8;
    ++v10;
    ++v9;
    if( v8 >= 2 )
      goto LABEL_14;
  }
  MappedWriterMdls = -1073741523;
LABEL_16:
  if( (_DWORD)v11 == 5 )
    MiDeleteMappedMdls(Partition);
LABEL_14:
  MiUnlockPartitionSystemThreads((INT64)Partition, (INT64)CurrentThread);
  return MappedWriterMdls;
}

Referenced by:

MiCreatePagingFile