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#] & [CE] "Memory Viewer" related question

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

Joined: 01 Jul 2012
Posts: 23

PostPosted: Thu Nov 28, 2013 10:03 pm    Post subject: [C#] & [CE] "Memory Viewer" related question Reply with quote

Hi,

I've been checking out about Memory Viewer. I don't really understand anything about it and how to solve things from it, but is that possible to make trainer with C# which edits these values in example "jne" -> "je"

I don't really know how to explain, but the memory viewer will open if I press some found address with right click and I press "disassemble this memory region"

What is that called and where do I can find some tutorials for it? In example if I want to edit basic memory values I can simply search C# ReadProcessMemory and WriteProcessMemory from Google and I get some results for that. Already got Memory editing work, but I've no idea how to edit these "jne", "jmp", "je" and etc values with C#.

Some help? Smile Thanks!
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Thu Nov 28, 2013 11:58 pm    Post subject: Reply with quote

JNE and JE are called "opcodes". (See here for more info on a detailed explanation if you want: http://en.wikipedia.org/wiki/Opcode)

Every opcode is defined by a sequence of bytes. For example:
0x73 = JNB (Jump if not below)
0x74 = JE (Jump if equal)
0x75 = JNZ (Jump if not zero) / JNE (Jump if not equal)
0x76 = JBE (Jump if below/equal)

And so on. (These are in their short-jump forms.)

With C# you just need to use WriteProcessMemory and toggle the byte to the jump type you need. Keep in mind that not all jumps are the same size of bytes so you can't always just overwrite 1 of the bytes and have it work.

In your case you want to change 0x75 with 0x74.

There are plenty of source code examples of how to write to memory on this forum in C# and other languages.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Epz
Newbie cheater
Reputation: 0

Joined: 01 Jul 2012
Posts: 23

PostPosted: Fri Nov 29, 2013 6:14 am    Post subject: Reply with quote

Figured it out, but:

E: Oh. Fine. I found byte of array for that address and it needs to be modified. I see that the address is green in addresses bar including array of bytes as a value, but address still changes in every start of game. Possible to search address itself with byte of arrays in C#? Surprised



GTbo9RH.png
 Description:
 Filesize:  26.31 KB
 Viewed:  15429 Time(s)

GTbo9RH.png



xY3CQ1y.png
 Description:
 Filesize:  76.15 KB
 Viewed:  15429 Time(s)

xY3CQ1y.png


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

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Fri Nov 29, 2013 11:40 am    Post subject: Reply with quote

Memory changes are not permanent. You need to apply your hack everytime the game is started. Given the screenshots you showed, you are patching a fairly well used function inside a system DLL, I don't recommend patching the file itself to always have it enabled.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Epz
Newbie cheater
Reputation: 0

Joined: 01 Jul 2012
Posts: 23

PostPosted: Fri Nov 29, 2013 11:48 am    Post subject: Reply with quote

But in example (at all) if we don't watch pictures anymore. I find always one result as green address (including byte of array in it's value) with byte of array I already found from disassembler, but address of byte of array changes everytime when I start the game. Is that possible to find "green" address which doesn't change (?pointer?) ? :/

And in otherwords I guess I need to find address using byte of array, because everytime my trainer starts loses the address where this byte of array is stored.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Fri Nov 29, 2013 12:07 pm    Post subject: Reply with quote

You can scan for the array of bytes leading to that area. For example you have:

Code:
msvcrt.memcpy+6D - 49 8B C3              - mov rax,r11
msvcrt.memcpy+70 - C3                    - ret
msvcrt.memcpy+71 - 88 11                 - mov [rcx],dl
msvcrt.memcpy+73 - 48 FF C1              - inc rcx
msvcrt.memcpy+76 - 49 FF C8              - dec r8
msvcrt.memcpy+79 - 75 F6                 - jne msvcrt.memcpy+71
msvcrt.memcpy+7B - E9 38FFFFFF           - jmp msvcrt.memset+98
msvcrt.memcpy+80 - 49 83 F8 08           - cmp r8,08
msvcrt.memcpy+84 - 73 16                 - jae msvcrt.memcpy+9C
msvcrt.memcpy+86 - 4D 85 C0              - test r8,r8
msvcrt.memcpy+89 - 74 42                 - je msvcrt.memcpy+CD
msvcrt.memcpy+8B - 8A 04 0A              - mov al,[rdx+rcx]
msvcrt.memcpy+8E - 88 01                 - mov [rcx],al
msvcrt.memcpy+90 - 48 FF C1              - inc rcx


An array of bytes you can scan for would be:
C3 88 11 48 FF C1 49 FF C8

This will find you the location you want. Then +9 from the starting address will be the byte you want to patch.

So with Cheat Engine you could patch it like this:
Code:
[ENABLE]
label(patch)
registersymbol(patch)
aobscan(_memcpy,C3 88 11 48 FF C1 49 FF C8)

_memcpy+9:
patch:
db 74

[DISABLE]
patch:
db 75
unregistersymbol(patch)


In C# you can to array of byte scanning using some code I wrote here:
http://www.gamedeception.net/index.php?threads/findpattern-in-c.14470/

_________________
- 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 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