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 


General function to tell if memory is being edited

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
booingthetroll
Expert Cheater
Reputation: 0

Joined: 30 Aug 2011
Posts: 114
Location: ::1

PostPosted: Thu Mar 21, 2013 12:13 pm    Post subject: General function to tell if memory is being edited Reply with quote

Hi, recently, a game I play started to detect runtime memory modifications, and it does a hash check when you first open it. For that reason, I'd like to know a few common memory edit detection functions(preferably Microsoft). Could you list a few, please?
Back to top
View user's profile Send private message
Innovation
Grandmaster Cheater
Reputation: 12

Joined: 14 Aug 2008
Posts: 617

PostPosted: Thu Mar 21, 2013 7:58 pm    Post subject: Reply with quote

The game might have an internal CRC (cyclic redundancy check) where it compares the code against what it should be.
Back to top
View user's profile Send private message
SteveAndrew
Master Cheater
Reputation: 30

Joined: 02 Sep 2012
Posts: 323

PostPosted: Thu Mar 21, 2013 8:22 pm    Post subject: Reply with quote

As Innovation pointed out, if it only does the check when it starts up then there's no problem you just modify the game while its running after it's already started up and done it's 'check'

However if it has a CRC check that runs constantly while the game is running, and you've found that an address you've attempted to modify crashes the game, instead of modifying it, add that address to your CT and do a 'find what accesses this address' and wait a little bit...

You should find the CRC check, if the game doesn't also have some anti-debugger tricks that is (try the veh debugger if the windows one crashes when doing this, if that one doesn't work either you'll first have to bypass the debugger to even get to the find the CRC check Wink)

Once the CRC check is found though, it's relatively easy to bypass!

_________________
Back to top
View user's profile Send private message
Cryoma
Member of the Year
Reputation: 198

Joined: 14 Jan 2009
Posts: 1819

PostPosted: Thu Mar 21, 2013 8:48 pm    Post subject: Reply with quote

What do you do with the CRC if/when you find it?
Asking out of general curiosity and for any stray googlers.
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 Mar 21, 2013 10:02 pm    Post subject: Reply with quote

Cryoma wrote:
What do you do with the CRC if/when you find it?
Asking out of general curiosity and for any stray googlers.


Most CRC checks are handled one of two ways:
1.) Each byte in a memory region is compared to an original byte.
2.) A checksum is calculated of the region and then compared to a stored value.

In the case of 1, you change the compare function to either just return true that it's valid, or change the compare to use the same buffer twice so it is just comparing each byte to itself.

In case of 2, you'd just change the resulting checksum to that of your newly edited region.

There are plenty of other ways of handling them such as hooking, redirecting the check to a fake buffer with the original data, etc. too.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
SteveAndrew
Master Cheater
Reputation: 30

Joined: 02 Sep 2012
Posts: 323

PostPosted: Fri Mar 22, 2013 12:28 am    Post subject: Reply with quote

Cryoma wrote:
What do you do with the CRC if/when you find it?
Asking out of general curiosity and for any stray googlers.


Well Wiccaan explained it pretty well! So yes the two main / public ways of bypassing them involve making a copy of the unmodified memory and redirecting the check to read from it rather than the real memory (which you'll be modifying with your cheats) or forget making a big copy of the memory and just return valid checksums... (The thing about the 'returning valid checksums' method though is that for different versions of the game the checksums will be different, so just hard coding them will only work for your self (usually)) I came up with a solution where the bypass; bypasses itself only [ex. a JMP (0xe9 to your bypass hook code counts as modifying the memory] just so it can retrieve the valid checksums however many there are[for the different regions it checks] With the valid checksums then you can just return them and save memory compared to the first method (which takes up practically 2 copies of the game in memory, compared to just a few bytes)


For googlers out there who may come upon this thread, here are both of these methods I've described implemented and working for Crysis 3 (the latest game with a CRC check I've bypassed)


http://forum.cheatengine.org/viewtopic.php?t=563373

A commonly used CRC Check routine looks like this: (In fact if your game in question uses this same CRC Check you can find it by looking for these bytes or assembler instructions without even debugging at all Wink)

CRCCheckLoop:
0FB6 39 - movzx edi,byte ptr [ecx]
8B F0 - mov esi,eax
C1 EE 18 - shr esi,18
33 F7 - xor esi,edi
C1 E0 08 - shl eax,08
33 04 B5 ? ? ? ? - xor eax,[SomeAddressHere]
41 - inc ecx
4A - dec edx
75 E8 - jne CRCCheckLoop
5F - pop edi
5E - pop esi
C3 - ret



P.S. If Resident Evil 6 PC has a CRC Check count on me being the first to bypass it and release it here Wink

Also aiming for worlds first Resident Evil 6 cheats!! Can I do it? Or will someone beat me to the punch? Razz

Although I really shouldn't said that as now someone's going to try and put up a table before me!! lol xD

But hey it's fair game for competition! This is the first time I've actually been here right as release! So hopefully I can squeeze a couple cheats out before anyone else Very Happy

