Beispiel #1
0
void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
{
	FastMutex::ScopedLock lock(_mutex);

	if (!_path.empty()) throw LibraryAlreadyLoadedException(path);
	_path = path;
}
void SharedLibraryImpl::loadImpl(const std::string& path)
{
	FastMutex::ScopedLock lock(_mutex);

	if (_handle) throw LibraryAlreadyLoadedException(path);
	_handle = shl_load(path.c_str(), BIND_DEFERRED, 0);
	if (!_handle) throw LibraryLoadException(path);
	_path = path;
}
void SharedLibraryImpl::loadImpl(const std::string& path)
{
	FastMutex::ScopedLock lock(_mutex);

	if (_handle) throw LibraryAlreadyLoadedException(_path);
	DWORD flags(0);
	Path p(path);
	if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
	_handle = LoadLibraryExA(path.c_str(), 0, flags);
	if (!_handle) throw LibraryLoadException(path);
	_path = path;
}
Beispiel #4
0
void SharedLibraryImpl::loadImpl(const std::string& path)
{
	FastMutex::ScopedLock lock(_mutex);

	if (_handle) throw LibraryAlreadyLoadedException(path);
	_handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL);
	if (!_handle)
	{
		const char* err = dlerror();
		throw LibraryLoadException(err ? std::string(err) : path);
	}
	_path = path;
}
Beispiel #5
0
void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
{
	FastMutex::ScopedLock lock(_mutex);

	if (_handle) throw LibraryAlreadyLoadedException(_path);
	DWORD flags(0);
#if !defined(_WIN32_WCE)
	Path p(path);
	if (p.isAbsolute()) flags |= LOAD_WITH_ALTERED_SEARCH_PATH;
#endif
	std::wstring upath;
	UnicodeConverter::toUTF16(path, upath);
	_handle = LoadLibraryExW(upath.c_str(), 0, flags);
	if (!_handle) throw LibraryLoadException(path);
	_path = path;
}
Beispiel #6
0
void SharedLibraryImpl::loadImpl(const std::string& path, int flags)
{
	FastMutex::ScopedLock lock(_mutex);

	if (_handle) throw LibraryAlreadyLoadedException(path);
	int realFlags = RTLD_LAZY;
	if (flags & SHLIB_LOCAL_IMPL)
		realFlags |= RTLD_LOCAL;
	else
		realFlags |= RTLD_GLOBAL;
	_handle = dlopen(path.c_str(), realFlags);
	if (!_handle)
	{
		const char* err = dlerror();
		throw LibraryLoadException(err ? std::string(err) : path);
	}
	_path = path;
}
Beispiel #7
0
void SharedLibraryImpl::loadImpl(const std::string& path, int /*flags*/)
{
    FastMutex::ScopedLock lock(_mutex);

    if (_moduleId) throw LibraryAlreadyLoadedException(path);
    int fd = open(const_cast<char*>(path.c_str()), O_RDONLY, 0);
    if (fd)
    {
        _moduleId = loadModule(fd, LOAD_GLOBAL_SYMBOLS);
        if (!_moduleId)
        {
            int err = errno;
            close(fd);
            throw LibraryLoadException(Poco::format("error %d", err));
        }
    }
    else
    {
        int err = errno;
        throw LibraryLoadException(Poco::format("cannot open library (error %d)", err));
    }
    _path = path;
}