mdbx: workaround for NtExtendSection() on Wine.

This fixes https://github.com/erthink/libmdbx/issues/83

Change-Id: I8e00aa91c86348fad9dbe4285143671d9cb3f802
This commit is contained in:
Leo Yuriev 2020-02-17 22:40:38 +03:00
parent d1173a1596
commit 60a6560a3b
3 changed files with 12 additions and 6 deletions

View File

@ -717,6 +717,7 @@ static uint64_t WINAPI stub_GetTickCount64(void) {
/*----------------------------------------------------------------------------*/
#ifndef MDBX_ALLOY
MDBX_NtExtendSection mdbx_NtExtendSection;
MDBX_GetFileInformationByHandleEx mdbx_GetFileInformationByHandleEx;
MDBX_GetVolumeInformationByHandleW mdbx_GetVolumeInformationByHandleW;
MDBX_GetFinalPathNameByHandleW mdbx_GetFinalPathNameByHandleW;
@ -775,4 +776,6 @@ static void mdbx_winnt_import(void) {
const HINSTANCE hNtdll = GetModuleHandleA("ntdll.dll");
mdbx_NtFsControlFile =
(MDBX_NtFsControlFile)GetProcAddress(hNtdll, "NtFsControlFile");
mdbx_NtExtendSection =
(MDBX_NtExtendSection)GetProcAddress(hNtdll, "NtExtendSection");
}

View File

@ -67,11 +67,6 @@ typedef struct _SECTION_BASIC_INFORMATION {
LARGE_INTEGER SectionSize;
} SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION;
extern NTSTATUS NTAPI NtExtendSection(IN HANDLE SectionHandle,
IN PLARGE_INTEGER NewSectionSize);
typedef enum _SECTION_INHERIT { ViewShare = 1, ViewUnmap = 2 } SECTION_INHERIT;
extern NTSTATUS NTAPI NtMapViewOfSection(
IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress,
IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize,
@ -1404,8 +1399,10 @@ MDBX_INTERNAL_FUNC int mdbx_mresize(int flags, mdbx_mmap_t *map, size_t size,
if (!(flags & MDBX_RDONLY) && limit == map->limit && size > map->current) {
/* growth rw-section */
if (!mdbx_NtExtendSection)
return ERROR_CALL_NOT_IMPLEMENTED /* workaround for Wine */;
SectionSize.QuadPart = size;
status = NtExtendSection(map->section, &SectionSize);
status = mdbx_NtExtendSection(map->section, &SectionSize);
if (!NT_SUCCESS(status))
return ntstatus2errcode(status);
map->current = size;

View File

@ -849,6 +849,12 @@ typedef DWORD(WINAPI *MDBX_OfferVirtualMemory(
MDBX_INTERNAL_VAR MDBX_OfferVirtualMemory mdbx_OfferVirtualMemory;
#endif /* unused for now */
typedef enum _SECTION_INHERIT { ViewShare = 1, ViewUnmap = 2 } SECTION_INHERIT;
typedef NTSTATUS(NTAPI *MDBX_NtExtendSection)(IN HANDLE SectionHandle,
IN PLARGE_INTEGER NewSectionSize);
MDBX_INTERNAL_VAR MDBX_NtExtendSection mdbx_NtExtendSection;
#endif /* Windows */
/*----------------------------------------------------------------------------*/