问题描述
我尝试运行下面的简单代码:
extrn MessageBoxA: PROC
extrn ExitProcess: PROC
.data
titles db 'Win64',0
msg db 'Hello World!',0
.code
main proc
sub rsp,28h ; 32 byte for 4 arguments,8 byte for 'call' it self
mov rcx,0 ; hWnd = HWND_DESKTOP
lea rdx,msg ; LPCSTR lpText
lea r8,titles ; LPCSTR lpCaption
mov r9d,0 ; uType = MB_OK
call MessageBoxA
mov ecx,eax
add rsp,28h
main endp
End
extrn MessageBoxA: PROC
extrn ExitProcess: PROC
.data
titles db 'Win64',0
msgBox_ready:
sub rsp,8 byte for 'call' it self
mov rcx,0 ; hWnd = HWND_DESKTOP
lea rdx,msg ; LPCSTR lpText
lea r8,titles ; LPCSTR lpCaption
mov r9d,0 ; uType = MB_OK
call MessageBoxA
mov ecx,eax
add rsp,28h
.code
main proc
call msgBox_ready
main endp
End
如果我将msgBox_ready
的内容移到函数main
上似乎没问题。有什么问题可能是因为它不在.code
节之外吗?
解决方法
我使用jmp msgbox_ready
而不是call msgbox_ready
解决了该问题,该功能可以正常工作。阅读Assembly 'call' vs 'jmp'