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 


New to scripting with aobscan need help

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

Joined: 22 Dec 2013
Posts: 8

PostPosted: Wed Jan 01, 2014 1:23 am    Post subject: New to scripting with aobscan need help Reply with quote

Hi, I am trying to write my first script and need some help, I have found 2 multilevel pointers in a game and want to make them into aobscan scripts.

I have found how to do that but I can’t seem to get it to work because I probably have it set up wrong.

What I want is when I check the box in the script for it to find the array and freeze or don’t use the mana and gold but I’m not sure what command to give it to do that.

The mana line is CraftWorld.exe+E1884 - F3 0F11 46 1C - movss [esi+1C],xmm0

The gold line is CraftWorld.exe+57A83 - 01 5F 4C - add [edi+4C],ebx

My array for mana is F3 0F 11 46 1C 76 05 F3 0F 11 4E 1C 0F 57 C0 0F 2F 46 1C

I still need to find the array for gold but I can add it later.

So what command would I put in the newmem area for each to freeze it or to not use it?
Back to top
View user's profile Send private message
UnIoN
Expert Cheater
Reputation: 2

Joined: 17 May 2011
Posts: 146

PostPosted: Wed Jan 01, 2014 1:59 am    Post subject: Reply with quote

thats not lua but auto assemble (asm)?

for gold aob, click on disassembler and read bytes near opcode?

you know that you can do a aob scan in ce to verify that he finds your aob first (or only) ?

btw. the gold line is for "add"... if you want to stop decreasing when bying you need othere line with "dec"...
Back to top
View user's profile Send private message
Bartimaeus
How do I cheat?
Reputation: 0

Joined: 22 Dec 2013
Posts: 8

PostPosted: Wed Jan 01, 2014 10:51 am    Post subject: Reply with quote

OK I think I have it so far.
Thanks goes to UnIoN, Rydian, and Geri for their help and Tutorials.

This is my script,
Code:

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)
label(gold)
registersymbol(gold)
aobscan(aob1,01 5F 4C 8B 47 4C B9 ?? ?? ?? ?? 3B C1 0F 4F C1)

newmem: //this is allocated memory, you have read,write,execute access
sub [edi+4C],ebx //place your code here

originalcode:
add [edi+4C],ebx
mov eax,[edi+4C]

exit:
jmp returnhere

aob1:
gold:
jmp newmem
nop
returnhere:


 
 
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
gold:
db 01 5F 4C 8B 47 4C
unregistersymbol(gold)
add [edi+4C],ebx
mov eax,[edi+4C]
//Alt: db 01 5F 4C 8B 47 4C


And it seems to work just fine but I would like to ask for more help, right now the gold is just not spent I would like to be able to start a new game at 0 gold and be able to buy anything so I think I need a way to make the gold go up when I use it or for things in store to cost 0.

I also need to know what code to use on the mana it is, movss [esi+1C],xmm0 to make it not spend like the gold does now.

Thanks for the help,
Bartimaeus
Back to top
View user's profile Send private message
UnIoN
Expert Cheater
Reputation: 2

Joined: 17 May 2011
Posts: 146

PostPosted: Wed Jan 01, 2014 12:10 pm    Post subject: Reply with quote

in asm you have two options
1. set gold every time to a choosen value
2. compare with value 0 and set than to a choosen value only if 0
Code:
option 1:
mov [edi+4C],(int)9999

option 2:
cmp [edi+4C],00
jg abovezero
mov [edi+4C],(int)1000
jmp exit

abovezero:
add [edi+4C],ebx
mov eax,[edi+4C]


for mana you can change xmm0 before it moves to esi+1C or you can move directly to esi+1C

to store something to xmm0 you need first a register
Code:
push eax  //save to prevent crash
mov [eax],(float)100 // if its a float value
movss xmm0,[eax]
pop eax //restore to prevent crash
Back to top
View user's profile Send private message
Bartimaeus
How do I cheat?
Reputation: 0

Joined: 22 Dec 2013
Posts: 8

PostPosted: Wed Jan 01, 2014 2:50 pm    Post subject: Reply with quote

I tried,
Code:

push eax  //save to prevent crash
mov [eax],(float)100 // if its a float value
movss xmm0,[eax]
pop eax //restore to prevent crash


and

Code:

