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 


Reading eax register in C++

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

Joined: 10 Jul 2014
Posts: 9

PostPosted: Wed Sep 02, 2015 3:51 pm    Post subject: Reading eax register in C++ Reply with quote

So I have an instruction that looks like this
Code:

mov cl,[eax+16]


eax holds the address of the item I want to change.
How would I go about getting it's value in C++?

Also, is there a library for a simple aobscan in c++ or would I have to write that myself?


Thanks
Back to top
View user's profile Send private message
deama1234
Master Cheater
Reputation: 3

Joined: 20 Dec 2014
Posts: 328

PostPosted: Wed Sep 02, 2015 4:15 pm    Post subject: Reply with quote

It's more fun to learn assembly.
Back to top
View user's profile Send private message
Spub
How do I cheat?
Reputation: 0

Joined: 10 Jul 2014
Posts: 9

PostPosted: Wed Sep 02, 2015 4:23 pm    Post subject: Reply with quote

deama1234 wrote:
It's more fun to learn assembly.

While that may be true, I want to do this in c++ because there are some special GUI things I would like to do that CE just can't.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25820
Location: The netherlands

PostPosted: Wed Sep 02, 2015 4:29 pm    Post subject: Reply with quote

you can always create a CEplugin which launches your gui and then make use of the lua interface

But if you insist, it's going to either require a code injection or a breakpoint.

For code injection:
Find the address to hook (e.g aobscan or modulename+offset)

Allocate some memory somewhere
In that code write the bytes that make up code that will save EAX to a known location and jump back after the instruction

Then write the bytes at the found location to make it jump to your allocated code. (do it in this order as there's a chance the code will execute before the first part is written)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Sep 02, 2015 5:59 pm    Post subject: Reply with quote

Take a look at the GetThreadContext API:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms679362%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Spub
How do I cheat?
Reputation: 0

Joined: 10 Jul 2014
Posts: 9

PostPosted: Wed Sep 02, 2015 6:11 pm    Post subject: Reply with quote

Dark Byte wrote:
you can always create a CEplugin which launches your gui and then make use of the lua interface

But if you insist, it's going to either require a code injection or a breakpoint.

For code injection:
Find the address to hook (e.g aobscan or modulename+offset)

Allocate some memory somewhere
In that code write the bytes that make up code that will save EAX to a known location and jump back after the instruction

Then write the bytes at the found location to make it jump to your allocated code. (do it in this order as there's a chance the code will execute before the first part is written)


Okay, seems simple enough. I'm assuming that if I attempt this on a steam game like Dark Souls (even if I'm offline) a vac ban could ensue?

atom0s wrote:
Take a look at the GetThreadContext API:
Sorry, but you can't post url's yet


I'm not quite sure what this does. Does it let me view register values?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Sep 03, 2015 12:33 am    Post subject: Reply with quote

When a thread is suspended, you can obtain the threads context to view the register data. The context structure you pass as the 2nd parameter is filled with the threads information when you call this API. It will contain the various data you have opened the handle to the thread with.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Spub
How do I cheat?
Reputation: 0

Joined: 10 Jul 2014
Posts: 9

PostPosted: Thu Sep 03, 2015 12:14 pm    Post subject: Reply with quote

Well, after more access violations than I can count I finally got GetThreadContext() working. I still need some help though Smile
I took a snapshot of all the threads and filtered to only the ones that match my game's process id, but there still a bunch of them. How do I know which one to get the context of?
And secondly, how do I get the context of the thread at the right time? Does that have to do with the breakpoints that Dark Byte mentioned?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Sep 03, 2015 9:08 pm    Post subject: Reply with quote

Yes you will need to set a breakpoint and handle it (attach to the process as a debugger).
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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