The MSDN documentation says two things.
Firstly (in the "Comments" section),
"If the application specifies a size for the file association object that is larger than the size of the actual named file on disk, and if the page protection allows write access (that is, the flProtect parameter specifies PAGE_READWRITE or PAGE_EXECUTE_READWRITE ), then the file on disk will grow in accordance with the specified size of the map object If the file is expanded, the contents of the file between the old end of the file and the new end of the file are not guaranteed to be zero, the behavior is determined by the file system "
This basically means that your file on disk will be modified when you map it to a memory area larger than the file calling CreateFileMapping() , and fill it with unspecified material.
Secondly (in the "Return Value" section),
"If the object exists before the function is called, the function returns a handle to the existing object ( with its current size, not the specified size ), and GetLastError returns ERROR_ALREADY_EXISTS ."
For me, this means that your call to resize_file() will have no effect if your file is already displayed. You must undo it, call resize_file() , and then reassign it, which may or may not be what you want.
source share