Is it possible to access memory from an application to another ? How?

我的梦境 提交于 2020-01-04 05:24:12

问题


The title is a bit confused. But, I'm trying to do is some thing like:

I have button (Button1 from TButton class)in a application. I want to get the pointer value of this button and check it properties from a second application.

Some one can say if it is possible ? And if it's not, explain why ?

Tks.


Re-opening 'cause I got other informations on internet.

If I use things like ? ReadProcessMemory

Examples: http://www.codeproject.com/KB/threads/int64_memsteal.aspx http://forum.cheatengine.org/viewtopic.php?p=4150408&sid=2358f118bab9f54b032d99377aed0545


回答1:


It is possible. Just use the Windows API functions WriteProcessMemory/ReadProcessMemory. Pass in the handle of the process and the pointer to the data.




回答2:


applications are protected from each other trying to corrupt each other. There is specific hardware in your PC to do this ( a MMU). It makes things both robust and secure.

So you can't simply go poking around in the memory of another application. You can share memory between applications using memory mapped files.... but thats more for data transfer typically.

However with windows controls (buttons, windows, etc) they are GDI objects and you can use windows API for sending messages to other applications controls to make them do things or query their properties.

Alternatively you can expose a cross process API, RPC / Com / Webservices / Sockets to allow other applications to query and change state




回答3:


It is not impossible... It's just pretty complicated.

Like you wrote yourself, you can use ReadProcessMemory to read part of the memory of another application. The thing is to find the right address to read. Even if you would find the right way to do it, that would probably break between versions of delphi.

Of course, if your target application "expose" some methods to do it (by answering a windows message, for exemple), it's a different story.




回答4:


Depending really on the OS

Normally all new OSes, and the multiuser OSes give memory protection. So you can't access the memory of another proccess unless you have privileges to do this through the OS system calls.

In an OS like MSDOS, you can have access to whatever address you want. With C you can declare a char far * pointer and assign it an address.

I used that to do a ncurses like library, accessing the video memory directly and writing/reading 8bit portions of the memory to set/get console text attributes.

What you want can be done by IPC or RPC if you're in a remote machine. You don't get a pointer, but can access the button properties using your favorite IPC/RPC api.




回答5:


I first have a question for you: Why do you want to do this and is the application yours?

If its is for testing/debugging and you can build the target in debug mode you can use the Debugging Application Programming Interface to access whatever you want (from a debug build application that is).

Maybe you can find some info in this question Writing a very basic debugger



来源:https://stackoverflow.com/questions/5137036/is-it-possible-to-access-memory-from-an-application-to-another-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!