简体   繁体   中英

How to learn if i am compiling for 32bit or 64bit and how to change that?

So i was having trouble with reading memory. I was successful reading values that has short addresses like 0x5CD38994 but when i try longer addresses like 0x2840C6C68D8 i only get 0. Some people said that i should compile my code for 64bit. But i don't know if i am compiling it for 32bit or 64bit. How to learn that and is it changed on my IDE or is it about compiler? I am using Eclipse IDE and GCC compiler. What should i do to compile my code for 64bit?

That works:

ReadProcessMemory(pHandle, (LPVOID)0x5CD38994, &my_value, sizeof(my_value),0);

That does not:

ReadProcessMemory(pHandle, (LPVOID)0x2840C6C68D8, &my_value, sizeof(my_value),0);

0x2840C6C68D8 is a 64 bit address. You cannot use ReadProcessMemory() from a 32bit process and try to read a 64bit address, you must compile for x64.

To compile for x64 on GCC use gcc -m64 , you should be able to add that to your compiler/linker flags somewhere in the settings for your IDE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM