我正在修复其他人的代码并注意到该人多次调用 LoadLibrary,如下所示:
LoadLibrary("C:\\Windows\\SysWOW64\\msjint40");
LoadLibrary("C:\\Windows\\SysWOW64\\msjtes40");
LoadLibrary("C:\\Windows\\SysWOW64\\expsrv");
这有什么意义呢?返回指针未保存!该程序稍后会调用一堆其他 DLL,这些 DLL 使用 MSJTES40 中的函数,但不在加载库的上下文中。
评论说 - “else preload to optimize”
,但程序的其余部分如何知道 DLL 的位置?
感谢您提供任何信息。
最佳答案
LoadLibrary
将指定的模块带入地址空间。库不能加载两次,所以这样做会导致预加载(加载的模块可能有其他依赖项),因此这可以看作是一种优化。对库的第二次调用(他们使用返回值的地方)应该更快完成。
If the specified module is a DLL that is not already loaded for the calling process, the system calls the DLL's DllMain function with the DLL_PROCESS_ATTACH value.
也来自文档。
Do not make assumptions about the operating system version based on a LoadLibrary call that searches for a DLL. If the application is running in an environment where the DLL is legitimately not present but a malicious version of the DLL is in the search path, the malicious version of the DLL may be loaded
假设硬编码 DLL 位置会使您的程序面临各种恶作剧!
关于c - LoadLibrary 调用,返回的指针未保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8822969/