Edit: Should have posted this in another category after seeing all the other options I have. If this needs moved, please do so! Thanks@
I was looking to move a camera around in a game by just changing the X,Y,Z coordinates in physical memory of the game. I have the addresses and I can successfully change my camera position by manually going in and modifying them. However, I'm trying to create a program to make the arrows on the keyboard do this for me.
I have the concept down, but I'm at a stand still! Coordinates are floats or doubles. In this case, X-4 bytes(float), Y-4 bytes(float), Z-4 bytes(float). So we have a total of 12 consecutive bytes. 3 float numbers. Now, I am using ReadProcessMemory to get the current float values. Then using GetAsyncVirtualKey(VK_LEFT) I would DECREASE my X float value, VK_RIGHT would INCREASE my X float value, etc. Then use WriteProcessMemory to write those new values to the same camera addresses.
I know this works because I've WriteProcessMemory set values and it moves the camera on my hotkey.
I guess my problem is, converting the 4 byte hex to a float number in decimal then increasing or decreasing by lets say 0.001 each time we press a hotkey. Then converting it back to hex and writing it. Maybe this is too complicated?
Any advice? Here's portion of my code:
BYTE xRock0[4];
BYTE xRock1[4];
BYTE yRock0[4];
BYTE yRock1[4];
//??? float zRock[4];
BYTE subRock=0.001f;
I have function on 100ms timer.
void timer() {
if(GetAsyncKeyState(VK_LEFT)&1) {
// THERE ARE 2 ADDYS FOR CAM, NOT SURE WHICH CHANGES SO I DO BOTH
ReadProcessMemory(hand, (void*)0x4BB2E1AC, &xRock0,4,&bytes);
ReadProcessMemory(hand, (void*)0x4BF3F75C, &xRock1,4,&bytes);
xRock0[4]=xRock0[4]-subRock;
xRock1[4]=xRock1[4]-subRock;
WriteProcessMemory(hand,(void*)0x4BB2E1AC,&xRock0,4,&bytes);
WriteProcessMemory(hand, (void*)0x4BF3F75C, &xRock1,4,&bytes);
}
if(GetAsyncKeyState(VK_RIGHT)&1) {
ReadProcessMemory(hand, (void*)0x4BB2E1AC, &xRock0,4,&bytes);
ReadProcessMemory(hand, (void*)0x4BF3F75C, &xRock1,4,&bytes);
xRock0[4]=xRock0[4]+subRock;
xRock1[4]=xRock1[4]+subRock;
WriteProcessMemory(hand,(void*)0x4BB2E1AC,&xRock0,4,&bytes);
WriteProcessMemory(hand, (void*)0x4BF3F75C, &xRock1,4,&bytes);
} if(GetAsyncKeyState(VK_UP)&1) {
ReadProcessMemory(hand, (void*)0x4BB2E1B0, &yRock0,4,&bytes);
ReadProcessMemory(hand, (void*)0x4BF3F760, &yRock1,4,&bytes);
yRock0[4]=yRock0[4]+subRock;
yRock1[4]=yRock1[4]+subRock;
WriteProcessMemory(hand,(void*)0x4BB2E1B0,&yRock0,4,&bytes);
WriteProcessMemory(hand, (void*)0x4BF3F760, &yRock1,4,&bytes);
} if(GetAsyncKeyState(VK_DOWN)&1) {
ReadProcessMemory(hand, (void*)0x4BB2E1B0, &yRock0,4,&bytes);
ReadProcessMemory(hand, (void*)0x4BF3F760, &yRock1,4,&bytes);
yRock0[4]=yRock0[4]-subRock;
yRock1[4]=yRock1[4]-subRock;
WriteProcessMemory(hand,(void*)0x4BB2E1B0,&yRock0,4,&bytes);
WriteProcessMemory(hand, (void*)0x4BF3F760, &yRock1,4,&bytes);
}
}
[Edited by - DeltronZero on February 10, 2008 12:41:10 PM]