Memory mapped files are one of my favorite features. This is absolutely no danger . This is one of the base extremely optimized Windows I / O features. If you run an EXE or load an indirect DLL, it is implemented internally as a mapping file with a memory mapping.
All types of file systems are supported, including FAT.
By the way, atzz says that memory mapped files are allowed on network drives. I can add that this is not only allowed, but it is strongly recommended to use a file with memory mapping also with files from the network. In case the I / O operation will be cached very well, that does not work with other (C / C ++) I / O.
If you want the EXE to not work if you open it from a CD or a network, you can mark Program Executable with one bit in the header (linker switch / SWAPRUN see http://msdn.microsoft.com/en-us/ library / chzz5ts6.aspx ). For documents opened from a USB drive, there is no option.
But what kind of problem do users have? Are they using the Safely Remove Hardware icon? Then they must learn to do this in the same way as they have to learn not to turn off the power of the computer, but to turn off the computer correctly.
Could you explain why you find the dangers of using memory-mapped files, and in which situations you have problems, and the use of other I / O operations does not have such a problem?
source share