Avatar of Cédric MARCOUX
Cédric MARCOUXFlag for Belgium asked on

Reading Memory of another process in Delphi

Hi!
Could someone tell me how to read memory area of a defined process?
I mean I launch example.exe and I would like to know:

How to retrieve start and end of the memory area address of example.exe
Ability to read certain byte in this memory area and convert it to string value
Ability to search for some occurence in this area..

Any idea?
Delphi

Avatar of undefined
Last Comment
Computer101

8/22/2022 - Mon
developmentguru

 It would help to know more about what you are trying to do.  It is possible that there is an easier solution to what you are trying to do if you could tell us more about it.

  If you really need to be able to have full access to the memory of another process that you are starting, I believe there is a Microsoft debugging API.  Check out this link:

http://msdn2.microsoft.com/en-us/library/ms679303.aspx

Hopefully you do not need the whole debugging API as you will likely need to translate it yourself.  If you need to read the values of on screen controls or something similar there is likely an easier way.

Either way, let me know.
ASKER
Cédric MARCOUX

I simply need to read some value in other process memory area.
This could be some simple string or some boolean.
My work will be to know at wich address I need to read it, however i would like to know "how" to read it before searching for exact address
developmentguru

 Without more information all I can give you some generalizations.  If you know that you need to read a global variable then you should be able to count on it's location (offset from beginnning of user memory).

  If it is a variable that is in some dynamically created class then you would need to find the offset to the base object, then the offset to it's child object etc until you get to the one you want to read.

  If you want to read a string who's scope is limited to a procedure / function then you would need to be able to stop the process within the procedure and read it off of the stack.

  If you are talking about a Delphi program then you may find some help by looking into Delphi's memory manager.

  Since each development environment can have it's own memory manager, it would not be simple to find variables in a program if you do not know the program's origins.  For most modern development environments variables do not have one set address (for the most part).  If you have a window that has a text entry field which, when edited, writes it's text into a string variable then every copy of that window will have it's own string variable.  Which do you want?

  I presumed that you wanted to do this programmatically.  If not then you could always use a separate debugger to attach to the running process.  In a case where you know nothing about the program this would likely be faster than trying to write your own program to do it.  If you open the process in a debugger, and you are good at reading assembly language, then you can follow the execution of the program and see where the variables are.

I hope this helps.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
CodedK

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Cédric MARCOUX

Thanks,

however I was searching for a piece of nearly code to read a memory address..
I think I will never find :(
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
Cédric MARCOUX

Thanks for comment
I have try using sources, but this too complicated for the use I want to do...
I keep you informed abou my progress...
Computer101

Forced accept.

Computer101
EE Admin
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.