I have to find a button’s name in a running process memory in Mac OSX and change it.
Supposing there is a “Test” application where it has a “Hello” button, is there any way to attach to “Test” application and change the “Hello!” button to “Bye!”?
I assume this could be done either using GDB or Xcode. If not, how can I do this?
Edit
Assuming you are really looking for dynamic data (as opposed to what your sample seemed to suggest :)) you could always just work with the debugger commands. This will require you to have a sense of the possible memory range to scan (or you’ll simply get useless memory violations):
Use gdb commands, loop constructs and libc functions
This example scans the region 0x1234…0x4321 for the first match and prints/examines the output address.
You can use similar tricks (
strncpy…?) to overwrite the memory if you had access to it.Of course the program may fail dramatically if you do things like changing the length of a substring.. YMMV).
Original answer:
You “need to”? I doubt it. Your best bet is to work with the windowing/UI API’s of your operating system to retrieve the actual window that display the text and make it display another text (usually by sending it appropriate control messages). You’ll need plenty of COW powers (think: root) to pull that off.
To answer the direct question:
Usually, messages like this are constants (static data) and as such are either
Both of which are usually (these days at least) in read-only memory segments (think of sharing of memory mapped pages; this gives the kernel opportunity to share mapped regions of shared binary objects between processes – also it serves the obvious security purposes).
On the upside,
will tell you whether you can use
sed, a hex editor or any other suitable editor to manipulate the binary even before it starts. There are two drawbacks I can think of here: