i need a bit of help in creating a structure for this format:


Header:

Type/Size Description
-------------------------------------------------------------------------
4 "Buzz"
dword number of sections
12*31 up to 31 section dir entries

=========================================
Section dir entry:

Type/Size Description
-------------------------------------------------------------------------
4 four-char name of section
dword offset from begin of file
dword size in bytes


i use now something like this:


BuzzSection struct
s_name dword ?
s_offset dword ?
s_size dword ?
BuzzSection ends

BuzzHeader struct
text dword ?
noSections dword ?
section BuzzSection <?>
BuzzHeader ends


i want to use (if it is possible) to access the second section, s_size attribute:
mov BuzzHeader.section[2].s_size, 1

thanks
Posted on 2003-10-29 01:50:34 by TBD
hey buzzz

can u put sum of code you usin may b i'll try

salad
Posted on 2003-10-29 02:08:22 by salad.dressing
u hav to creat array of secions to be able to acess second or more secions.
how will u acess if you not create array. and i think yu cannot acess that way. put some code i'll try

salad
Posted on 2003-10-29 02:12:41 by salad.dressing
here it is the code that i use now (a bit cumbersome).
i want to use as an array, but i dont know how to set the structure.
Posted on 2003-10-29 02:37:30 by TBD
BuzzSection struct

s_name dword ?
s_offset dword ?
s_size dword ?
BuzzSection ends

BuzzHeader struct
text dword ?
noSections dword ?
section BuzzSection 31 dup ({})
BuzzHeader ends

_DATA SEGMENT
bzTest BuzzHeader {}
_DATA ENDS

mov bzTest.section(0*12).s_name, eax
mov bzTest.section(1*12).s_name, eax
MASM does not calculate the index into the array - it is left to the programmer to use a register index or literal. The above code really doesn't offer anything above what your already doing. MASM is not that smart - it just replaces the ".Name" with an offset:

bzTest.section(2*12).s_offset

...equals...

OFFSET bzTest + 8 + 24 + 4

...and there is minor checking to insure the ".Name" is within the parent structure.

Seems the error is in jumping over the first section?
            mov ecx, BuzzHeader.noSections[eax]

[COLOR=red]add eax, sizeof BuzzHeader[/COLOR]
_scan_sections:
mov ebx, BuzzSection.s_name[eax]
...if you include one section in the header structure definition and then add the size of that header definition then the resulting address points to the second section. Is this desired? Maybe, this would work?
BuzzHeader struct

text dword ?
noSections dword ?
BuzzHeader ends
Posted on 2003-10-29 08:26:57 by bitRAKE