Friday, July 31, 2009

Memory address c++?

I want to read and modify a memory address.(Creating a game trainer)


I have all the needed addresses but i don't know how i can use them.


Do i have to use ASM or C++


An example of reading a memory address.





Thanks!

Memory address c++?
Suppose you want to set the 8-bit byte at memory address 0x11234ABCD to the value 99.





First you need to know what size your compiler assigns to the various variable types. If you can't find it in the manual, you can make a test program. Something like:





int l = sizeof(long);


int s = sizeof(short);


int c = sizeof(char);





Assuming that sizeof(char0 = 1;





char *pChar;


pChar = 0x11234ABCD;


*pChar = 99;








In C++, the in sizes of the variable are an option left to the compiler designer, as long as the follow rules like a long has to be at least as big as a short. Because of that, it may not be possible to move a variable directly into the location you want, you may have to set it by masking bits.
Reply:use a pointer to access a value.


int *p;// u can use any datatype, it will point only to variables of that type.


*p=2;


or int q=2;


and then p=%26amp;q;// p stores address of q


now cout%26lt;%26lt;p;// gives address of the locatio it is pointing to





hope it works!

hawthorn

No comments:

Post a Comment