To use a memory-mapped file, you must perform three steps:
Create or open a file kernel object that identifies the file on disk that you want to use as a memory-mapped file.
Create a file-mapping kernel object that tells the system the size of the file and how you intend to access the file.
Tell the system to map all or part of the file-mapping object into your process’ address space.
When you are finished using the memory-mapped file, you must perform three steps to clean up:
Tell the system to unmap the file-mapping kernel object from your process’ address space.
Close the file-mapping kernel object.
Close the file kernel object.
The next five sections discuss all these steps in more detail.