mov [esi+1C],(float)100


for the mana both crashed the game. Any suggestions?

The gold script works great Smile

Thanks,
Bartimaeus
Back to top
View user's profile Send private message
UnIoN
Expert Cheater
Reputation: 2

Joined: 17 May 2011
Posts: 146

PostPosted: Wed Jan 01, 2014 2:59 pm    Post subject: Reply with quote

please provide more lines from mana (above and under)
Back to top
View user's profile Send private message
Bartimaeus
How do I cheat?
Reputation: 0

Joined: 22 Dec 2013
Posts: 8

PostPosted: Wed Jan 01, 2014 3:18 pm    Post subject: Reply with quote

Here,
Code:

CraftWorld.exe+E1875 - movd xmm0,eax
CraftWorld.exe+E1879 - cvtdq2ps xmm0,xmm0
CraftWorld.exe+E187C - addss xmm0,[esi+1C]
CraftWorld.exe+E1881 - comiss xmm0,xmm1
CraftWorld.exe+E1884 - movss [esi+1C],xmm0  // where my pointer is
CraftWorld.exe+E1889 - jna CraftWorld.exe+E1890  //<---- these have a line linking them
CraftWorld.exe+E188B - movss [esi+1C],xmm1       //    |
CraftWorld.exe+E1890 - xorps xmm0,xmm0           //<----


Thanks again for your help Smile
Bartimaeus
Back to top
View user's profile Send private message
UnIoN
Expert Cheater
Reputation: 2

Joined: 17 May 2011
Posts: 146

PostPosted: Wed Jan 01, 2014 5:56 pm    Post subject: Reply with quote

so this opcodes are operating when you loose some mana?

then (assuming xmm0 holds you reduced mana, and xmm1 holds you max mana):
Code:
[ENABLE]
CraftWorld.exe+E1884:
movss [esi+1C],xmm1
[DISABLE]
CraftWorld.exe+E1884:
movss [esi+1C],xmm0
Back to top
View user's profile Send private message
Bartimaeus
How do I cheat?
Reputation: 0

Joined: 22 Dec 2013
Posts: 8

PostPosted: Wed Jan 01, 2014 6:15 pm    Post subject: Reply with quote

So this is my script,
Code:

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)
label(mana)
registersymbol(mana)
aobscan(aob2,F3 0F 11 46 1C 76 05 F3 0F 11 4E 1C 0F 57 C0 0F 2F 46 1C)

newmem: //this is allocated memory, you have read,write,execute access
movss [esi+1C],xmm1

originalcode:
movss [esi+1C],xmm0

exit:
jmp returnhere

aob2:
mana:
jmp newmem
nop
returnhere:




[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
mana:
db F3 0F 11 46 1C
unregistersymbol(mana)
movss [esi+1C],xmm0


and this is the crash dump I get,
h t t p ://s12.postimg.org/rj3a51dhp/crashdump.png
sorry can't post images from url's yet

I get a crash dump like that on all 3 tries.
Back to top
View user's profile Send private message
UnIoN
Expert Cheater
Reputation: 2

Joined: 17 May 2011
Posts: 146

PostPosted: Thu Jan 02, 2014 3:34 am    Post subject: Reply with quote

you are doing a lot wrong


1. at your injection line, you have still a nop command, the array of bytes for movss [esi+1C],xmm0 should be 5 bytes long, your code injection jmp newmem, nop is 6 bytes long and is destroying the gamecode, that is causing your crash.

2. asm executes your code 1 command per line so when you write
Code:
newmem:
movss [esi+1C],xmm1

originalcode:
movss [esi+1C],xmm0
both lines will be performed every time. to prevent this, you need jmp/comparing with jne/je/jng/jnl etc for example
Code:
newmem:
movss [esi+1C],xmm1
jmp exit

originalcode:
movss [esi+1C],xmm0

exit:
jmp returnhere
Back to top
View user's profile Send private message
Bartimaeus
How do I cheat?
Reputation: 0

Joined: 22 Dec 2013
Posts: 8

PostPosted: Thu Jan 02, 2014 7:54 pm    Post subject: Reply with quote

Thank you UnIoN for all your help Smile I have learned a lot from you. Here are the 2 finished scripts if you want to see them.
Code:

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)
label(items)
registersymbol(items)
aobscan(aob1,01 5F 4C 8B 47 4C B9 ?? ?? ?? ?? 3B C1 0F 4F C1)

