嘿,我已经使用 masm 2 周了,我正在尝试逐行读取包含文件路径的文本文件
example of text file
C:\a.rar
C:\a.txt
C:\a.png
然后我想读入文件路径的全部内容并得到文件路径的md5校验和
下面的代码第一次完美运行(第一个消息框是文件路径,第二个是文件内容,第三个是 md5 校验和)
但是在第一个循环之后它读取第二个文件路径但无法读取第二个文件的内容然后崩溃,因为它没有任何 md5 校验和。
不重置某些东西或不关闭某些东西一定是一个简单的错误,但我花了大约 20 个小时在这上面,但无法让它工作
例如下面的代码在一个按钮中,当你按下按钮时,这就是它应该做的
message box C:\a.rar
message box "contents of file"
message box 44644af7515bc4870d44fa688684798
message box C:\a.txt
message box "contents of file"
message box 6057f13c496ecf7fd777ceb9e79ae285
message box C:\a.png
message box "contents of file"
message box 01654ab48d84f484z446ba48453cb48
但这就是发生的事情
message box C:\a.rar
message box "contents of file"
message box 44644af7515bc4870d44fa688684798
message box C:\a.txt
blank contents cant read the contents of the file on loop (this is the problem)
message box blank because it cant md5 no contents
碰撞
有人可以帮忙吗
LOCAL Buffer3 :DWORD
invoke CreateFile, ADDR filestoscan, GENERIC_READ, 0, 0,OPEN_EXISTING, 0, 0
mov hFile, eax
invoke GetFileSize,hFile,NULL
mov Byteforstreamreader,eax
streamreader2:
.if Byteforstreamreader != 0
invoke ReadFile, hFile, ADDR Buffer2,1, ADDR BytesWritten, 0
.if Buffer2 == 13
invoke CreateFile, ADDR StringBuffer, GENERIC_READ, 0, 0,OPEN_EXISTING, 0, 0
mov hFile2, eax
invoke GetFileSize,hFile2,NULL
mov Bytes,eax
invoke ReadFile, hFile2, ADDR FileBuffer,Bytes, ADDR BytesWritten, 0
invoke CloseHandle,hFile2
invoke MessageBoxA, NULL, addr StringBuffer, offset BoxCaption, NULL
invoke MessageBoxA, NULL, addr FileBuffer, offset BoxCaption, NULL
invoke MD5_Startup
invoke MD5_Init, offset ctxt
invoke MD5_Read, offset ctxt, offset FileBuffer, Bytes
invoke MD5_Digest, offset ctxt, offset filehash
invoke MD52String, offset filehash, offset strn, 1
invoke MessageBoxA, NULL, addr strn, offset BoxCaption, NULL
mov FileBuffer,0
mov StringBuffer,0
dec Byteforstreamreader
jmp streamreader2
.endif
mov eax,offset Buffer2
mov Buffer3,eax
invoke lstrcat,ADDR StringBuffer,addr Buffer2
dec Byteforstreamreader
jmp streamreader2
.endif
.if Byteforstreamreader == 0
invoke CloseHandle,hFile
.endif
.data
filestoscan db "myfiles.txt",0
FileBuffer DB 50000 DUP(?)
Bytes dd ?
Bytes2 dd ?
BytesWritten dd ?
BytesWritten3 dd ?
hFile dd ?
hFile2 dd ?
.data ?
hFile dd ?
Byteforstreamreader dd ?
BytesWritten2 dd ?
StringBuffer DB 100 DUP(?)
Buffer2 db 500 dup (?)
ctxt db 1000 dup (?)
filehash db 1000 dup (?)
strn db 33 dup(?) ; use dw for unicode
作为一个附带问题,如果有人可以回答,我认为必须在文件缓冲区上保留 50000 字节以便我可以打开一个 50000 字节或更小的文件,这似乎是不对的。我如何在不保留所有内存的情况下打开任何文件大小,因为其中一些文件可能是 100 mb 或更多
谢谢你