extract api functions from .dll

.paul.

Well-known member
Joined
May 22, 2007
Messages
212
Programming Experience
1-3
how can i query a dynamic link library + get a list of the functions, including declarations + constant declarations used?
 
Reflection. Here is an example to get public info about current assembly, should give you some indication what it's about, there a lot more information available and other ways of filtering. There is much info about reflection to find on web.
VB.NET:
'Imports System.Reflection

Using sw As IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter("assembly info.txt", False)
    Dim asm As Assembly = Me.GetType.Assembly
    sw.WriteLine(String.Format("Assembly name {0}", asm.GetName.Name))
    For Each t As Type In asm.GetExportedTypes
        sw.WriteLine(String.Format("Type name {0}", t.Name))
        For Each m As MethodInfo In t.GetMethods
            sw.WriteLine(String.Format("Method name {0}", m.Name))
            For Each p As ParameterInfo In m.GetParameters
                sw.WriteLine(String.Format("   Parameter name {0}, type {1}", p.Name, p.ParameterType.ToString))
            Next
        Next
        For Each p As PropertyInfo In t.GetProperties
            sw.WriteLine(String.Format("Property name {0}, type {1}", p.Name, p.PropertyType.ToString))
        Next
        For Each f As FieldInfo In t.GetFields
            sw.WriteLine(String.Format("Field name {0}, type {1}", f.Name, f.FieldType.ToString))
        Next
        sw.WriteLine()
    Next
End Using
 
actually that doesn't work with a lot of dlls, unless they contain an assembly manifest. what i want to write is something like the vb6 "Depends" tool
 
These dlls are probably not managed and not activex, ie libraries you can't reference with a VB.Net assembly, but only make declared function calls to.
 
Can't you use this Dependecy Walker tool to get the info you need?
 
i could but it displays a lot of information i don't want.
i'm trying to list all of the functions from a chosen dll
 
Command-line tool Link.exe (previously DumpBin.exe?) will list the exported function names, run it from Visual Studio command prompt, for example "link -dump -exports filename.dll", add "-out:fileout.txt" to save output to a file. If you run it on the .obj or .lib file with "-symbol" option it will also list decorated names that can be used with UndName.exe utility to get the full method definition including parameters.

The Win32 APIs to achieve this in code looks to be the Debug Help Library.
 
didn't notice this message.
can i run that command with system.diagnostics.process.start(etc)
i got some information from msdn forum, but i'm confused with that too
 
It needs some libraries available in Path, I could only run it from the Visual Studio Command Promt where the necessary environment paths have been set.
 
i just ran link.exe
it does what you said.
what i was thinking of writing is a utility that lists the functions, something like link does, from which i could extract the vb style API declarations.
so i'd have a browse button and an openfiledialog, then use link, manipulate the result and then display the API declarations in a rtf textbox.
but looking at the output from link, i wouldn't know where to start
 
Back
Top