_________________
Back to top
View user's profile Send private message
booingthetroll
Expert Cheater
Reputation: 0

Joined: 30 Aug 2011
Posts: 114
Location: ::1

PostPosted: Fri Mar 22, 2013 9:28 am    Post subject: Reply with quote

:S
I don't think it could be a CRC, since... well... it's a huge program with very little lag and from what I can tell, everything except their .data section and runtime allocated memory is detected. My friend thinks it could be hashing the entire data section... would this be possible?
Back to top
View user's profile Send private message
jucce
Advanced Cheater
Reputation: 1

Joined: 02 Apr 2013
Posts: 99

PostPosted: Wed Apr 03, 2013 9:39 pm    Post subject: Reply with quote

booingthetroll wrote:
:S
I don't think it could be a CRC, since... well... it's a huge program with very little lag and from what I can tell, everything except their .data section and runtime allocated memory is detected. My friend thinks it could be hashing the entire data section... would this be possible?
Well a CRC is basically a much simpler hash function. In fact calculating a CRC should be less resource intensive compared to calculating a "proper" hash. It might not be very costly at all if it's implemented in a clever way so I don't see why they couldn't use a CRC to protect it.
Back to top
View user's profile Send private message
TsTg
Master Cheater
Reputation: 5

Joined: 12 Dec 2012
Posts: 340
Location: Somewhere....

PostPosted: Thu Apr 04, 2013 8:36 am    Post subject: Reply with quote

@SteveAndrews: yes Crysis 3 was possible to eliminate the check with hooking the main bypass routine, that gives the many of 'mini checks' thier correct hashes to check for, right ?, that happens because the main routine is the one controlling the whole thing.

Some other games(like Sleeping dogs, and the first 2 versions of Hitman absolution), uses a main routine too, but that routine doesn't give the hashes to the others like in crysis 3, here's a mini check sample i took(this one inclined with the game saving routine):

push ebp
mov ebp,esp
push FF
push HKShip.AK::MusicEngine::Init+1A6B7C
mov eax,fs:[00000000]
push eax
mov fs:[00000000],esp
sub esp,0C
push ebx
push esi
push edi

-This Part will calculate the memory area to be checked and it's size (it's here from 400000 to 405000), notice all those contants
mov eax,838D209A
mov edi,3BF86F57 : [DEDEDEDE]
mov [ebp-14],eax
mov [ebp-10],edi
mov esi,[ebp-14]
mov edi,[ebp-10]
mov edx,esi
shr edx,06
xor edx,esi
and edx,3F
mov eax,edx
shl eax,06
or eax,edx
xor eax,esi
xor eax,29D46CFB
mov ecx,edi
shr ecx,0A
xor ecx,edi
shr ecx,10
and ecx,0F
ror eax,0D
sub eax,530D2766 : [DEDEDEDE]
rol eax,1F
mov edx,eax
shr edx,09
xor edx,eax
shr edx,08
and edx,1F
mov esi,edx
shl esi,09
or esi,edx
shl esi,08
xor esi,eax
mov eax,ecx
shl eax,0A
or eax,ecx
shl eax,10
xor eax,edi
add eax,480DDC73 : [DEDEDEDE]
rol eax,0A
sub eax,3112CBB0 : [DEDEDEDE]
ror eax,16
mov ecx,eax
shr ecx,12
xor ecx,eax
and ecx,00003FFF
mov edx,ecx
shl edx,12
or edx,ecx
xor edx,eax
mov [ebp-14],esi
mov [ebp-10],edx
mov edi,[ebp-10]
add edi,[ebp-14]
mov [ebp-10],edi
mov eax,[ebp+10]
mov ecx,[ebp+08]
push eax
push ecx
push HKShip.AK::MusicEngine::Init+3C8094
xor esi,esi
call HKShip.AK::MemoryMgr::GetPoolName
mov edx,[ebp-10]
mov eax,[ebp-14]
mov ecx,[ebp-10]
sub edx,eax
mov eax,[ebp-10]
mov edi,[ebp-10]
add esp,0C
sub ecx,eax
mov [ebp-18],05D3E4E7 <----Correct CRC value
cmp ebx,ecx

mov eax,9307FA73
lea ebx,[esi+01]
cmp ecx,edx
je HKShip.AK::MemoryMgr::SetMonitoring+9D856

-The integrity calculation part
lea ecx,[ecx+00]
imul esi,esi,00000097
mov eax,edi
sub eax,ecx
movzx eax,byte ptr [eax-01]
add ecx,ebx
add esi,eax
cmp ecx,edx
jne HKShip.AK::MemoryMgr::SetMonitoring+9D840


