.586
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
.data
hFile dd 0
szTextBuffer db 0fh dup (0)
szTextToWrite db 'WWWWWWWWW',0
szReadException db 'Exception occurd when Read',0
szWriteException db 'Exception occurd when write',0
szWarningCaption db 'WARNING',0
szCaption db 'Title',0
szFileName db 'D:\WIN32汇编源码\文件操作\app.exe',0
.code
start:
invoke CreateFile,addr szFileName,GENERIC_READ OR GENERIC_WRITE,FILE_SHARE_READ OR FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL
.if eax==INVALID_HANDLE_VALUE
invoke ExitProcess,0
.endif
mov hFile,eax
invoke ReadFile,hFile,addr szTextBuffer,0fh,NULL,NULL
.if !eax
invoke MessageBox,NULL,addr szReadException,addr szWarningCaption,MB_OK
invoke ExitProcess,0
.endif
invoke MessageBox,NULL,addr szTextBuffer,addr szCaption,MB_OK
invoke WriteFile,hFile,addr szTextToWrite,0eh,NULL,NULL
.if !eax
invoke MessageBox,NULL,addr szWriteException,addr szWarningCaption,MB_OK
invoke ExitProcess,0
.endif
invoke MessageBox,NULL,szTextToWrite,szCaption,MB_OK
ret
end start
如上所示,自己写的readfile和writefile的代码,学习编程,但是老弹出错误,
本人用od调试,发现CreateFileA执行时成功的,返回正确的句柄,但是执行
到ReadFileA就出现错误弹窗,检查了几遍都找不到原因,求老师们能指导下
错误信息
0x7c801892 指令引用 的0x00000000内存不能为written
等指导,谢谢
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)