From 91a9d4d91605d7f36717abdd74547c56f3e5b1ce Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Mon, 25 Dec 2017 18:31:59 +0300 Subject: [PATCH] mdbx: more ntpapi for Windows. Change-Id: I616b09502302be9e3017db7e99cf4dcf8697f32f --- src/osal.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/osal.c b/src/osal.c index 1068fc27..263b1c1a 100644 --- a/src/osal.c +++ b/src/osal.c @@ -1,4 +1,4 @@ -/* https://en.wikipedia.org/wiki/Operating_system_abstraction_layer */ +/* https://en.wikipedia.org/wiki/Operating_system_abstraction_layer */ /* * Copyright 2015-2017 Leonid Yuriev @@ -61,6 +61,24 @@ extern NTSTATUS NTAPI NtCreateSection( IN OPTIONAL PLARGE_INTEGER MaximumSize, IN ULONG SectionPageProtection, IN ULONG AllocationAttributes, IN OPTIONAL HANDLE FileHandle); +typedef struct _SECTION_BASIC_INFORMATION { + ULONG Unknown; + ULONG SectionAttributes; + LARGE_INTEGER SectionSize; +} SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION; + +typedef enum _SECTION_INFORMATION_CLASS { + SectionBasicInformation, + SectionImageInformation, + SectionRelocationInformation, // name:wow64:whNtQuerySection_SectionRelocationInformation + MaxSectionInfoClass +} SECTION_INFORMATION_CLASS; + +extern NTSTATUS NTAPI NtQuerySection( + IN HANDLE SectionHandle, IN SECTION_INFORMATION_CLASS InformationClass, + OUT PVOID InformationBuffer, IN ULONG InformationBufferSize, + OUT PULONG ResultLength OPTIONAL); + extern NTSTATUS NTAPI NtExtendSection(IN HANDLE SectionHandle, IN PLARGE_INTEGER NewSectionSize); @@ -839,8 +857,10 @@ int mdbx_mmap(int flags, mdbx_mmap_t *map, size_t must, size_t limit) { rc = NtCreateSection( &map->section, - /* DesiredAccess */ SECTION_MAP_READ | SECTION_EXTEND_SIZE | - ((flags & MDBX_WRITEMAP) ? SECTION_MAP_WRITE : 0), + /* DesiredAccess */ (flags & MDBX_WRITEMAP) + ? SECTION_QUERY | SECTION_MAP_READ | SECTION_EXTEND_SIZE | + SECTION_MAP_WRITE + : SECTION_QUERY | SECTION_MAP_READ | SECTION_EXTEND_SIZE, /* ObjectAttributes */ NULL, /* MaximumSize */ NULL, /* SectionPageProtection */ (flags & MDBX_RDONLY) ? PAGE_READONLY : PAGE_READWRITE,