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 


Clearing All Userdefined Symbols
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Fri Mar 04, 2016 1:25 pm    Post subject: Clearing All Userdefined Symbols Reply with quote

Reason:
For instance if I defined symbols (JumpHack) & (No_Damage). If I fail to unregister (No_Damage) & reActivate the JumpHack Script. CE will use the registered memory location of (JumpHack). This doesnt Always happen but it happens from time to time. Especially when I crash the game.


Just wondering if there is a way to Unregister all symbols with a simple LUA action.

_________________
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Mar 06, 2016 3:19 pm    Post subject: Reply with quote

Not entirely sure that I follow. However...

In memory viewer, select view from the drop-down menu. Click on Userdefined symbols. From here, you can delete them all, or, a single entry at a time.

Alternatively:

Ctrl+M, Ctrl+U, right-click delete/delete all

Writing a simple LUA script to do that for you should be easy, but someone else will have to chime in for that. Perhaps, having an option under settings to automatically remove any remaining, user-defined symbols upon attachment of target process would be a good idea.
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Sun Mar 06, 2016 3:51 pm    Post subject: Reply with quote

++METHOS wrote:
Perhaps, having an option under settings to automatically remove any remaining, user-defined symbols upon attachment of target process would be a good idea.


Yep thats basically what I am looking for. Just want to clear all symbols with one click. I admit I have a real hard time with LUA sometimes to many redundancies. If thr was a way to simply grab all the registered symbols with LUA the rest would be easy. Unfortunately I have had no luck.

_________________
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Mar 06, 2016 4:14 pm    Post subject: Reply with quote

Writing an LUA script to perform this task should be easy for the LUA experts on this forum. All you would have to do is drop it in to your autorun folder, and it could run in the background, every time you started CE.

Last edited by ++METHOS on Mon Mar 07, 2016 4:42 pm; edited 1 time in total
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Mar 07, 2016 11:24 am    Post subject: Re: Clearing All Userdefined Symbols Reply with quote

akumakuja28 wrote:
Reason:
For instance if I defined symbols (JumpHack) & (No_Damage). If I fail to unregister (No_Damage) & reActivate the JumpHack Script. CE will use the registered memory location of (JumpHack). This doesnt Always happen but it happens from time to time. Especially when I crash the game.


Just wondering if there is a way to Unregister all symbols with a simple LUA action.

I'm not sure what exactly you want to achieve. Maybe you don't need "unregister all symbols" at all.

Do you have two scripts, first one "jump" and the second one "nodamage" (fall protect?).

_________________
Back to top
View user's profile Send private message MSN Messenger
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4291

PostPosted: Mon Mar 07, 2016 2:40 pm    Post subject: Reply with quote

I don't think there's any easy way of unregistering all userdefined symbols.

If you have two scripts, then try to keep the symbols separate from each other. If one script is dependent on another one being active, then add it as a child of the script that needs to be active, right click on the main one, and select "Group config -> Hide children when deactivated".

If you're talking about the prompt you get when you reattach CE to another process while a script is still active asking you if you want to disable the scripts without executing the [DISABLE] section, then of course it's not going to unregister the symbol since you're not telling it to. I'm not entirely sure in what order CE executes an AA script, but maybe Lua code is run before it looks up the symbols. If that's the case, unregister it by using unregisterSymbol(symbolname) in a luacall or {$lua} section in [ENABLE]. If that fails, you should be able to use the function registerSymbolLookupCallback(function(string):integer, location): ID to make it safe.

Posting all applicable scripts would be helpful.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Mon Mar 07, 2016 4:01 pm    Post subject: Reply with quote

I've made it:
put the lua file in the autorun folder in cheat engine dir.
it adds a button just below speedhack that unregisters all the registered symbols.
KNOWN ISSUES:
when you click execute on the AA window, then click cancel, it still counts the symbols as registered, not a big issue, I could fix it if needed.
[important] does not remove the registered symbols from the list when you unregister them in script, I'll fix it soon.
FEATURE
supports block comments, for example:
Code:
alloc(m,1024)
{
this is a block comment
registersymbol(m)
}
label(x)
m+43:
x:
dd 13
registersymbol(x)

only x will be added to the registered symbols list.
please give your opinions.



clear_symbols_button.lua
 Description:

Download
 Filename:  clear_symbols_button.lua
 Filesize:  753 Bytes
 Downloaded:  587 Time(s)

Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Mon Mar 07, 2016 4:25 pm    Post subject: Reply with quote

Yeah This Awesome. Thank You.

And my apologizes for the confusion about the intial post it was only a Reason for the request. I always find some strange bug when i am hacking into a game.

Thanks Redouane. Do you care if I edit and reuse your contribution?

_________________
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Mon Mar 07, 2016 4:31 pm    Post subject: This post has 1 review(s) Reply with quote

akumakuja28 wrote:
Yeah This Awesome. Thank You.

And my apologizes for the confusion about the intial post it was only a Reason for the request. I always find some strange bug when i am hacking into a game.

Thanks Redouane. Do you care if I edit and reuse your contribution?


You're welcome.

Of course, feel free to edit, I've fixed the previous issues, and here is the updated version.



clear_symbols_button.lua
 Description:
adds a button below the speedhack that unregisters all the userdefined symbols

Download
 Filename:  clear_symbols_button.lua
 Filesize:  1.29 KB
 Downloaded:  594 Time(s)

Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 55

Joined: 01 Oct 2008
Posts: 942

PostPosted: Mon Mar 07, 2016 4:59 pm    Post subject: Reply with quote

Redouane wrote:

...
please give your opinions.


Nice!
The script may need to identify which lines is in Lua block ({$lua}) or aa block (initial and {$asm}), 'registersymbol' is also a lua function may appear in Lua block and unbalanced {} inside Lua block may confuse those that on AA block.

In ce 6.5, the Prologue function has a second parameter of postaob, if set to true, the AA script is comment remove and Lua expanded by ce before sending to the Prologue Lua script ie. Pure AA Script without comment.
So should be a lot easy to identify the AA registersymbol line. But then it cannot work with ce 6.4 with same correctness.

bye~

_________________
- Retarded.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Mon Mar 07, 2016 7:47 pm    Post subject: Reply with quote

Good work, Redouane! I'm curious about why you chose not to have the script utilize CE's delete user-defined symbols feature?

Thanks.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4291

PostPosted: Tue Mar 08, 2016 1:45 am    Post subject: Reply with quote

++METHOS - I'm not sure if there are any besides unregisterSymbol(name). I tried searching through main.lua but couldn't find anything that would give any reference to all registered symbols.

Redouane - Your script also doesn't take into account symbols registered manually and symbols registered via a Lua script w/ either registerSymbol(...) or SymbolList.register(). This also won't work if there's anything before the AA call to registersymbol(...) (i.e. spaces), nor will it work if anyone capitalizes any letter in registersymbol (e.g. registerSymbol(...) is perfectly valid).
Redouane wrote:
[important] does not remove the registered symbols from the list when you unregister them in script, I'll fix it soon.
Not that important. If you call unregistersymbol(...) and pass it some argument that's not actually a registered symbol, it doesn't generate an error or anything, it just returns.

Besides, if you're really worried about something like this, you should've had much bigger concerns than that. Check to see just how many times that function you pass to registerAutoAssemblerPrologue is called. It's not that bad now since you remove it if you find "unregistersymbol", but still, it's something you should be aware of.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Tue Mar 08, 2016 3:06 am    Post subject: Reply with quote

Hmm. I wish I knew LUA, but I don't. So something like this can't be done with LUA(?):

++METHOS wrote:
In memory viewer, select view from the drop-down menu. Click on Userdefined symbols. From here, you can delete them all, or, a single entry at a time.


Thanks.
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Tue Mar 08, 2016 4:20 am    Post subject: Reply with quote

panraven wrote:

The script may need to identify which lines is in Lua block ({$lua}) or aa block (initial and {$asm}), 'registersymbol' is also a lua function may appear in Lua block and unbalanced {} inside Lua block may confuse those that on AA block.


ah forgot about them, should be easy to deal with, I'll just hook registerSymbol/unregisterSymbol like this:
Code:

do
local f,g = registerSymbol,unregisterSymbol;
registerSymbol = function(sym,addr,opt)
-- add userdefinedsymbol
return f(sym,addr,opt);
end
unregisterSymbol = function(sym)
-- remove userdefinedsymbol
return g(sym);
end
RegisterSymbol,UnregisterSymbol = registerSymbol,unregisterSymbol;
end

it'll also deal with registerSymbol inside luacall, calls to registerSymbol inside loadstring etc.
Quote:

In ce 6.5, the Prologue function has a second parameter of postaob, if set to true, the AA script is comment remove and Lua expanded by ce before sending to the Prologue Lua script ie. Pure AA Script without comment.
So should be a lot easy to identify the AA registersymbol line. But then it cannot work with ce 6.4 with same correctness.


Very useful, because when parsing comments, there are many tricky cases, examples:
Code:

{comment} // one line multiline comment
//{comment // multiline comment inside on-line one
{comment}{comment} // two multiline comments in one line
db 'this is a string{',0 // { inside a string, no comments at all


parkourpenguin wrote:

Your script also doesn't take into account symbols registered manually


It's quite uncommon, I've never found it necessary to register a symbol manually.
Not sure if it's possible to do it.

parkourpenguin wrote:

and symbols registered via a Lua script w/ either registerSymbol(...) or SymbolList.register(). This also won't work if there's anything before the AA call to registersymbol(...) (i.e. spaces), nor will it work if anyone capitalizes any letter in registersymbol (e.g. registerSymbol(...) is perfectly valid).


All fixed now, except the SymbolList methods, can you please explain how they work?
(It's probably possible to edit the methods in the metatable of the SymbolList objects)

Should only work on CE 6.5



clear_symbols_button.lua
 Description:

Download
 Filename:  clear_symbols_button.lua
 Filesize:  1.77 KB
 Downloaded:  555 Time(s)

Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4291

PostPosted: Tue Mar 08, 2016 11:38 am    Post subject: Reply with quote

The documentation in main.lua explains it well enough. When you call register(), it basically just takes every symbol in the list and registers it. I've never used it nor have I ever seen anyone else use it, so it's probably a pretty rare thing.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
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 Lua Scripting 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