newmem: //this is allocated memory, you have read,write,execute access
mov [edi+4C],(int)999 //place your code here

originalcode:
add [edi+4C],ebx
mov eax,[edi+4C]

exit:
jmp returnhere

aob1:
items:
jmp newmem
nop
returnhere:


 
 
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
items:
db 01 5F 4C 8B 47 4C
unregistersymbol(items)
add [edi+4C],ebx
mov eax,[edi+4C]
//Alt: db 01 5F 4C 8B 47 4C

Code:

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(exit)
label(mana)
registersymbol(mana)
aobscan(aob2,F3 0F 11 46 1C 76 05 F3 0F 11 4E 1C 0F 57 C0 0F 2F 46 1C)

newmem: //this is allocated memory, you have read,write,execute access
movss [esi+1C],xmm1
jmp exit

originalcode:
movss [esi+1C],xmm0

exit:
jmp returnhere

aob2:
mana:
jmp newmem
returnhere:




[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)
mana:
db F3 0F 11 46 1C
unregistersymbol(mana)
movss [esi+1C],xmm0

I just have a couple more questions, you said
Quote:
the array of bytes for movss [esi+1C],xmm0 should be 5 bytes long
I thought while learning how to do AOB's that you want it a few lines past your point to be able to find it easier when new versions come out? Should I change my code's AOB's to just the line I'm using?

And how did you know the nop was 6 bytes long?

On a side note the new gold code I changed to items it seems that every item in game draws from [edi+4C] so when I put my code in anything I pick up becomes 999 of that item Smile
Back to top
View user's profile Send private message
UnIoN
Expert Cheater
Reputation: 2

Joined: 17 May 2011
Posts: 146

PostPosted: Fri Jan 03, 2014 3:36 am    Post subject: Reply with quote

1. your aob is good, aob stands for "array of bytes" (opcodes written in bytes). with this you can search for a pattern that is (hopefully) everytime the game reloads the same.
aob can help to make your table work for future releases, but you dont know it, it can be for example that the offset from [esi+1C] will change to [esi+1A]. you dont know it.
the main reason why aob exists, is that some games are creating their code dynamically at runtime. for example when it loads a new level. so that your code that you wanna manipulate will always be at a different address. aob scans for your pattern and finds the new address.

the counterpart, you dont know when the game loads new array of bytes that will slightly be the same as your pattern and that can break your code.
other counterpart is, on some games (big library files) it can take up to 10 seconds when you click on activate on the table until it takes effect



2. just my experience while dealing with opcodes, movss and the SSE registers (xmm0...). if you create a code injection (jmp newmem) it normally needs 5 bytes. but i still am learning too, i am not a ASM developer. if yes i would give you more detailed information why that statement is X's bytes long



3. you will find out, a lot games are using the same code to do different things. the hard part will come, if you need to manipulate this only if you want, for example, when the code will be used for your health, enemys health, health displaying, movements etc... all at the same time...

the worst case i have encountered until now is with games created with "RPG Mager". almost all game logic is using the same code
Back to top
View user's profile Send private message
Bartimaeus
How do I cheat?
Reputation: 0

Joined: 22 Dec 2013
Posts: 8

PostPosted: Fri Jan 03, 2014 8:31 am    Post subject: Reply with quote

Thanks UnIoN you have been a great help.
Back to top
View user's profile Send private message
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 893

PostPosted: Fri Jan 03, 2014 7:39 pm    Post subject: Reply with quote

The jump to your code-cave assembles into five bytes of machine code. You can determine how many (if any) nops you need by looking at the bits that you're overwriting with your jump. You didn't include byte-code with your snippets, and I'm not able to guess from memory, but you can look in the memory viewer at the code you're replacing and work it out... if the opcode you're injecting at is less than five bytes, then you must include the next and the next until they add up to five or more bytes. Then, if the number is greater than five you have to pad your jump with nops (which are one byte each) equal to the remainder. One of the nice features of the templates that the autoassembler provides is that it can compute the necessary number of nops and set it up for you automagically. Just select the line you want to hack, do a ctrl+a to bring up the autoassembler, then choose to add a table framework and a code injection.
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 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