Sign in to follow this  

Float Arrays + Hexadecimal

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Perhaps you are doing something hundred times more advanced than what I would do..

However, you said:

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.

So why are you doing everything else and not just modifying the values exactly had if you done them manually.

If this is in a loop, it will continually check keystates, so holding down the left arrow will appear the camera to slide.

Edit: why are you not using ints right off the bat?

Share this post


Link to post
Share on other sites
Quote:
Original post by CrazyfoolSo why are you doing everything else and not just modifying the values exactly had if you done them manually.

If this is in a loop, it will continually check keystates, so holding down the left arrow will appear the camera to slide.

Edit: why are you not using ints right off the bat?


I WANT the camera to slide across the map like if I were in developer mode or something. I want my camera to follow my arrow directions and move around the map without moving my character. << In note to that, I have already figured out how to change the perspective so I can "detach" the cam from the player, which in turn allows me to modify the camera coordinates.

I am trying to modify them how I would manually, but there's no point to the fact of what I'm trying to accomplish. Also I'm not understanding why I would use int's when they are floating point numbers. Thank you for the help though!

Share this post


Link to post
Share on other sites
Quote:
Original post by Mike.Popoloski
This is crazy. Why are you modifying the physical memory? I'm not sure if physical memory addresses even are guaranteed to stay the same between program runs. Is there a reason why you aren't just modifying the camera's coordinates directly?


The addresses for this FPS are static. I can always change them no matter when the game runs. Modifying directly? :[ Confused!

Share this post


Link to post
Share on other sites
Quote:
Original post by Mike.Popoloski
Are you trying to make a hack for another game? I don't think we condone that sort of stuff here at GDNet.


Why not? I mean, if it were a single player game then I certainly can't see the harm. It could even be a learning experience for a developer when considering how to write anti-hacking methods (or possibly: why investing effort into them may not pay off).

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
Quote:
Original post by Mike.Popoloski
Are you trying to make a hack for another game? I don't think we condone that sort of stuff here at GDNet.


Why not? I mean, if it were a single player game then I certainly can't see the harm. It could even be a learning experience for a developer when considering how to write anti-hacking methods (or possibly: why investing effort into them may not pay off).


No, I'm not trying to hack a game. I'm actually trying to anti-hack a game believe it or not. I'm trying to get comfortable with what I can do with the cam SERVER SIDE. Client side, it's not possible to do this sort of thing. Eventually the cam will attach to other players' first person view so I can monitor what they are doing. I see no harm in this if I am hosting a cheat-free server.

Can anyone offer me some advice on my issue?

EDIT:
Quote:
Original post by Crazyfool
Er, when I said ints, I guess Imeant FLOATS, I should have just posted my code for a working camera that does exactly what you're trying to do (unless its a mod/hack for another game)


This would be so greatful of you!

Share this post


Link to post
Share on other sites

This topic is 3593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this