| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		ParkourPenguin I post too much
  Reputation: 152
  Joined: 06 Jul 2014 Posts: 4706
 
  | 
		
			
				 Posted: Wed Jul 24, 2019 7:04 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				processBaseAddress is a uint32_t*. Arithmetic addition/subtraction on pointers is done in units of the size of the pointed-to type. i.e. this code works as expected:
 
 	  | Code: | 	 		  int mem[5] = {0,1,4,9,16};
 
int *p = mem;
 
*p;      // 0
 
*(p+1);  // 1
 
*(p+2);  // 4
 
... | 	  
 
In your case, the expression "processBaseAddress + 0x00224308" evaluates to 0x00400000 + 4 * 0x00224308 = 00C90C20.
 _________________
 I don't know where I'm going, but I'll figure it out when I get there.  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Winter_Snake How do I cheat?
  Reputation: 0
  Joined: 22 Jul 2019 Posts: 8
 
  | 
		
			
				 Posted: Wed Jul 24, 2019 7:13 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				| How would I go about to make this work then?
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		ParkourPenguin I post too much
  Reputation: 152
  Joined: 06 Jul 2014 Posts: 4706
 
  | 
		
			
				 Posted: Wed Jul 24, 2019 7:21 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				You could change it to a char* or unsigned char *. Or maybe divide the offset by 4. Whatever you feel like doing.
 _________________
 I don't know where I'm going, but I'll figure it out when I get there.  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Winter_Snake How do I cheat?
  Reputation: 0
  Joined: 22 Jul 2019 Posts: 8
 
  | 
		
			
				 Posted: Wed Jul 24, 2019 8:28 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				Dividing the 0x00224308 by 2 or 4 still result in the wrong placement.
 
 
 	  | Code: | 	 		  
 
[0x00400000] + [0x00224308] = [0x00C90C20]
 
[0x00224308] / 2= [0x00112184] -> [0x00400000] + [0x00112184] = [0x00848610]
 
[0x00224308] / 4= [0x000890C2] -> [0x00400000] + [0x000890C2] = [0x00624308]
 
 | 	  
 
 
None of which give me the same address Cheat Engine is pointing too. (Again, [0x0019A3E8])
 
 
As for changing the type to char/unsigned char - it results in the cashBaseAddress being empty and processBaseAddress as weird letters.
 
 
https://imgur.com/qKvlBzC
 
https://imgur.com/Q0lecSn
 
 
(Sorry about the pictures, I can't upload files/pictures either - it just errors out.)
 
 
Mod edit: fixed image links.
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		ParkourPenguin I post too much
  Reputation: 152
  Joined: 06 Jul 2014 Posts: 4706
 
  | 
		
			
				 Posted: Wed Jul 24, 2019 8:52 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				You're printing the address and not the value stored at the address.
 
"game.exe+00224308 -> 0019A3E8" means the value stored at the address game.exe+00224308 is 0019A3E8.
 
 
Putting a char* through a stream will output the text stored at the address rather than the address itself. void* should work as well:
 
https://stackoverflow.com/questions/17813423/cout-with-char-argument-prints-string-not-pointer-value
 
 
Honestly, there are a lot of wrong things with your code, and I don't think I can help you learn how to do it correctly in a few forum posts.
 
(dividing the offset by 4 isn't good either, but it is the simplest hack I could think of to fix your code)
 
 
Perhaps you should start on a simpler project first. The book C++ Primer (5th edition) is a good resource for beginners to learn C++. There have been a lot of changes to C++ since then, but it's still a good resource today.
 
Beyond the basics, learn about strict aliasing and the C++ type system in general. You could also benefit from information on best practices and good interface design.
 
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
 _________________
 I don't know where I'm going, but I'll figure it out when I get there.  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Winter_Snake How do I cheat?
  Reputation: 0
  Joined: 22 Jul 2019 Posts: 8
 
  | 
		
			
				 Posted: Wed Jul 24, 2019 9:28 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				That's okay, I actually figured it out and got it to work without dividing by 4 and all that other hacky nonsense.
 
 
My main problem was I thought Cheat Engine was showing the address, not the value. Wasn't thinking too bright on that one. So thanks for pointing it out.
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |