How to understand .def files?
LIBRARY Vcam.ax
EXPORTS
DllMain PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterSer开发者_开发知识库ver PRIVATE
The above is from Filters.def
, what does it actually do?
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.
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
精彩评论