以下是MASM代码:
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
include \masm32\include\msvcrt.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\msvcrt.lib
.code
start:
jmp Debut
Suite:
mov esi, 7706304eh
call esi
jmp 00000000h
Debut:
xor eax, eax
push eax
call Suite
db "C:\WINDOWS\system32\calc.exe"
end start如您所见,我需要使用与操作码'E9‘相对应的特殊JMP指令。但是,使用MASM似乎语法不正确。
我有以下错误消息:
A2076 : Jump destination must specify a label我知道'jmp _label‘很有效,但这不是我在这里寻找的。所以我尝试了另一种方式,比如"jmp dword ptr ds: 000000h“或‘mov eax,000000h;jmp eax’,但是生成的操作码与'E9‘不匹配。我真的在那种情况下迷路了。有人能帮我吗?
提前谢谢你的帮助。
发布于 2013-11-27 01:23:43
OP说:一旦编译了这段代码,我将用一个有效的地址替换000000h地址。ASM代码中地址的存在是为了在编译代码后保持相同数量的操作码。
那么你可能想要写的是:
my_jump:
jmp near ptr $ ; produces a 4 byte long relative jump instruction that jmps-to-self当您知道您希望它跳转的目标地址,并在eax中加载了该地址时,您可以编写以下代码:
mov eax, .... ; desired target address
sub eax, offset my_jump+4 ; compute relative offset for jmp to get to target
mov dword ptr my_jump+1, eax ; update the jump instructio这应该能行。它的缺点是是自修改代码,这在您的操作系统下可能是不允许的,如果允许的话,也不被接受为良好的实践。
一种更容易更好的方法是将所需的目标位置放置在一个众所周知的数据位置中,并修改您的代码以使用该位置:
.data
target_location dword 0 ; filled in later
.code
Suite:
mov esi, 7706304eh ; hardwiring this constant is bad practice, too, but you didn't ask about that
call esi
mov esi, target_location
jmp esi这段代码不是自我修改的,在汇编程序中这种技巧是很常见的。
发布于 2013-11-26 22:08:37
如果您只想将特定的字节序列(e9和一些零)发送到代码中,那么可以使用db。
发布于 2013-11-26 22:24:07
“E9”操作码有“跳转短”命令
如果您定义“标签”,则在“jmp”指令附近的某个位置(范围为-128…)。( 127字节),然后您可以编写如下内容:
jmp short label
label:如果您想跳转到地址0x00000000,那么您可以使用这个结构,但是jmp的操作码(一般情况下)不等于'E9':
org 0
label0:
...
jmp label0https://stackoverflow.com/questions/20228956
复制相似问题