-1

我正在尝试初始化一个 WIN32_FIND_DATA 结构,在该结构中存储有关使用 FindFirstFile 和 FindNextFile windows 函数找到的文件的信息。问题是我不知道如何在 yasm 中初始化一个结构。这是我的代码:

    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

我得到的错误是:

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)
4

1 回答 1

2
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

您必须指定结构名称,否则汇编程序无法知道您指的是哪些字段。

于 2016-12-29T13:40:12.577 回答