Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would I search the memory of a process for a specific string?

I'm interested in the basics. I have no idea where to begin with this. I've created this test program:

#include <stdio.h>

int main()
{
    char* test = "TEST04560";
    getchar();
    printf("%s\n", test);
}

The goal is to locate the memory address of "TEST04560" using an external program. I know how to use ReadProcessMemory and WriteProcessMemory but I don't know how to go about searching for a specific string in a program's memory. Any tips in the right direction are greatly appreciated.


1 Answers

What operating system? Most all OSes have some sort of "debugging" facility that allows you to observe/modify other processes (if you have permissions, of course).

On Linux, this is ptrace.

On Windows, there is ReadProcessMemory, and friends.

And for searching data of any type, there is memcmp. If you know how to use ReadProcessMemory, you certainly are familiar with this function.

like image 61
Jonathon Reinhart Avatar answered Dec 24 '25 07:12

Jonathon Reinhart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!