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 


Auto assembly disable self
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
hdf13
Advanced Cheater
Reputation: 1

Joined: 18 Sep 2013
Posts: 75

PostPosted: Sat Aug 23, 2014 6:16 am    Post subject: Auto assembly disable self Reply with quote

I'm not sure if this is the right forum section to ask this, but is it possible for an option/auto assembly, to run only once, and than disable itself? So each time it is activated, nothing happens, until the replaced code segment is run by the game, than once it was, the cheat disables itself.

Edit:
Solution can be found here: http://forum.cheatengine.org/viewtopic.php?p=5549105#5549105


Last edited by hdf13 on Fri Aug 29, 2014 8:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sat Aug 23, 2014 7:45 am    Post subject: Re: Auto assembly disable self Reply with quote

hdf13 wrote:
I'm not sure if this is the right forum section to ask this, but is it possible for an option/auto assembly, to run only once, and than disable itself? So each time it is activated, nothing happens, until the replaced code segment is run by the game, than once it was, the cheat disables itself.

example
Code:

...
alloc(flag, 4)
flag:
db 00
...
script:
...
push ecx
mov ecx,[flag]
cmp ecx,1
pop ecx
je exit
mov [flag], 1
...

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
hdf13
Advanced Cheater
Reputation: 1

Joined: 18 Sep 2013
Posts: 75

PostPosted: Sat Aug 23, 2014 8:28 am    Post subject: Reply with quote

That is not good, as it does not put the original code back in place, it does not free up the allocated memory, and it does not uncheck the box by the script in the table.
Back to top
View user's profile Send private message
omoe
Grandmaster Cheater
Reputation: 8

Joined: 11 Jun 2013
Posts: 547

PostPosted: Thu Aug 28, 2014 3:42 pm    Post subject: Reply with quote

Use lua ,
memoryrecord_freeze(memoryrecord) to activate
memoryrecord_unfreeze(memoryrecord) to deactivate

_________________
Hey! , Rep++ .
Back to top
View user's profile Send private message
hdf13
Advanced Cheater
Reputation: 1

Joined: 18 Sep 2013
Posts: 75

PostPosted: Thu Aug 28, 2014 5:57 pm    Post subject: Reply with quote

@omoe:

Your solution has actually nothing to do with my problem.
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Thu Aug 28, 2014 6:19 pm    Post subject: Reply with quote

Some time ago, Dark Byte has made an AA template for a script that will revert to the original code after one execution.

http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles/417-restore-code

However this will not uncheck the activation box by itself.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
hdf13
Advanced Cheater
Reputation: 1

Joined: 18 Sep 2013
Posts: 75

PostPosted: Fri Aug 29, 2014 5:20 am    Post subject: Reply with quote

@Geri:

Would readmem() not be a better method in this case? But still, it is pretty important, that the script gets properly deactivated. The idea is, to be able to make options, that you activate with a hotkey, and they run only once, but than you can reactivate them again. So like to set a specific value to something, add to a value, or to run an ingame function.

I guess, there is no way to do this now than, so this is a feature request.
Need a function, that runs in auto assembly, and when run, deactivates the option, as if the X in the table was clicked. I don't think LUA would work, as that only works as a preprocessor.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Aug 29, 2014 5:33 am    Post subject: Reply with quote

What about a script that instantly deactivates itself after being activated ? (before the code has been executed)

e.g in the enable section start a timer with an interval of 1 millisecond that disables the script. And let the script have an empty [disable] section. Then let your own script restore the bytes


alternatively, look at template->call ce lua function.
Then from inside your code injection call a lua script that disables the specific cheat entry in cheat engine

_________________
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
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri Aug 29, 2014 6:12 am    Post subject: Reply with quote

hdf13 wrote:
@Geri:

Would readmem() not be a better method in this case? But still, it is pretty important, that the script gets properly deactivated. The idea is, to be able to make options, that you activate with a hotkey, and they run only once, but than you can reactivate them again. So like to set a specific value to something, add to a value, or to run an ingame function.


Readmem is not enough, because you have to make lots of changes in the template to use it for your own code. Not every code has the same length etc.

You can reactivate them again. If you scroll at the bottom of the article, you will see an example for it.

Quote:
The script above is having a little problem, it is not doing anything when you disable the code, so users would actually hit the hotkey twice to enable the cheat after every use. To solve that, here is another example:

Code:
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
globalalloc(mycode,512)
globalalloc(originalcode,6)
label(returnhere)
originalcode:
db 29 83 58 04 00 00

fullaccess(00420F3E,6) //make read/write/execute
00420F3E:
jmp mycode
nop
returnhere:

mycode:
mov [ebx+0458],(int)999

