Home

Awesome

Overview

Dumplib is a helper tool to create import libraries (.lib files) with correct extern "C" name decorations for x86 PE files compiled by MSVC. (This means not x64 because x64 files do not have decorated export names; for x64, see Remarks below.) Its main use is to allow creating import libraries for DLLs for which no import library is available, and to customize existing import libraries, e.g. to remove unwanted exports that cause linker collisions.

Dumplib mostly just applies a bunch of regexes and hacks. Most of the actual work is done by dumpbin.exe which generates the export listing dumplib parses. Executing dumplib generates three files:

Usage

  1. Create an export listing of the target file using the x86 version of dumpbin. To do so, open a 'VS2017 x86 Native Tools Command Prompt' (or similar depending on your version). Note the part that says x86, this is important because each tool invoked from this prompt will generate a different (wrong) output in x64 mode. Assuming you want to create an import library for ucrtbase.dll, execute dumpbin /EXPORTS ucrtbase.dll > ucrtbase-exports.txt.
  2. Execute dumplib ucrtbase-exports.txt ucrtbase.dll. The second argument supplies the name of the executable to be generated, which will usually be the same as the original, but can be changed if desired.
  3. Depending on the size and complexity of your file, you may see a number of warnings scroll by. If you missed the part that said to open an x86 prompt, this number will be large. Otherwise, take note of what, if anything, was not parsed correctly so you can make manual fixups later if needed.
  4. The aforementioned three files (.cpp, .def, .bat) should now be present in the directory. You can edit these to remove any declarations you don't want. Removing the declaration from the .def file is sufficient for this.
  5. Once you are done, open the .bat file in notepad to modify the first path to point to the same batch file you used to open the VS command prompt. The other filenames and paths should already be correct.
  6. Run the .bat file.
  7. There should now be an output directory (to prevent accidental overwriting of the input files) containing your import library and DLL.

Remarks