tags:

views:

78

answers:

2
LIBRARY     Vcam.ax
EXPORTS
            DllMain                 PRIVATE
            DllGetClassObject       PRIVATE
            DllCanUnloadNow         PRIVATE
            DllRegisterServer       PRIVATE
            DllUnregisterServer     PRIVATE

The above is from Filters.def, what does it actually do?

+1  A: 

See MSDN:

Module-Definition (.def) Files

Exporting from a DLL Using DEF Files

About PRIVATE, they say this:

The optional keyword PRIVATE prevents entryname from being placed in the import library generated by LINK. It has no effect on the export in the image also generated by LINK.

In other words, those functions are hidden from the DLL's table of entry points and reserved for the OS.

Potatoswatter
Why's `.def` necessary,isn't `.h` enough?
@u: You wouldn't want to export every little function in the program.
Potatoswatter
.h files are for source code at compiletime. .def files are for other programs at runtime.
DeadMG
+1  A: 

The .def file on Win32 describes what functions get exported from a DLL. Unlike with .so files on gcc/Linux, where every symbol gets exported by default, you have to tell the compiler what functions to export. The standard way is to list it in a .def file. The other way is to use __declspec(dllexport) with Visual C++ (where using decorated function names would be no fun to use).

There are some keywords to place after the function name; you can speficy an ordinal number, that it shouldn't be exported by name (good for hiding your function names), or that it is private.

The documentation on MSDN describes the complete format:
Module-Definition (.def) Files

vividos
`.def` doesn't affect the size of `.dll`, is it right?
The .def file is packaged within the .dll. However, the reality is that the .def file's size is trivial compared to the .dll's compiled size.
DeadMG
The .def file isn't "linked in", it's more of an instruction for the linker which functions to include in the export table of the DLL. In a way the .def file can affect the size of a DLL: When a function isn't exported by the .def file, and the /OPT:REF option is used to remove unused functions and data, and the function isn't used from inside the DLL, then the linker might decide to not include the function altogether. See this link for the /OPT switch:http://msdn.microsoft.com/en-us/library/bxwfs976%28VS.80%29.aspx
vividos