File indexing completed on 2025-01-18 09:30:44
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_DLL_DETAIL_TYPE_INFO_HPP_
0010 #define BOOST_DLL_DETAIL_TYPE_INFO_HPP_
0011
0012 #include <typeinfo>
0013 #include <cstring>
0014 #include <boost/dll/config.hpp>
0015 #if defined(_MSC_VER)
0016 #include <boost/winapi/basic_types.hpp>
0017 #endif
0018
0019 namespace boost { namespace dll { namespace detail {
0020
0021 #if defined(_MSC_VER)
0022
0023 #if defined ( _WIN64 )
0024
0025 template<typename Class, typename Lib, typename Storage>
0026 const std::type_info& load_type_info(Lib & lib, Storage & storage)
0027 {
0028 struct RTTICompleteObjectLocator
0029 {
0030 boost::winapi::DWORD_ signature;
0031 boost::winapi::DWORD_ offset;
0032 boost::winapi::DWORD_ cdOffset;
0033 boost::winapi::DWORD_ pTypeDescriptorOffset;
0034 boost::winapi::DWORD_ pClassDescriptorOffset;
0035 };
0036
0037 RTTICompleteObjectLocator** vtable_p = &lib.template get<RTTICompleteObjectLocator*>(storage.template get_vtable<Class>());
0038
0039 vtable_p--;
0040 auto vtable = *vtable_p;
0041
0042 auto nat = reinterpret_cast<const char*>(lib.native());
0043
0044 nat += vtable->pTypeDescriptorOffset;
0045
0046 return *reinterpret_cast<const std::type_info*>(nat);
0047
0048 }
0049
0050 #else
0051
0052 template<typename Class, typename Lib, typename Storage>
0053 const std::type_info& load_type_info(Lib & lib, Storage & storage)
0054 {
0055 struct RTTICompleteObjectLocator
0056 {
0057 boost::winapi::DWORD_ signature;
0058 boost::winapi::DWORD_ offset;
0059 boost::winapi::DWORD_ cdOffset;
0060 const std::type_info* pTypeDescriptor;
0061 void* pClassDescriptor;
0062 };
0063
0064 RTTICompleteObjectLocator** vtable_p = &lib.template get<RTTICompleteObjectLocator*>(storage.template get_vtable<Class>());
0065
0066 vtable_p--;
0067 auto vtable = *vtable_p;
0068 return *vtable->pTypeDescriptor;
0069
0070 }
0071
0072 #endif
0073
0074 #else
0075
0076 template<typename Class, typename Lib, typename Storage>
0077 const std::type_info& load_type_info(Lib & lib, Storage & storage)
0078 {
0079 return lib.template get<const std::type_info>(storage.template get_type_info<Class>());
0080
0081 }
0082
0083 #endif
0084
0085
0086 }}}
0087 #endif