boostorg / dll

Library for comfortable work with DLL and DSO
https://boost.org/libs/dll
52 stars 43 forks source link

Fix an assertion when a DLL doesn't export any public symbols at all #40

Closed Naios closed 4 years ago

Naios commented 4 years ago

Can be reproduced with any shared library on Windows that was built from an empty source file, for example with the following .dll: example.dll.zip.

h.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT_].VirtualAddress evaluates to 0 in such cases and thus real_offset becomes 0 which triggers the assertion below.

https://github.com/boostorg/dll/blob/ab379539806956b4113050ebb978615a4f6a09f0/include/boost/dll/detail/pe_info.hpp#L217

apolukhin commented 4 years ago

Many thanks for the fix! Added some tests in 4740f758dbd79b6f4278b0fef300139b94162b6f