Hi

I have a structure with many members and i was wandering if is there a way to initialise only some of its members (of course other than at run time). Something like:

TEST STRUCT

member1 dd ?
member2 dd ?
member3 dd ?
...
member100 dd ?
TEST ENDS

my_struct TEST < member2=4,member3=5>


Thanks

Eugen
Posted on 2003-10-12 23:15:38 by Eugen
Eugen,

You can do it in the .DATA section.


my_struct TEST < 0,1,2,3,4,5,6,7,8,9> etc ....


Partial member settings are probably best done at run time and you save the space in the .DATA section so you are not losing much by doing it.

Regards,
http://www.asmcommunity.net/board/cryptmail.php?tauntspiders=in.your.face@nomail.for.you&id=2f46ed9f24413347f14439b64bdc03fd
Posted on 2003-10-13 00:19:55 by hutch--
Eugen, the data values can be left out, but the commas must be included up to the greatest initialized item:
TEST STRUCT

member1 dd ?
member2 dd ?
member3 dd ?
...
member100 dd ?
TEST ENDS

my_struct TEST <,4,5>
It is not helpful for very long structures, but there is the line length limit to concern ourselves with before initializing very large structures.

Additionally, if the instances of the structure fall within certain classes then this might be an option:
TheStruct STRUCT

item1 DWORD 0
item2 DWORD 0
item3 DWORD 0
TheStruct ends


ts_Class1 STRUCT
TheStruct <,,1>
ts_Class1 ends

ts_Class2 STRUCT
TheStruct <,,2>
ts_Class2 ends

ts_Class3 STRUCT
TheStruct <,,3>
ts_Class3 ends


ts11 ts_Class1 < <1> >
ts12 ts_Class1 < <2> >
ts13 ts_Class1 < <3> >

ts21 ts_Class1 < <1> >
ts22 ts_Class1 < <2> >
ts23 ts_Class1 < <3> >

ts31 ts_Class1 < <1> >
ts32 ts_Class1 < <2> >
ts33 ts_Class1 < <3> >


mov eax,ts11.item1
...works as expected! :cool:
Posted on 2003-10-13 01:30:57 by bitRAKE
You can also just do this:

TEST STRUCT

member1 dd 8
member2 dd ?
member3 dd 9
...
member100 dd 157
TEST ENDS

my_struct TEST <>
Posted on 2003-10-13 01:47:14 by donkey