The following flags are four possible values for the parameter fdwProtect:
All pages of a section are to be set to the commit state.
The file specified for a section's file mapping is an executable image file.
All pages of a section are to be set as noncacheable.
All pages of a section are to be set to the reserved state.
If none of these flags are specified, SEC_COMMIT is the default. Thisbehaves the same way as MEM_COMMIT in VirtualAlloc().
The SEC_RESERVE flag is intended for file mappings that are backed by thepaging file, and therefore use SEC_RESERVE only when hFile is -1. The pagesare reserved just as they are when the MEM_RESERVE flag is used inVirtualAlloc(). The pages can be committed by subsequently using theVirtualAlloc() application programming interface (API), specifyingMEM_COMMIT. Once committed, these pages cannot be decommitted.
The SEC_NOCACHE flag is intended for architectures that require variouslocking structures to be located in memory that is not ever fetched intothe CPU cache. On x86 and MIPS machines, use of this flag just slows downthe performance because the hardware keeps the cache coherent. Certaindevice drivers may require noncached data so that programs can writethrough to the physical memory. SEC_NOCACHE requires that eitherSEC_RESERVE or SEC_COMMIT be used in addition to SEC_NOCACHE.
The SEC_IMAGE flag indicates that the file handle points to an executablefile, and it should be loaded as such. The mapping information and fileprotection are taken from the image file, and therefore no other optionsare allowed when SEC_IMAGE is used.
Under Windows NT, the Win32 loader simply sits on top of the memory mappedfile subsystem, and so when the loader needs to load a PE executable, itsimply calls down into the existing memory mapped file code. Therefore, itis extremely easy for to support SEC_IMAGE in CreateFileMapping() underWindows NT.
In Windows 95, the loader is more complex and the memory mapped files aresimple and only support the bare minimum of functionality to make theexisting MapViewOfFile() work. Therefore, Windows 95 does not supportSEC_IMAGE. There is support for SEC_NOCACHE, SEC_RESERVE and SEC_COMMIT.