LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 654|回复: 2

请叫这段程序

[复制链接]
发表于 2005-6-24 11:04:57 | 显示全部楼层 |阅读模式
static void patch_jump(char *code_to_patch,char *target)
{
        int distance;
        distance = (int)target - ((int)code_to_patch +5) ;
        *code_to_patch++= 0xe9; /* jump */
        *code_to_patch++ = ((char *)&distance)[0];
        *code_to_patch++ = ((char *)&distance)[1];
        *code_to_patch++ = ((char *)&distance)[2];
        *code_to_patch = ((char *)&distance)[3];

}
这段程序的结果是什么啊?看不明白:(
发表于 2005-6-25 22:50:46 | 显示全部楼层
把从code_to_patch 开始的地址写上一个跳转指令.
跳转到 target 地址执行.
回复 支持 反对

使用道具 举报

发表于 2005-7-10 10:43:58 | 显示全部楼层
*code_to_patch++ = ((char *)&distance)[0];
*code_to_patch++ = ((char *)&distance)[1];
*code_to_patch++ = ((char *)&distance)[2];
*code_to_patch = ((char *)&distance)[3];

难道1int=4Byte ??
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表