Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

把test_hook.cc放在x86模拟器里面,发现调用原始的方法是错误的 #42

Open
liminghuyii2 opened this issue Aug 31, 2019 · 0 comments

Comments

@liminghuyii2
Copy link

int main() {
#if defined(APPLE)
void *handle = dlopen("libc.dylib", RTLD_NOW);
#else
void *handle = dlopen("libc.so", RTLD_NOW);
#endif
assert(handle != nullptr);
void *symbol = dlsym(handle, "getenv");
assert(symbol != nullptr);
printf("Orig getenv = %p\n", symbol);
WInlineHookFunction(
symbol,
reinterpret_cast<void *>(Hooked_getenv),
reinterpret_cast<void **>(&Origin_getenv)
);
// WImportHookFunction(
// "_getenv",
// reinterpret_cast<void *>(Hooked_getenv),
// reinterpret_cast<void **>(&Origin_getenv)
// );
const char *val = getenv("lody1"); //这里如果是输入“lody“可以hook成功打印出了"are you ok?",但是如果是“lody1”就会出现Segmentation fault 139错误
std::cout << val;
return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant