The Masm32 writes the size of the structure incorrectly

16 views Asked by At

.386

.model flat, stdcall
option casemap: none

includelib C:\masm32\lib\kernel32.lib

        ExitProcess proto stdcall, :dword



struc_SectionHeaders struct

        Name                  db 8 dup(?)

        VirtualSize             dd ?

        VirtualAddress          dd ?

        SizeOfRawData           dd ?

        PointerToRawData        dd ?

        PointerToRelocations    dd ?

        PointerToLineNumbers    dd ?

        NumberOfRelocations     dw ?

        NumberOfLineNumbers     dw ?

        Characteristics         dd ?


struc_SectionHeaders ends



        e_lfanew equ  03ch
        OptionalHeaderOffset equ 18h


.data

abc db 'a', 'b', 'c'
       


.code
      

Program:


        MOV EAX, sizeof struc_SectionHeaders

        invoke ExitProcess, 0

     
end Program

When we run the program, a number of 20 hex is placed in the accumulator, which is wrong. The correct number is 28 hex. But if we change the 'name' field of Structure to something else, for example SName, the correct number will be obtained. Why?

I removed all the includes to avoid interference, but again the wrong number is displayed. Only when we change the structure field to something other than the 'name', the correct number is obtained. thank you

0

There are 0 answers