regarding MapViewOfFile
-
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!
-
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!
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"
-
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"
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
-
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
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 calledMapViewOfFile()
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"