MapViewOfFileVlm

[This is preliminary documentation and subject to change.]

The MapViewOfFileVlm function maps a view of a file into the address space of the calling process.

LPVOID MapViewOfFileVlm(
  HANDLE hFileMappingObject,  // file-mapping object to map into 
                              // address space
  DWORD dwDesiredAccess,      // desired access mode
  DWORDLONG ulOffset,         // offset into mapping region
  DWORDLONG ulNumberOfBytesToMap,  // size of mapping in bytes
  PVOID64 lpBaseAddress       // address of region of shared memory
);
 

Parameters

hFileMappingObject
Handle to a file-mapping object to be mapped into the calling process's address space. The CreateFileMapping and OpenFileMapping functions return this handle. The mapped view must have been created by using CreateFileMapping with the SEC_VLM flag set in the fdwProtect parameter.
dwDesiredAccess
Type of access to the file view to be mapped and, therefore, the type of protection for the pages mapped by the file. This parameter can be one of the following values.
Value Meaning
FILE_MAP_READ Read-only access. The object whose handle is passed in the hFileMappingObject parameter must have been created with PAGE_READWRITE or PAGE_READONLY protection. A read-only view of the file is mapped.
FILE_MAP_WRITE Read-write access. The hFileMappingObject object must have been created with PAGE_READWRITE protection. A read-write view of the file is mapped.

ulOffset
64-bit file offset where mapping is to begin. The ulOffset parameter must specify a 64K-aligned offset within the file to map. Specifying an address that is not a multiple of 64K is an error.
ulNumberOfBytesToMap
Number of bytes of the file to map. If the ulNumberOfBytesToMap parameter is zero, the entire file is mapped. The call to MapViewOfFileVlm fails if there is not enough address space to map the requested number of bytes.
lpBaseAddress
Base address of the point in the process's address space at which the mapping is to begin. Note that the address is rounded down to the nearest 64K boundary by the system. A value of NULL for this parameter allows the system to choose the mapping base address without consideration of calling process requirements.

Return Values

If the function succeeds, the return value is the starting address of the mapped view, after any rounding down.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

Mapping a file makes the specified portion of the file visible in the address space of the calling process.

Multiple views of a file (or of a file-mapping object and its mapped file) are said to be "coherent" if they contain identical data at a specified time. Coherence occurs if the file views are derived from the same file-mapping object. A process can duplicate a file-mapping object handle in another process by using the DuplicateHandle function. A process other than the file-mapping object's creator can open the object by name by using the OpenFileMapping function.

A mapped view of a file is not guaranteed to be coherent with a file being accessed by the ReadFile, WriteFile, ReadFileVlm or WriteFileVlm function.

A call to MapViewOfFileVlm fails if there is not enough address space to map the requested number of bytes.

Because VLM virtual space is not paged, page file size is not a concern.

Note  To guard against an access violation, use structured exception handling to protect any code that writes to or reads from a memory-mapped view. For more information on structured exception handling, see Reading and Writing.

QuickInfo

  Windows NT: Requires version 5.0 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.

See Also

Memory Management Overview, Memory Management Functions, Very Large Memory (VLM), CreateFileMapping, DuplicateHandle, GetSystemInfo, MapViewOfFileEx, OpenFileMapping, ReadFile, ReadFileVlm, SYSTEM_INFO, UnmapViewOfFileVlm, WriteFile, WriteFileVlm