Does Win32 support CreateFileMapping files in FAT file systems?

I am concerned about the danger of using IO with memory, through CreateFileMapping , in FAT file systems. A specific scenario is users opening documents directly from USB drives (yes, you forbid them to do this!).

MSDN "Managing Files with Associated Files" says nothing about file system limitations.

Update

I had no real reason to worry besides the vague feeling that I was reading about problems with them at some point (my career is more than 25 years old, so I have many uncertain depths in my memory, all the way back to 8-bit microsam!). The question of whether they should support or not is very important for me to recommend, so I wanted to ask if anyone could confirm my problems. Thank you for calming down.

+4
source share
2 answers

Yes Yes. It even supports displaying files on CDFS or network drives. What is the source of your doubts?

+6
source

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?

+7
source

Source: https://habr.com/ru/post/1315393/


All Articles