内存地址,以及如何打印它的值
Memory address , and how to print its value
我在 link ("How to get the starting/base address of a process in C++?") 找到了代码。
当我 运行 它时,它说我 ("Base Address: 400000") 现在我知道内存地址使用十六进制而不是十进制。所以我有很多问题想问你:
- 如何将其转换为内存地址?
- 如何使用该地址并修改值?
- 是否可以打印进程正在使用的所有内存地址?
- 是否可以获取地址指示的值?
谢谢
How can i translate it into an Memory Address?
该数字已代表内存地址,无需翻译。
How can i Use that address & modify the value?
在嵌入式系统领域,我们采用指针并将它们分配给指针。如果我们想访问一个 16 位寄存器或内存地址,我们会分配一个 uint16_t
指针指向该值。
uint16_t * memory_pointer = (uint16_t *) 0x40000000;
It's possible to print ALL the Memory Address that the process are using?
这是一个操作系统问题。一些操作系统极力阻止一个程序访问另一个进程的内存区域。当您的进程运行并使用与您的进程相同的内存区域时,"other process" 可能会交换到磁盘。所以这是否可能取决于您平台的操作系统。
It's possible to get the Value indicated by the Address?
取决于操作系统和平台。某些平台在特定地址处有内存,访问该范围之外的地址会导致 未定义的行为 。
一些操作系统会防止访问进程外的内存(例如内核内存)。在这种情况下访问内存的结果取决于操作系统。
访问内存的方法是解引用一个指针。在 C++ 中,对于字节访问,您将使用指向 uint8_t
的指针。
我在 link ("How to get the starting/base address of a process in C++?") 找到了代码。
当我 运行 它时,它说我 ("Base Address: 400000") 现在我知道内存地址使用十六进制而不是十进制。所以我有很多问题想问你:
- 如何将其转换为内存地址?
- 如何使用该地址并修改值?
- 是否可以打印进程正在使用的所有内存地址?
- 是否可以获取地址指示的值?
谢谢
How can i translate it into an Memory Address?
该数字已代表内存地址,无需翻译。
How can i Use that address & modify the value?
在嵌入式系统领域,我们采用指针并将它们分配给指针。如果我们想访问一个 16 位寄存器或内存地址,我们会分配一个 uint16_t
指针指向该值。
uint16_t * memory_pointer = (uint16_t *) 0x40000000;
It's possible to print ALL the Memory Address that the process are using?
这是一个操作系统问题。一些操作系统极力阻止一个程序访问另一个进程的内存区域。当您的进程运行并使用与您的进程相同的内存区域时,"other process" 可能会交换到磁盘。所以这是否可能取决于您平台的操作系统。
It's possible to get the Value indicated by the Address?
取决于操作系统和平台。某些平台在特定地址处有内存,访问该范围之外的地址会导致 未定义的行为 。
一些操作系统会防止访问进程外的内存(例如内核内存)。在这种情况下访问内存的结果取决于操作系统。
访问内存的方法是解引用一个指针。在 C++ 中,对于字节访问,您将使用指向 uint8_t
的指针。