I wanna create a script/program that will modify value in memory of another process. With GDB I've discovered that variable I want modify is located on heap. Because this variable is create dynamically with every program start, it is placing under another address. I've tried to find pointer on a stack that will point to this value, but also pointer is in another place every program start. Finally I've found variable position with breakpoint in main loop and reading position from registers.
Is any better way to find variable that will be good for script?