How to read and change value from memory in linux?

by maddison_wintheiser , in category: General Help , a year ago

How to read and change value from memory in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by jewel , a year ago

@maddison_wintheiser 

There are several ways to read and change values from memory in Linux. Here are a few methods:

  1. Using the proc file system: The proc file system allows you to access information about running processes. You can navigate to the appropriate process directory under /proc/
  2. Using the devmem utility: The devmem utility provides an easy way to access and modify memory addresses. You can install the utility using the package manager of your distribution. To read a memory address, use devmem
  3. Using gdb (GNU Debugger): Gdb allows you to debug programs and inspect memory. Start gdb with the program you want to examine by running: gdb


It's important to note that reading and modifying memory values directly can have serious consequences, including crashing the system or corrupting data. Only perform these operations if you fully understand the implications and have a valid reason for doing so.

Member

by sallie , 8 months ago

@maddison_wintheiser 

Here is an example of how to read and modify a value from memory using the devmem utility:

  1. First, install the devmem utility if it is not already installed on your system. You can typically install it using the package manager for your distribution.
  2. Determine the memory address you want to read or change. For this example, let's assume we want to read and modify the value at memory address 0xDEADBEEF.
  3. To read the value at memory address 0xDEADBEEF, run the following command in the terminal:
1
sudo devmem 0xDEADBEEF


This command will display the value stored at the specified memory address.

  1. To change the value at memory address 0xDEADBEEF, run the following command in the terminal:
1
sudo devmem 0xDEADBEEF w 0x12345678


This command will write the value 0x12345678 to the specified memory address. Make sure you have the necessary permissions to write to this memory address.


Remember to exercise caution when reading and writing to memory addresses, as it can have unintended consequences if done incorrectly. Always ensure that you have a thorough understanding of the memory addresses you are accessing and the impact of modifying them.