summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-14 21:50:52 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-14 21:50:52 +0300
commita6b0d0df4854ffda2577e2b61844467253eb9e0f (patch)
treea5effd9ddd4a259c874bf0ba641802a28f0d308b
parent593550b8eea8998c3b6b9e9eb3e04eec82854ae2 (diff)
adaptation of GetFileInformationByHandleEx for Windows XP
-rw-r--r--plugins/Dbx_mdbx/src/libmdbx/src/osal.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/plugins/Dbx_mdbx/src/libmdbx/src/osal.c b/plugins/Dbx_mdbx/src/libmdbx/src/osal.c
index 8466b8f7e6..344a76c9bb 100644
--- a/plugins/Dbx_mdbx/src/libmdbx/src/osal.c
+++ b/plugins/Dbx_mdbx/src/libmdbx/src/osal.c
@@ -19,6 +19,8 @@
#if defined(_WIN32) || defined(_WIN64)
#include <winternl.h>
+typedef BOOL (WINAPI *pfnGetFileInformationByHandleEx)(HANDLE, FILE_INFO_BY_HANDLE_CLASS, LPVOID, DWORD);
+
static int waitstatus2errcode(DWORD result) {
switch (result) {
case WAIT_OBJECT_0:
@@ -780,14 +782,15 @@ int mdbx_mmap(int flags, mdbx_mmap_t *map, size_t size, size_t limit) {
if (GetFileType(map->fd) != FILE_TYPE_DISK)
return ERROR_FILE_OFFLINE;
- FILE_REMOTE_PROTOCOL_INFO RemoteProtocolInfo;
- if (GetFileInformationByHandleEx(map->fd, FileRemoteProtocolInfo,
- &RemoteProtocolInfo,
- sizeof(RemoteProtocolInfo))) {
- if ((RemoteProtocolInfo.Flags & (REMOTE_PROTOCOL_INFO_FLAG_LOOPBACK |
- REMOTE_PROTOCOL_INFO_FLAG_OFFLINE)) !=
- REMOTE_PROTOCOL_INFO_FLAG_LOOPBACK)
- return ERROR_FILE_OFFLINE;
+ pfnGetFileInformationByHandleEx pfunc = (pfnGetFileInformationByHandleEx)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetFileInformationByHandleEx");
+ if (pfunc) {
+ FILE_REMOTE_PROTOCOL_INFO RemoteProtocolInfo;
+ if (pfunc(map->fd, FileRemoteProtocolInfo,
+ &RemoteProtocolInfo,
+ sizeof(RemoteProtocolInfo))) {
+ if ((RemoteProtocolInfo.Flags & (REMOTE_PROTOCOL_INFO_FLAG_LOOPBACK | REMOTE_PROTOCOL_INFO_FLAG_OFFLINE)) != REMOTE_PROTOCOL_INFO_FLAG_LOOPBACK)
+ return ERROR_FILE_OFFLINE;
+ }
}
#if defined(_WIN64) && defined(WOF_CURRENT_VERSION)