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 


What's the scope on labels in autoassembly scripts?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 890

PostPosted: Thu Jul 08, 2010 5:23 pm    Post subject: What's the scope on labels in autoassembly scripts? Reply with quote

Stupid question, but what scope do labels have when used in the auto-assembler? Are they part of the global symbol table, meaning that no two simultaneously running scripts should have labels using the same name unless they are to be referring to the same address? If I use the templates more than once in a table, do I need to change the exit/returnhere/etc labels?

How about alloc? Do I need to make sure not to use the "newmem" default more than once?

It's silly, I know, that I've been playing with this thing for a couple of weeks now and am still clueless.

Thanks,
adude
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 371

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

PostPosted: Thu Jul 08, 2010 7:02 pm    Post subject: This post has 2 review(s) Reply with quote

labels and allocs are only valid in the script they are in. More specifically, in the [enable] [disable] (or both)

So you can safely run two scripts with the same labels
As for using the template twice in the same script, ce will deal with this for you (it adds a number after the label names)

To use a label outside the scope of the current script, you must use the "registersymbol" command so that other scripts (and the rest of ce, like tables) can understand what you mean with the specific label name

As for alloc there is a special variant for this:
GlobalAlloc(name,size)

If you use GlobalAlloc it will be registered as a symbol so it's usable by the rest of CE, AND any new call to GlobalAlloc won't allocate the memory again but just gives the already allocated block(But make sure the sizes you give in all scripts are the same, a re-alloc because the size is bigger means that some of the old data will be gone)

---
Of course, most likely you'll be fine with the normal alloc in enable and dealloc in disable, there's usually not that much need for multiple scripts to allocate the same block of memory. Only useful when some scripts need to make use of the same allocated memory, and you're not sure which one will get executed first by the user

_________________
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
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 890

PostPosted: Thu Jul 08, 2010 11:58 pm    Post subject: Reply with quote

Wow, that's awesome! I've been manually appending digits to my labels out of ignorance - a mundane task that is rather prone to error. And I never even thought to try adding a second template - I've been copying and pasting!

With regard to globalalloc, I suppose the advantage versus using a normal alloc combined with a registered symbol is in the case where you're not sure which block is going to be run first?

Man, CE is just chock full of neat stuff. Thanks for the tool and thank you for the awesome support.

Sincerely,
adude
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