This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

using pointers in C to access other memory  RSS feed

 
Ranch Hand
Posts: 151
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when incrementing a pointer:
does this only increment within the memory allocated to your program or does it increment through the entire system memory?
am i able to read and manipulate the contents of memory of other programs? for example, i could write nulls to the memory the os itself was using and crash it?
how would i know which program owns any given area in memory, and what the variables there are being used for?
what kind of useful things can you do with this? or can it be done at all...
 
author
Posts: 23813
140
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

S Fox wrote:
does this only increment within the memory allocated to your program or does it increment through the entire system memory?



Most modern computers uses virtual memory addresses that is managed by an MMU (memory management unit). This prevents different applications from accidentally stepping on each other. This also allows the application to keep the same addresses for variables, while the OS can move the application around in memory (or swap it out entirely) as needed.

Incrementing the address pointer simply increments the virtual address -- so no accessing memory that your application doesn't own.

S Fox wrote:
am i able to read and manipulate the contents of memory of other programs? for example, i could write nulls to the memory the os itself was using and crash it?
how would i know which program owns any given area in memory, and what the variables there are being used for?



You can increment (and actually set) to any address that you want. However, it will be a virtual address. If you set it to an invalid virtual address (not found in the MMU), or one without the correct permissions (such as code being read only), when it is used in a way that is not allowed, you will get a segmentation fault / violation, and if configured, a core dump.

Henry
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!