jmpews / Dobby

a lightweight, multi-platform, multi-architecture hook framework.
Apache License 2.0
3.89k stars 796 forks source link

Linux hook 部分函数崩溃,例如close 最简单的在自定义hook函数里面return 原函数 报段错误核心已存储 #183

Open xuhongios opened 2 years ago

xuhongios commented 2 years ago

int (*linuxold_close)(int fd);

int hook_close(int fd) { printf("hook_close函数%d\n",fd); return linuxold_close(fd); }

void *printf_addr = DobbySymbolResolver(NULL, "close");

if (printf_addr) {

    DobbyHook(printf_addr, hookFunc, oriFunc);
}
xuhongios commented 2 years ago

就是一个简单的hook然后曲调用做一个打印再回到原函数,linuxold_close调用就会崩溃,版本是master上面之间clone的,然后按照主机的方式、自己编的.a文件,大部分函数都可以正常和hook

PyLuaDebugger commented 1 year ago

你的示例代码是错的,oriFunc和linuxold_close不是同一个东西? 虽然我这边也有同样的问题,oriFunc基本上都闪退,不管是简单的还是复杂的。

xuhongios commented 1 year ago

这个地方是代码片段,那个orifunc是填错了应该是&linuxold_close