-4

i found that code at this link ("How to get the starting/base address of a process in C++?").

When i run it , it says me ("Base Address: 400000") Now i know that the Memory Address work whit Hexadecimal not Decimal . So there're many question that i wanna ask you :

  1. How can i translate it into an Memory Address?
  2. How can i Use that address & modify the value?
  3. It's possible to print ALL the Memory Address that the process are using?
  4. It's possible to get the Value indicated by the Address?

Thanks

Community
  • 1
  • 1
  • 4
    "Now i know that the Memory Address work whit Hexadecimal not Decimal" - this is not true, and barely makes sense. – user253751 Jan 19 '17 at 22:24
  • 1
    The base the is used to represent a number is irrelevant to that number's value. 0x10 16 and binary 10000 are identical values. – François Andrieux Jan 19 '17 at 22:29
  • it's already a memory address just the notation is `0x400000`. to modify this address you cannot its constant like you write: `5++`. to print the value inside it you use dereference operator `*`: `cout << *ptrToAddr;` – Raindrop7 Jan 19 '17 at 22:49

1 Answers1

1

How can i translate it into an Memory Address?

The number already represents a memory address, no translations required.

How can i Use that address & modify the value?

In the embedded systems arena, we take pointers and assign them to pointers. If we want to access a 16-bit registers or memory address, we would assign a uint16_t pointer to the value.
uint16_t * memory_pointer = (uint16_t *) 0x40000000;

It's possible to print ALL the Memory Address that the process are using?

This is an operating system issue. Some operating systems try heavily to prevent one program from accessing the memory area of another process. The "other process" may be swapped to disk when your process runs and use the same memory area that your process does. So whether this is possible or not depends on your platform's operating system.

It's possible to get the Value indicated by the Address?

Depends on the operating system and the platform. Some platforms have memory at specific addresses and accessing an address outside that range results in undefined behavior.

Some operating systems guard against accessing memory outside your process (such as the kernel's memory). The results of accessing the memory in this case depends on the operating system.

The method for accessing memory is to dereference a pointer. In C++, for byte access, you would use a pointer to uint8_t.

Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154