2016-12-29 86 views
-1

我試圖初始化一個WIN32_FIND_DATA結構體,該結構體用於存儲有關FindFirstFile和FindNextFile窗口函數的文件信息。問題是我無法弄清楚如何在yasm中初始化一個stuct。 這裏是我的代碼:初始化yasm x86程序集中的一個結構體

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) 
+0

你期望'a,''b'等等能做什麼?結構中沒有這個名字的字段! –

+0

你的意思是我應該有'而','.dwFileAttributes'? –

+0

@WeeBey:彙編程序無法猜測你想要什麼。你必須使用正確的標識符。你必須完全限定它們:'WIN32_FIND_DATA.dwFileAttributes'等。 –

回答

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 

您必須指定結構名稱,否則彙編器無法知道哪些字段,你指的是。

+0

謝謝,這就是我一直在尋找的! –