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 


How to make readmem in 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 Jul 28, 2021 8:20 pm    Post subject: How to make readmem in c++ Reply with quote

I made a CRC bypass and I want to make it in C++.
Alloc(CRC1Copy,2048)

CRC1Copy:
Readmem(CRC1,2048)
so I use memcpy but not work, how?
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 Jul 28, 2021 10:49 pm    Post subject: Reply with quote

Show the code you are trying to do in C++, just saying you tried memcpy isn't really showing what you have tried to do or if you're just using things wrong.
_________________
- 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 Jul 28, 2021 10:53 pm    Post subject: Reply with quote

void* CRC1Copy = new void*;
memcpy(CRC1Copy,(void*)baseoffect + CRCOffset,sizeof(void*) * 2048)
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 Jul 28, 2021 11:12 pm    Post subject: Reply with quote

If you know the size that you plan to copy, there is no reason to ever use 'new'. (You should basically never be using it in C++ anymore unless you are absolutely sure you need to and understand what you're doing.)

You are also using 'new' wrong and creating an invalid pointer/type for what you're trying to do. You are also going to land up overwriting invalid memory creating a heap corruption. Using 'new void*' is only creating a single void* object which is 4 bytes long.

Instead, you should just make a buffer with the size you want, such as:

Code:

    uint8_t buffer[2048]{};
    std::memcpy(&buffer, (void*)SomeAddress, 2048);


Where SomeAddress is the addr you want to read from.

Keep in mind, memcpy only works when you're injected into the target process. You must be within the same process memory space for it to work. Otherwise, you need to use ReadProcessMemory, or other remote process calls that deal with reading memory.

_________________
- 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: Thu Jul 29, 2021 8:58 pm    Post subject: Reply with quote

Crashes when I using memcpy so I try ReadProcessMemory
DWORD CRCADD= moduleBase + 0x013F87B6;
uint8_t CRC[2048]{};
ReadProcessMemory(GetModuleHandle(NULL), (LPCVOID)CRCADD,&CRC, (SIZE_T)2048,0);
like this
but When I find Memory Address
add [eax],al
add [eax],al
add [eax],al
add [eax],al
it's wrong And after a while the crashes
How to fix it?
I'm making dll
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: Fri Jul 30, 2021 1:53 pm    Post subject: Reply with quote

If your DLL is injected into the remote process, you don't need to use ReadProcessMemory. Just stick to using memcpy. As for the crash you need to debug to find out why it is crashing. In most cases, it's probably because you have an invalid address you are trying to read from. That can be due to just a bad address in general or bad casting.

A common cause is due to how you are handling the additions from a module base and any offset. Such as:
Code:
DWORD CRCADD= moduleBase + 0x013F87B6;


Depending on what type moduleBase is, you can be creating an invalid/incorrect address. Try casting it first to a DWORD as well such as:

Code:
DWORD CRCADD= (DWORD)moduleBase + 0x013F87B6;

_________________
- 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: Fri Jul 30, 2021 9:42 pm    Post subject: :( Reply with quote

Hmm... Sometimes it crashes and sometimes it doesn't crash. Is this game weird?
Back to top
View user's profile Send private message
STN
I post too much
Reputation: 42

Joined: 09 Nov 2005
Posts: 2672

PostPosted: Fri Aug 13, 2021 9:01 am    Post subject: Re: :( Reply with quote

comm3451 wrote:
Hmm... Sometimes it crashes and sometimes it doesn't crash. Is this game weird?


Probably not, we can't say until we see the rest of your code and learn the game's name.

_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.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