Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out which dlls an executable will load?

Tags:

executable

dll

If I have a Windows executable, how can I find out which dlls it will load?

I'm just talking about which ones that will be loaded statically, not ones it might load dynamically with something like LoadLibrary.

like image 213
David Norman Avatar asked Jan 24 '09 00:01

David Norman


People also ask

How does exe find DLL?

If the DLL is listed in the Windows registry in the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\KnownDLLs key, Windows searches for the DLL in the following locations in order: The %SystemRoot%\SYSTEM32 directory. The .exe file directory. The current directory.

How do I list registered DLLs?

To view all the registered DLLs you can use the following free utilities: RegDllView is a tool to view registered dll/ocx/exe files on your system and can also Register dll files from Explorer. ListDLLs is another tool that reports the DLLs loaded into processes.


7 Answers

dumpbin is a tool that comes with VC++.

To see what DLLs a program will import:

  • Open Visual Studio
  • Menu Item Tools | Visual Studio Command prompt
  • cd to folder containing executable
  • dumpbin /dependents whatever.exe
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 

To see what functions (and DLLs) it will import, use

C:\> dumpbin /imports whatever.exe 
like image 163
Graeme Perrow Avatar answered Sep 21 '22 19:09

Graeme Perrow


There are utilities that will do this for you.

In the past I've used the MS tool (depends.exe) that came with (I think) VB.:
VS2010 VS2012 VS2013 VS2015 Current

and there's this as well:
http://dependencywalker.com/

and probably others as well.

like image 39
gkrogers Avatar answered Sep 17 '22 19:09

gkrogers


Open the command prompt and then type below command

tasklist /m /fi "imagename eq netbeans.exe"

Type instead netbeans.exe whatever name your exe file name.

like image 27
LOKESH Avatar answered Sep 19 '22 19:09

LOKESH


Dependency Walker can help you determine which .dll will be loaded.

like image 31
David Segonds Avatar answered Sep 20 '22 19:09

David Segonds


Just go to the command prompt and type tasklist /m, you will see the list of dll files used by specific program.

like image 29
Subek Shakya Avatar answered Sep 19 '22 19:09

Subek Shakya


Solution for Microsoft .Net:

foreach (AssemblyName a in Assembly.ReflectionOnlyLoadFrom("SAMPLE.EXE").GetReferencedAssemblies()) 
{
    MessageBox.Show(a.Name); 
}
like image 24
htc Avatar answered Sep 18 '22 19:09

htc


There is a handy tool called NDepend that will give you all DLL dependencies.

like image 44
FlySwat Avatar answered Sep 21 '22 19:09

FlySwat