//restore with original bytes
pushad //can't be bothered
pushfd
cld
mov ecx,6  //nr of bytes
mov esi, originalcode
mov edi, 00420F3E
rep movsb
popfd
popad


jmp returnhere
 
 
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
globalalloc(mycode,512)                   //I have changed the alloc to globalalloc so it is allocated only once, not all the time when you run the script
globalalloc(originalcode,6)
label(returnhere)
originalcode:
db 29 83 58 04 00 00

fullaccess(00420F3E,6) //make read/write/execute
00420F3E:
jmp mycode
nop
returnhere:

mycode:
mov [ebx+0458],(int)999

//restore with original bytes
pushad //can't be bothered
pushfd
cld
mov ecx,6  //nr of bytes
mov esi, originalcode
mov edi, 00420F3E
rep movsb
popfd
popad


jmp returnhere


This way, the script will be executed once, whenever you enable or disable the cheat. In order to avoid allocating memory over and over again, I have used globalalloc instead of alloc.

Quote:
GLOBALALLOC(name,size) : Will allocate a certain amount of memory and registers the specified name. Using GlobalAlloc in other scripts will then not allocate the memory again, but reuse the already existing memory. (Or allocate it anyhow if found it was not allocated yet)


I think that this is about the most similar result compared to what you are looking for without using lua. The memory will not be deallocated, but at least not allocated again and again. The checkbox will not be unchecked automatically, but whenever it is switched into either on or off state, it will enable the script for one use.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
hdf13
Advanced Cheater
Reputation: 1

Joined: 18 Sep 2013
Posts: 75

PostPosted: Fri Aug 29, 2014 7:00 am    Post subject: Reply with quote

Dark Byte wrote:
What about a script that instantly deactivates itself after being activated ? (before the code has been executed)

e.g in the enable section start a timer with an interval of 1 millisecond that disables the script. And let the script have an empty [disable] section. Then let your own script restore the bytes


alternatively, look at template->call ce lua function.
Then from inside your code injection call a lua script that disables the specific cheat entry in cheat engine


This solution sounds interesting, but what about unregistersymbol and dealloc if there is no disable section?
Also, can you give an example, for how to disable a cheat entry with lua from auto assembly? I can't see any such function in the lua docs for CE.

@Geri:
The unregistersymbol problem persists with your approach as well.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Aug 29, 2014 7:11 am    Post subject: Reply with quote

there is NO way to free the memory from inside your code (if it's gone your code will end up executing non existent code and thus crash)

But if you use globalalloc instead of alloc all future allocations will make use of that one block of memory, preventing memory leaks

And there is really no need to unregister symbols. Unregistering symbols just means that ce will error out when a specific symbol is looked up instead of giving the last known address of that symbol (Also, since your injected code would destroy itself there'd be no need to even bother registering symbols)

--

one other method you could do is in [enable] launch a timer with a function that disables the entry IF a specific address has been given a value, and also let your own script check if that address if set, and if not, run the code once and set it else skip, and in the [disable] have code that cleans up everything as usual

_________________
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


Last edited by Dark Byte on Fri Aug 29, 2014 7:17 am; edited 2 times in total
Back to top
View user's profile Send private message MSN Messenger
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri Aug 29, 2014 7:16 am    Post subject: Reply with quote

hdf13 wrote:

@Geri:
The unregistersymbol problem persists with your approach as well.


Yes, you can't use unregistersymbol. But if the problem is registering a symbol over and over again, you can use globalalloc instead of registersymbol. Globalalloc is allocating memory and registering it for global use (even outside of the script) and it will be done only once.

Other than that, yes. I said this solution is just similar to what you are looking for, but not exactly what you wish to achieve.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
hdf13
Advanced Cheater
Reputation: 1

Joined: 18 Sep 2013
Posts: 75

PostPosted: Fri Aug 29, 2014 7:32 am    Post subject: Reply with quote

Ok, so I can use globalalloc to store variables persistently (like value addresses), so no need for registersymbol, I now know, how the code can put original values back, once it is run, all that remains is to instantly disable itself, but I have no idea, how to do that with lua calls, or how to do that timer bit. Can you give an example for those?
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5636

PostPosted: Fri Aug 29, 2014 5:17 pm    Post subject: Reply with quote

There is no AA command for this, so it can be done only in lua as DB said. But I have never tried this, so ask him about it.
_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Fri Aug 29, 2014 5:48 pm    Post subject: Reply with quote

You must use additional coding (LUA or other) to force the script to disable itself after each run. You can not use assembly inside of that script to achieve this.

The only purpose I can see with wanting to do this is to remain undetected against periodic memory checks. If you have another reason, I would be interested in knowing what that reason is.
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
Goto page 1, 2  Next
Page 1 of 2

 
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