如果我有一个 Windows 可执行文件,我如何找出它将加载哪些 dll?
我只是在谈论哪些将静态加载,而不是可能使用 LoadLibrary 之类的动态加载。
dumpbin是 VC++ 自带的一个工具。
要查看程序将导入哪些 DLL:
Dump of file whatever.exe File Type: EXECUTABLE IMAGE Image has the following dependencies: AIOUSB.DLL sqlite3.dll wxmsw293u_core_vc_custom.dll wxbase293u_vc_custom.dll KERNEL32.dll ole32.dll OLEAUT32.dll MSVCP90.dll MSVCR90.dll
要查看它将导入哪些函数(和 DLL),请使用
C:\> dumpbin /imports whatever.exe
打开命令提示符,然后键入以下命令
任务列表 /m /fi "imagename eq netbeans.exe"
键入 netbeans.exe,无论您的 exe 文件名如何。
Dependency Walker可以帮助您确定将加载哪个 .dll。
只需转到命令提示符并键入tasklist /m
,您将看到特定程序使用的 dll 文件列表。
Microsoft .Net 的解决方案:
foreach (AssemblyName a in Assembly.ReflectionOnlyLoadFrom("SAMPLE.EXE").GetReferencedAssemblies())
{
MessageBox.Show(a.Name);
}
progfr 简单实用:[ http://members.fortunecity.com/michaelmoser/tip11.htm]
有一个名为 NDepend 的方便工具,它将为您提供所有 DLL 依赖项。
Dependencies - 一个开源的现代 Dependency Walker显示 Windows 可执行文件将加载哪些 DLL,并且它在现代 Windows 10 中运行良好。
它不如Dependency Walker强大,但后者可能会或可能不会在 Windows 10 中工作,因为它最后一次更新是在 2006 年。(较新版本的 Dependency Walker 与 Windows 10 的某些版本的 Windows Development Kit 捆绑在一起,但不是更多。)
Process Explorer 随附 SysInternals Suite https://docs.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite
好处:允许探索已经运行的进程(我还没有找到将依赖walker附加到现有进程的方法)