I am looking for advice on how to manipulate functions by injecting code directly into memory during runtime. The aim is to eventually run run an external application that is able to manipulate running processes for optimisation purposes. So far, I have gone down the route of using GDB to manipulate memory, by following this tutorial:
However, it is fairly dated now and i cant seem to get it working on a 64-bit architecture... I would appreciate any advice on this topic. Cheers
To allow this opens up huge security vulnerabilities, so it is strictly forbidden in any sane environment. Newer Linux in particular (and more so on x86_64) strictly separates executable memory areas from modifiable areas. Besides, modern CPUs don't react kindly to code changes outside their caches and such. Perhaps the nearest would be to load shared libraries dynamically.
This kind of operation is part of the workings of most scripting languages, like Perl or Python.