added SharedLibrary::setSearchPath(); set minimum required Windows version to XP SP2 (0x0502)

This commit is contained in:
Günter Obiltschnig 2019-08-17 10:04:16 +02:00
parent d6de752356
commit 13552f7bb7
14 changed files with 75 additions and 14 deletions

View File

@ -119,12 +119,12 @@
#endif
#define _WIN32_WINNT WINVER
#elif !defined(_WIN32_WINNT)
// last resort = Win XP, SP1 is minimum supported
#define _WIN32_WINNT 0x0501
// last resort = Win XP, SP2 is minimum supported
#define _WIN32_WINNT 0x0502
#ifdef NTDDI_VERSION
#undef NTDDI_VERSION
#endif
#define NTDDI_VERSION 0x05010100
#define NTDDI_VERSION 0x05020000
#endif
#endif // POCO_FORCE_MIN_WINDOWS_OS_SUPPORT

View File

@ -122,6 +122,16 @@ public:
/// (e.g., "d.so", "d.dll") unless the library has
/// been compiled with -DPOCO_NO_SHARED_LIBRARY_DEBUG_SUFFIX.
static bool setSearchPath(const std::string& path);
/// Adds the given path to the list of paths shared libraries
/// are searched in.
///
/// Returns true if the path was set, otherwise false.
///
/// Currently only supported on Windows, where it calls
/// SetDllDirectory(). On all other platforms, does not
/// do anything and returns false.
private:
SharedLibrary(const SharedLibrary&);
SharedLibrary& operator = (const SharedLibrary&);

View File

@ -37,6 +37,7 @@ protected:
void* findSymbolImpl(const std::string& name);
const std::string& getPathImpl() const;
static std::string suffixImpl();
static bool setSearchPathImpl(const std::string& path);
private:
std::string _path;

View File

@ -31,7 +31,7 @@ protected:
enum Flags
{
SHLIB_GLOBAL_IMPL = 1,
SHLIB_LOCAL_IMPL = 2
SHLIB_LOCAL_IMPL = 2
};
SharedLibraryImpl();
@ -42,6 +42,7 @@ protected:
void* findSymbolImpl(const std::string& name);
const std::string& getPathImpl() const;
static std::string suffixImpl();
static bool setSearchPathImpl(const std::string& path);
private:
std::string _path;

View File

@ -37,6 +37,7 @@ protected:
void* findSymbolImpl(const std::string& name);
const std::string& getPathImpl() const;
static std::string suffixImpl();
static bool setSearchPathImpl(const std::string& path);
private:
std::string _path;

View File

@ -36,6 +36,7 @@ protected:
void* findSymbolImpl(const std::string& name);
const std::string& getPathImpl() const;
static std::string suffixImpl();
static bool setSearchPathImpl(const std::string& path);
private:
std::string _path;

View File

@ -36,6 +36,7 @@ protected:
void* findSymbolImpl(const std::string& name);
const std::string& getPathImpl() const;
static std::string suffixImpl();
static bool setSearchPathImpl(const std::string& path);
private:
std::string _path;

View File

@ -58,11 +58,11 @@
#if !defined(_WIN32_WCE)
#if defined(_WIN32_WINNT)
#if (_WIN32_WINNT < 0x0501)
#if (_WIN32_WINNT < 0x0502)
#error Unsupported Windows version.
#endif
#elif defined(NTDDI_VERSION)
#if (NTDDI_VERSION < 0x05010100)
#if (NTDDI_VERSION < 0x05020000)
#error Unsupported Windows version.
#endif
#elif !defined(_WIN32_WINNT)
@ -73,8 +73,8 @@
// best to determine the appropriate values
// and may redefine these. See Platform_WIN32.h
// for details.
#define _WIN32_WINNT 0x0501
#define NTDDI_VERSION 0x05010100
#define _WIN32_WINNT 0x0502
#define NTDDI_VERSION 0x05020000
#endif
#endif

View File

@ -106,4 +106,10 @@ std::string SharedLibrary::suffix()
}
bool SharedLibrary::setSearchPath(const std::string& path)
{
return setSearchPathImpl(path);
}
} // namespace Poco

View File

@ -59,7 +59,7 @@ void SharedLibraryImpl::unloadImpl()
bool SharedLibraryImpl::isLoadedImpl() const
{
return _handle != 0;
return _handle != 0;
}
@ -91,4 +91,10 @@ std::string SharedLibraryImpl::suffixImpl()
}
bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
{
return false;
}
} // namespace Poco

View File

@ -74,7 +74,7 @@ void SharedLibraryImpl::unloadImpl()
bool SharedLibraryImpl::isLoadedImpl() const
{
return _handle != 0;
return _handle != 0;
}
@ -127,4 +127,10 @@ std::string SharedLibraryImpl::suffixImpl()
}
bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
{
return false;
}
} // namespace Poco

View File

@ -99,14 +99,14 @@ void SharedLibraryImpl::unloadImpl()
bool SharedLibraryImpl::isLoadedImpl() const
{
return _moduleId != 0;
return _moduleId != 0;
}
void* SharedLibraryImpl::findSymbolImpl(const std::string& name)
{
poco_assert (_moduleId != 0);
FastMutex::ScopedLock lock(_mutex);
MODULE_INFO mi;
@ -132,4 +132,10 @@ std::string SharedLibraryImpl::suffixImpl()
}
bool SharedLibraryImpl::setSearchPathImpl(const std::string&)
{
return false;
}
} // namespace Poco

View File

@ -63,7 +63,7 @@ void SharedLibraryImpl::unloadImpl()
bool SharedLibraryImpl::isLoadedImpl() const
{
return _handle != 0;
return _handle != 0;
}
@ -95,4 +95,14 @@ std::string SharedLibraryImpl::suffixImpl()
}
bool SharedLibraryImpl::setSearchPathImpl(const std::string& path)
{
#if _WIN32_WINNT >= 0x0502
return SetDllDirectoryA(path.c_str()) != 0;
#else
return false;
#endif
}
} // namespace Poco

View File

@ -68,7 +68,7 @@ void SharedLibraryImpl::unloadImpl()
bool SharedLibraryImpl::isLoadedImpl() const
{
return _handle != 0;
return _handle != 0;
}
@ -106,4 +106,16 @@ std::string SharedLibraryImpl::suffixImpl()
}
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