1 // Copyright 2016 Klemens Morgenstern, Antony Polukhin
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org
9 #ifndef BOOST_DLL_DETAIL_TYPE_INFO_HPP_
10 #define BOOST_DLL_DETAIL_TYPE_INFO_HPP_
15 namespace boost { namespace dll { namespace detail {
17 #if defined(BOOST_MSVC) || defined(BOOST_MSVC_VER)
19 #if defined ( _WIN64 )
21 template<typename Class, typename Lib, typename Storage>
22 const std::type_info& load_type_info(Lib & lib, Storage & storage)
24 struct RTTICompleteObjectLocator
26 boost::detail::winapi::DWORD_ signature; //always zero ?
27 boost::detail::winapi::DWORD_ offset; //offset of this vtable in the complete class
28 boost::detail::winapi::DWORD_ cdOffset; //constructor displacement offset
29 boost::detail::winapi::DWORD_ pTypeDescriptorOffset; //TypeDescriptor of the complete class
30 boost::detail::winapi::DWORD_ pClassDescriptorOffset; //describes inheritance hierarchy (ignored)
33 RTTICompleteObjectLocator** vtable_p = &lib.template get<RTTICompleteObjectLocator*>(storage.template get_vtable<Class>());
36 auto vtable = *vtable_p;
38 auto nat = reinterpret_cast<const char*>(lib.native());
40 nat += vtable->pTypeDescriptorOffset;
42 return *reinterpret_cast<const std::type_info*>(nat);
48 template<typename Class, typename Lib, typename Storage>
49 const std::type_info& load_type_info(Lib & lib, Storage & storage)
51 struct RTTICompleteObjectLocator
53 boost::detail::winapi::DWORD_ signature; //always zero ?
54 boost::detail::winapi::DWORD_ offset; //offset of this vtable in the complete class
55 boost::detail::winapi::DWORD_ cdOffset; //constructor displacement offset
56 const std::type_info* pTypeDescriptor; //TypeDescriptor of the complete class
57 void* pClassDescriptor; //describes inheritance hierarchy (ignored)
60 RTTICompleteObjectLocator** vtable_p = &lib.template get<RTTICompleteObjectLocator*>(storage.template get_vtable<Class>());
63 auto vtable = *vtable_p;
64 return *vtable->pTypeDescriptor;
72 template<typename Class, typename Lib, typename Storage>
73 const std::type_info& load_type_info(Lib & lib, Storage & storage)
75 return lib.template get<const std::type_info>(storage.template get_type_info<Class>());
83 #endif /* BOOST_DLL_DETAIL_TYPE_INFO_HPP_ */