Good evening,
I am trying to understand how to use STRUCT so that I may use it in a course project.
I cut and pasted the following code from a program that apparently works.
However, I get errors when trying to assemble.
Here is the code (I commented all but a few field declarations):
IMAGE_SECTION_HEADER STRUCT
; ISH_Name DB 8 DUP (?)
;UNION
;ISH_PhysicalAddress DD ?
;ISH_VirtualSize DD ?
;ENDS
ISH_VirtualAddress DD ?
ISH_SizeOfRawData DD ?
;ISH_PointerToRawData DD ?
;ISH_PointerToRelocations DD ?
;ISH_PointerToLinenumbers DD ?
;ISH_NumberOfRelocations DW ?
;ISH_NumberOfLinenumbers DW ?
ISH_Characteristics DD ?
IMAGE_SECTION_HEADER ENDS
After reading from MASM resources, I can't find the error ... the code seems to me to respect the syntax rules.
In some readings I find references to using angle brackets or braces to actually allocate memory space.
Here is the error listing:
Assembling: C:\filework4modified.asm
C:\filework4modified.asm(119) : error A2160: non-benign structure redefinition: label incorrect : IMAGE_SECTION_HEADER
C:\filework4modified.asm(119) : error A2163: non-benign structure redefinition: incorrect initializers : IMAGE_SECTION_HEADER
C:\filework4modified.asm(127) : error A2161: non-benign structure redefinition: too few labels : IMAGE_SECTION_HEADER
C:\filework4modified.asm(127) : error A2163: non-benign structure redefinition: incorrect initializers : IMAGE_SECTION_HEADER
Any assistance would be appreciated.
MF
From the windows.inc file in MASM32, you have this structure.
IMAGE_SECTION_HEADER STRUCT
Name1 db IMAGE_SIZEOF_SHORT_NAME dup(?)
union Misc
PhysicalAddress dd ?
VirtualSize dd ?
ends
VirtualAddress dd ?
SizeOfRawData dd ?
PointerToRawData dd ?
PointerToRelocations dd ?
PointerToLinenumbers dd ?
NumberOfRelocations dw ?
NumberOfLinenumbers dw ?
Characteristics dd ?
IMAGE_SECTION_HEADER ENDS
With your commented out sections, the structure will not work as the name you are after will produce the wrong offset for the data.
Hello mf, also look in \masm32\include\Windows.inc - there are lots of structs there which can be studied. Help about structs is also available in \masm32\help\masm32.hlp.
In other words, you declared a STRUCT with the same name as another one which is part of the windows.inc file (which you most probably included in the source code), but has a different structure. The assembler could not deal with the redefinition.
You have two choices:
a) Use a different name for the STRUCT and put in whatever elements you need with whatever names you wish.
b) Use the STRUCT as defined in the windows.inc file and use only the elements you need.
When you declare an "official" STRUCT, you don't have to repeat all the details which are listed in the .INC file. If you don't need to initialize any of the members, it's as simple as:
myimage IMAGE_SECTION_HEADER <>
Raymond