Help😎 [C++] Get address value as Array of Bytes

Posts 1–3 of 3 · Page 1 of 1
😎 [C++] Get address value as Array of Bytes




Hi, i'm using this code to read a process memory address:

Code:
DWORD address 0xPSEUDUMADDY;
int myint;
ReadProcessMemory(pHandle, (LPVOID)address, &myint, sizeof(myint), 0);

I need to change it from (example) "F3 0F 7E 41" to "F3 0F 7E 45", how do i get the value of address in Array of Bytes in c++?
Quote Originally Posted by CaET View Post
"F3 0F 7E 41" to "F3 0F 7E 45"
if you just need to change 4th byte you don't need to read/write array of bytes, just add offset of 3 to your address:
Code:
DWORD address 0x...;
BYTE buf = 0x45;
WriteProcessMemory(pHandle, (LPVOID)(address + 3), (LPCVOID)&buf, sizeof(buf), 0);
if it is just a bad example (so you really need write array of bytes), then you could do it like this
Code:
DWORD address 0x...;
BYTE buf[] = { 0xF3, 0x0F, 0x7E, 0x45 };
WriteProcessMemory(pHandle, (LPVOID)address, (LPCVOID)buf, sizeof(buf), 0);
and for read:
Code:
DWORD address 0x...;
BYTE buf[4];
ReadProcessMemory(pHandle, (LPVOID)address, (LPCVOID)buf, sizeof(buf), 0);
btw, if you need just 4 bytes you still can use unsigned int (DWORD) because it can contain 4 bytes, for example (for write F3 0F 7E 45 to ur address):
Code:
DWORD address 0x...;
DWORD buf = 0x457E0FF3;
WriteProcessMemory(pHandle, (LPVOID)address, (LPCVOID)&buf, sizeof(buf), 0);
(you need to use it in reversed order, because int uses little-endian bytes order)

not sure, did I answer ur question, whatever..
Yeah , that's it. Thank you =)
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us