Comments (10)
崩溃的问题,你需要调试一下自己的 old_mmap11
函数了,可以把 old_mmap11
改为直接调用系统
mmap
看看还会崩吗?
你的第二种写法中正则有错误,应改为:
xhook_register("^/system/.*$", "mmap", my_mmap, NULL);
from xhook.
void *(*old_mmap)(void *start, size_t len, int prot, int flags, int fd, off_t offset);
void *(my_mmap)(void *start, size_t len, int prot, int flags, int fd, off_t offset){
LOGD("[mmap] ==============");
return old_mmap(start, len, prot, flags, fd, offset);
};
我是这样写的,然后传入的,大佬帮忙看下哪里不对吗
from xhook.
syscall调用,会导致
from xhook.
void *my_mmap(void *start, size_t len, int prot, int flags, int fd, off_t offset)
{
LOGD("[mmap] =========");
return mmap(start, len, prot, flags, fd, offset);
};
xhook_register("^/system/.*$", "mmap", my_mmap, NULL);
这样调用会崩溃吗?
from xhook.
这样调用正常了,请教一下,我觉得这样不是会陷入死循环吗,为什么没有呢
from xhook.
因为你的代码只对符合 ^/system/.*$
正则的 ELF 做了hook,而 my_mmap
所在的so库不在 /system
目录下,所以没有被hook到。
如果你配置的正则包含了 my_mmap
所在的so库,就会陷入死循环。如果要避免死循环,就需要避免对 mmap
的直接依赖,改成这样:
typedef void (*my_mmap_t)(void *, size_t, int, int, int, off_t);
my_mmap_t old_mmap = NULL;
void *my_mmap(void *start, size_t len, int prot, int flags, int fd, off_t offset)
{
LOGD("[mmap] =========");
return old_mmap(start, len, prot, flags, fd, offset);
};
xhook_register("^/.*$", "mmap", my_mmap, (void **)&old_mmap);
from xhook.
我的理解是:
hook了 libc.so中的 mmap函数,然后所有调用mmap的时候都执行钩子函数,
你在上面提到的 my_mmap
不是很理解这句话,我要Hook的是mmap,我理解为my_mmap替换了mmap
为什么你提到了是我要hook my_mmap,大佬帮忙解惑下
是不是可以理解为:hook到的只是用正则匹配到的调用mmap的地方
from xhook.
xhook是通过替换PLT/GOT中的函数地址达到hook效果的,不是inline hook的方式。通俗的说:假设mmap的实现在libc.so中,libbiz.so中有逻辑调用了mmap函数,xhook替换的是“libbiz.so运行时指向libc.so中的mmap函数的指针”,并不是替换libc.so中mmap的实现逻辑。
建议看一下这篇文字:https://github.com/iqiyi/xHook/blob/master/docs/overview/android_plt_hook_overview.zh-CN.md
from xhook.
谢谢啦,这个问题搞懂了,给你点个赞 :)
from xhook.
不客气的
from xhook.
Related Issues (20)
- 想问个项目中的代码问题 HOT 1
- 请问哪些数据可以进一步了解更多关于底层编译链接知识。
- arm64的PLT和arm的PLT有啥区别吗?
- error: ‘PAGE_MASK’ undeclared (first use in this function)
- 在二进制文件中使用libxhook对__android_log_print进行hook,hook不成功
- 请问如何知道自己被hook了?
- hook libil2cpp.so 失败,求助
- float args in hooked function
- Can't hook library HOT 1
- Android 11 support
- libc.so (memcmp) xh_core_refresh crash pls help me. HOT 1
- how to hook c++ class instance's method?
- hook libil2cpp.so 失败,求助 HOT 1
- 请问这里的函数返回值为什么是void*,而非void? HOT 1
- 请教两个问题
- 执行demo里面的./gradlew assembleDebug报错
- 在安卓aab包,xhook会失败。。 HOT 2
- xhook not working in some cases
- 希望支持安卓11
- __system_property_get no work in xiaomi android 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xhook.