| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		comm3451 How do I cheat?
  Reputation: 0
  Joined: 28 Jul 2021 Posts: 8
 
  | 
		
			
				 Posted: Wed Aug 18, 2021 2:59 am    Post subject: delphi to c++ | 
				       | 
			 
			
				
  | 
			 
			
				function RPM4Byte(Addr: DWORD): DWORD;
 
var
 
  Value: DWORD;
 
begin
 
  ReadProcessMemory(HW, Pointer(Addr), @Value, SizeOf(Value), iRead);
 
  Result := Value;
 
end;
 
DWORD RPM4Byte(DWORD addr)
 
{
 
		HANDLE hProcess = GetModuleHandle(NULL);
 
		DWORD value;
 
		ReadProcessMemory(hProcess, (LPVOID)addr, &value, sizeof(value), NULL);
 
		return value;
 
}
 
I'm making dll game hack
 
This is Delphi source 
 
so I make it to c++
 
but It doesn't work
 
Why use ReadProcessMemory?
 
After playing the game, the pointer is not correct so it crashes.
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		atom0s Moderator
  Reputation: 205
  Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
  | 
		
			
				 Posted: Wed Aug 18, 2021 1:09 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				If you are injected into the process, then you can just directly read from the address using pointer casting. Such as:
 
 
 	  | Code: | 	 		  
 
auto addr = 0x1234FFFF;
 
auto value = *(uint32_t*)addr;
 
 | 	  
 
 
As for why it doesn't work, this is not correct:
 
 	  | Code: | 	 		  | HANDLE hProcess = GetModuleHandle(NULL); | 	  
 
 
ReadProcessMemory takes an opened permission handle, not a module base address for the first parameter. You need to either properly open one with OpenProcess, or obtain one by other means.
 _________________
 - Retired.  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		comm3451 How do I cheat?
  Reputation: 0
  Joined: 28 Jul 2021 Posts: 8
 
  | 
		
			
				 Posted: Wed Aug 18, 2021 7:17 pm    Post subject: hmm | 
				       | 
			 
			
				
  | 
			 
			
				I made it like this
 
DWORD RPM4Byte(DWORD addr)
 
{
 
		HWND hwnd = FindWindowA(NULL, "KartRider Client");
 
		if(hwnd == NULL)
 
		{
 
			printf("error");
 
			return 1;
 
		}else
 
		{
 
			DWORD procID;
 
			GetWindowThreadProcessId(hwnd, &procID);
 
			HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
 
			DWORD value;
 
			ReadProcessMemory(hProcess, (LPVOID)addr, &value, sizeof(value), NULL);
 
			return value;
 
		}
 
}
 
and 
 
DWORD FindRanking()
 
{
 
	try
 
	{
 
		DWORD addr = 0x00C7BFAC;
 
		addr = RPM4Byte(addr) + 0x18;
 
		addr = RPM4Byte(addr) + 0xdc;
 
		addr = RPM4Byte(addr) + 0x1f0;
 
		addr = RPM4Byte(addr) + 0;
 
		addr = RPM4Byte(addr) + 0x1cc;
 
		return addr;
 
	}catch(int i)
 
	{
 
	
 
	}
 
	
 
        DWORD pt = FindRanking()
 
        printf("%d",pt);
 
I used it but It says 405550497
	
  
	 
	
	
		
	 
	
		|  Description: | 
		
			
		 | 
	 
	
		|  Filesize: | 
		 32.49 KB | 
	 
	
		|  Viewed: | 
		 5345 Time(s) | 
	 
	
		
  
 
  | 
	 
	 
	 
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		atom0s Moderator
  Reputation: 205
  Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
  | 
		
			
				 Posted: Wed Aug 18, 2021 10:24 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				I'd really suggest learning what you're doing first. There's a handful of problems with that code. Just copy-pasting stuff together isn't really going to teach you anything. You're creating various types of leaks with what you're doing as is.
 _________________
 - Retired.  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		comm3451 How do I cheat?
  Reputation: 0
  Joined: 28 Jul 2021 Posts: 8
 
  | 
		
			
				 Posted: Wed Aug 18, 2021 11:00 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				DWORD value = NULL;
 
Right?
 
btw I'm making racing game hack
 
Its name is "KartRider"
 
and I have hack Delphi Source
 
I want to change It to c++ dll so I making it
 
DWORD addr = 0x00C7BFAC;
 
addr = RPM4Byte(addr) + 0x18;
 
addr = RPM4Byte(addr) + 0xdc;
 
addr = RPM4Byte(addr) + 0x1f0;
 
addr = RPM4Byte(addr) + 0;
 
addr = RPM4Byte(addr) + 0x1cc;
 
addr = RPM4Byte(addr);
 
return addr;
 
This is the source for ranking
 
And Why I don't use like this?
 
auto addr = 0x1234FFFF;
 
auto value = *(uint32_t*)addr;
 
because after one game is over, when I try to play next game, the value is not correct, so it crash and Delphi source use ReadProcessMemory and WriteProcessMemory.
 
anyway This is the delphi source.
 
drive.google.1com/file/d/1Kx-7Z6e3bVUFed5hWuDrzie82M-Ghjg1/view?usp=sharing
 
1com = com
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |