MiReadImageHeaders

NTSTATUS __stdcall MiReadImageHeaders(
        _FILE_OBJECT *FileObject,
        INT64 BugCheckParameter3,
        _MDL *MemoryDescriptorList,
        _LARGE_INTEGER *Timeout){
  __int64 v5; 
  _EPROCESS *Process; 
  __int64 v7; 
  unsigned __int64 v8; 
  NTSTATUS v11; 
  NTSTATUS LowPart; 
  _LARGE_INTEGER v13; 
  _MDL *i; 
  _EPROCESS *v16; 
  unsigned __int64 v17; 
  char *MappedSystemVa; 
  int v19; 
  unsigned __int64 v20; 
  size_t v21; 
  char *v22; 
  signed __int64 v23; 
  UINT64 Flags; 
  __int128 Object; 
  __int64 v26; 
  _LARGE_INTEGER StartingOffset; 

  v5 = (__int64)MemoryDescriptorList->MappedSystemVa & 0xFFF;
  Process = MemoryDescriptorList->Process;
  v7 = MemoryDescriptorList->ByteCount + 4095i64;
  Timeout[1].QuadPart = 0i64;
  v8 = (unsigned __int64)(v5 + v7) >> 12;
  StartingOffset.QuadPart = (_QWORD)Process << 12;
  if( BugCheckParameter3 )
  {
    LowPart = MiCopyFromDirectMapExtent(BugCheckParameter3);
  }
  else
  {
    Object = 0i64;
    v26 = 0i64;
    KeInitializeEvent((INT64)&Object, 0, 0);
    LODWORD(Flags) = 2;
    MiPageRead(
      FileObject,
      MemoryDescriptorList,
      &StartingOffset,
      (_KEVENT *)&Object,
      (_IO_STATUS_BLOCK *)Timeout,
      Flags,
      0i64);
    LowPart = v11;
    if( v11 == 259 )
    {
      KeWaitForSingleObject((UINT64)&Object, 9, 0, 0, 0i64);
      LowPart = Timeout->anonymous_0.LowPart;
    }
  }
  if( LowPart < 0 )
  {
    dword_140C4C958 = 32;
    if( !MiIsRetryIoStatus((unsigned int)LowPart, 0i64) && LowPart != -1073741740 && LowPart != -1073741209 )
      return -1073741792;
  }
  else
  {
    v13 = Timeout[1];
    if( v13.QuadPart != v8 << 12 )
      memset(
        (char *)MemoryDescriptorList->MappedSystemVa + v13.QuadPart,
        0i64,
        ((_DWORD)v8 << 12) - v13.anonymous_0.LowPart);
    for( i = MemoryDescriptorList->Next; i; i = i->Next )
    {
      v16 = i->Process;
      v17 = (((__int64)i->MappedSystemVa & 0xFFF) + (unsigned __int64)i->ByteCount + 4095) >> 12;
      if( Process < (_EPROCESS *)((char *)v16 + v17) && (_EPROCESS *)((char *)Process + v8) > v16 )
      {
        MappedSystemVa = (char *)MemoryDescriptorList->MappedSystemVa;
        if( v16 > Process )
        {
          v23 = (char *)v16 - (char *)Process;
          v22 = (char *)i->MappedSystemVa;
          if( v8 - v23 <= v17 )
            LODWORD(v17) = v8 - v23;
          MappedSystemVa += 4096 * v23;
          v21 = (_DWORD)v17 << 12;
        }
        else
        {
          v19 = v8;
          v20 = v17 - ((char *)Process - (char *)v16);
          if( v20 <= v8 )
            v19 = v20;
          v21 = v19 << 12;
          v22 = (char *)i->MappedSystemVa + 4096 * ((char *)Process - (char *)v16);
        }
        memmove(MappedSystemVa, v22, v21);
      }
    }
  }
  return LowPart;
}

Referenced by:

MiCreateImageFileMap