Is there any really low level programming language that can get access the memory variable directly? For example, if I have a program have a variable i. Can anyone access the memory to change my program variable i to another value?
Is there any really low level programming language that can get access the memory
Share
As an example of how to change the variable in a program from “the outside”, consider the use of a debugger. Example program:
(The program prints the value of
ievery 3 seconds.)In another terminal, find the process id of the running program and attach the
gdbdebugger to it:Now the output of the program changes:
So, yes, it’s possible to change the variable of a program from the “outside” if you have access to its memory. There are plenty of caveats here, e.g. one needs to locate where and how the variable is stored. Here it was easy because I compiled the program with debugging symbols. For an arbitrary program in an arbitrary language it’s much more difficult, but still theoretically possible. Of course, if I weren’t the owner of the running process, then a well-behaved operating system would not let me access its memory (without “hacking”), but that’s a whole another question.