DLL Questions Series, 3

Posted on 2000-02-16
Last Modified: 2010-04-02
This is the second part of the series.
The Overview can be found at: 
The previous parts can be found at:

This question is not hard, but it can in my opinion grow into an interesting discussion.

"Polite" programmists will provide an .H file for there DLL, and also a .LIB file. But if one doesn't, and only ships out a .DLL file,

1) How does the potential user of a DLL know what exports can he use from this DLL?
2) How can he create a LIB from this DLL? (This was already discussed in Part 2 of the series, but since "nietod" couldn't name any specific utilities, I repeat the question here).
3) What other things must a DLL creator do in order to qualify for being "polite"?
Question by:Lescha
  • 6
  • 5

Author Comment

ID: 2529953
Oops, sorry... Naturally, it's the _third_ part of the series ;)
LVL 12

Expert Comment

ID: 2530066
Hi Lescha:

1) You can use QuickView (right-click on the DLL and select Quick View) for a list of exported function names if you do not have the .H file, otherwise the .H file descrive all you need to know.

2) If by .LIB you mean a compiled library, I am not sure if you can do this. If you mean a .DEF file containing the list of exports you can create this from the QuickView report.

3) A 'polite' DLL creator really just needs to ensure that a user of the DLL can acess the functions within it. To that end a .H file is really all that is required, though providing a .DEF/.LIB(?) file is a courtesy that allows easy setup of early bound DLLs.

Unfortunately, in the abscence of a .H file, a DLL is essentially useless if you cannot determine the arguments (from the author) for each function it contains. It is essentially not possible to determine the arguments from the DLL directly.

LVL 11

Expert Comment

ID: 2530519
I answered several questions about this issue.  URLs below, cut-n-paste in a forthcoming comments. 
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

LVL 11

Expert Comment

ID: 2530525
** Q.10032070 "View DLL's" (5 pts) **

> where I can obtain a free View DLL's (see for each *.DLL the functions with sintax, parameters, etc) ?

** Accepted Answer **

(Assuming a Win32 platform and C language)

You can get the list of names that a DLL exports but function parameters are a different thing.

The easiest way of getting the list of exported names is to QuickView the DLL.  QuickView comes with every Win32 platform so no need to look elswhere.

Look for the section "Export table" for the exported names.

Now, some issues:

1) How to determine if the name refers to a function or a variable?

Each entry in the export table has an address.  Look for the "Sections" part to see which section the address resides in.  The section's characteristics state if it contains executable code.

2) Why there are some entries without names?

A DLL can export functions by name or by ordinal number (or both).  Functions exported by ordinal number only need an import library or a DEF file to be called by name (you cannot infer the name from the DLL).

3) What about parameters?

Due to the way parameters are passed, you cannot infer the parameters from the DLL (unless it's C++).

However, sometimes you'll see entries like _FunctionName@8

That means that the function FunctionName() takes 8 bytes of paramteres.  There is no way (aside from disassembly) to know if it is two 4-byte longs, four 2-byte shorts, eight chars or any combination thereof (and I'm not even talking about pointers, floating point types or structs).

More than that, depending on the calling convention, the parameters may be pushed on the stack in a left-to-rigt order, right-to-left order or passed in registers.

If it's C++ code, the function name is mangled (compiler specific) and contains the number and types of the parameters in the name.
LVL 11

Expert Comment

ID: 2530531
** Q.10119315 "Getting Parameters to DLL functions" (10 pts) **

If I have a dll, with exported functions, but no .lib or .h file. Is it possible to work out what parameters thoses functions take, and therefore do a GetProcAddress.. and call them ?

any clues anyone ?

** Combined Answers **

The general answer is no.
If the DLL functions use the __stdcall convention, you can see how many BYTES the function expects to be pushed on the stack from it's name (the format is funcname@num).  Most arguments will be 32bit integers or pointers so you can guess the number of arguments as num/4.

Also, Borland C++ comes with an IMPLIB program that is supposed to generate import libraries from DLL files.

A brief search showed that it is downloadable from: Disks
(As part of the MASM package).

Author Comment

ID: 2532155
"rwilson": by .lib I mean a static library containing stubs of functions within the .dll. See discussion of this point in Part 2 of the Series.


For all:

I will increase the points for this question to 100 that will go to the Expert naming one of those utilities that "nietod" mentioned in Part 2: the one to create a .lib from .dll.

This question remains open, but I will post Part 4 shortly.

Author Comment

ID: 2532160
Adjusted points to 100

Author Comment

ID: 2532165
Oh, and for "alexo": this IMPLIB you mentioned for Borland C++, does it work also on .dll that is generated with Visual Studio?

If no, it's not quite relevant.
If yes, please lock the answer.
LVL 11

Expert Comment

ID: 2535082
It works with MS DLLs also.
Unfortunately the file is no longer there.  I'll search for a replacement...
LVL 11

Accepted Solution

alexo earned 100 total points
ID: 2535182
OK, Borland (Inprise) is giving away their C++ compiler.  AFAIK, implib is part of the package.  Even if not, sounds like a good deal to me.

Author Comment

ID: 2535954
Thanks to all the Experts who participated in answering:

"nietod", "alexo".

Next part will be posted shortly.

Author Comment

ID: 2535971
I forgot to mention the Expert named "rwilson". Sorry about that.

Closing question does not necessarily ends the discussion, so if anyone has anything to add - about politeness or other things - feel free to do that.

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question