expdef - def file generator
Updated: 2011-10-07 15:10:39
If you found mistake, simply select it
and press Control+Enter
and press Control+Enter
EXPDEF is a small utility that generates module definition file for Windows DLL.
IntroductionThis is a problem to staticaly link your Win32 project in Visual Studio with DLL if your haven't import library for this DLL. Microsoft provides command line tool LIB.EXE that can create such import library if your have corresponding module definition (.DEF) file, but there is no standard ways to create .DEF file.
Overview of DEF file syntaxThe basic syntax of .DEF file in part that describes exported functions is listed below.
LIBRARY mylib.dll EXPORTS ; entryname[=internalname] [@ordinal [NONAME]] [DATA] [PRIVATE] entryname entryname @ordinal entryname=internalname
- mylib.dll - DLL name to which our library references. Note that that this name can be different from library name. if your create your import library with MyCoolImportLibrary.LIB, and use LIBRARY mylib.dll in MyCoolImportLibrary.DEF then your application will require mylib.DLL and not MyCoolImportLibrary.DLL.
- entryname - public name of exported function
- internalname - internal private name of function
- ordinal - some integer index whith which function is exported, using NONAME means that function will be exported only by ordinal without name
Using DUMPBINMicrosoft provides the command line utility DUMPBIN.EXE that helps to obtain the list of exported symbols for the DLL. Sample output from DUMPBIN.EXE is listed below.
>DUMPBIN /EXPORTS mylib.dll Microsoft (R) COFF Binary File Dumper Version 6.00.8168 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. Dump of file mylib.dll File Type: DLL ... ordinal hint RVA name 1994 0 000012A0 ACCESS_DESCRIPTION_free 2751 1 00001230 ACCESS_DESCRIPTION_it 1925 2 00001280 ACCESS_DESCRIPTION_new ...
SolutionThe format of .DLL (and other PE files) described in WinNT.h from Microsoft SDK and we can write our own utility that reads DLL and generates .DEF.
Using expdef and lib toolsSample of EXPDEF usage in conjuction with Microsoft LIB tool is listed below. Note: to call LIB tool you need it to be in PATH environment variable. You can set up PATH and other environment to right way by calling vsvars32.bat, which is typicaly in C:\Program Files\Microsoft Visual Studio 8\Common7\Tools directory (for Visual Studio 2005).
>EXPDEF.EXE -p -o mylib.dll >mylib.def >LIB.EXE /VERBOSE /MACHINE:IX86 /DEF:mylib.def Microsoft (R) Library Manager Version 6.00.8168 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. Creating library mylib.lib and object mylib.exp
Overview of expdef command line switchesYour can list all supported command line switches using expdef /? to see help screen in listing above.
Usage: expdef [-v] [-dname] [-l] [-p] [-o] [-u] [-r] [-f] filename.dll Where: -v - verbose output -dname - output def file name (stdout used if not taken) -l - invoke LIB tool automaticaly (requires -d option) -p - print ordinals -o - order by ordinals -u - create underscored aliases -r - create ununderscored aliases (remove underscore if present) -f - use filename instead of internal module name
- -p - puts functions ordinals into .DEF file.
- -o - order list of functions by ordinal value (default order is as is in original .DLL).
- -u - create aliases for functions: _FUNCTION_NAME=FUNCTION_NAME.
- -r - opposite to -u - remove underscores if they are present.
- -f - by default, to generate LIBRARY mylib.dll expression used internal module name, which is hardwired in it. Real file name of DLL can be different from internal, and in some cases we need to refer to real name instead of internal.
Source codeSource code of expdef utility to view it online can be found here.
|Name||Last modified||Size||Hash MD5/SHA1|
|expdef.exe||2011-09-30||176.0 KB||50548909517f65dc9acc1a4bfbc53cf6 / 6b3f8b1a40b9fb2d855f5d78e73a9585022fb312|
|expdef.zip||2011-09-30||84.8 KB||5d6d734e916dda6b8e1a7a93e875faa9 / 700a780747772345a84f97328320dae2df3a4750|
|expdef_src.zip||2011-09-30||2.0 KB||0b2b0c79cbf43153ba64e7d844867507 / 0727db2e6a4b2e42106a96b91d7e6f3843c44ad6|