我想获取 EAX/EBX/ESP/EIP 等中的值并将它们保存在 C 变量中。例如:
int cEax;
asm("mov cEax,%eax"); ...
你可以用这个
register int eax asm("eax");
register int eax asm("ebx");
register int eax asm("esp");
//...
int cEax = eax;
int cEbx = ebx;
int cEsp = esp;
//...
您还可以像使用任何其他变量一样在表达式中使用这些寄存器,或者直接使用该寄存器的值而不分配给另一个变量。
在没有内联汇编的情况下获取 eip 会更棘手,但在 gcc 中你可以使用__builtin_return_address or the label as values扩大。
void* getEIP()
{
return __builtin_return_address(0);
}
void *currentInstruction = getEIP();
currentAddr: void *nextInstruction = &¤tAddr;
如果你想要内联汇编,你可以使用以下方式这一页
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)