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 


Need help with Injection Script to restore original value

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

Joined: 13 Feb 2015
Posts: 48

PostPosted: Thu Mar 19, 2015 4:47 pm    Post subject: Need help with Injection Script to restore original value Reply with quote

  

Last edited by Darcon2k on Thu Mar 26, 2015 9:51 am; edited 1 time in total
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Thu Mar 19, 2015 5:05 pm    Post subject: Reply with quote

Why don't you use the available script template of cheat engine? It's far more easier and far less frail to errors than writing a script on hand ...
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Mar 19, 2015 5:05 pm    Post subject: Reply with quote

Highlight the code in Memory Viewer
Select Tools > Auto Assemble
Select Template > AOB Injection
Accept the defaults

Add the following under the code: label in the script

Code:
mov [ebp-04],0


or

Code:
mov [esi+20],0


Not sure which address you want to zero out
Back to top
View user's profile Send private message
Darcon2k
Cheater
Reputation: 0

Joined: 13 Feb 2015
Posts: 48

PostPosted: Thu Mar 19, 2015 6:01 pm    Post subject: Reply with quote

  

Last edited by Darcon2k on Thu Mar 26, 2015 9:50 am; edited 2 times in total
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Thu Mar 19, 2015 6:04 pm    Post subject: Reply with quote

Well, that's because a code injection is not really supposed to work that way ...
Back to top
View user's profile Send private message
Darcon2k
Cheater
Reputation: 0

Joined: 13 Feb 2015
Posts: 48

PostPosted: Thu Mar 19, 2015 6:14 pm    Post subject: Reply with quote

  

Last edited by Darcon2k on Thu Mar 26, 2015 9:52 am; edited 1 time in total
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Mar 19, 2015 6:51 pm    Post subject: Reply with quote

As long as nothing else is accessing that address, you can do:

Code:
code:
  //mov [esi+20],0
  //mov ecx,[esi+20]
  mov ecx,0
  test ecx,ecx
  jmp return
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Thu Mar 19, 2015 7:14 pm    Post subject: Reply with quote

Either set it up to write a predetermined value (e.g. 90000) upon disable/deactivate, or, set it up to save the value of [esi+20] upon enable/activate, and just write that value upon disable/deactivate...whichever you prefer.
Back to top
View user's profile Send private message
Darcon2k
Cheater
Reputation: 0

Joined: 13 Feb 2015
Posts: 48

PostPosted: Thu Mar 19, 2015 9:36 pm    Post subject: Reply with quote

  

Last edited by Darcon2k on Thu Mar 26, 2015 9:52 am; edited 1 time in total
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Thu Mar 19, 2015 10:34 pm    Post subject: Reply with quote

Have you checked to see if the instruction is accessing other addresses?

Anyway, you can just save the value and load it using a custom symbol as described.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Mar 19, 2015 10:54 pm    Post subject: Reply with quote

Code:
[ENABLE]
aobscan(myaob,8B 4E 20 85 C9 0F 84)
alloc(newmem,$1000)

label(code)
label(return)

alloc(save_ptr,4)
alloc(save_val,4)

newmem:
  cmp dword ptr [save_ptr],0
  jne code
  mov ecx,[esi+20]
  mov [save_val],ecx
  mov [save_ptr],esi
  add [save_ptr],20
  mov [esi+20],0

code:
  mov ecx,[esi+20]
  test ecx,ecx
  jmp return

myaob:
  jmp newmem
return:
registersymbol(myaob)
registersymbol(save_ptr)
registersymbol(save_val)

[DISABLE]
save_ptr:
  readmem(save_val,4)
myaob:
  db 8B 4E 20 85 C9
unregistersymbol(myaob)
unregistersymbol(save_ptr)
unregistersymbol(save_val)
dealloc(newmem)
dealloc(save_ptr)
dealloc(save_val)
Back to top
View user's profile Send private message
Darcon2k
Cheater
Reputation: 0

Joined: 13 Feb 2015
Posts: 48

PostPosted: Fri Mar 20, 2015 1:19 am    Post subject: Reply with quote

  

Last edited by Darcon2k on Thu Mar 26, 2015 9:51 am; edited 1 time in total
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Mar 20, 2015 12:30 pm    Post subject: This post has 1 review(s) Reply with quote

Oh, duh. That disable sets the value back inside my own variable's address. Not the address at which it was pointing.

Uhm, I think I typed this LUA correctly...

Code:
[DISABLE]
{$lua}
writeInteger(readInteger("save_ptr"), readInteger("save_val"))
{$asm}
myaob:
  db 8B 4E 20 85 C9
unregistersymbol(myaob)
unregistersymbol(save_ptr)
unregistersymbol(save_val)
dealloc(newmem)
dealloc(save_ptr)
dealloc(save_val)
Back to top
View user's profile Send private message
Darcon2k
Cheater
Reputation: 0

Joined: 13 Feb 2015
Posts: 48

PostPosted: Fri Mar 20, 2015 8:20 pm    Post subject: Reply with quote

Zanzer

Thank you so much! Everything working perfectly.
Back to top
View user's profile Send private message
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