如何在EXE文件中查找函数地址以进行hook / detour? [英] How to find a functions address to hook/detour in an EXE file?

查看:108
本文介绍了如何在EXE文件中查找函数地址以进行hook / detour?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我再次开车对着墙,需要你帮助一些低级的东西。我已成功挂钩导出DLL函数(使用此代码btw。 )注入到我的目标进程(例如,我可以很容易地从 user32.dll 中迂回 MessageBoxW 。不幸的是,我的目标是一个不同的情况:我必须绕过一个定义在可执行文件内的函数我注入我的代码。应用程序是开源的,所以我知道关于钩住它需要的功能的一切,但二进制文件是用证书签名的,所以我不能编译自己的版本。是否可以在运行时获取函数的地址或使用另一种技术绕行?目标是一个正常32位Windows二进制btw。没有什么特别的我想);

I drove against a wall again and need your help with some low-level stuff. I already succeeded in hooking exported DLL-Functions (with this code btw.) by injecting them into my target process (e.g. I can easily detour MessageBoxW from user32.dll). Unfortunately I aim for a different scenario: I have to detour a function defined inside the executable I'm injecting my code into. The application is Open-Source so I know everything about the function I'd need for hooking it, but the binary is signed with a certificate so I can not compile my own version. Is it possible to fetch the functions' address at runtime or detour it with another technique? The target is a "normal" 32bit Windows binary btw. nothing special I thought ;)

您的,
Nefarius

Yours, Nefarius

strong>也许是因为我的英语我不够详细,所以这里有一个示例代码:

maybe due to my lame English I was not detailed enough, so here a little sample code:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
    foo();
}

BOOL foo(char* someData)
{
    return printf("%s", someData);
}



现在我要绕过函数 foo ,它不存在于动态库中。这是我的问题。

Now I want to detour the function foo() which does not exist in a dynamic library. This is my problem. I don't know how and I'm not sure if this works like I think it does.

编辑:现在我知道这是可能,所以重要的问题改为:如何?我如何获得我需要的信息;函数地址?

Now I know it is possible, so the important question changed to: how? How do I get the information I need; the functions address?

推荐答案

我获得了我的目标,挂钩一些低级的Windows API函数,而不是最好的解决方案, ,Assembler不是我的...

I acquired my aim with hooking some low-level Windows API functions, not the best solution but it works, Assembler isn't mine...

这篇关于如何在EXE文件中查找函数地址以进行hook / detour?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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