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 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

  • More by Author

    Must Read