File Mapping
-
If a file has been mapped with MapViewOfFile, will the offsets in memory correspond to the ones in the disk. For example if I try to access the contents at file offset 0x100 in the disk, after I map the file would I still be using offset 0x100 or will the memory alignment make the offset change. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.
-
If a file has been mapped with MapViewOfFile, will the offsets in memory correspond to the ones in the disk. For example if I try to access the contents at file offset 0x100 in the disk, after I map the file would I still be using offset 0x100 or will the memory alignment make the offset change. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.
Toni78 wrote: will the offsets in memory correspond to the ones in the disk Yes, they will. However, ensure that either the whole file has been mapped, or the relevant portion that you want to access, has been mapped. Note that the "offset" must be added to the address returned by MapViewOfFile(). Optionally, MapViewOfFileEx() allows you to specify your own base address where the file will be "loaded". Memory alignment has to be taken into consideration when the file was opened with FILE_FLAG_NO_BUFFERING in the CreateFile() call. Bikram Singh
-
Toni78 wrote: will the offsets in memory correspond to the ones in the disk Yes, they will. However, ensure that either the whole file has been mapped, or the relevant portion that you want to access, has been mapped. Note that the "offset" must be added to the address returned by MapViewOfFile(). Optionally, MapViewOfFileEx() allows you to specify your own base address where the file will be "loaded". Memory alignment has to be taken into consideration when the file was opened with FILE_FLAG_NO_BUFFERING in the CreateFile() call. Bikram Singh
Thank you for your help.:) After I posted the question and I got no reply, I realized that I could test this by myself by loading the file and doing a byte compare with the file in the disk:cool:. At the end the files were identical so apparently there were no memory alignment issues. But I wasn't aware about FILE_FLAG_NO_BUFFERING:confused:. Either way, thank you again. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.