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 


C# Find out what addresses this instruction accesses

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ranseier
Newbie cheater
Reputation: 0

Joined: 27 Sep 2015
Posts: 23

PostPosted: Mon Oct 19, 2015 3:02 pm    Post subject: C# Find out what addresses this instruction accesses Reply with quote

Hi,

I found an address in the memory viewer where I can do the "Find out what addresses this instruction accesses" which returns all enemies healths in the game. Thanks to the AOB signatur this address is stable during game restarts.

Now I want to get the same result in C# - get all the enemies health values.

I am using this class http://www.cheatengine.org/forum/viewtopic.php?p=5242821&sid=3170ae57f3052fd995f64e24ff8e091e so the AOB scan is no problem.

But how about the the part that "Find out what addresses this instruction accesses" does? I have no clue what technique is used here.

Thanks for any hints!
Back to top
View user's profile Send private message
ulysse31
Master Cheater
Reputation: 2

Joined: 19 Mar 2015
Posts: 324
Location: Paris

PostPosted: Mon Oct 19, 2015 8:20 pm    Post subject: Reply with quote

AFAIK cheat engine is using the debugger to retrieve those addresses.

A fairly simple solution for you would be to hook the code and retrieve the offset.

If your code updating life is :
mov [eax+0c], ebx

then a simple :
push ecx
push edx
lea ecx,[eax+0c]
mov edx, 0x00434256
mov [edx],ecx
pop edx
pop ecx

this would store the first address whose life is being modified to 0X00434256 memory address.
now you can modify the code to figure out how many adress are being accessed and you can log all of them with a bit more of assembly code.
Back to top
View user's profile Send private message
ranseier
Newbie cheater
Reputation: 0

Joined: 27 Sep 2015
Posts: 23

PostPosted: Tue Oct 20, 2015 5:00 am    Post subject: Reply with quote

After watching Fleeps "C++ Mid Function Hooking/Codecaving Tutorial" on youtube, I learned how to hook the code. It looks like C++ is more suited for dll injection than C#.

ulysse3131 wrote:

now you can modify the code to figure out how many adress are being accessed and you can log all of them with a bit more of assembly code.


Do you have an example or a hint how to do that? I am quite new to ASM.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Tue Oct 20, 2015 9:49 am    Post subject: Reply with quote

ranseier wrote:
ulysse3131 wrote:

now you can modify the code to figure out how many adress are being accessed and you can log all of them with a bit more of assembly code.

Do you have an example or a hint how to do that? I am quite new to ASM.

I'd do it by allocating some memory, then making a routine that loops through that memory comparing the stored addresses to the one that's being accessed by the game's instruction.

For example, using CE's auto assembler, let's assume the eax register points to the enemy's address. Then:
Code:
alloc(newmem,1024)
alloc(enemyAddresses,1024)

label(addEnemyAddress)
label(exitAdd)
label(exit)

newmem:
  //game's code, example:
  mov esi,[eax]
  //eax is a pointer, [eax] is the enemy's address
  //then:
  push ecx
  push edi
  mov ecx,enemyAddresses
  call addEnemyAddress
  pop edi
  pop ecx
  //continue game's code here
addEnemyAddress:
  mov edi,[ecx]
  cmp esi,edi
  je exit
  test edi,edi
  jz exitAdd
  add ecx,4
  jmp addEnemyAddress
exitAdd:
  mov [ecx],esi
exit:
  ret


Of course, if it's possible for an enemy to be destroyed, then you'd need a way of removing that enemy's address from this list. That would be a bit more challenging to do, but it's still easily possible. Just loop through the list, and once you find it, move every address after it back one until you reach a null address (a value of 0).

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
ulysse31
Master Cheater
Reputation: 2

Joined: 19 Mar 2015
Posts: 324
Location: Paris

PostPosted: Tue Oct 20, 2015 2:27 pm    Post subject: Reply with quote

Yes, that chunk of code is pretty good, unfortunately I don't think there is a "newbie" way to make this, you'll need to learn a bit of assembly to get something decent.
Back to top
View user's profile Send private message
ranseier
Newbie cheater
Reputation: 0

Joined: 27 Sep 2015
Posts: 23

PostPosted: Tue Oct 20, 2015 2:30 pm    Post subject: Reply with quote

thank you guys, I will try it.
Back to top
View user's profile Send private message
ulysse31
Master Cheater
Reputation: 2

Joined: 19 Mar 2015
Posts: 324
Location: Paris

PostPosted: Tue Oct 20, 2015 7:04 pm    Post subject: Reply with quote

Just be very careful with the stack, remember "call" modifies the stack and 1 call must ultimately meet 1 (and only one) ret.
Remember to push every register you use and pop it afterwards.
If you crash your game it very likely will be because one of the above 2.

If you meet problems don't hesitate to post your code here.

The given chunk of code assumes there is a pointer to your final address but it might not be the case so before you start coding, take the line of code that is from the game and that you found and determine wether it's a pointer or not.

Also if you don't wanna allocate memory you can scan for code caves, it's very likely you'll have pretty large ones.
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