From a6b0d0df4854ffda2577e2b61844467253eb9e0f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 14 Jan 2018 21:50:52 +0300 Subject: adaptation of GetFileInformationByHandleEx for Windows XP --- plugins/Dbx_mdbx/src/libmdbx/src/osal.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'plugins/Dbx_mdbx') 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 +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) -- cgit v1.2.3