When I debugging remote process with gdb-server and Ida, and put breakpoint in the code, when the process stopped at this breakpoint how can I call to function and after that return to my code ?
In IDA, you can use the Appcall feature
In GDB, you can use print
or call
commands: https://sourceware.org/gdb/onlinedocs/gdb/Calling.html
(this works only when using the actual gdb
program)
In Assembly there are no real self-contained functions (as in programming languages like c++) anymore. Especially the concept of local variables and parameters is not really there. Instead, everything is stored in registers or on the stack. Now assuming that there is a way to call a function (I'll get to it later on how that would be possible) you would risk overwriting registers that are used by something else. Doing so will cause data corruption and you risk that the program produces unexpected results. Also arguments are stored in a specific register or on the stack, so you might need to modify those.
Now when you identified the function and pre-loaded all the registers and prepared the stack all you need to do is change the instruction pointer to the function you want to run, execute it and set the instruction pointer back when you're done with it.