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 


Code cave usage?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
podstanar
Advanced Cheater
Reputation: 4

Joined: 02 May 2012
Posts: 82
Location: Flatland

PostPosted: Thu May 03, 2012 7:57 pm    Post subject: Code cave usage? Reply with quote

Hello,as the title states,i need help about code caves usage. I've been practicing and came up with this script(Spider Solitaire).In short,how can i implement code cave/s in it:

Code:
[ENABLE]
alloc(code_moves,512)
alloc(code_score,512)
label(return_moves)
label(return_score)

{-------------------}
{       Moves       }
{-------------------}

01004DC0:
jmp code_moves
db 90
return_moves:

code_moves:
db C7 86 50 03 00 00 00 00 00 00

jmp return_moves

{-------------------}
{       Score       }
{-------------------}

010035D1:
jmp code_score
db 90
return_score:

code_score:
db 89 08 C7 00 F4 01 00 00 3B 0A 0F 8E C9 33 31 00

jmp return_score

[DISABLE]
dealloc(code_moves)
01004DC0:
db FF 86 50 03 00 00
dealloc(code_score)
010035D1:
db 89 08 3B 0A 7E 02


Everything i tried so far crashed the game, if someone can actually explain or give an example, it will be much appreciated.
Back to top
View user's profile Send private message
podstanar
Advanced Cheater
Reputation: 4

Joined: 02 May 2012
Posts: 82
Location: Flatland

PostPosted: Fri May 04, 2012 4:07 am    Post subject: Reply with quote

Maybe i was not clear enough, actually i want to use code caves instead of allocating memory, the point is to be able to create trainer with CE(i guess static place in memory is needed for trainers, otherwise i will just stick with "alloc" function). I know how to find them(using CE's code cave finder) but i need to know how to properly use them in my scripts. For example, how can i use one cave for multiple injections?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Fri May 04, 2012 6:23 am    Post subject: Reply with quote

don't use code caves, just use alloc. CE trainers work perfectly fine with memory allocations
_________________
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
igor
Expert Cheater
Reputation: 1

Joined: 04 Apr 2012
Posts: 145

PostPosted: Fri May 04, 2012 9:09 am    Post subject: Reply with quote

The Beginners Guide to Codecaves
http://www.codeproject.com/Articles/20240/The-Beginners-Guide-to-Codecaves
Back to top
View user's profile Send private message
podstanar
Advanced Cheater
Reputation: 4

Joined: 02 May 2012
Posts: 82
Location: Flatland

PostPosted: Sat May 05, 2012 6:51 am    Post subject: Reply with quote

Thanks. On my second question, does anybody know how can i implement the code i posted above in only one cave? Instead of injecting at two places in memory can it be done on only one?
Back to top
View user's profile Send private message
igor
Expert Cheater
Reputation: 1

Joined: 04 Apr 2012
Posts: 145

PostPosted: Sat May 05, 2012 8:35 am    Post subject: Reply with quote

416c6558 wrote:
Thanks. On my second question, does anybody know how can i implement the code i posted above in only one cave? Instead of injecting at two places in memory can it be done on only one?

No you can't use in one cave. You have to use seperate addresses.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sat May 05, 2012 9:07 am    Post subject: Reply with quote

as for your original code that you posted, that will not work, and code caves are not going to help you

First part:
Code:

01004DC0:
jmp code_moves
db 90
return_moves:

code_moves:
db C7 86 50 03 00 00 00 00 00 00

jmp return_moves

It looks like you are overwriting a 10 byte instruction and then jump back 6 bytes after the instruction, so executing 00 00 00 : which is add [eax],al

change the script to:
Code:

01004DC0:
jmp code_moves
nop
nop
nop
nop
nop
return_moves:

code_moves:
mov [esi+00000350],00000000

jmp return_moves


As for score:
Code:

010035D1:
jmp code_score
db 90
return_score:

code_score:
db 89 08 C7 00 F4 01 00 00 3B 0A 0F 8E C9 33 31 00

jmp return_score

here 3 things are wrong.
1: The number of nops, you're jumping into random code again

2: You only need to replace 2 instructions, not 4

3: 0F 8E C9 33 31 00 : Is "jng xxxxxxxx" , which is a relative instruction based on the current eip. The location of "jng xxxxxxxx" determines the bytes of that instruction
Also, this instruction is beyond the minimum number of instructions to replace, so you don't even need to do this

the correct script would be:
Code:

010035D1:
jmp code_score
nop
nop
nop
return_score:

code_score:
mov [eax],ecx
mov [eax],000001F4

jmp return_score



Tip: Use the template->code injection menu option in the auto assembler to write a functional code injection for you, it fills in the correct number of nops

_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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