Good morning, Is it possible for MapViewOfFile to return the same address twice? However, UnmapViewOfFile misbehaves when it has to unmap the same address twice. We get an Error 487 : Invalid address. Here is some pseudo code which shows how we are using MapViewOfFile and UnMapViewOfFile:
retval = UnmapViewOfFile(TmpPrevMapPtr);
if (retval == 0){
DWORD lasterr = GetLastError();
printf("UNMAP Last Error = %d ...
}
MapPtr = (char*)::MapViewOfFile( hMapping, FILE_MAP_WRITE | FILE_MAP_READ,0,baseoff,
mappedlength);
if (MapPtr == 0){
throw cException(ERR_MEMORYMAPPING,TempFileName);
}
Thank you.
After you did
UnmapViewOfFilethat virtual address is free to be used for other operation. So yes, the subsequentMapViewOfFilemay return this address.