各位帮忙看看,为啥运行到call WriteFile就挂了
.386
.model flat,stdcall
option casemap:none
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;include定义
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
include e:\masm32\include\windows.inc
include e:\masm32\include\user32.inc
include e:\masm32\include\kernel32.inc
includelib e:\masm32\lib\user32.lib
includelib e:\masm32\lib\kernel32.lib
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;数据段
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.data?
array db 10000 dup(?) ;默认求(1-10000)素数
h_file dd ? ;文件句柄
buf db 100 dup(?) ;缓冲区
.data
g_count dd 10000 ;区间
g_bound dd 100 ;上界
suc_word dd 0 ;文件操作参数
.const
file_name db 'd:\\result.txt',0 ;存放结果的文件名
sz_finish db '计算完成',0
sz_format db ' %5d ',0
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;代码段
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.code
start:
pushad
;初始化 array全体元素为0
mov ecx, 0
mov al, 0
@init:
cmp ecx, g_count
jg @init_finish
mov array[ecx], al
inc ecx
jmp @init
@init_finish:
;计算过程
mov eax, 1
mov array[2], 0
@find_init:
inc eax
cmp array[eax], 1
je @find_init
cmp eax, g_bound
jg @find_finish
mov cx,1
@find_begin:
push eax
inc cx
mul cx
push ax
mov ax, dx
shl eax, 8
pop ax
cmp eax, g_count
jg @go_init
mov array[eax], 1
pop eax
jmp @find_begin
@go_init:
pop eax
jmp @find_init
@find_finish:
;写入结果
push NULL
push FILE_ATTRIBUTE_NORMAL
push CREATE_ALWAYS
push NULL
push FILE_SHARE_READ
push GENERIC_WRITE
push offset file_name
call CreateFile
mov h_file, eax
mov ecx, 1
@continue:
cmp ecx, g_count
jg @finish
inc ecx
test array[ecx], 0
je @write_in
jmp @continue
@write_in:
push ecx
push offset sz_format
push offset buf
call wsprintf
push NULL
push offset suc_word
push 7
push offset buf
push h_file
运行到这附近--> call WriteFile
jmp @continue
@finish:
push h_file
call CloseHandle
popad
end start
只是一个很简单的筛选法求素数,前面的过程应该问题不大,只是输出结果的时候有些问题,请大家帮忙看看,谢谢,刚开始学汇编,有很多不懂,多多指教,也请大家多多拍砖,把我代码各个方面存在的问题都指出来。
.model flat,stdcall
option casemap:none
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;include定义
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
include e:\masm32\include\windows.inc
include e:\masm32\include\user32.inc
include e:\masm32\include\kernel32.inc
includelib e:\masm32\lib\user32.lib
includelib e:\masm32\lib\kernel32.lib
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;数据段
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.data?
array db 10000 dup(?) ;默认求(1-10000)素数
h_file dd ? ;文件句柄
buf db 100 dup(?) ;缓冲区
.data
g_count dd 10000 ;区间
g_bound dd 100 ;上界
suc_word dd 0 ;文件操作参数
.const
file_name db 'd:\\result.txt',0 ;存放结果的文件名
sz_finish db '计算完成',0
sz_format db ' %5d ',0
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;代码段
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.code
start:
pushad
;初始化 array全体元素为0
mov ecx, 0
mov al, 0
@init:
cmp ecx, g_count
jg @init_finish
mov array[ecx], al
inc ecx
jmp @init
@init_finish:
;计算过程
mov eax, 1
mov array[2], 0
@find_init:
inc eax
cmp array[eax], 1
je @find_init
cmp eax, g_bound
jg @find_finish
mov cx,1
@find_begin:
push eax
inc cx
mul cx
push ax
mov ax, dx
shl eax, 8
pop ax
cmp eax, g_count
jg @go_init
mov array[eax], 1
pop eax
jmp @find_begin
@go_init:
pop eax
jmp @find_init
@find_finish:
;写入结果
push NULL
push FILE_ATTRIBUTE_NORMAL
push CREATE_ALWAYS
push NULL
push FILE_SHARE_READ
push GENERIC_WRITE
push offset file_name
call CreateFile
mov h_file, eax
mov ecx, 1
@continue:
cmp ecx, g_count
jg @finish
inc ecx
test array[ecx], 0
je @write_in
jmp @continue
@write_in:
push ecx
push offset sz_format
push offset buf
call wsprintf
push NULL
push offset suc_word
push 7
push offset buf
push h_file
运行到这附近--> call WriteFile
jmp @continue
@finish:
push h_file
call CloseHandle
popad
end start
只是一个很简单的筛选法求素数,前面的过程应该问题不大,只是输出结果的时候有些问题,请大家帮忙看看,谢谢,刚开始学汇编,有很多不懂,多多指教,也请大家多多拍砖,把我代码各个方面存在的问题都指出来。
...全文
相关推荐
Hook Api,hook ReadFile,hook WriteFile,hook LoadLibrary
通过对ReadFile、WriteFile和LoadLibrary等函数的Hook,我们可以实现文件操作的监控、动态库的控制以及其他高级功能。
node.js中的fs.writeFile方法使用说明
这个方法非常适合在处理大量数据或者需要非阻塞I/O操作时使用,以保持程序的高效率运行。
WriteFile.zip
《深入理解WriteFile函数:操作系统内核编程的实践探索》在Windows系统编程中,`WriteFile`函数是一个至关重要的接口,它允许应用程序向设备或文件写入数据。
bac.rar_writefile
标题"Bac.rar_writefile"指的是一个使用WriteFile函数进行块读写操作的示例或教程。
wrightFile:包装 fs.writeFile、mkdirp 和其他整洁
一、fs.writeFile的封装fs.writeFile是Node.js原生提供的一个用于写入文件的方法。然而,它并没有提供错误处理和文件存在的判断等功能。


