Page 1 of 1

Question about globals and several lock scripts

PostPosted: Tue Jan 04, 2011 11:53 pm
by cobr_h
Suppose I have replicated a Lock() code on several MHS entries like this:
Entry #1:
Code: Select all
int timehit=0;
VOID Lock(...) {
...use/change 'timehit' here...
}


Entry #2:
Code: Select all
int timehit=0;
VOID Lock(...) {
...use/change 'timehit' here...
}


Entry #n:
Code: Select all
int timehit=0;
VOID Lock(...) {
...use/change 'timehit' here...
}


For every script, will the 'timehit' address be allocated into different memory regions? In other words, are them 'globals' only in the scope of the script, or script for entry 2 will change value of 'timehit' on all other scripts?

What I need is timehit being exclusive for every entry, so entry #2 does not change entry#1's. It seems (as I am 'redeclaring' the variable, that it is global only in the scope of the script so, what if I wanted to declare a global I wish to share with all other script lock entries?

Thank you!

Re: Question about globals and several lock scripts

PostPosted: Wed Jan 05, 2011 8:07 pm
by L. Spiro
Each script is contained within itself and there is no way to access memory from another script.
The only way to share globals across scripts is to predefine an address inside the target process and each script can access it via extern.
Of course, the address must be hardcoded.


L. Spiro