cmp dword ptr [ebp+08],00
jne HKShip.AK::MemoryMgr::SetMonitoring+9D89B
test [HKShip.g_LEngineDefaultPoolId+82BAC],bl
jne HKShip.AK::MemoryMgr::SetMonitoring+9D88F
or [HKShip.g_LEngineDefaultPoolId+82BAC],ebx
mov [ebp-04],00000000
mov ecx,HKShip.g_LEngineDefaultPoolId+828EC
call HKShip.AK::MemoryMgr::GetPoolName+1EFF70
push HKShip.AK::MusicEngine::Init+2D6D40
call HKShip.AK::MusicEngine::Init+618C1
add esp,04
mov [ebp-04],FFFFFFFF
mov [HKShip.g_LEngineDefaultPoolId+828EC],00000002
jmp HKShip.AK::MemoryMgr::SetMonitoring+9D8D4
test [HKShip.g_LEngineDefaultPoolId+82BAC],bl
jne HKShip.AK::MemoryMgr::SetMonitoring+9D8CA
or [HKShip.g_LEngineDefaultPoolId+82BAC],ebx
mov [ebp-04],ebx
mov ecx,HKShip.g_LEngineDefaultPoolId+828EC
call HKShip.AK::MemoryMgr::GetPoolName+1EFF70
push HKShip.AK::MusicEngine::Init+2D6D40
call HKShip.AK::MusicEngine::Init+618C1
add esp,04
mov [ebp-04],FFFFFFFF
mov [HKShip.g_LEngineDefaultPoolId+828EC],00000003
lea ecx,[esi+esi*8]
mov eax,ecx
shr eax,0B
xor eax,ecx

mov ecx,[ebp-18] <-----at the begnning of the routine, [ebp-18] was given the value 05D3E4E7
imul eax,eax,00008001
sub eax,ecx <-----if the subtraction result is zero(meaning eax equals ecx, equals 05D3E4E7), then the jump is not taken to bad boy routine
jne HKShip.AK::MemoryMgr::SetMonitoring+9D9ED


-Normal game code here (good boy)
mov ecx,[ebp+10]
lea eax,[ecx-02]
cmp eax,03
ja HKShip.AK::MemoryMgr::SetMonitoring+9DA29
jmp dword ptr [eax*4+HKShip.AK::MemoryMgr::SetMonitoring+9DA3C]
mov edx,[ebp+08]
sub esp,0C
mov eax,esp
mov [eax],edx
mov edx,[ebp+0C]
mov [eax+04],edx
mov [eax+08],ecx
call HKShip.exe+151850
mov ecx,eax
call HKShip.exe+63E30
mov ecx,[ebp-0C]
mov fs:[00000000],ecx
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret
call HKShip.exe+151850
sub esp,0C
cmp [eax+04],ebx
mov eax,esp
jne HKShip.AK::MemoryMgr::SetMonitoring+9D972
mov ecx,[ebp+08]
mov edx,[ebp+0C]
mov [eax],ecx
mov ecx,[ebp+10]
mov [eax+04],edx
mov [eax+08],ecx
call HKShip.exe+151850
mov ecx,eax
call HKShip.AK::MemoryMgr::GetPoolName+133A40
mov ecx,[ebp-0C]
mov fs:[00000000],ecx
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret
mov edx,[ebp+08]
mov ecx,[ebp+0C]
mov [eax],edx
mov edx,[ebp+10]
mov [eax+04],ecx
mov [eax+08],edx
call HKShip.exe+151850
mov ecx,eax
call HKShip.AK::MemoryMgr::SetMonitoring+E0440
mov ecx,[ebp-0C]
mov fs:[00000000],ecx
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret
call HKShip.exe+151850
mov ecx,eax
call HKShip.exe+2EE720
mov ecx,[ebp-0C]
mov fs:[00000000],ecx
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret
mov edx,[ebp+08]
sub esp,0C
mov eax,esp
mov [eax],edx
mov edx,[ebp+0C]
mov [eax+04],edx
mov [eax+08],ecx
call HKShip.exe+151850
mov ecx,eax
call HKShip.AK::MemoryMgr::GetPoolName+184790
mov ecx,[ebp-0C]
mov fs:[00000000],ecx
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret

-Error sub routine(bad boy)
mov ebp,esp
mov [ebp+04],HKShip.exe+21638
lea ebx,[ebx+05]
mov ebp,esp
add ebp,0C
mov [ebp+00],HKShip.exe+F8D8
lea ebp,[ebp+04]
dec ebx
jne HKShip.AK::MemoryMgr::SetMonitoring+9D9FE
mov eax,00000002
mov esi,FFB26D7F
mov eax,000FF440
call HKShip.AK::MemoryMgr::SetMonitoring+9DA1F
pop edx
xor esi,eax
sub edx,0E
add esi,edx
jmp esi <---ESI here jumps to the 'corrupt' message routine
mov ecx,[ebp-0C]
pop edi
pop esi
mov fs:[00000000],ecx
pop ebx
mov esp,ebp
pop ebp
ret


___________________________________________________
so what i'm saying here that some games has the checks already containing thier values (statically), at the same time, the routine above is checked by others within the same way with other values that are also static, and of course if you tried to change one, you will get caught with other routines, so either eliminate them all or do code\execution redirection, as this one has no way to patch integrity with just 2 bytes.
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 Discussions 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