sumit
sumit

Reputation: 2151

How to view DLL functions?

I have a DLL file. How can I view the functions in that DLL?

Upvotes: 215

Views: 550845

Answers (12)

Jeromy Adofo
Jeromy Adofo

Reputation: 205

You can use gendef tool (also part of the MinGW-w64 toolchain).

To display exported symbols from a DLL on STDOUT:

gendef - mysharedlib.dll

To generate a .def file from a DLL:

gendef mysharedlib.dll

Upvotes: 1

Rainb
Rainb

Reputation: 2465

Here is a free,cli,portable software solution! Works on Linux,Windows,Mac OS

Provided that you have python.

you need to install pefile, no dependencies pip install pefile or pacman -S ${MINGW_PACKAGE_PREFIX}-python-pefile if you are in msys2

import pefile

def list_exports(file_path):
    pe = pefile.PE(file_path)
    # Check if the PE file has an export directory
    if hasattr(pe, 'DIRECTORY_ENTRY_EXPORT'):
        exports = []
        for exp in pe.DIRECTORY_ENTRY_EXPORT.symbols:
            export_dict = {
                'Address': hex(pe.OPTIONAL_HEADER.ImageBase + exp.address),
                'Name': exp.name.decode() if exp.name else '',
                'Ordinal': exp.ordinal
            }
            exports.append(export_dict)
        return exports
    else:
        return None

# Usage
file_path = r"C:\Windows\System32\bcrypt.dll"  # Replace with your file path
exports = list_exports(file_path)
if exports:
    for export in exports:
        print(f"Address: {export['Address']} Name: {export['Name']} Ordinal: {export['Ordinal']}")
else:
    print("No exports found.")

Upvotes: 2

detunized
detunized

Reputation: 15299

For native code it's probably best to use Dependency Walker. It's also possible to use the dumpbin command line utility that comes with Visual Studio.

Upvotes: 98

Robert Brisita
Robert Brisita

Reputation: 5844

For non .NET dlls, installing binutils on a Linux system presents the objdump command that can be used to display information of a dll.

objdump --private-headers <file.dll>

Look for the Export Address Table section in the output.

Upvotes: 6

cslewy
cslewy

Reputation: 676

You may try the Object Browser in Visual Studio.

Select Edit Custom Component Set. From there, you can choose from a variety of .NET, COM or project libraries or just import external DLLs via Browse.

Upvotes: 56

gwt
gwt

Reputation: 2423

If a DLL is written in one of the .NET languages and if you only want to view what functions, there is a reference to this DLL in the project.

Then doubleclick the DLL in the references folder and then you will see what functions it has in the OBJECT EXPLORER window.

If you would like to view the source code of that DLL file you can use a decompiler application such as .NET reflector.

Upvotes: 2

Adriaan Stander
Adriaan Stander

Reputation: 166506

Without telling us what language this DLL/assembly is from, we can only guess.

So how about .NET Reflector.

Upvotes: 7

grizlyk
grizlyk

Reputation: 1

.NET ildasm

ildasm helped and even dumped methods body, but to edit .DLL you also need any hex editor.

ildasm example to fix Help Viewer v2.x issue:
error: "An error occurred while updating content: File '???.cab' was not signed by Microsoft"

here could be image
more example files

Upvotes: 0

jmcarter9t
jmcarter9t

Reputation: 823

Use dumpbin command-line.

  • dumpbin /IMPORTS <path-to-file> should provide the function imported into that DLL.
  • dumpbin /EXPORTS <path-to-file> should provide the functions it exports.

Upvotes: 55

Shayan
Shayan

Reputation: 867

Use dotPeek by JetBrains.

https://www.jetbrains.com/decompiler/

dotPeek is a free tool based on ReSharper. It can reliably decompile any .NET assembly into C# or IL code.

Upvotes: 14

altumano
altumano

Reputation: 2735

For .NET DLLs you can use ildasm

Upvotes: 15

Ken D
Ken D

Reputation: 5968

Use the free DLL Export Viewer, it is very easy to use.

Upvotes: 72

Related Questions