I am sorry to inform you that only with basic knowledge you will not be able to do this - even with advanced knowledge this is not trivial. You need to somehow enter the process space of the other program, learn or discover how your data structures are set from memory, know the local and the exact time which should read the memory of the program, and map the information read in its concept of "variable".
There are many other considerations. For example, it depends heavily on the environment in which the program is running. Is your app a phone app (iOS / Android / WinPhone) or tablets (iOS / Android / Windows)? No way - the operating system isolates apps so they do not have access to other apps. Is it a desktop application (Windows or Mac)? Your program would have to have access to the virtual memory space of the other program, which is not the case most of the time (you may need to use a driver ) to gain access to the memory space of the other process.)
Ok, assuming you can at some point read the entire memory of the other program (as I said above, it's not a likely assumption). What kind of variable do you want to read? If it is a local variable of a method, it will be allocated in the program's execution stack, so you will have to access memory exactly at the time that function is running, and know inside the stack which value corresponds to the variable you want (another non-trivial task). Another thing: it might be that the variable represents not a primitive value, but an object - which is stored not in the heap, but in the heap of objects (what happens when you use new
in Java, for example). Then in the stack you will only have the address of the memory space where the value of the variable is. And that value can change - in Java or C #, when the garbage collector runs, the object has chances of being moved.
Finally, if you want to hack another program, trying to get the value of one of your variables is not the best way:)