计算JMP指令的地址 [英] Calculating JMP instruction's address

查看:462
本文介绍了计算JMP指令的地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用JMP指令这应该引起我的函数替换它的开始挂钩的功能。但问题是,我不知道如何计算JMP偏移来定位我的函数的地址。嗯,我知道该怎么做,如果你在内存(目标地址 - 当前地址)向前跳,但我还没有这方面的想法如何确定它,当你在内存跳回

I am trying to hook a function by replacing its beginning with a JMP instruction which should lead to my function. But the problem is that I don't know how to calculate the JMP offset to target the address of my function. Well, I know how to do it if you jump forward in memory (Destination addr - Current addr), but I haven't got any ideas how to determine it when you jump back in memory.

有人能帮忙吗?

推荐答案

只要使用负偏移向后跳。

Just use negative offset to jump backwards.

记住要占 JMP 指令的大小。偏移量是相对于 JMP 指令,而不是开始的结束。如果当前的地址是你即将写 JMP ,那么你需要5 + DEST电流的offet因为 JMP <大小/ code>指令加上偏移,如果5个字节。

And remember to account for the size of the JMP instruction. The offset is relative to the end of the JMP instruction and not the beginning. If the current address is where you are about to write the JMP then you need an offet of 5+dest-current since the size of the JMP instruction plus the offset if 5 bytes.

这篇关于计算JMP指令的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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