Skip to main content
MapViewOfFile2 function

Maps a view of a file or a pagefile-backed section into the address space of the specified process.


PVOID MapViewOfFile2(
  _In_     HANDLE  FileMappingHandle,
  _In_     HANDLE  ProcessHandle,
  _In_     ULONG64 Offset,
  _In_opt_ PVOID   BaseAddress,
  _In_     SIZE_T  ViewSize,
  _In_     ULONG   AllocationType,
  _In_     ULONG   PageProtection


FileMappingHandle [in]

A HANDLE to a section that is to be mapped into the address space of the specified process.

ProcessHandle [in]

A HANDLE to a process into which the section will be mapped.

Offset [in]

The offset from the beginning of the section. This must be 64k aligned.

BaseAddress [in, optional]

The desired base address of the view. The address is rounded down to the nearest 64k boundary. If this parameter is NULL, the system picks the base address.

ViewSize [in]

The number of bytes to map. A value of zero (0) specifies that the entire section is to be mapped.

AllocationType [in]

The type of allocation. This parameter can be zero (0) or one of the following constant values:

  • MEM_RESERVE - Maps a reserved view
  • MEM_LARGE_PAGES - Maps a large page view
PageProtection [in]

The desired page protection.

Return value

Returns the base address of the mapped view, if successful. Otherwise, returns NULL and extended error status is available using GetLastError.


Minimum supported client

Windows 10, version 1703 [desktop apps only]

Minimum supported server

Windows Server 2016 [desktop apps only]


WinBase.h (include Windows.h)





See also