Cygwin: memory: declare extended memory API

Windows 10 1803 introduced an extended memory API allowing
to specify memory regions allocations are to be taken off.

In preparation of using this API, define the struct
MEM_EXTENDED_PARAMETER and friends.  Declare and allow to
autoload the functions VirtualAlloc2 and NtMapViewOfSectionEx.

Introduce a wincap flag has_extended_mem_api.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2020-04-07 14:13:50 +02:00
parent ccb3a40dad
commit e18f7f99cc
5 changed files with 69 additions and 0 deletions

View File

@ -597,6 +597,9 @@ LoadDLLfunc (QueryInterruptTime, 4, KernelBase)
LoadDLLfunc (QueryInterruptTimePrecise, 4, KernelBase)
LoadDLLfunc (QueryUnbiasedInterruptTime, 4, KernelBase)
LoadDLLfunc (QueryUnbiasedInterruptTimePrecise, 4, KernelBase)
LoadDLLfunc (VirtualAlloc2, 28, kernelbase)
LoadDLLfunc (NtMapViewOfSectionEx, 36, ntdll)
/* ldap functions are cdecl! */
#pragma push_macro ("mangle")

View File

@ -1427,6 +1427,9 @@ extern "C"
NTSTATUS NTAPI NtMapViewOfSection (HANDLE, HANDLE, PVOID *, ULONG_PTR, SIZE_T,
PLARGE_INTEGER, PSIZE_T, SECTION_INHERIT,
ULONG, ULONG);
NTSTATUS NTAPI NtMapViewOfSectionEx (HANDLE, HANDLE, PVOID *, PLARGE_INTEGER,
PSIZE_T, ULONG, ULONG,
PMEM_EXTENDED_PARAMETER, ULONG);
NTSTATUS NTAPI NtNotifyChangeDirectoryFile (HANDLE, HANDLE, PIO_APC_ROUTINE,
PVOID, PIO_STATUS_BLOCK,
PFILE_NOTIFY_INFORMATION, ULONG,

View File

@ -45,6 +45,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
has_extended_mem_api:false,
},
};
@ -75,6 +76,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
has_extended_mem_api:false,
},
};
@ -105,6 +107,7 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
has_extended_mem_api:false,
},
};
@ -135,6 +138,7 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
has_extended_mem_api:false,
},
};
@ -165,6 +169,7 @@ wincaps wincap_10_1507 __attribute__((section (".cygwin_dll_common"), shared))
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
has_extended_mem_api:false,
},
};
@ -195,6 +200,7 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
has_extended_mem_api:false,
},
};
@ -225,6 +231,7 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
has_extended_mem_api:false,
},
};
@ -255,6 +262,7 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_broken_csi3j:false,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
has_extended_mem_api:true,
},
};
@ -285,6 +293,7 @@ wincaps wincap_10_1809 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_broken_csi3j:true,
has_con_broken_il_dl:false,
has_con_esc_rep:false,
has_extended_mem_api:true,
},
};
@ -315,6 +324,7 @@ wincaps wincap_10_1903 __attribute__((section (".cygwin_dll_common"), shared)) =
has_con_broken_csi3j:false,
has_con_broken_il_dl:true,
has_con_esc_rep:true,
has_extended_mem_api:true,
},
};

View File

@ -39,6 +39,7 @@ struct wincaps
unsigned has_con_broken_csi3j : 1;
unsigned has_con_broken_il_dl : 1;
unsigned has_con_esc_rep : 1;
unsigned has_extended_mem_api : 1;
};
};
@ -101,6 +102,7 @@ public:
bool IMPLEMENT (has_con_broken_csi3j)
bool IMPLEMENT (has_con_broken_il_dl)
bool IMPLEMENT (has_con_esc_rep)
bool IMPLEMENT (has_extended_mem_api)
void disable_case_sensitive_dirs ()
{

View File

@ -94,4 +94,55 @@ details. */
#define GetWindowsDirectoryW dont_use_GetWindowsDirectory
#define GetWindowsDirectoryA dont_use_GetWindowsDirectory
#ifdef __cplusplus
extern "C" {
#endif
/* Define extended memory API here as long as not available from mingw-w64. */
typedef struct _MEM_ADDRESS_REQUIREMENTS
{
PVOID LowestStartingAddress;
PVOID HighestEndingAddress;
SIZE_T Alignment;
} MEM_ADDRESS_REQUIREMENTS, *PMEM_ADDRESS_REQUIREMENTS;
typedef enum MEM_EXTENDED_PARAMETER_TYPE
{
MemExtendedParameterInvalidType = 0,
MemExtendedParameterAddressRequirements,
MemExtendedParameterNumaNode,
MemExtendedParameterPartitionHandle,
MemExtendedParameterUserPhysicalHandle,
MemExtendedParameterAttributeFlags,
MemExtendedParameterMax
} MEM_EXTENDED_PARAMETER_TYPE, *PMEM_EXTENDED_PARAMETER_TYPE;
#define MEM_EXTENDED_PARAMETER_TYPE_BITS 8
typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER
{
struct
{
DWORD64 Type : MEM_EXTENDED_PARAMETER_TYPE_BITS;
DWORD64 Reserved : 64 - MEM_EXTENDED_PARAMETER_TYPE_BITS;
};
union
{
DWORD64 ULong64;
PVOID Pointer;
SIZE_T Size;
HANDLE Handle;
DWORD ULong;
};
} MEM_EXTENDED_PARAMETER, *PMEM_EXTENDED_PARAMETER;
PVOID VirtualAlloc2 (HANDLE, PVOID, SIZE_T, ULONG, ULONG,
PMEM_EXTENDED_PARAMETER, ULONG);
#ifdef __cplusplus
}
#endif
#endif /*_WINLEAN_H*/