后藤在C的具体地址 [英] Goto a specific Address in C

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

问题描述

我怎样才能JMP到一个特定的地址用C?

How can I JMP to a specific address in C?

我想用

goto 0x10080000

这不工作,有没有其他的方法可以让我改变程序计数器??

This is not working, is there other way I can change the address of Program Counter??

推荐答案

可以的的地址给一个函数指针,然后跳进:

You can cast the address to a function pointer and then jump into:

((void (*)(void))0x10008000)();

要让它多一点明确的:

typedef void (*func_t)(void);
...
((func_t)0x10008000)();

但是这是一个函数,编译器将发出一个分支指令将要返回(当时是由你来让你的函数返回与否)。
还要注意,编译器将产生code,它希望找到在给定的地址的C函数,关于函数的参数是如何给出回来了。

But this is a function, the compiler will emit a branch instruction that expect to return (then is up to you to make your function return or not). Also notice that the compiler will produce a code that expect to find a C function at the given address, about how the function arguments are given and returned.

如果您需要发出一个分支指令没有回报,你需要使用内联汇编。

If you need to emit a branch instruction without return you need to use inline assembly.

这篇关于后藤在C的具体地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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