File Index Symbol Index

/******************************************************************************** * * * memoryapi.h -- ApiSet Contract for api-ms-win-core-memory-l1-1-0 * * * * Copyright (c) Microsoft Corporation. All rights reserved. * * * ********************************************************************************/
#ifdef _MSC_VER
#pragma once
#endif // _MSC_VER
#ifndef _MEMORYAPI_H_
#define _MEMORYAPI_H_
#include <apiset.h>
#include <apisetcconv.h>
#include <minwindef.h>
#include <minwinbase.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#if _MSC_VER >= 1200
#pragma warning(push) #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
#define FILE_MAP_WRITE SECTION_MAP_WRITE
#define FILE_MAP_READ SECTION_MAP_READ
#define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
#define FILE_MAP_EXECUTE SECTION_MAP_EXECUTE_EXPLICIT // not included in FILE_MAP_ALL_ACCESS
#define FILE_MAP_COPY 0x00000001
#define FILE_MAP_RESERVE 0x80000000
#define FILE_MAP_TARGETS_INVALID 0x40000000
#define FILE_MAP_LARGE_PAGES 0x20000000
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
_Ret_maybenull_
_Post_writable_byte_size_(dwSize)
LPVOID
VirtualAlloc
( );
_Success_(return != FALSE)
BOOL
VirtualProtect
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
_When_(((dwFreeType&(MEM_RELEASE|MEM_DECOMMIT)))==(MEM_RELEASE|MEM_DECOMMIT), __drv_reportError("Passing both MEM_RELEASE and MEM_DECOMMIT to VirtualFree is not allowed. This results in the failure of this call"))
_When_(dwFreeType==0, __drv_reportError("Passing zero as the dwFreeType parameter to VirtualFree is not allowed. This results in the failure of this call"))
_When_(((dwFreeType&MEM_RELEASE))!=0 && dwSize!=0, __drv_reportError("Passing MEM_RELEASE and a non-zero dwSize parameter to VirtualFree is not allowed. This results in the failure of this call"))
_Success_(return != FALSE)
BOOL
VirtualFree
( );
SIZE_T
VirtualQuery
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
_Ret_maybenull_
_Post_writable_byte_size_(dwSize)
LPVOID
VirtualAllocEx
( );
_Success_(return != FALSE)
BOOL
VirtualProtectEx
( );
SIZE_T
VirtualQueryEx
( );
_Success_(return != FALSE)
BOOL
ReadProcessMemory
( );
_Success_(return != FALSE)
BOOL
WriteProcessMemory
( );
_Ret_maybenull_
HANDLE
CreateFileMappingW
( );
#ifdef UNICODE
#define CreateFileMapping CreateFileMappingW #endif
_Ret_maybenull_
HANDLE
OpenFileMappingW
( );
#ifdef UNICODE
#define OpenFileMapping OpenFileMappingW #endif
_Ret_maybenull_ __out_data_source(FILE)
LPVOID
MapViewOfFile
( );
_Ret_maybenull_ __out_data_source(FILE)
LPVOID
MapViewOfFileEx
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
_When_(((dwFreeType&(MEM_RELEASE|MEM_DECOMMIT)))==(MEM_RELEASE|MEM_DECOMMIT), __drv_reportError("Passing both MEM_RELEASE and MEM_DECOMMIT to VirtualFree is not allowed. This results in the failure of this call"))
_When_(dwFreeType==0, __drv_reportError("Passing zero as the dwFreeType parameter to VirtualFree is not allowed. This results in the failure of this call"))
_When_(((dwFreeType&MEM_RELEASE))!=0 && dwSize!=0, __drv_reportError("Passing MEM_RELEASE and a non-zero dwSize parameter to VirtualFree is not allowed. This results in the failure of this call"))
_When_(((dwFreeType&MEM_DECOMMIT))!=0, __drv_reportError("Calling VirtualFreeEx without the MEM_RELEASE flag frees memory but not address descriptors (VADs); results in address space leaks"))
_Success_(return != FALSE)
BOOL
VirtualFreeEx
( );
BOOL
FlushViewOfFile
( );
BOOL
UnmapViewOfFile
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
SIZE_T
GetLargePageMinimum
( );
_Success_(return != FALSE)
BOOL
GetProcessWorkingSetSizeEx
( );
BOOL
SetProcessWorkingSetSizeEx
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
BOOL
VirtualLock
( );
BOOL
VirtualUnlock
( );
#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#pragma endregion #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
_Success_(return == 0)
UINT
GetWriteWatch
( );
UINT
ResetWriteWatch
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
typedef
enum
_MEMORY_RESOURCE_NOTIFICATION_TYPE
{
LowMemoryResourceNotification
,
HighMemoryResourceNotification
}
MEMORY_RESOURCE_NOTIFICATION_TYPE
;
_Ret_maybenull_
HANDLE
CreateMemoryResourceNotification
( );
_Success_(return != FALSE)
BOOL
QueryMemoryResourceNotification
( );
#endif // (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
#if (_WIN32_WINNT >= _WIN32_WINNT_WS03)
#define FILE_CACHE_FLAGS_DEFINED
#define FILE_CACHE_MAX_HARD_ENABLE 0x00000001
#define FILE_CACHE_MAX_HARD_DISABLE 0x00000002
#define FILE_CACHE_MIN_HARD_ENABLE 0x00000004
#define FILE_CACHE_MIN_HARD_DISABLE 0x00000008
_Success_(return != FALSE)
BOOL
GetSystemFileCacheSize
( );
BOOL
SetSystemFileCacheSize
( );
#endif // (_WIN32_WINNT >= _WIN32_WINNT_WS03)
#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
_Ret_maybenull_
HANDLE
CreateFileMappingNumaW
( );
#ifdef UNICODE
#define CreateFileMappingNuma CreateFileMappingNumaW #endif
#endif // (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
typedef
struct
_WIN32_MEMORY_RANGE_ENTRY
{
PVOID
VirtualAddress
;
SIZE_T
NumberOfBytes
; }
WIN32_MEMORY_RANGE_ENTRY
, *
PWIN32_MEMORY_RANGE_ENTRY
;
BOOL
PrefetchVirtualMemory
( );
#endif // (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#pragma endregion #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
_Ret_maybenull_
HANDLE
CreateFileMappingFromApp
( );
_Ret_maybenull_ __out_data_source(FILE)
PVOID
MapViewOfFileFromApp
( );
BOOL
UnmapViewOfFileEx
( );
#endif // (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
_Success_(return != FALSE)
BOOL
AllocateUserPhysicalPages
( );
_Success_(return != FALSE)
BOOL
FreeUserPhysicalPages
( );
_Success_(return != FALSE)
BOOL
MapUserPhysicalPages
( );
#endif // (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
_Success_(return != FALSE)
BOOL
AllocateUserPhysicalPagesNuma
( );
_Post_writable_byte_size_(dwSize)
LPVOID
VirtualAllocExNuma
( );
#endif // (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#define MEHC_PATROL_SCRUBBER_PRESENT 0x1
_Success_(return != FALSE)
BOOL
GetMemoryErrorHandlingCapabilities
( );
_Function_class_(BAD_MEMORY_CALLBACK_ROUTINE)
typedef
BAD_MEMORY_CALLBACK_ROUTINE
( );
typedef
BAD_MEMORY_CALLBACK_ROUTINE
*
PBAD_MEMORY_CALLBACK_ROUTINE
;
_Success_(return != NULL)
PVOID
RegisterBadMemoryNotification
( );
_Success_(return != FALSE)
BOOL
UnregisterBadMemoryNotification
( );
#endif // (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#pragma endregion #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
// This API is not actually available in all blue builds since it is part
// of the S14 GDR release, however because there is no new version for GDR
// this is the most accurate version available. To safely use this API on
// BLUE builds callers will need to use LoadLibrary and GetProcAddress to
// check for the existance of the API's before calling them.
#if (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE)
#if ((NTDDI_VERSION > NTDDI_WINBLUE) || (NTDDI_VERSION == NTDDI_WINBLUE && defined(WINBLUE_KBSPRING14)))
typedef
enum
OFFER_PRIORITY
{
VmOfferPriorityVeryLow
=
1
,
VmOfferPriorityLow
,
VmOfferPriorityBelowNormal
,
VmOfferPriorityNormal
}
OFFER_PRIORITY
;
DWORD
OfferVirtualMemory
( );
DWORD
ReclaimVirtualMemory
( );
DWORD
DiscardVirtualMemory
( );
#endif /* NTDDI_VERSION > NTDDI_WINBLUE || (NTDDI_VERSION == NTDDI_WINBLUE && defined(WINBLUE_KBSPRING14))) */
#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
BOOL
SetProcessValidCallTargets
( );
BOOL
SetProcessValidCallTargetsForMappedView
( );
_Ret_maybenull_
_Post_writable_byte_size_(Size)
PVOID
VirtualAllocFromApp
( );
_Success_(return != FALSE)
BOOL
VirtualProtectFromApp
( );
_Ret_maybenull_
HANDLE
OpenFileMappingFromApp
( );
#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN10) */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Application Family
#if WINAPI_PARTITION_APP && !(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#define CreateFileMapping CreateFileMappingW
FORCEINLINE
_Ret_maybenull_
HANDLE
WINAPI
CreateFileMappingW(
_In_ HANDLE hFile,
_In_opt_ LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
_In_ DWORD flProtect,
_In_ DWORD dwMaximumSizeHigh,
_In_ DWORD dwMaximumSizeLow,
_In_opt_ LPCWSTR lpName
)
{
return CreateFileMappingFromApp (hFile,
lpFileMappingAttributes,
flProtect,
(((ULONG64) dwMaximumSizeHigh) << 32) | dwMaximumSizeLow,
lpName);
}
FORCEINLINE
_Ret_maybenull_ __out_data_source(FILE)
LPVOID
WINAPI
MapViewOfFile(
_In_ HANDLE hFileMappingObject,
_In_ DWORD dwDesiredAccess,
_In_ DWORD dwFileOffsetHigh,
_In_ DWORD dwFileOffsetLow,
_In_ SIZE_T dwNumberOfBytesToMap
)
{
return MapViewOfFileFromApp (hFileMappingObject,
dwDesiredAccess,
(((ULONG64) dwFileOffsetHigh) << 32) | dwFileOffsetLow,
dwNumberOfBytesToMap);
}
#endif
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
FORCEINLINE
_Ret_maybenull_ _Post_writable_byte_size_(dwSize)
LPVOID
WINAPI
VirtualAlloc(
_In_opt_ LPVOID lpAddress,
_In_ SIZE_T dwSize,
_In_ DWORD flAllocationType,
_In_ DWORD flProtect
)
{
return VirtualAllocFromApp (lpAddress, dwSize, flAllocationType, flProtect);
}
FORCEINLINE
_Success_(return != FALSE)
BOOL
WINAPI
VirtualProtect(
_In_ LPVOID lpAddress,
_In_ SIZE_T dwSize,
_In_ DWORD flNewProtect,
_Out_ PDWORD lpflOldProtect
)
{
return VirtualProtectFromApp (lpAddress, dwSize, flNewProtect, lpflOldProtect);
}
#define OpenFileMapping OpenFileMappingW
FORCEINLINE
_Ret_maybenull_
HANDLE
WINAPI
OpenFileMappingW(
_In_ DWORD dwDesiredAccess,
_In_ BOOL bInheritHandle,
_In_ LPCWSTR lpName
)
{
return OpenFileMappingFromApp (dwDesiredAccess, bInheritHandle, lpName);
}
#endif
#endif /* WINAPI_PARTITION_APP && !(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#if (NTDDI_VERSION >= NTDDI_WIN10_RS1)
typedef
enum
WIN32_MEMORY_INFORMATION_CLASS
{
MemoryRegionInfo
}
WIN32_MEMORY_INFORMATION_CLASS
;
#if _MSC_VER >= 1200
#pragma warning(push)
typedef
struct
WIN32_MEMORY_REGION_INFORMATION
{
PVOID
AllocationBase
;
ULONG
AllocationProtect
;
union
{
ULONG
Flags
;
struct
{
ULONG
Private
:
1
;
ULONG
MappedDataFile
:
1
;
ULONG
MappedImage
:
1
;
ULONG
MappedPageFile
:
1
;
ULONG
MappedPhysical
:
1
;
ULONG
DirectMapped
:
1
;
ULONG
Reserved
:
26
;
SIZE_T
RegionSize
;
SIZE_T
CommitSize
; }
WIN32_MEMORY_REGION_INFORMATION
;
#if _MSC_VER >= 1200
#pragma warning(pop)
#endif
_Success_(return != FALSE)
BOOL
QueryVirtualMemoryInformation
( );
#endif // (NTDDI_VERSION >= NTDDI_WIN10_RS1)
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
#if (NTDDI_VERSION >= NTDDI_WIN10_RS2)
_Ret_maybenull_ __out_data_source(FILE)
PVOID
MapViewOfFileNuma2
( );
#if !defined(MIDL_PASS)
_Ret_maybenull_ __out_data_source(FILE)
PVOID
MapViewOfFile2
( ) {
return
MapViewOfFileNuma2
(
FileMappingHandle
,
ProcessHandle
,
Offset
,
BaseAddress
,
ViewSize
,
AllocationType
,
PageProtection
, }
#endif // !defined(MIDL_PASS)
#endif // (NTDDI_VERSION >= NTDDI_WIN10_RS2)
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
BOOL
UnmapViewOfFile2
( );
BOOL
VirtualUnlockEx
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#if (NTDDI_VERSION >= NTDDI_WIN10_RS4)
#pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
_Ret_maybenull_
_Post_writable_byte_size_(Size)
PVOID
VirtualAlloc2
( );
_Ret_maybenull_ __out_data_source(FILE)
PVOID
MapViewOfFile3
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion #pragma region Application Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM)
_Ret_maybenull_
_Post_writable_byte_size_(Size)
PVOID
VirtualAlloc2FromApp
( );
_Ret_maybenull_ __out_data_source(FILE)
PVOID
MapViewOfFile3FromApp
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#endif // (NTDDI_VERSION >= NTDDI_WIN10_RS4)
#if (NTDDI_VERSION >= NTDDI_WIN10_RS5)
#pragma region Desktop Family or OneCore Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
_Ret_maybenull_
HANDLE
CreateFileMapping2
( );
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_SYSTEM) */
#pragma endregion
#endif // (NTDDI_VERSION >= NTDDI_WIN10_RS5)
#if _MSC_VER >= 1200
#pragma warning(pop)
#endif
#ifdef __cplusplus
}
#endif
#endif // _MEMORYAPI_H_