首页 > 解决方案 > 在寄存器之外传递参数

问题描述

我正在尝试将第二个参数传递给我的 ls 命令ls -a -l,但不使用寄存器。

这里,-a 参数的地址在 esi。我想将 -l 放在内存中的某个位置,而不是寄存器。我已经尝试过使用堆栈,但lea esp, [esp-18]没有将地址放在堆栈上。相反,它放置值(0x00006c2d,对于 -l)。

push 0x0000612d ; -a 
mov esi, esp
mov dword [esp-30], 0x00006c2d ; -l
push eax
push edi ; 0000
;sub esp,4
;lea esp, [esp-18] ;  the value is loaded instead of the address
push eax
push esi ; location to -a (2nd arg of argv)
push ebx ; location of /bin/ls (1st arg of argv)
mov ecx, esp

我想知道当我没有寄存器时如何添加参数。

标签: assemblyx86nasm

解决方案


推荐阅读