Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


delphi to c++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
comm3451
How do I cheat?
Reputation: 0

Joined: 28 Jul 2021
Posts: 8

PostPosted: Wed Aug 18, 2021 2:59 am    Post subject: delphi to c++ Reply with quote

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
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Wed Aug 18, 2021 1:09 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
comm3451
How do I cheat?
Reputation: 0

Joined: 28 Jul 2021
Posts: 8

PostPosted: Wed Aug 18, 2021 7:17 pm    Post subject: hmm Reply with quote

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



{6AFB9994-0482-4515-86C4-A013DA3F8002}.png.jpg
 Description:
 Filesize:  32.49 KB
 Viewed:  4042 Time(s)

{6AFB9994-0482-4515-86C4-A013DA3F8002}.png.jpg


Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Wed Aug 18, 2021 10:24 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
comm3451
How do I cheat?
Reputation: 0

Joined: 28 Jul 2021
Posts: 8

PostPosted: Wed Aug 18, 2021 11:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites