aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp')
-rw-r--r--contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp b/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp
new file mode 100644
index 0000000000..b4f697ea0a
--- /dev/null
+++ b/contrib/libs/poco/Foundation/src/SharedLibrary_WIN32U.cpp
@@ -0,0 +1,121 @@
+//
+// SharedLibrary_WIN32U.cpp
+//
+// Library: Foundation
+// Package: SharedLibrary
+// Module: SharedLibrary
+//
+// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/SharedLibrary_WIN32U.h"
+#include "Poco/UnicodeConverter.h"
+#include "Poco/Path.h"
+#include "Poco/UnWindows.h"
+
+
+namespace Poco {
+
+
+FastMutex SharedLibraryImpl::_mutex;
+
+
+SharedLibraryImpl::SharedLibraryImpl()
+{
+ _handle = 0;
+}
+
+
+SharedLibraryImpl::~SharedLibraryImpl()
+{
+}
+
+
+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;
+}
+
+
+void SharedLibraryImpl::unloadImpl()
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle)
+ {
+ FreeLibrary((HMODULE) _handle);
+ _handle = 0;
+ }
+ _path.clear();
+}
+
+
+bool SharedLibraryImpl::isLoadedImpl() const
+{
+ return _handle != 0;
+}
+
+
+void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
+{
+ FastMutex::ScopedLock lock(_mutex);
+
+ if (_handle)
+ {
+#if defined(_WIN32_WCE)
+ std::wstring uname;
+ 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;
+}
+
+
+const std::string& SharedLibraryImpl::getPathImpl() const
+{
+ return _path;
+}
+
+
+std::string SharedLibraryImpl::suffixImpl()
+{
+#if defined(_DEBUG) && !defined(POCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX)
+ return "d.dll";
+#else
+ return ".dll";
+#endif
+}
+
+
+bool SharedLibraryImpl::setSearchPathImpl(const std::string& path)
+{
+#if _WIN32_WINNT >= 0x0502
+ std::wstring wpath;
+ Poco::UnicodeConverter::toUTF16(path, wpath);
+ return SetDllDirectoryW(wpath.c_str()) != 0;
+#else
+ return false;
+#endif
+}
+
+
+} // namespace Poco