Is it possible to run a process with gdb, modify some memory and then detach from the process afterwards?
I can't start the process from outside of gdb as I need to modify the memory, before the first instruction is executed.
When you detach from a process started with gdb, gdb will hang, but killing gdb from another process makes the debugged process still running.
I currently use the following script to launch the process:
echo '# custom gdb function that finds the entry_point an assigns it to $entry_point_address entry_point b *$entry_point_address run set *((char *)0x100004147) = 0xEB set *((char *)0x100004148) = 0xE2 detach # gdb hangs here quit # quit never gets executed ' | gdb -quiet "$file" This happens in both of my gdb versions:
GNU gdb 6.3.50-20050815 (Apple version gdb-1824) GNU gdb 6.3.50-20050815 (Apple version gdb-1822 + reverse.put.as patches v0.4)
6.3? That was released almost a decade back.llvm+clanginstead ofgcc, it makes sense that they would also preferlldbovergdb.detachdoesn't work.