Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. File Mapping

File Mapping

Scheduled Pinned Locked Moved C / C++ / MFC
performancetutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Toni78
    wrote on last edited by
    #1

    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.

    B 1 Reply Last reply
    0
    • T Toni78

      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.

      B Offline
      B Offline
      bikram singh
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • B 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

        T Offline
        T Offline
        Toni78
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups