MapViewOfFile Function (Memoryapi.h)
페이지 정보
작성자 PI 작성일25-08-31 23:49 (수정:25-08-31 23:49)관련링크
본문
Maps a view of a file mapping into the tackle area of a calling process. To specify a prompt base deal with for the view, use the MapViewOfFileEx operate. However, this apply will not be really useful. A handle to a file mapping object. The CreateFileMapping and OpenFileMapping features return this handle. The type of access to a file mapping object, which determines the page safety of the pages. This parameter may be one in every of the following values, or a bitwise OR combination of multiple values the place acceptable. Using bitwise OR, you possibly can mix the values above with these values. When a process writes to a copy-on-write page, the system copies the original web page to a brand new web page that's personal to the process. The new page is backed by the paging file. The protection of the brand new page modifications from copy-on-write to read/write. When copy-on-write access is specified, Memory Wave the system and process commit cost taken is for the complete view as a result of the calling process can doubtlessly write to each page in the view, making all pages private.
The contents of the brand new page are by no means written back to the unique file and are misplaced when the view is unmapped. Home windows Server 2003 and Home windows XP: This worth is accessible beginning with Windows XP with SP2 and Home windows Server 2003 with SP1. For more information about access to file mapping objects, see File Mapping Security and Entry Rights. A excessive-order DWORD of the file offset the place the view begins. A low-order DWORD of the file offset the place the view is to begin. The mixture of the high and low offsets must specify an offset throughout the file mapping. They must additionally match the digital memory allocation granularity of the system. That is, the offset must be a multiple of the VirtualAlloc allocation granularity. The variety of bytes of a file mapping to map to the view. All bytes have to be within the utmost measurement specified by CreateFileMapping. If this parameter is zero (zero), the mapping extends from the required offset to the top of the file mapping.
If the operate succeeds, the return value is the starting tackle of the mapped view. If the operate fails, the return value is NULL. To get extended error info, call GetLastError. Mapping a file makes the desired portion of a file visible within the tackle area of the calling process. For files which might be bigger than the deal with space, MemoryWave you can solely map a small portion of the file data at one time. When the primary view is full, you may unmap it and map a brand new view. To acquire the dimensions of a view, use the VirtualQuery perform. A number of views of a file (or a file mapping object and its mapped file) are coherent if they contain equivalent information 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 process can duplicate a file mapping object handle into one other course of by utilizing the DuplicateHandle perform, or one other course of can open a file mapping object by identify through the use of the OpenFileMapping perform.
With one vital exception, file views derived from any file mapping object that is backed by the same file are coherent or identical at a specific time. Coherency is assured for views within a course of and for views which are mapped by completely different processes. The exception is expounded to distant recordsdata. Although MapViewOfFile works with distant information, it doesn't keep them coherent. For example, if two computers each map a file as writable, and each change the same web page, every laptop solely sees its own writes to the web page. When the data gets up to date on the disk, it isn't merged. A mapped view of a file just isn't guaranteed to be coherent with a file that is being accessed by the ReadFile or WriteFile perform. Do not store pointers within the memory mapped file; retailer offsets from the bottom of the file mapping so that the mapping can be used at any handle. ERROR exceptions, use structured exception handling to protect any code that writes to or reads from a Memory Wave mapped view of a file aside from the page file. For more data, see Studying and Writing From a File View. When modifying a file by means of a mapped view, the last modification timestamp will not be updated robotically. If required, the caller should use SetFileTime to set the timestamp. Worth), the paging file must be massive sufficient to carry the complete mapping. If it's not, MapViewOfFile fails. The preliminary contents of the pages in a file mapping object backed by the paging file are 0 (zero). RESERVE). Mapping the file makes your complete mapped digital tackle vary unavailable to other allocations in the process. After a page from the reserved range is dedicated, it can't be freed or decommitted by calling VirtualFree. Reserved and dedicated pages are released when the view is unmapped and the file mapping object is closed. For particulars, see the UnmapViewOfFile and CloseHandle features.

댓글목록
등록된 댓글이 없습니다.