2.11. File Mapping

The 32-bit APIs provides a feature calledfile mapping, which allows you to map a file directly into the virtual memory space of an application. We will see in Chapter 6 that this capability is often used to implement interprocess communication schemes, but the technique is also useful for simplifying or speeding file access.

You can map a file for either read-only or read-write access. Once mapped, you access the file by address (using array or pointer syntax) rather than using file access functions such as ReadFile or WriteFile (see also ReadProcessMemory and WriteProcessMemory). When used in read-write mode, the technique is especially useful because it gives you total control over when data gets flushed to disk.

For example, ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.