mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 18:42:41 +01:00
trunk/branch integration: fix
This commit is contained in:
@@ -64,13 +64,17 @@ SharedLibraryImpl::~SharedLibraryImpl()
|
|||||||
|
|
||||||
void SharedLibraryImpl::loadImpl(const std::string& path)
|
void SharedLibraryImpl::loadImpl(const std::string& path)
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
if (_handle) throw LibraryAlreadyLoadedException(path);
|
if (_handle) throw LibraryAlreadyLoadedException(path);
|
||||||
_handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL);
|
int flags = RTLD_LAZY | RTLD_GLOBAL;
|
||||||
if (!_handle)
|
#if defined(RTLD_DEEPBIND)
|
||||||
{
|
flags |= RTLD_DEEPBIND;
|
||||||
const char* err = dlerror();
|
#endif
|
||||||
|
_handle = dlopen(path.c_str(), flags);
|
||||||
|
if (!_handle)
|
||||||
|
{
|
||||||
|
const char* err = dlerror();
|
||||||
throw LibraryLoadException(err ? std::string(err) : path);
|
throw LibraryLoadException(err ? std::string(err) : path);
|
||||||
}
|
}
|
||||||
_path = path;
|
_path = path;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/SharedLibrary_WIN32.h"
|
#include "Poco/SharedLibrary_WIN32.h"
|
||||||
|
#include "Poco/Path.h"
|
||||||
#include "Poco/UnWindows.h"
|
#include "Poco/UnWindows.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -57,12 +58,12 @@ SharedLibraryImpl::~SharedLibraryImpl()
|
|||||||
|
|
||||||
void SharedLibraryImpl::loadImpl(const std::string& path)
|
void SharedLibraryImpl::loadImpl(const std::string& path)
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
||||||
_handle = LoadLibraryA(path.c_str());
|
_handle = LoadLibraryA(path.c_str());
|
||||||
if (!_handle) throw LibraryLoadException(path);
|
if (!_handle) throw LibraryLoadException(path);
|
||||||
_path = path;
|
_path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include "Poco/SharedLibrary_WIN32U.h"
|
#include "Poco/SharedLibrary_WIN32U.h"
|
||||||
#include "Poco/UnicodeConverter.h"
|
#include "Poco/UnicodeConverter.h"
|
||||||
|
#include "Poco/Path.h"
|
||||||
#include "Poco/UnWindows.h"
|
#include "Poco/UnWindows.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -58,14 +59,19 @@ SharedLibraryImpl::~SharedLibraryImpl()
|
|||||||
|
|
||||||
void SharedLibraryImpl::loadImpl(const std::string& path)
|
void SharedLibraryImpl::loadImpl(const std::string& path)
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
if (_handle) throw LibraryAlreadyLoadedException(_path);
|
||||||
std::wstring upath;
|
DWORD flags(0);
|
||||||
UnicodeConverter::toUTF16(path, upath);
|
#if !defined(_WIN32_WCE)
|
||||||
_handle = LoadLibraryW(upath.c_str());
|
Path p(path);
|
||||||
if (!_handle) throw LibraryLoadException(path);
|
if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
|
||||||
_path = path;
|
#endif
|
||||||
|
std::wstring upath;
|
||||||
|
UnicodeConverter::toUTF16(path, upath);
|
||||||
|
_handle = LoadLibraryExW(upath.c_str(), 0, flags);
|
||||||
|
if (!_handle) throw LibraryLoadException(path);
|
||||||
|
_path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -92,11 +98,17 @@ void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
|
|||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
if (_handle)
|
if (_handle)
|
||||||
{
|
{
|
||||||
return (void*) GetProcAddress((HMODULE) _handle, name.c_str());
|
#if defined(_WIN32_WCE)
|
||||||
}
|
std::wstring uname;
|
||||||
else return 0;
|
UnicodeConverter::toUTF16(name, uname);
|
||||||
|
return (void*) GetProcAddressW((HMODULE) _handle, uname.c_str());
|
||||||
|
#else
|
||||||
|
return (void*) GetProcAddress((HMODULE) _handle, name.c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user