updated boost on windows
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015-2017 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -8,11 +8,13 @@
|
||||
#ifndef BOOST_DLL_DETAIL_AGGRESSIVE_PTR_CAST_HPP
|
||||
#define BOOST_DLL_DETAIL_AGGRESSIVE_PTR_CAST_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/type_traits/is_member_pointer.hpp>
|
||||
@@ -20,7 +22,6 @@
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
#include <boost/type_traits/remove_pointer.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <cstring> // std::memcpy
|
||||
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 301)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef BOOST_DLL_DETAIL_CTOR_DTOR_HPP_
|
||||
#define BOOST_DLL_DETAIL_CTOR_DTOR_HPP_
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
@@ -46,7 +46,7 @@ struct constructor<Class(Args...)> {
|
||||
//! The allocating constructor. @warning May differ with the compiler. Use @ref constructor::call_allocating instead.
|
||||
allocating_t allocating;
|
||||
|
||||
//! Call the standard contructor
|
||||
//! Call the standard constructor
|
||||
void call_standard (Class * const ptr, Args...args){ (ptr->*standard)(static_cast<Args>(args)...); }
|
||||
|
||||
//! Call the deleting destructor
|
||||
@@ -91,7 +91,7 @@ struct destructor {
|
||||
//! The deleting destructor. @warning May differ with the compiler. Use @ref destructor::call_deallocating instead.
|
||||
deleting_t deleting;
|
||||
|
||||
//! Call the standard contructor
|
||||
//! Call the standard constructor
|
||||
void call_standard(Class * const ptr){ standard(ptr); }
|
||||
|
||||
//! Call the deleting destructor
|
||||
@@ -130,7 +130,7 @@ destructor<Class> load_dtor(Lib & lib, const mangled_storage_impl::dtor_sym & dt
|
||||
typedef typename destructor<Class>::standard_t standard_t;
|
||||
//@apolukhin That does NOT work this way with MSVC-14 x32 via memcpy. The x64 is different.
|
||||
//standard_t dtor = &lib.template get< typename boost::remove_pointer<standard_t>::type >(dt);
|
||||
void * buf = &lib.template get<int>(dt);
|
||||
void * buf = &lib.template get<unsigned char>(dt);
|
||||
standard_t dtor;
|
||||
std::memcpy(&dtor, &buf, sizeof(dtor));
|
||||
return destructor<Class>(dtor);
|
||||
@@ -152,12 +152,12 @@ constructor<Signature> load_ctor(Lib & lib, const mangled_storage_impl::ctor_sym
|
||||
{
|
||||
//the only way this works on mingw/win.
|
||||
//For some reason there is always an 0xA in the following poniter, which screws with the this pointer.
|
||||
void *buf = &lib.template get<int>(ct.C1);
|
||||
void *buf = &lib.template get<unsigned char>(ct.C1);
|
||||
std::memcpy(&s, &buf, sizeof(void*));
|
||||
}
|
||||
if (!ct.C3.empty())
|
||||
{
|
||||
void *buf = &lib.template get<int>(ct.C3);
|
||||
void *buf = &lib.template get<unsigned char>(ct.C3);
|
||||
std::memcpy(&a, &buf, sizeof(void*));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
#ifndef BOOST_DLL_DEMANGLE_SYMBOL_HPP_
|
||||
#define BOOST_DLL_DEMANGLE_SYMBOL_HPP_
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#if defined(BOOST_MSVC) || defined(BOOST_MSVC_FULL_VER)
|
||||
|
||||
@@ -88,7 +89,7 @@ inline std::string demangle_symbol(const char *mangled_name)
|
||||
|
||||
}
|
||||
|
||||
//for my personal convinience
|
||||
//for my personal convenience
|
||||
inline std::string demangle_symbol(const std::string& mangled_name)
|
||||
{
|
||||
return demangle_symbol(mangled_name.c_str());
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
explicit mangled_storage_base(library_info & li) : mangled_storage_base(li.symbols()) {}
|
||||
|
||||
explicit mangled_storage_base(
|
||||
const boost::filesystem::path& library_path,
|
||||
const boost::dll::fs::path& library_path,
|
||||
bool throw_if_not_native_format = true)
|
||||
: mangled_storage_base(library_info(library_path, throw_if_not_native_format).symbols())
|
||||
{
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
}
|
||||
|
||||
void load(library_info & li) { storage_.clear(); add_symbols(li.symbols()); };
|
||||
void load(const boost::filesystem::path& library_path,
|
||||
void load(const boost::dll::fs::path& library_path,
|
||||
bool throw_if_not_native_format = true)
|
||||
{
|
||||
storage_.clear();
|
||||
|
||||
@@ -36,7 +36,7 @@ class mangled_storage_impl : public mangled_storage_base
|
||||
{
|
||||
return get_name<Return>();
|
||||
}
|
||||
//function to remove preceeding 'class ' or 'struct ' if the are given in this format.
|
||||
//function to remove preceding 'class ' or 'struct ' if the are given in this format.
|
||||
|
||||
inline static void trim_typename(std::string & val);
|
||||
public:
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
void mangled_storage_impl::trim_typename(std::string & val)
|
||||
{
|
||||
//remove preceeding class or struct, because you might want to use a struct as class, et vice versa
|
||||
//remove preceding class or struct, because you might want to use a struct as class, et vice versa
|
||||
if (val.size() >= 6)
|
||||
{
|
||||
using namespace std;
|
||||
@@ -98,46 +98,48 @@ namespace parser
|
||||
{
|
||||
namespace x3 = spirit::x3;
|
||||
|
||||
auto ptr_rule_impl(std::integral_constant<std::size_t, 32>)
|
||||
inline auto ptr_rule_impl(std::integral_constant<std::size_t, 32>)
|
||||
{
|
||||
return -((-x3::space) >> "__ptr32");
|
||||
}
|
||||
auto ptr_rule_impl(std::integral_constant<std::size_t, 64>)
|
||||
inline auto ptr_rule_impl(std::integral_constant<std::size_t, 64>)
|
||||
{
|
||||
return -((-x3::space) >> "__ptr64");
|
||||
}
|
||||
|
||||
auto ptr_rule() { return ptr_rule_impl(std::integral_constant<std::size_t, sizeof(std::size_t)*8>());}
|
||||
inline auto ptr_rule() {
|
||||
return ptr_rule_impl(std::integral_constant<std::size_t, sizeof(std::size_t)*8>());
|
||||
}
|
||||
|
||||
auto const visibility = ("public:" | x3::lit("protected:") | "private:");
|
||||
auto const virtual_ = x3::space >> "virtual";
|
||||
auto const static_ = x3::space >> x3::lit("static") ;
|
||||
|
||||
auto const_rule_impl(true_type ) {return x3::space >> "const";};
|
||||
auto const_rule_impl(false_type) {return x3::eps;};
|
||||
inline auto const_rule_impl(true_type ) {return x3::space >> "const";};
|
||||
inline auto const_rule_impl(false_type) {return x3::eps;};
|
||||
template<typename T>
|
||||
auto const_rule() {using t = is_const<typename remove_reference<T>::type>; return const_rule_impl(t());}
|
||||
|
||||
auto volatile_rule_impl(true_type ) {return x3::space >> "volatile";};
|
||||
auto volatile_rule_impl(false_type) {return x3::eps;};
|
||||
inline auto volatile_rule_impl(true_type ) {return x3::space >> "volatile";};
|
||||
inline auto volatile_rule_impl(false_type) {return x3::eps;};
|
||||
template<typename T>
|
||||
auto volatile_rule() {using t = is_volatile<typename remove_reference<T>::type>; return volatile_rule_impl(t());}
|
||||
|
||||
|
||||
auto inv_const_rule_impl(true_type ) {return "const" >> x3::space ;};
|
||||
auto inv_const_rule_impl(false_type) {return x3::eps;};
|
||||
inline auto inv_const_rule_impl(true_type ) {return "const" >> x3::space ;};
|
||||
inline auto inv_const_rule_impl(false_type) {return x3::eps;};
|
||||
template<typename T>
|
||||
auto inv_const_rule() {using t = is_const<typename remove_reference<T>::type>; return inv_const_rule_impl(t());}
|
||||
|
||||
auto inv_volatile_rule_impl(true_type ) {return "volatile" >> x3::space;};
|
||||
auto inv_volatile_rule_impl(false_type) {return x3::eps;};
|
||||
inline auto inv_volatile_rule_impl(true_type ) {return "volatile" >> x3::space;};
|
||||
inline auto inv_volatile_rule_impl(false_type) {return x3::eps;};
|
||||
template<typename T>
|
||||
auto inv_volatile_rule() {using t = is_volatile<typename remove_reference<T>::type>; return inv_volatile_rule_impl(t());}
|
||||
|
||||
|
||||
auto reference_rule_impl(false_type, false_type) {return x3::eps;}
|
||||
auto reference_rule_impl(true_type, false_type) {return x3::space >>"&" ;}
|
||||
auto reference_rule_impl(false_type, true_type ) {return x3::space >>"&&" ;}
|
||||
inline auto reference_rule_impl(false_type, false_type) {return x3::eps;}
|
||||
inline auto reference_rule_impl(true_type, false_type) {return x3::space >>"&" ;}
|
||||
inline auto reference_rule_impl(false_type, true_type ) {return x3::space >>"&&" ;}
|
||||
|
||||
|
||||
template<typename T>
|
||||
@@ -158,7 +160,7 @@ namespace parser
|
||||
ptr_rule();
|
||||
}
|
||||
template<>
|
||||
auto type_rule<void>(const std::string &) { return x3::string("void"); };
|
||||
inline auto type_rule<void>(const std::string &) { return x3::string("void"); };
|
||||
|
||||
auto const cdecl_ = "__cdecl" >> x3::space;
|
||||
auto const stdcall = "__stdcall" >> x3::space;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -8,14 +8,16 @@
|
||||
#ifndef BOOST_DLL_DETAIL_POSIX_ELF_INFO_HPP
|
||||
#define BOOST_DLL_DETAIL_POSIX_ELF_INFO_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/dll/detail/x_info_interface.hpp>
|
||||
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
@@ -91,7 +93,7 @@ typedef Elf_Sym_template<boost::uint64_t> Elf64_Sym_;
|
||||
|
||||
template <class AddressOffsetT>
|
||||
class elf_info: public x_info_interface {
|
||||
boost::filesystem::ifstream& f_;
|
||||
std::ifstream& f_;
|
||||
|
||||
typedef boost::dll::detail::Elf_Ehdr_template<AddressOffsetT> header_t;
|
||||
typedef boost::dll::detail::Elf_Shdr_template<AddressOffsetT> section_t;
|
||||
@@ -111,7 +113,7 @@ class elf_info: public x_info_interface {
|
||||
BOOST_STATIC_CONSTANT(unsigned char, STV_PROTECTED_ = 3); /* Not preemptible, not exported */
|
||||
|
||||
public:
|
||||
static bool parsing_supported(boost::filesystem::ifstream& f) {
|
||||
static bool parsing_supported(std::ifstream& f) {
|
||||
const unsigned char magic_bytes[5] = {
|
||||
0x7f, 'E', 'L', 'F', sizeof(boost::uint32_t) == sizeof(AddressOffsetT) ? 1 : 2
|
||||
};
|
||||
@@ -128,7 +130,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
explicit elf_info(boost::filesystem::ifstream& f) BOOST_NOEXCEPT
|
||||
explicit elf_info(std::ifstream& f) BOOST_NOEXCEPT
|
||||
: f_(f)
|
||||
{}
|
||||
|
||||
@@ -186,14 +188,14 @@ private:
|
||||
if (section.sh_type == SHT_SYMTAB_) {
|
||||
symbols.resize(static_cast<std::size_t>(section.sh_size / sizeof(symbol_t)));
|
||||
|
||||
const boost::filesystem::ifstream::pos_type pos = f_.tellg();
|
||||
const std::ifstream::pos_type pos = f_.tellg();
|
||||
f_.seekg(section.sh_offset);
|
||||
read_raw(symbols[0], static_cast<std::size_t>(section.sh_size - (section.sh_size % sizeof(symbol_t))) );
|
||||
f_.seekg(pos);
|
||||
} else if (section.sh_type == SHT_STRTAB_) {
|
||||
text.resize(static_cast<std::size_t>(section.sh_size));
|
||||
|
||||
const boost::filesystem::ifstream::pos_type pos = f_.tellg();
|
||||
const std::ifstream::pos_type pos = f_.tellg();
|
||||
f_.seekg(section.sh_offset);
|
||||
read_raw(text[0], static_cast<std::size_t>(section.sh_size));
|
||||
f_.seekg(pos);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2016 Klemens D. Morgenstern
|
||||
// Copyright 2015-2018 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -8,13 +8,16 @@
|
||||
#ifndef BOOST_DLL_DETAIL_MACHO_INFO_HPP
|
||||
#define BOOST_DLL_DETAIL_MACHO_INFO_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/dll/detail/x_info_interface.hpp>
|
||||
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
@@ -155,7 +158,7 @@ typedef nlist_template<boost::uint64_t> nlist_64_;
|
||||
|
||||
template <class AddressOffsetT>
|
||||
class macho_info: public x_info_interface {
|
||||
boost::filesystem::ifstream& f_;
|
||||
std::ifstream& f_;
|
||||
|
||||
typedef boost::dll::detail::mach_header_template<AddressOffsetT> header_t;
|
||||
typedef boost::dll::detail::load_command_ load_command_t;
|
||||
@@ -167,7 +170,7 @@ class macho_info: public x_info_interface {
|
||||
BOOST_STATIC_CONSTANT(boost::uint32_t, SEGMENT_CMD_NUMBER = (sizeof(AddressOffsetT) > 4 ? load_command_types::LC_SEGMENT_64_ : load_command_types::LC_SEGMENT_));
|
||||
|
||||
public:
|
||||
static bool parsing_supported(boost::filesystem::ifstream& f) {
|
||||
static bool parsing_supported(std::ifstream& f) {
|
||||
static const uint32_t magic_bytes = (sizeof(AddressOffsetT) <= sizeof(uint32_t) ? 0xfeedface : 0xfeedfacf);
|
||||
|
||||
uint32_t magic;
|
||||
@@ -176,7 +179,7 @@ public:
|
||||
return (magic_bytes == magic);
|
||||
}
|
||||
|
||||
explicit macho_info(boost::filesystem::ifstream& f) BOOST_NOEXCEPT
|
||||
explicit macho_info(std::ifstream& f) BOOST_NOEXCEPT
|
||||
: f_(f)
|
||||
{}
|
||||
|
||||
@@ -192,16 +195,16 @@ private:
|
||||
load_command_t command;
|
||||
f_.seekg(sizeof(header_t));
|
||||
for (std::size_t i = 0; i < h.ncmds; ++i) {
|
||||
const boost::filesystem::ifstream::pos_type pos = f_.tellg();
|
||||
const std::ifstream::pos_type pos = f_.tellg();
|
||||
read_raw(command);
|
||||
if (command.cmd != cmd_num) {
|
||||
f_.seekg(pos + static_cast<boost::filesystem::ifstream::pos_type>(command.cmdsize));
|
||||
f_.seekg(pos + static_cast<std::ifstream::pos_type>(command.cmdsize));
|
||||
continue;
|
||||
}
|
||||
|
||||
f_.seekg(pos);
|
||||
callback_f(*this);
|
||||
f_.seekg(pos + static_cast<boost::filesystem::ifstream::pos_type>(command.cmdsize));
|
||||
f_.seekg(pos + static_cast<std::ifstream::pos_type>(command.cmdsize));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -8,13 +8,17 @@
|
||||
#ifndef BOOST_DLL_DETAIL_WINDOWS_PE_INFO_HPP
|
||||
#define BOOST_DLL_DETAIL_WINDOWS_PE_INFO_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/dll/detail/x_info_interface.hpp>
|
||||
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
@@ -25,13 +29,13 @@ namespace boost { namespace dll { namespace detail {
|
||||
// http://msdn.microsoft.com/en-us/magazine/cc301808.aspx
|
||||
//
|
||||
|
||||
// Basic Windows typedefs. We can not use <boost/detail/winapi/basic_types.hpp> header
|
||||
// Basic Windows typedefs. We can not use <boost/winapi/basic_types.hpp> header
|
||||
// because that header must be included only on Windows platform
|
||||
typedef unsigned char BYTE_;
|
||||
typedef unsigned short WORD_;
|
||||
typedef unsigned long DWORD_;
|
||||
typedef long LONG_;
|
||||
typedef unsigned long ULONG_;
|
||||
typedef boost::uint32_t DWORD_;
|
||||
typedef boost::int32_t LONG_;
|
||||
typedef boost::uint32_t ULONG_;
|
||||
typedef boost::int64_t LONGLONG_;
|
||||
typedef boost::uint64_t ULONGLONG_;
|
||||
|
||||
@@ -161,7 +165,7 @@ typedef IMAGE_NT_HEADERS_template<boost::dll::detail::ULONGLONG_> IMAGE_NT_HEAD
|
||||
|
||||
template <class AddressOffsetT>
|
||||
class pe_info: public x_info_interface {
|
||||
boost::filesystem::ifstream& f_;
|
||||
std::ifstream& f_;
|
||||
|
||||
typedef IMAGE_NT_HEADERS_template<AddressOffsetT> header_t;
|
||||
typedef IMAGE_EXPORT_DIRECTORY_ exports_t;
|
||||
@@ -174,7 +178,7 @@ class pe_info: public x_info_interface {
|
||||
}
|
||||
|
||||
public:
|
||||
static bool parsing_supported(boost::filesystem::ifstream& f) {
|
||||
static bool parsing_supported(std::ifstream& f) {
|
||||
dos_t dos;
|
||||
f.seekg(0);
|
||||
f.read(reinterpret_cast<char*>(&dos), sizeof(dos));
|
||||
@@ -193,7 +197,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
explicit pe_info(boost::filesystem::ifstream& f) BOOST_NOEXCEPT
|
||||
explicit pe_info(std::ifstream& f) BOOST_NOEXCEPT
|
||||
: f_(f)
|
||||
{}
|
||||
|
||||
@@ -370,15 +374,14 @@ public:
|
||||
MSVCR110D.dll
|
||||
*/
|
||||
/*
|
||||
std::vector<std::string> depend_of(boost::system::error_code &ec) BOOST_NOEXCEPT {
|
||||
std::vector<std::string> depend_of(boost::dll::fs::error_code &ec) BOOST_NOEXCEPT {
|
||||
std::vector<std::string> ret;
|
||||
|
||||
IMAGE_DOS_HEADER* image_dos_header = (IMAGE_DOS_HEADER*)native();
|
||||
if(!image_dos_header) {
|
||||
// ERROR_BAD_EXE_FORMAT
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::executable_format_error,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::executable_format_error
|
||||
);
|
||||
|
||||
return ret;
|
||||
@@ -387,9 +390,8 @@ public:
|
||||
IMAGE_OPTIONAL_HEADER* image_optional_header = (IMAGE_OPTIONAL_HEADER*)((boost::dll::detail::BYTE_*)native() + image_dos_header->e_lfanew + 24);
|
||||
if(!image_optional_header) {
|
||||
// ERROR_BAD_EXE_FORMAT
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::executable_format_error,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::executable_format_error
|
||||
);
|
||||
|
||||
return ret;
|
||||
@@ -398,9 +400,8 @@ public:
|
||||
IMAGE_IMPORT_DESCRIPTOR* image_import_descriptor = (IMAGE_IMPORT_DESCRIPTOR*)((boost::dll::detail::BYTE_*)native() + image_optional_header->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
|
||||
if(!image_import_descriptor) {
|
||||
// ERROR_BAD_EXE_FORMAT
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::executable_format_error,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::executable_format_error
|
||||
);
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Copyright 2014-2015 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2016-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -7,10 +8,9 @@
|
||||
#ifndef BOOST_DLL_DETAIL_POSIX_PATH_FROM_HANDLE_HPP
|
||||
#define BOOST_DLL_DETAIL_POSIX_PATH_FROM_HANDLE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#include <boost/dll/detail/system_error.hpp>
|
||||
#include <boost/dll/detail/posix/program_location_impl.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/predef/os.h>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
@@ -30,7 +30,7 @@ namespace boost { namespace dll { namespace detail {
|
||||
);
|
||||
}
|
||||
|
||||
inline boost::filesystem::path path_from_handle(void* handle, boost::system::error_code &ec) {
|
||||
inline boost::dll::fs::path path_from_handle(void* handle, boost::dll::fs::error_code &ec) {
|
||||
handle = strip_handle(handle);
|
||||
|
||||
// Iterate through all images currently in memory
|
||||
@@ -53,12 +53,11 @@ namespace boost { namespace dll { namespace detail {
|
||||
}
|
||||
|
||||
boost::dll::detail::reset_dlerror();
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::bad_file_descriptor,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::bad_file_descriptor
|
||||
);
|
||||
|
||||
return boost::filesystem::path();
|
||||
return boost::dll::fs::path();
|
||||
}
|
||||
|
||||
}}} // namespace boost::dll::detail
|
||||
@@ -79,12 +78,12 @@ namespace boost { namespace dll { namespace detail {
|
||||
// ... // Ignoring remaning parts of the structure
|
||||
};
|
||||
|
||||
inline boost::filesystem::path path_from_handle(const void* handle, boost::system::error_code &ec) {
|
||||
inline boost::dll::fs::path path_from_handle(const void* handle, boost::dll::fs::error_code &ec) {
|
||||
static const std::size_t work_around_b_24465209__offset = 128;
|
||||
const struct soinfo* si = reinterpret_cast<const struct soinfo*>(
|
||||
static_cast<const char*>(handle) + work_around_b_24465209__offset
|
||||
);
|
||||
boost::filesystem::path ret = boost::dll::symbol_location_ptr(si->base, ec);
|
||||
boost::dll::fs::path ret = boost::dll::symbol_location_ptr(si->base, ec);
|
||||
|
||||
if (ec) {
|
||||
ec.clear();
|
||||
@@ -120,7 +119,7 @@ namespace boost { namespace dll { namespace detail {
|
||||
};
|
||||
#endif // #if BOOST_OS_QNX
|
||||
|
||||
inline boost::filesystem::path path_from_handle(void* handle, boost::system::error_code &ec) {
|
||||
inline boost::dll::fs::path path_from_handle(void* handle, boost::dll::fs::error_code &ec) {
|
||||
// RTLD_DI_LINKMAP (RTLD_DI_ORIGIN returns only folder and is not suitable for this case)
|
||||
// Obtain the Link_map for the handle that is specified.
|
||||
// The p argument points to a Link_map pointer (Link_map
|
||||
@@ -145,19 +144,18 @@ namespace boost { namespace dll { namespace detail {
|
||||
#endif
|
||||
if (!link_map) {
|
||||
boost::dll::detail::reset_dlerror();
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::bad_file_descriptor,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::bad_file_descriptor
|
||||
);
|
||||
|
||||
return boost::filesystem::path();
|
||||
return boost::dll::fs::path();
|
||||
}
|
||||
|
||||
if (!link_map->l_name || *link_map->l_name == '\0') {
|
||||
return program_location_impl(ec);
|
||||
}
|
||||
|
||||
return boost::filesystem::path(link_map->l_name);
|
||||
return boost::dll::fs::path(link_map->l_name);
|
||||
}
|
||||
|
||||
}}} // namespace boost::dll::detail
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -8,9 +8,8 @@
|
||||
#ifndef BOOST_DLL_DETAIL_POSIX_PROGRAM_LOCATION_IMPL_HPP
|
||||
#define BOOST_DLL_DETAIL_POSIX_PROGRAM_LOCATION_IMPL_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#include <boost/dll/detail/system_error.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/predef/os.h>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
@@ -22,23 +21,22 @@
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
|
||||
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
|
||||
ec.clear();
|
||||
|
||||
char path[1024];
|
||||
uint32_t size = sizeof(path);
|
||||
if (_NSGetExecutablePath(path, &size) == 0)
|
||||
return boost::filesystem::path(path);
|
||||
|
||||
return boost::dll::fs::path(path);
|
||||
|
||||
char *p = new char[size];
|
||||
if (_NSGetExecutablePath(p, &size) != 0) {
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::bad_file_descriptor,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::bad_file_descriptor
|
||||
);
|
||||
}
|
||||
|
||||
boost::filesystem::path ret(p);
|
||||
boost::dll::fs::path ret(p);
|
||||
delete[] p;
|
||||
return ret;
|
||||
}
|
||||
@@ -48,10 +46,10 @@ namespace boost { namespace dll { namespace detail {
|
||||
|
||||
#include <stdlib.h>
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
inline boost::filesystem::path program_location_impl(boost::system::error_code& ec) {
|
||||
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code& ec) {
|
||||
ec.clear();
|
||||
|
||||
return boost::filesystem::path(getexecname());
|
||||
return boost::dll::fs::path(getexecname());
|
||||
}
|
||||
}}} // namespace boost::dll::detail
|
||||
|
||||
@@ -62,7 +60,7 @@ namespace boost { namespace dll { namespace detail {
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
inline boost::filesystem::path program_location_impl(boost::system::error_code& ec) {
|
||||
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code& ec) {
|
||||
ec.clear();
|
||||
|
||||
int mib[4];
|
||||
@@ -74,7 +72,7 @@ namespace boost { namespace dll { namespace detail {
|
||||
size_t cb = sizeof(buf);
|
||||
sysctl(mib, 4, buf, &cb, NULL, 0);
|
||||
|
||||
return boost::filesystem::path(buf);
|
||||
return boost::dll::fs::path(buf);
|
||||
}
|
||||
}}} // namespace boost::dll::detail
|
||||
|
||||
@@ -82,19 +80,18 @@ namespace boost { namespace dll { namespace detail {
|
||||
|
||||
#elif BOOST_OS_BSD_NET
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
|
||||
return boost::filesystem::read_symlink("/proc/curproc/exe", ec);
|
||||
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
|
||||
return boost::dll::fs::read_symlink("/proc/curproc/exe", ec);
|
||||
}
|
||||
}}} // namespace boost::dll::detail
|
||||
|
||||
#elif BOOST_OS_BSD_DRAGONFLY
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
|
||||
return boost::filesystem::read_symlink("/proc/curproc/file", ec);
|
||||
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
|
||||
return boost::dll::fs::read_symlink("/proc/curproc/file", ec);
|
||||
}
|
||||
}}} // namespace boost::dll::detail
|
||||
|
||||
@@ -103,7 +100,7 @@ namespace boost { namespace dll { namespace detail {
|
||||
#include <fstream>
|
||||
#include <string> // for std::getline
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
|
||||
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
|
||||
ec.clear();
|
||||
|
||||
std::string s;
|
||||
@@ -111,26 +108,24 @@ namespace boost { namespace dll { namespace detail {
|
||||
std::getline(ifs, s);
|
||||
|
||||
if (ifs.fail() || s.empty()) {
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::bad_file_descriptor,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::bad_file_descriptor
|
||||
);
|
||||
}
|
||||
|
||||
return boost::filesystem::path(s);
|
||||
return boost::dll::fs::path(s);
|
||||
}
|
||||
}}} // namespace boost::dll::detail
|
||||
|
||||
#else // BOOST_OS_LINUX || BOOST_OS_UNIX || BOOST_OS_HPUX || BOOST_OS_ANDROID
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
inline boost::filesystem::path program_location_impl(boost::system::error_code &ec) {
|
||||
inline boost::dll::fs::path program_location_impl(boost::dll::fs::error_code &ec) {
|
||||
// We can not use
|
||||
// boost::dll::detail::path_from_handle(dlopen(NULL, RTLD_LAZY | RTLD_LOCAL), ignore);
|
||||
// because such code returns empty path.
|
||||
|
||||
return boost::filesystem::read_symlink("/proc/self/exe", ec); // Linux specific
|
||||
return boost::dll::fs::read_symlink("/proc/self/exe", ec); // Linux specific
|
||||
}
|
||||
}}} // namespace boost::dll::detail
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015-2016 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -8,15 +8,13 @@
|
||||
#ifndef BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
|
||||
#define BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#include <boost/dll/shared_library_load_mode.hpp>
|
||||
#include <boost/dll/detail/posix/path_from_handle.hpp>
|
||||
#include <boost/dll/detail/posix/program_location_impl.hpp>
|
||||
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/swap.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/predef/os.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
@@ -48,7 +46,7 @@ public:
|
||||
~shared_library_impl() BOOST_NOEXCEPT {
|
||||
unload();
|
||||
}
|
||||
|
||||
|
||||
shared_library_impl(BOOST_RV_REF(shared_library_impl) sl) BOOST_NOEXCEPT
|
||||
: handle_(sl.handle_)
|
||||
{
|
||||
@@ -60,16 +58,26 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void load(boost::filesystem::path sl, load_mode::type mode, boost::system::error_code &ec) {
|
||||
|
||||
static boost::dll::fs::path decorate(const boost::dll::fs::path & sl) {
|
||||
boost::dll::fs::path actual_path = (
|
||||
std::strncmp(sl.filename().string().c_str(), "lib", 3)
|
||||
? boost::dll::fs::path((sl.has_parent_path() ? sl.parent_path() / L"lib" : L"lib").native() + sl.filename().native())
|
||||
: sl
|
||||
);
|
||||
actual_path += suffix();
|
||||
return actual_path;
|
||||
}
|
||||
|
||||
void load(boost::dll::fs::path sl, load_mode::type mode, boost::dll::fs::error_code &ec) {
|
||||
typedef int native_mode_t;
|
||||
unload();
|
||||
|
||||
// Do not allow opening NULL paths. User must use program_location() instead
|
||||
if (sl.empty()) {
|
||||
boost::dll::detail::reset_dlerror();
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::bad_file_descriptor,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::bad_file_descriptor
|
||||
);
|
||||
|
||||
return;
|
||||
@@ -90,8 +98,8 @@ public:
|
||||
}
|
||||
#else
|
||||
if (!sl.is_absolute() && !(mode & load_mode::search_system_folders)) {
|
||||
boost::system::error_code current_path_ec;
|
||||
boost::filesystem::path prog_loc = boost::filesystem::current_path(current_path_ec);
|
||||
boost::dll::fs::error_code current_path_ec;
|
||||
boost::dll::fs::path prog_loc = boost::dll::fs::current_path(current_path_ec);
|
||||
if (!current_path_ec) {
|
||||
prog_loc /= sl;
|
||||
sl.swap(prog_loc);
|
||||
@@ -105,18 +113,21 @@ public:
|
||||
if (!!(mode & load_mode::append_decorations)) {
|
||||
mode &= ~load_mode::append_decorations;
|
||||
|
||||
boost::filesystem::path actual_path = (
|
||||
std::strncmp(sl.filename().string().c_str(), "lib", 3)
|
||||
? (sl.has_parent_path() ? sl.parent_path() / L"lib" : L"lib").native() + sl.filename().native()
|
||||
: sl
|
||||
);
|
||||
actual_path += suffix();
|
||||
|
||||
boost::dll::fs::path actual_path = decorate(sl);
|
||||
handle_ = dlopen(actual_path.c_str(), static_cast<native_mode_t>(mode));
|
||||
if (handle_) {
|
||||
boost::dll::detail::reset_dlerror();
|
||||
return;
|
||||
}
|
||||
boost::dll::fs::error_code prog_loc_err;
|
||||
boost::dll::fs::path loc = boost::dll::detail::program_location_impl(prog_loc_err);
|
||||
if (boost::dll::fs::exists(actual_path) && !boost::dll::fs::equivalent(sl, loc, prog_loc_err)) {
|
||||
// decorated path exists : current error is not a bad file descriptor and we are not trying to load the executable itself
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::executable_format_error
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Opening by exactly specified path
|
||||
@@ -126,28 +137,26 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::bad_file_descriptor,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::bad_file_descriptor
|
||||
);
|
||||
|
||||
// Maybe user wanted to load the executable itself? Checking...
|
||||
// We assume that usually user wants to load a dynamic library not the executable itself, that's why
|
||||
// we try this only after traditional load fails.
|
||||
boost::system::error_code prog_loc_err;
|
||||
boost::filesystem::path loc = boost::dll::detail::program_location_impl(prog_loc_err);
|
||||
if (!prog_loc_err && boost::filesystem::equivalent(sl, loc, prog_loc_err) && !prog_loc_err) {
|
||||
// As is known the function dlopen() loads the dynamic library file
|
||||
// named by the null-terminated string filename and returns an opaque
|
||||
// "handle" for the dynamic library. If filename is NULL, then the
|
||||
boost::dll::fs::error_code prog_loc_err;
|
||||
boost::dll::fs::path loc = boost::dll::detail::program_location_impl(prog_loc_err);
|
||||
if (!prog_loc_err && boost::dll::fs::equivalent(sl, loc, prog_loc_err) && !prog_loc_err) {
|
||||
// As is known the function dlopen() loads the dynamic library file
|
||||
// named by the null-terminated string filename and returns an opaque
|
||||
// "handle" for the dynamic library. If filename is NULL, then the
|
||||
// returned handle is for the main program.
|
||||
ec.clear();
|
||||
boost::dll::detail::reset_dlerror();
|
||||
handle_ = dlopen(NULL, static_cast<native_mode_t>(mode));
|
||||
if (!handle_) {
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::bad_file_descriptor,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::bad_file_descriptor
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -170,11 +179,11 @@ public:
|
||||
boost::swap(handle_, rhs.handle_);
|
||||
}
|
||||
|
||||
boost::filesystem::path full_module_path(boost::system::error_code &ec) const {
|
||||
boost::dll::fs::path full_module_path(boost::dll::fs::error_code &ec) const {
|
||||
return boost::dll::detail::path_from_handle(handle_, ec);
|
||||
}
|
||||
|
||||
static boost::filesystem::path suffix() {
|
||||
static boost::dll::fs::path suffix() {
|
||||
// https://sourceforge.net/p/predef/wiki/OperatingSystems/
|
||||
#if BOOST_OS_MACOS || BOOST_OS_IOS
|
||||
return ".dylib";
|
||||
@@ -183,13 +192,12 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void* symbol_addr(const char* sb, boost::system::error_code &ec) const BOOST_NOEXCEPT {
|
||||
void* symbol_addr(const char* sb, boost::dll::fs::error_code &ec) const BOOST_NOEXCEPT {
|
||||
// dlsym - obtain the address of a symbol from a dlopen object
|
||||
void* const symbol = dlsym(handle_, sb);
|
||||
if (symbol == NULL) {
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::invalid_seek,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::invalid_seek
|
||||
);
|
||||
}
|
||||
|
||||
@@ -212,4 +220,3 @@ private:
|
||||
}}} // boost::dll::detail
|
||||
|
||||
#endif // BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -7,10 +8,8 @@
|
||||
#ifndef BOOST_DLL_SYSTEM_ERROR_HPP
|
||||
#define BOOST_DLL_SYSTEM_ERROR_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#include <boost/predef/os.h>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#if !BOOST_OS_WINDOWS
|
||||
@@ -30,12 +29,12 @@ namespace boost { namespace dll { namespace detail {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void report_error(const boost::system::error_code& ec, const char* message) {
|
||||
inline void report_error(const boost::dll::fs::error_code& ec, const char* message) {
|
||||
#if !BOOST_OS_WINDOWS
|
||||
const char* const error_txt = dlerror();
|
||||
if (error_txt) {
|
||||
boost::throw_exception(
|
||||
boost::system::system_error(
|
||||
boost::dll::fs::system_error(
|
||||
ec,
|
||||
message + std::string(" (dlerror system message: ") + error_txt + std::string(")")
|
||||
)
|
||||
@@ -44,7 +43,7 @@ namespace boost { namespace dll { namespace detail {
|
||||
#endif
|
||||
|
||||
boost::throw_exception(
|
||||
boost::system::system_error(
|
||||
boost::dll::fs::system_error(
|
||||
ec, message
|
||||
)
|
||||
);
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
|
||||
#include <typeinfo>
|
||||
#include <cstring>
|
||||
#include <boost/dll/config.hpp>
|
||||
#if defined(BOOST_MSVC) || defined(BOOST_MSVC_VER)
|
||||
#include <boost/winapi/basic_types.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
|
||||
@@ -23,11 +27,11 @@ const std::type_info& load_type_info(Lib & lib, Storage & storage)
|
||||
{
|
||||
struct RTTICompleteObjectLocator
|
||||
{
|
||||
boost::detail::winapi::DWORD_ signature; //always zero ?
|
||||
boost::detail::winapi::DWORD_ offset; //offset of this vtable in the complete class
|
||||
boost::detail::winapi::DWORD_ cdOffset; //constructor displacement offset
|
||||
boost::detail::winapi::DWORD_ pTypeDescriptorOffset; //TypeDescriptor of the complete class
|
||||
boost::detail::winapi::DWORD_ pClassDescriptorOffset; //describes inheritance hierarchy (ignored)
|
||||
boost::winapi::DWORD_ signature; //always zero ?
|
||||
boost::winapi::DWORD_ offset; //offset of this vtable in the complete class
|
||||
boost::winapi::DWORD_ cdOffset; //constructor displacement offset
|
||||
boost::winapi::DWORD_ pTypeDescriptorOffset; //TypeDescriptor of the complete class
|
||||
boost::winapi::DWORD_ pClassDescriptorOffset; //describes inheritance hierarchy (ignored)
|
||||
};
|
||||
|
||||
RTTICompleteObjectLocator** vtable_p = &lib.template get<RTTICompleteObjectLocator*>(storage.template get_vtable<Class>());
|
||||
@@ -50,9 +54,9 @@ const std::type_info& load_type_info(Lib & lib, Storage & storage)
|
||||
{
|
||||
struct RTTICompleteObjectLocator
|
||||
{
|
||||
boost::detail::winapi::DWORD_ signature; //always zero ?
|
||||
boost::detail::winapi::DWORD_ offset; //offset of this vtable in the complete class
|
||||
boost::detail::winapi::DWORD_ cdOffset; //constructor displacement offset
|
||||
boost::winapi::DWORD_ signature; //always zero ?
|
||||
boost::winapi::DWORD_ offset; //offset of this vtable in the complete class
|
||||
boost::winapi::DWORD_ cdOffset; //constructor displacement offset
|
||||
const std::type_info* pTypeDescriptor; //TypeDescriptor of the complete class
|
||||
void* pClassDescriptor; //describes inheritance hierarchy (ignored)
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -8,11 +8,10 @@
|
||||
#ifndef BOOST_DLL_DETAIL_WINDOWS_PATH_FROM_HANDLE_HPP
|
||||
#define BOOST_DLL_DETAIL_WINDOWS_PATH_FROM_HANDLE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#include <boost/dll/detail/system_error.hpp>
|
||||
#include <boost/detail/winapi/dll.hpp>
|
||||
#include <boost/detail/winapi/get_last_error.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/winapi/dll.hpp>
|
||||
#include <boost/winapi/get_last_error.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
@@ -20,40 +19,43 @@
|
||||
|
||||
namespace boost { namespace dll { namespace detail {
|
||||
|
||||
static inline boost::system::error_code last_error_code() BOOST_NOEXCEPT {
|
||||
boost::detail::winapi::DWORD_ err = boost::detail::winapi::GetLastError();
|
||||
return boost::system::error_code(
|
||||
err,
|
||||
boost::system::system_category()
|
||||
inline boost::dll::fs::error_code last_error_code() BOOST_NOEXCEPT {
|
||||
boost::winapi::DWORD_ err = boost::winapi::GetLastError();
|
||||
return boost::dll::fs::error_code(
|
||||
static_cast<int>(err),
|
||||
boost::dll::fs::system_category()
|
||||
);
|
||||
}
|
||||
|
||||
inline boost::filesystem::path path_from_handle(boost::detail::winapi::HMODULE_ handle, boost::system::error_code &ec) {
|
||||
BOOST_STATIC_CONSTANT(boost::detail::winapi::DWORD_, ERROR_INSUFFICIENT_BUFFER_ = 0x7A);
|
||||
BOOST_STATIC_CONSTANT(boost::detail::winapi::DWORD_, DEFAULT_PATH_SIZE_ = 260);
|
||||
inline boost::dll::fs::path path_from_handle(boost::winapi::HMODULE_ handle, boost::dll::fs::error_code &ec) {
|
||||
BOOST_STATIC_CONSTANT(boost::winapi::DWORD_, ERROR_INSUFFICIENT_BUFFER_ = 0x7A);
|
||||
BOOST_STATIC_CONSTANT(boost::winapi::DWORD_, DEFAULT_PATH_SIZE_ = 260);
|
||||
|
||||
// On success, GetModuleFileNameW() doesn't reset last error to ERROR_SUCCESS. Resetting it manually.
|
||||
boost::winapi::GetLastError();
|
||||
|
||||
// If `handle` parameter is NULL, GetModuleFileName retrieves the path of the
|
||||
// executable file of the current process.
|
||||
boost::detail::winapi::WCHAR_ path_hldr[DEFAULT_PATH_SIZE_];
|
||||
boost::detail::winapi::GetModuleFileNameW(handle, path_hldr, DEFAULT_PATH_SIZE_);
|
||||
ec = last_error_code();
|
||||
boost::winapi::WCHAR_ path_hldr[DEFAULT_PATH_SIZE_];
|
||||
boost::winapi::GetModuleFileNameW(handle, path_hldr, DEFAULT_PATH_SIZE_);
|
||||
ec = boost::dll::detail::last_error_code();
|
||||
if (!ec) {
|
||||
return boost::filesystem::path(path_hldr);
|
||||
return boost::dll::fs::path(path_hldr);
|
||||
}
|
||||
|
||||
for (unsigned i = 2; i < 1025 && static_cast<boost::detail::winapi::DWORD_>(ec.value()) == ERROR_INSUFFICIENT_BUFFER_; i *= 2) {
|
||||
for (unsigned i = 2; i < 1025 && static_cast<boost::winapi::DWORD_>(ec.value()) == ERROR_INSUFFICIENT_BUFFER_; i *= 2) {
|
||||
std::wstring p(DEFAULT_PATH_SIZE_ * i, L'\0');
|
||||
const std::size_t size = boost::detail::winapi::GetModuleFileNameW(handle, &p[0], DEFAULT_PATH_SIZE_ * i);
|
||||
ec = last_error_code();
|
||||
const std::size_t size = boost::winapi::GetModuleFileNameW(handle, &p[0], DEFAULT_PATH_SIZE_ * i);
|
||||
ec = boost::dll::detail::last_error_code();
|
||||
|
||||
if (!ec) {
|
||||
p.resize(size);
|
||||
return boost::filesystem::path(p);
|
||||
return boost::dll::fs::path(p);
|
||||
}
|
||||
}
|
||||
|
||||
// Error other than ERROR_INSUFFICIENT_BUFFER_ occurred or failed to allocate buffer big enough
|
||||
return boost::filesystem::path();
|
||||
// Error other than ERROR_INSUFFICIENT_BUFFER_ occurred or failed to allocate buffer big enough.
|
||||
return boost::dll::fs::path();
|
||||
}
|
||||
|
||||
}}} // namespace boost::dll::detail
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015-2016 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
|
||||
#define BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#include <boost/dll/shared_library_load_mode.hpp>
|
||||
#include <boost/dll/detail/aggressive_ptr_cast.hpp>
|
||||
#include <boost/dll/detail/system_error.hpp>
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/swap.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
#include <boost/detail/winapi/dll.hpp>
|
||||
#include <boost/winapi/dll.hpp>
|
||||
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
@@ -31,7 +29,7 @@ class shared_library_impl {
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(shared_library_impl)
|
||||
|
||||
public:
|
||||
typedef boost::detail::winapi::HMODULE_ native_handle_t;
|
||||
typedef boost::winapi::HMODULE_ native_handle_t;
|
||||
|
||||
shared_library_impl() BOOST_NOEXCEPT
|
||||
: handle_(NULL)
|
||||
@@ -40,7 +38,7 @@ public:
|
||||
~shared_library_impl() BOOST_NOEXCEPT {
|
||||
unload();
|
||||
}
|
||||
|
||||
|
||||
shared_library_impl(BOOST_RV_REF(shared_library_impl) sl) BOOST_NOEXCEPT
|
||||
: handle_(sl.handle_)
|
||||
{
|
||||
@@ -52,14 +50,20 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void load(boost::filesystem::path sl, load_mode::type mode, boost::system::error_code &ec) {
|
||||
typedef boost::detail::winapi::DWORD_ native_mode_t;
|
||||
static boost::dll::fs::path decorate(const boost::dll::fs::path& sl) {
|
||||
boost::dll::fs::path actual_path = sl;
|
||||
actual_path += suffix();
|
||||
return actual_path;
|
||||
}
|
||||
|
||||
void load(boost::dll::fs::path sl, load_mode::type mode, boost::dll::fs::error_code &ec) {
|
||||
typedef boost::winapi::DWORD_ native_mode_t;
|
||||
unload();
|
||||
|
||||
if (!sl.is_absolute() && !(mode & load_mode::search_system_folders)) {
|
||||
boost::dll::fs::error_code current_path_ec;
|
||||
boost::dll::fs::path prog_loc = boost::dll::fs::current_path(current_path_ec);
|
||||
|
||||
boost::system::error_code current_path_ec;
|
||||
boost::filesystem::path prog_loc = boost::filesystem::current_path(current_path_ec);
|
||||
if (!current_path_ec) {
|
||||
prog_loc /= sl;
|
||||
sl.swap(prog_loc);
|
||||
@@ -71,18 +75,17 @@ public:
|
||||
if (!!(mode & load_mode::append_decorations)) {
|
||||
mode &= ~load_mode::append_decorations;
|
||||
|
||||
handle_ = boost::detail::winapi::LoadLibraryExW((sl.native() + L".dll").c_str(), 0, static_cast<native_mode_t>(mode));
|
||||
if (!handle_) {
|
||||
// MinGW loves 'lib' prefix and puts it even on Windows platform
|
||||
const boost::filesystem::path load_path = (sl.has_parent_path() ? sl.parent_path() / L"lib" : L"lib").native() + sl.filename().native() + L".dll";
|
||||
handle_ = boost::detail::winapi::LoadLibraryExW(
|
||||
load_path.c_str(),
|
||||
0,
|
||||
static_cast<native_mode_t>(mode)
|
||||
);
|
||||
if (load_impl(decorate(sl), static_cast<native_mode_t>(mode), ec)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (handle_) {
|
||||
// MinGW loves 'lib' prefix and puts it even on Windows platform.
|
||||
const boost::dll::fs::path mingw_load_path = (
|
||||
sl.has_parent_path()
|
||||
? sl.parent_path() / L"lib"
|
||||
: L"lib"
|
||||
).native() + sl.filename().native() + suffix().native();
|
||||
if (load_impl(mingw_load_path, static_cast<native_mode_t>(mode), ec)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -95,14 +98,13 @@ public:
|
||||
// we have some path. So we do not check for path, only for extension. We can not be sure that
|
||||
// such behavior remain across all platforms, so we add L"." by hand.
|
||||
if (sl.has_extension()) {
|
||||
handle_ = boost::detail::winapi::LoadLibraryExW(sl.c_str(), 0, static_cast<native_mode_t>(mode));
|
||||
handle_ = boost::winapi::LoadLibraryExW(sl.c_str(), 0, static_cast<native_mode_t>(mode));
|
||||
} else {
|
||||
handle_ = boost::detail::winapi::LoadLibraryExW((sl.native() + L".").c_str(), 0, static_cast<native_mode_t>(mode));
|
||||
handle_ = boost::winapi::LoadLibraryExW((sl.native() + L".").c_str(), 0, static_cast<native_mode_t>(mode));
|
||||
}
|
||||
|
||||
// LoadLibraryExW method is capable of self loading from program_location() path. No special actions
|
||||
// must be taken to allow self loading.
|
||||
|
||||
if (!handle_) {
|
||||
ec = boost::dll::detail::last_error_code();
|
||||
}
|
||||
@@ -114,7 +116,7 @@ public:
|
||||
|
||||
void unload() BOOST_NOEXCEPT {
|
||||
if (handle_) {
|
||||
boost::detail::winapi::FreeLibrary(handle_);
|
||||
boost::winapi::FreeLibrary(handle_);
|
||||
handle_ = 0;
|
||||
}
|
||||
}
|
||||
@@ -123,22 +125,21 @@ public:
|
||||
boost::swap(handle_, rhs.handle_);
|
||||
}
|
||||
|
||||
boost::filesystem::path full_module_path(boost::system::error_code &ec) const {
|
||||
boost::dll::fs::path full_module_path(boost::dll::fs::error_code &ec) const {
|
||||
return boost::dll::detail::path_from_handle(handle_, ec);
|
||||
}
|
||||
|
||||
static boost::filesystem::path suffix() {
|
||||
static boost::dll::fs::path suffix() {
|
||||
return L".dll";
|
||||
}
|
||||
|
||||
void* symbol_addr(const char* sb, boost::system::error_code &ec) const BOOST_NOEXCEPT {
|
||||
void* symbol_addr(const char* sb, boost::dll::fs::error_code &ec) const BOOST_NOEXCEPT {
|
||||
if (is_resource()) {
|
||||
// `GetProcAddress` could not be called for libraries loaded with
|
||||
// `LOAD_LIBRARY_AS_DATAFILE`, `LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE`
|
||||
// or `LOAD_LIBRARY_AS_IMAGE_RESOURCE`.
|
||||
ec = boost::system::error_code(
|
||||
boost::system::errc::operation_not_supported,
|
||||
boost::system::generic_category()
|
||||
ec = boost::dll::fs::make_error_code(
|
||||
boost::dll::fs::errc::operation_not_supported
|
||||
);
|
||||
|
||||
return NULL;
|
||||
@@ -148,7 +149,7 @@ public:
|
||||
// there is no version for UNICODE on desktop/server Windows, because
|
||||
// names of functions are stored in narrow characters.
|
||||
void* const symbol = boost::dll::detail::aggressive_ptr_cast<void*>(
|
||||
boost::detail::winapi::get_proc_address(handle_, sb)
|
||||
boost::winapi::get_proc_address(handle_, sb)
|
||||
);
|
||||
if (symbol == NULL) {
|
||||
ec = boost::dll::detail::last_error_code();
|
||||
@@ -162,9 +163,26 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
// Returns true if this load attempt should be the last one.
|
||||
bool load_impl(const boost::dll::fs::path &load_path, boost::winapi::DWORD_ mode, boost::dll::fs::error_code &ec) {
|
||||
handle_ = boost::winapi::LoadLibraryExW(load_path.c_str(), 0, mode);
|
||||
if (handle_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ec = boost::dll::detail::last_error_code();
|
||||
if (boost::dll::fs::exists(load_path)) {
|
||||
// decorated path exists : current error is not a bad file descriptor
|
||||
return true;
|
||||
}
|
||||
|
||||
ec.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_resource() const BOOST_NOEXCEPT {
|
||||
return false; /*!!(
|
||||
reinterpret_cast<boost::detail::winapi::ULONG_PTR_>(handle_) & static_cast<boost::detail::winapi::ULONG_PTR_>(3)
|
||||
reinterpret_cast<boost::winapi::ULONG_PTR_>(handle_) & static_cast<boost::winapi::ULONG_PTR_>(3)
|
||||
);*/
|
||||
}
|
||||
|
||||
@@ -174,4 +192,3 @@ private:
|
||||
}}} // boost::dll::detail
|
||||
|
||||
#endif // BOOST_DLL_SHARED_LIBRARY_IMPL_HPP
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
|
||||
// Copyright 2015 Antony Polukhin.
|
||||
// Copyright 2015-2019 Antony Polukhin.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef BOOST_DLL_DETAIL_X_INFO_INTERFACE_HPP
|
||||
#define BOOST_DLL_DETAIL_X_INFO_INTERFACE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/dll/config.hpp>
|
||||
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user