In response to a question about matching non-contiguous file blocks to contiguous memory here , one respondent suggested that I use VirtualAllocEx () with MEM_RESERVE to set a "safe" value for the final (lpBaseAddress) parameter for MapViewOfFileEx ().
Further research showed that this approach results in a MapViewofFileEx () error with error 487: "Try to access an invalid address." On the MSDN page :
"There is no other memory allocation in the area used for matching, including using the VirtualAlloc or VirtualAllocEx function to reserve memory."
Although the documentation may be considered ambiguous regarding valid call sequences, experimentation suggests that it is not permissible to reserve memory for MapViewOfFileEx () using VirtualAllocEx ().
On the Internet, I found examples with hard-coded values - an example :
#define BASE_MEM (VOID*)0x01000000
...
hMap = MapViewOfFileEx( hFile, FILE_MAP_WRITE, 0, 0, 0, BASE_MEM );
To me this seems inadequate and unreliable ... It is not clear to me why this address is safe or how many blocks can be safely displayed there. It seems even more shaky, given that I need my solution to work in the context of other distributions ... and that I need my source to compile and work in 32 and 64-bit contexts.
, , - - MapViewOfFileEx .