Reading and Writing

To read from a file view, a process dereferences the pointer returned by the MapViewOfFile function:

DWORD dwLength;

dwLength = *((LPDWORD) lpMapAddress);

The process also uses the pointer returned by MapViewOfFile to write to the file view:

*((LPDWORD) lpMapAddress) = dwLength;

The FlushViewOfFile function copies the specified number of bytes of the file view to the physical file, without waiting for the cached write operation to occur:

if (!FlushViewOfFile(lpMapAddress, dwBytesToFlush)) {

ErrorHandler("Could not flush memory to disk.");

}