DLL EXE 混合 C++视窗

发布于 2024-08-18 11:42:42 字数 249 浏览 7 评论 0原文

我目前正在处理 DLL 注入,需要一个可以同时充当可执行文件和 DLL 的混合二进制文件。我想也许编写一个 DllMain 和 WinMain 函数,然后将其编译为可执行文件,但我不知道如果这样做会发生什么。我知道可以通过使用 thinstall 之类的东西来组合 dll 和 exe,或者将 dll 提取到临时位置,然后从那里开始,但我不想弄乱这些东西。所以基本上,是否可以定义 WinMain 和 Dll Main,然后将生成的可执行文件用作两者,如果不能,这是否可能?提前致谢!

I am currently working with DLL injection and need to have a single hybrid binary that could act as both an executable and a DLL. I thought of maybe writing a DllMain and WinMain function and then compiling it as an executable but I don't know what would happen if I did that. I know that it is posssible to combine a dll and exe by using something like thinstall or extracting the dll to a temporary location then going from there but I don't want to mess with any of that stuff. So basically, is it possible to define a WinMain and Dll Main and then use the resulting executable as both, and if not, is this even possible? Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦幻的味道 2024-08-25 11:42:42

不。DLL

和 EXE 都有一个 PE(可移植可执行文件)标头。该标头有一个字段IMAGE_FILE_HEADER::Characteristics。该字段的位 14 要么是 0(对于 EXE),要么是 1(对于 DLL)。

No.

Both a DLL and an EXE have a PE (Portable Executable) header. That header has a field IMAGE_FILE_HEADER::Characteristics. Bit 14 of that field is either 0 (for an EXE) or 1 (for a DLL).

韵柒 2024-08-25 11:42:42

为什么不将所有公共代码放入静态库 (.lib) 中,并将 DLL 项目和 EXE 项目作为静态库的一个非常薄的包装器?

Why don't you put all the common code into a static library (.lib) and have both DLL project and EXE project as a very thin wrapper around the static library?

娜些时光,永不杰束 2024-08-25 11:42:42

您可以创建可执行文件的临时副本,修补 PE 标头并注入此副本。另一种方法是将 DLL 作为可执行文件的二进制资源。在运行时,您可以将此二进制资源写入临时文件并使用它进行注入。

You could create a temporary copy of your executable, patch the PE header and inject this copy. Another way is to put the DLL as binary resource to the executable. On runtime you can write this binary resource to a temporary file and use this for injection.

你如我软肋 2024-08-25 11:42:42

也可以从 exe 导出函数。所以你应该能够 LoadLibrary("foo.exe") 后跟 GetProcAddress(hFoo,"bar")

It is possible to export functions from a exe too. So you should be able to LoadLibrary("foo.exe") followed by GetProcAddress(hFoo,"bar")

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文