MapViewOfFile Function (Memoryapi.h)
Rocky Tost edited this page 1 month ago


Maps a view of a file mapping into the address house of a calling process. To specify a instructed base handle for the view, use the MapViewOfFileEx operate. Nevertheless, this follow will not be recommended. A handle to a file mapping object. The CreateFileMapping and OpenFileMapping features return this handle. The kind of access to a file mapping object, which determines the page safety of the pages. This parameter might be one among the following values, or a bitwise OR combination of multiple values where appropriate. Using bitwise OR, Memory Wave Protocol you may combine the values above with these values. When a course of writes to a replica-on-write web page, the system copies the unique web page to a new page that is personal to the method. The brand new page is backed by the paging file. The protection of the new web page modifications from copy-on-write to read/write. When copy-on-write entry is specified, the system and process commit charge taken is for all the view because the calling course of can potentially write to every web page in the view, making all pages private.


The contents of the new page are never written back to the original file and are lost when the view is unmapped. Windows Server 2003 and Home windows XP: Memory Wave This worth is obtainable starting with Windows XP with SP2 and Windows Server 2003 with SP1. For extra details about access to file mapping objects, see File Mapping Safety and Entry Rights. A excessive-order DWORD of the file offset where the view begins. A low-order DWORD of the file offset where the view is to begin. The mixture of the excessive and low offsets should specify an offset inside the file mapping. They should additionally match the virtual Memory Wave Protocol allocation granularity of the system. That is, the offset must be a multiple of the VirtualAlloc allocation granularity. The number of bytes of a file mapping to map to the view. All bytes should be within the maximum dimension specified by CreateFileMapping. If this parameter is 0 (zero), the mapping extends from the specified offset to the end of the file mapping.


If the function succeeds, the return value is the beginning address of the mapped view. If the perform fails, Memory Wave Protocol the return worth is NULL. To get extended error data, name GetLastError. Mapping a file makes the required portion of a file seen in the tackle house of the calling process. For files which might be larger than the deal with house, you may solely map a small portion of the file information at one time. When the primary view is complete, you'll be able to unmap it and map a new view. To obtain the size of a view, Memory Wave Protocol use the VirtualQuery perform. Multiple views of a file (or a file mapping object and its mapped file) are coherent in the event that they comprise identical data at a specified time. This occurs if the file views are derived from any file mapping object that is backed by the same file. A course of can duplicate a file mapping object handle into one other process through the use of the DuplicateHandle function, Memory Wave Protocol or one other course of can open a file mapping object by title by utilizing the OpenFileMapping operate.