Initializing a struct in yasm x86 assembly

740 views Asked by At

I'm trying to initialize a WIN32_FIND_DATA structure in which to store info about files found with FindFirstFile and FindNextFile windows functions. The problem is that i can't figure out how to initialize a stuct in yasm. Here's my code:

    struc FILETIME
.dwLowDateTime resd 1
.dwHighDateTime resd 1
endstruc

struc WIN32_FIND_DATA
.dwFileAttributes   resd 1
.ftCreationTime     resb FILETIME_size
.ftLastAccessTime   resb FILETIME_size
.ftLastWriteTime    resb FILETIME_size
.nFileSizeHigh      resd 1
.nFileSizeLow       resd 1
.dwReserved0        resd 1
.dwReserved1        resd 1
.cFileName          resb 260
.cAlternateFileName resb 14
endstruc

[bits 32]

section .text 

extern _exit

global  _main 

_main: 

        push    0
        call    _exit
        ret 

section .data

dataWin32: 
    istruc WIN32_FIND_DATA 
        at a, dd     0
        at b, db     0
        at c, db     0
        at d, db     0
        at e, dd     0
        at f, dd     0
        at g, dd     0
        at h, dd     0
        at i, db     0
        a
    iend

The errors i get are:

testStruct.asm:38: error: undefined symbol `b' (first use)
testStruct.asm:38: error:  (Each undefined symbol is reported only once.)
testStruct.asm:39: error: undefined symbol `c' (first use)
testStruct.asm:40: error: undefined symbol `d' (first use)
testStruct.asm:41: error: undefined symbol `e' (first use)
testStruct.asm:42: error: undefined symbol `f' (first use)
testStruct.asm:43: error: undefined symbol `g' (first use)
testStruct.asm:44: error: undefined symbol `h' (first use)
testStruct.asm:45: error: undefined symbol `i' (first use)
1

There are 1 answers

1
LeDev On BEST ANSWER
dataWin32: 
istruc  WIN32_FIND_DATA 
at WIN32_FIND_DATA.dwFileAttributes,dd 0
at WIN32_FIND_DATA.ftCreationTime,db 0
at WIN32_FIND_DATA.ftLastAccessTime, db 0
at WIN32_FIND_DATA.ftLastWriteTime, db 0
at WIN32_FIND_DATA.nFileSizeHigh, dd 0
at WIN32_FIND_DATA.nFileSizeLow, dd 0
at WIN32_FIND_DATA.dwReserved0, dd 0
at WIN32_FIND_DATA.dwReserved1, dd 0
at WIN32_FIND_DATA.cFileName, db 0
at WIN32_FIND_DATA.cAlternateFileName,db 0
iend

You have to specify the struct name,otherwise the assembler cannot know which fields you are referring to.