我正在尝试在 FASM 中完成一项简单的任务,我已经为此苦苦挣扎了大约两个小时。
我已经用目标和问题评论了代码,但我会解释。
我正在尝试将特定文件的路径存储到变量中。该文件位于临时目录中。所以我必须先获取临时路径,然后将文件名附加到临时路径的末尾。
我正在尝试按顺序执行两次。但由于某种原因,我得到的字符串最终“搞砸了”。
我目前的代码如下:
include "win32ax.inc"
entry start
section ".data" data readable writeable
TmpDir rb 256d
aSTR dd ?
bSTR dd ?
cSTR db "aFILE.txt",0
dSTR db "bFILE.txt",0
section ".code" code readable executable
start:
;The goal is to get two seperate strings like so:
;1 - C:\PATH-TO-TEMP-DIR\aFILE.txt in "aSTR"
;2 - C:\PATH-TO-TEMP-DIR\bFILE.txt in "bSTR"
;Get temp directory
invoke GetTempPath,TmpDir,TmpDir
;Copy tempdir into aSTR
invoke lstrcpy,aSTR,TmpDir
;Add "aFILE.txt" to the end of aSTR
invoke lstrcat,aSTR,cSTR
;Copy tempdir into bSTR
invoke lstrcpy,bSTR,TmpDir
;Add "bFILE.txt" to the end of bSTR
invoke lstrcat,bSTR,dSTR
;Results in "C:\UC:\Users\user\AppData\Local\Temp\AppData\Local\Temp\A\\
;Instead of "C:\Users\user\AppData\Local\Temp\aFILE.txt"
invoke MessageBox,0,aSTR,"Test",0
;Results in "C:\Users\user\AppData\Local\Temp\AppData\Local\Temp\A\\"
;Instead of "C:\Users\user\AppData\Local\Temp\bFILE.txt"
invoke MessageBox,0,bSTR,"Test",0
invoke ExitProcess,0
section ".idata" import readable writeable
library kernel32, "KERNEL32.DLL",\
user32, "USER32.DLL"
import kernel32,\
lstrcpy, "lstrcpy",\
lstrcat, "lstrcat",\
GetTempPath, "GetTempPathA",\
ExitProcess, "ExitProcess"
import user32,\
MessageBox, "MessageBoxA"
任何解决此问题的帮助将不胜感激。谢谢!