Questions tagged [readprocessmemory]

ReadProcessMemory is a Windows API function that can read the memory of an external process into a local buffer. Use this tag if your question is in relation to errors when using this function or it's general usage.

ReadProcessMemory() is a commonly used Windows API function when interacting with the memory of another process running on the same system.

BOOL ReadProcessMemory(
  HANDLE  hProcess,
  LPCVOID lpBaseAddress,
  LPVOID  lpBuffer,
  SIZE_T  nSize,
  SIZE_T  *lpNumberOfBytesRead
);

Function Arguments

  • hProcess is a handle to the target process, usually the return value from a call to OpenProcess()

  • lpBaseAddress is a pointer to the address you want to read from

  • lpBuffer is a pointer to your local buffer, where the read memory is stored

  • nSize is how many bytes you want to read

  • lpNumberOfBytesRead is a pointer to SIZE_T which will store the number of bytes which the function successfully read

Return Value

  • If the function succeeds, it's return is nonzero, if it fails, it returns zero.

Remarks

  • nSize should be the same size as the buffer pointed to by lpBuffer.

  • lpNumberOfBytesRead is optional, you can pass in a zero but, this output variable is good for error checking

  • Run your program as administrator to ensure your have permissions

  • Your process handle must have the required process access rights, in this case PROCESS_VM_READ

  • Use the return value, the lpNumberofBytesRead and GetLastError() to help debug your problems

179 questions
25
votes
7 answers

How do you read directly from physical memory?

In C or C++ (windows), how do you read RAM by giving a physical (not virtual) address? That means without going trough virtual memory system (mmu tables), and being specific to one process. I already know the API ReadProcessMemory, which reads from…
tigrou
  • 3,666
  • 3
  • 27
  • 49
9
votes
3 answers

TBBUTTON struct not working with SendMessage

I'm trying to send the TB_GETBUTTON message to get info about the buttons inside this Toolbar control marked in red color: ( The System tray notification area ) The problem is that when I send the message, the Explorer refreshes itself, is very…
ElektroStudios
  • 17,150
  • 31
  • 162
  • 376
8
votes
1 answer

Reading all process memory to find address of a string variable c#

I have 2 programs written in c#, first one called "ScanMe" contains a string variable that contains value "FINDMEEEEEEE", and a double variable that has the value of 1546.22915487. And the other program called "MemoryScan" reads all the memory of…
Susta250
  • 99
  • 3
8
votes
1 answer

ReadProcessMemory with ctypes

im working on a little solitär trainer. I don't know why the function ReadProcessMemory doesn't work. Normally it returns a False or True but in that case nothing. The GetlastError() gives me the Errorcode 6. #-*- coding: cp1252 -*- import ctypes,…
John Doe
  • 136
  • 1
  • 2
  • 9
8
votes
6 answers

How to write a Perl, Python, or Ruby program to change the memory of another process on Windows?

I wonder if Perl, Python, or Ruby can be used to write a program so that it will look for 0x12345678 in the memory of another process (probably the heap, for both data and code data) and then if it is found, change it to 0x00000000? It is something…
nonopolarity
  • 130,775
  • 117
  • 415
  • 675
7
votes
1 answer

C# ReadProcessMemory: How to read a 64 bit memory address?

I am getting into reading application memory. I am using CheatEngine to get a memory address and then trying to return it's value. However, CheatEngine seems to be returning 64 bit memory addresses and so my ReadProcessMemory function keeps on…
KillerKode
  • 606
  • 1
  • 9
  • 24
5
votes
0 answers

Android How to work with processes and a memory like WinAPI allows

In WinAPI I can easily interact with almost all processes via OpenProcess, VirtualQueryEx, ReadProcessMemory, WriteProcessMemory. They are well described in MSDN and easy to use. Please tell me how can I interact with processes in Android... How…
ptrvoid
  • 76
  • 3
5
votes
1 answer

Converting a function from C++ to C#

Can the following snippet be converted to C#.NET? template cData Read(DWORD dwAddress) { cData cRead; //Generic Variable To Store Data ReadProcessMemory(hProcess, (LPVOID)dwAddress, &cRead, sizeof(cData), NULL); //Win API -…
mirc00
  • 63
  • 3
5
votes
1 answer

Read/WriteProcessMemory in Ruby

I have been experimenting with reading and writing process memory in Ruby in hopes to move some old C++ programs to a more dynamic language. However I've not been having an easy time moving over. I've done some reading but I can't find much on my…
ozdrgnaDiies
  • 1,799
  • 1
  • 17
  • 30
5
votes
1 answer

Getting base address of a process

I'm trying to make a program that read the timer value from Minesweeper. (OS is windows 7 64bit) Using cheat engine I found the base address of the variable, but it changes every time I run Minesweeper. What do I need to do to find out the base…
yoni0505
  • 329
  • 2
  • 3
  • 8
4
votes
2 answers

How to convert byte[] array to IntPtr?

Possible Duplicate: How to get IntPtr from byte[] in C# I'm reading strings from memory with byte[] array = reader.ReadProcessMemory((IntPtr)address, (uint)255, out bytesReadSize); and then I'm converthing this array to string. I've got a…
Patryk
  • 2,754
  • 9
  • 36
  • 76
4
votes
2 answers

C# pointer offset > 255 - ProcessMemoryReader

I know there are many tutorials out there showing you how to use the "ProcessMemoryReader" functions. But this problems seems to be unique or not solved yet. For quite a while I've been digging into other people's code to find a way to use multiple…
Arndroid
  • 186
  • 1
  • 12
4
votes
2 answers

Read process memory of a process does not return everything

I am trying to scan memory of a 3rd party application. I have already found out the address; right now is at 0x0643FB78. The thing is, I can never get up there since LPMODULEENTRY32->modBaseAddr is 0x00400000 and LPMODULEENTRY32->modBaseSize is…
Mikulas Dite
  • 7,202
  • 9
  • 52
  • 94
3
votes
1 answer

Get an image of process memory

My goal is to create a method that will take a process handle and return an array of bytes representing that process's memory. Here's what I have: [DllImport("Kernel32.dll")] public static extern bool ReadProcessMemory(IntPtr hProcess,…
Hui
  • 12,039
  • 8
  • 23
  • 20
3
votes
1 answer

C# ReadProcessMemory alternative

I'm trying to ReadProcessMemory on a certain process but it uses ObRegisterCallbacks to prevent another process to create a handle on it (OpenProcess). I have heard of people creating their own memory reading utilites in C# without ReadProcessMemory…
Joshe 343
  • 31
  • 3
1
2 3
11 12