Visual C内联汇编程序中的立即调用/jmp [英] Immediate call/jmp in Visual C inline assembler

查看:279
本文介绍了Visual C内联汇编程序中的立即调用/jmp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试立即调用或在VC ++ 2010内联汇编器中跳转

When I try to make an immediate call or jump in VC++ 2010 inline assembler

_asm 
{
    call 00405B90h;
    jmp 00405B90h;
    jmp far 00405B90h;
}

它会产生一个错误

C2415: improper operand type

有可能吗?

到目前为止,我有一个解决方法:

So far I have a work around:

_asm 
{
    push 00405B90h; // This is a jump work around
    call 00405B90h;        
}

推荐答案

取决于您要调用的内容,可以将var设置为该地址,然后执行以下操作:

depending on what you want to call, either set a var to the address and do:

DWORD var = 0xDEADBEEF;
__asm jmp [var]

或者,我该怎么做:

__asm
{
    mov eax,ModuleBase
    add eax,RVA
    call eax ;obviously call can be jmp
}

您可以轻松地对此宏(可能是添加寄存器参数的好主意):

you can easily macro this(probably a good idea to add a register param):

#define JMP_IMM(x) __asm mov eax,x \
                   __asm jmp eax


不幸的是,MASM不支持对绝对地址的相对调用,而其他汇编程序(如NASM)也不能对COFF目标文件执行此操作.因此,工具链的限制迫使您将这种效率较低的机器代码与间接调用或jmp结合使用.


Unfortunately MASM doesn't support relative calls to absolute addresses, and other assemblers like NASM can't do it for COFF object files either. So toolchain limitations force you to use this less efficient machine code with an indirect call or jmp.

  • 在user32.dll中直接调用函数时出错

    这篇关于Visual C内联汇编程序中的立即调用/jmp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