我有一个汇编语言程序,它试图打印出窗口环境变量的值,即“%AppData%”。不幸的是,我的程序只会崩溃。我怀疑问题是由不正确的堆栈保留引起的。这是我的代码:
includelib \Masm64\Lib\Kernel32.lib
includelib \Masm64\Lib\User32.lib
extern GetEnvironmentVariableA : proc
extern MessageBoxA : proc
extern ExitProcess : proc
dseg segment para 'DATA'
capt db 'Debug', 0
msg db 0 dup(30h)
evar db '%AppData%', 0
dseg ends
cseg segment para 'CODE'
start proc
sub rsp, 18h
mov r8d, 30h
lea rdx, [msg]
lea rcx, [evar]
call GetEnvironmentVariableA
sub rsp, 28h
xor r9d, r9d
lea r8, [capt]
lea rdx, [msg]
xor rcx, rcx
call MessageBoxA
fini: call ExitProcess
start endp
cseg ends
end
有什么建议么?