MakeDef : Intelligent DEF file Generator for Win32 Apps | CodeGuru

MakeDef : Intelligent DEF file Generator for Win32 Apps

The tool I want to post is a DEF-file generator for people who want to use import by ordinals in large projects. The problem is that you should manually process the output of the DUMPBIN.EXE or similar utility and then manually edit large DEF-files. Another problem is that you should keep old ordinal numbers untouched […]

Written By
CodeGuru Staff
CodeGuru Staff
Jan 5, 2000
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

The tool I want to post is a DEF-file generator for people who
want to use import by ordinals in large projects. The problem is that you
should manually process the output of the DUMPBIN.EXE or similar utility and
then manually edit large DEF-files. Another problem is that you should keep old
ordinal numbers untouched to provide backward compatibility with older
versions of your DLLs.

This utility uses a DEF-file and a binary module (usually a DLL) on
input. If DEF-file does not exists MakeDef creates an empty one, otherwise
DEF-file is opened in append-only mode (old contents remain unchanged anyway).
MakeDef reads the DEF-file and compares its contents with the DLL’s export
table. Any differences would be recorded to the end of the DEF file with
ordinal values greater than the maximum value used before. It guarantees that
the newly added exports would not ever conflict with previous versions of DLL.
All added exports have the NONAME attribute to strip them from the export
table. It will significantly reduce the size of your DLLs, but you would not
able to load such exports using LoadLibrary() function, so be careful.

Another working mode of MakeDef is _import_ table scanning. It’s useful in
the following situation: you have an EXE (or several EXE modules) and want to
export from the DLL only those functions which are really used in the EXE
file(s). In this case MakeDef would scan an import table of an EXE file and
store any differences in the DEF file, allowing linker to make correct export
table in the DLL.

MakeDef is a console mode utility suitable to use in makefiles and batch
builds. The utility itself is very little (8704 bytes), only MSVCRT.DLL is
required. It returns the various ERRORLEVELs to signal the processing results:

































ERRORLEVEL

Meaning

0

Ok, but there were no new exports

1

Ok, and there were new exports written to the DEF file

100

Temporary file creation error

101

Incorrect format of the DEF-file

102

Incorrect DLL/EXE name

103

Missing or corrupted DOS header

104

Missing or corrupted PE image header

105

Invalid PE image (internal error while processing)

106

Invalid parameters

The command line syntax is:

>MAKEDEF /DEF:<def_file_name> /IMAGE:<exe_or_dll_name> /IMPORTS:<dll_name>

Where:

  • /DEF specifies the name of the DEF-file to process
  • /IMAGE – the name of binary file to synchronize
  • The optional /IMPORTS parameter turns on import
    table scanning instead of export table processing (the default mode).
  • The <dll_name> part of the /IMPORTS directive specifies the DLL name, whose
    exports would be processed.

    Downloads

    Download Tool – 4 Kb

  • CodeGuru Logo

    CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

    Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

    Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.