可以调用一个.exe的DllMain吗? [英] Can the DllMain of an .exe be called?

查看:152
本文介绍了可以调用一个.exe的DllMain吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与这一个不完全相同(这不是理论上的,有只有一条没有消息循环的主线程,InitInstance和ExitInstance都不配合调用)。

My question is not exactly the same as this one (it's not theoretical, there is only a main thread without message loop, InitInstance and ExitInstance are no fitting calls).

我在使用没有消息循环的控制台应用程序;该应用程序使用LoadLibrary函数加载一个exe,以便它可以使用其导出的函数。坏消息:exe的DllMain函数不被调用(并且我验证了符号表,使用def文件,DllMain正确显示); 该文档说如果加载的模块是一个DLL(也是)坏的)。

I'm using a console app without message loop; this app loads an exe with the LoadLibrary function, so that it can use its exported functions. Bad news: the DllMain function of the exe is not called (and I verified the symbols tables, using a def file, DllMain appears correctly); the doc says it's called if the loaded module is a DLL (too bad).

当调用LoadLibrary时,有什么条件(如果存在)可能导致执行exe的DllMain函数(也可能再次调用FreeLibrary时) )?

What are the conditions (if they exist) which could lead to the execution of the exe's DllMain function when LoadLibrary is called (and maybe again when FreeLibrary is called)?

最好的问候

推荐答案

最明显的条件是调用LoadLibrary()的过程显式获取GetProcAddress(DllMain),然后调用它。

The most obvious condition is that the process calling LoadLibrary() explicitly gets GetProcAddress("DllMain") and then calls it.

这篇关于可以调用一个.exe的DllMain吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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