Could someone explain or forward me to a tutorial explaining how structures and classes are stored in memory and also especially how arrays of those or arrays of pointers to classes (instances that is). I'm trying to find out how an array of entities (defined as struct) is stored in memory and how I could access/find all instances of the struct (nr is dynamic). I guess there is some kind of lookuptable or whatever that has a pointer to each instance ? (I know the value of one or more of the variables of one or more of the instances).
Posted on 2003-02-24 07:53:09 by SFP
There is no classes in asm, expect for those that are being created now

Read the following on structs
Posted on 2003-02-24 08:14:18 by roticv
Thanks that helped me alot =)

One thing though. Take for instance a game, lets say you have a structure for ie objects, logically you have an array of objects you create to access them (some dynamic array) this I guess would be in asm pointers -> instance of struct (which the thread explained is just bytes). I'm still a bit weary on how to locate the calling/accessing array and also how to exactly FIND the structures in memory (which would be easy if I found the array which pointed to the instances, if i've understod/thought this out correct)
Posted on 2003-02-24 09:02:53 by SFP
Oh i almost forgott, the code for this is in a VM (Virtual Machine) not in the gameexecutable, but should still be in same memoryspace I guess.
Posted on 2003-02-24 09:37:34 by SFP
What do you mean by finding arrary in memory? I think you have a misconception with regards to structs. Whenever you pass to pass the arrary, you pass the pointer to the arrary. Arrarys are just a collection of data
Posted on 2003-02-25 06:55:44 by roticv
Nono, but for EACH player in the game there is an instance of the structure (each player has it's entitystructure which holds information such as playername etc) but to access each individual players structure you would have a table/array that points to each structure so that you could loop through each player ie for ( int i = 0; i < 10; i++ ) = "whatever"; you see?
Posted on 2003-02-25 08:04:39 by SFP
You mean this?

mystruct1 MYSTRUCT <?>
mystruct2 MYSTRUCT <?>
mystruct3 MYSTRUCT <?>
mystruct4 MYSTRUCT <?>
mystruct5 MYSTRUCT <?>
mystruct6 MYSTRUCT <?>
mystruct7 MYSTRUCT <?>
mystruct8 MYSTRUCT <?>
mystruct9 MYSTRUCT <?>
mystruct10 MYSTRUCT <?>

name db "whateva",0

mov ecx, 10
lea eax, name
mov edx, ecx
shr ecx,4 ;take sizeof mystruct be 2^4
add edx, OFFSET mystruct1
mov dword ptr[edx+4], OFFSET name
dec ecx
jnz loop

Sorry I can't say that I am a good teacher:grin:
Posted on 2003-02-25 11:12:02 by roticv