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. regarding MapViewOfFile

regarding MapViewOfFile

Scheduled Pinned Locked Moved C / C++ / MFC
jsonperformancehelpquestion
4 Posts 3 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.
  • N Offline
    N Offline
    namaskaaram
    wrote on last edited by
    #1

    when u use the MapViewOfFile API and set the 'dwNumberOfBytesToMap' to a particular value say "x" and then when u get the return pointer value(say "y") of the buffer that MapViewOfFile API returns, What happens when we try to write to the "y+x+1"th memory location.....will an error occour? cheerz!

    R 1 Reply Last reply
    0
    • N namaskaaram

      when u use the MapViewOfFile API and set the 'dwNumberOfBytesToMap' to a particular value say "x" and then when u get the return pointer value(say "y") of the buffer that MapViewOfFile API returns, What happens when we try to write to the "y+x+1"th memory location.....will an error occour? cheerz!

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      namaskaaram wrote:

      What happens when we try to write to the "y+x+1"th memory location.....will an error occour?

      Yes. You'll get an access violation exception and your program will be terminated by Windows unless you handle the exception.

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      B 1 Reply Last reply
      0
      • R Ryan Binns

        namaskaaram wrote:

        What happens when we try to write to the "y+x+1"th memory location.....will an error occour?

        Yes. You'll get an access violation exception and your program will be terminated by Windows unless you handle the exception.

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        Or unless you happen to already own that memory, which is more unfortunate - harder to find bugs in your program. I would rather see an access violation any day than to try to figure out 'who' overwrote some of my own memory. People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks

        R 1 Reply Last reply
        0
        • B Blake Miller

          Or unless you happen to already own that memory, which is more unfortunate - harder to find bugs in your program. I would rather see an access violation any day than to try to figure out 'who' overwrote some of my own memory. People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks

          R Offline
          R Offline
          Ryan Binns
          wrote on last edited by
          #4

          Yes. That would be a rare occurrence though because MapViewOfFile() returns addresses in a different address range to the addresses returned by allocating memory "normally". So unless you've called MapViewOfFile() twice, this probably won't happen. But you're right :)

          Ryan

          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

          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