我不断收到一条消息,说“在 HWProject4.exe 中的 0x007B1D3C 处抛出异常:0xC0000005:访问冲突读取位置 0x00000068。”在说 ret 20 的那一行。我认为这是因为我错误地访问了我的堆栈,但我不知道如何(我在纸上画了堆栈,不知道我在做什么)。
我的代码:
include Irvine32.inc
ExitProcess Proto, dwexitcode: DWORD
.data
num1 DWORD 1h
num2 DWORD 2h
num3 DWORD 3h
num4 DWORD 4h
num5 DWORD 5h
numofVar BYTE 5
title1 BYTE "System Parameters on Stack",0
titledivider BYTE "---------------------------",0
addresstxt BYTE "Address: ",0
arrow BYTE " => ",0
contenttxt BYTE "Content: ",0
.code
mdisplayText MACRO text, newLine:=<0>
mov edx, OFFSET text
call WriteString
COMMENT !
cmp newline, 0
jz done
mov ecx, newLine
L1:
call crlf
loop L1
!
IF (newLine GT 0)
mov ecx, newLine
L1:
call crlf
loop L1
ELSE
ENDIF
;done:
;ret
ENDM
runLevelTwo PROC ;,
;numbofVars:BYTE
push ebp
mov ebp, esp
pushad
mov esi, ebp
add esi, 8
mov eax, 0
mov eax, esi
;movzx ecx, numbofVars
mov ecx, 5
displaying:
mdisplayText addresstxt
call WriteHex
mdisplayText 'h'
mdisplayText arrow
mdisplayText contenttxt
mov eax, [esi]
call WriteHex
mdisplayText 'h'
call crlf
add esi, type DWORD
mov eax, esi
loop displaying
popad
pop ebp
ret
runLevelTwo ENDP
runLevelOne PROC
push num5
push num4
push num3
push num2
push num1
call runLevelTwo ;numofVar
ret 20
runLevelOne ENDP
main PROC
mdisplayText title1, 1
mov edx, OFFSET titledivider
call WriteString
call crlf
call runLevelOne
exit
main ENDP
END main