source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/memoryapi.h@ 1167

Last change on this file since 1167 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 11.4 KB
Line 
1/**
2 * This file is part of the mingw-w64 runtime package.
3 * No warranty is given; refer to the file DISCLAIMER within this package.
4 */
5#ifndef _MEMORYAPI_H_
6#define _MEMORYAPI_H_
7
8#include <apiset.h>
9#include <apisetcconv.h>
10#include <minwindef.h>
11#include <minwinbase.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
18 typedef enum _MEMORY_RESOURCE_NOTIFICATION_TYPE {
19 LowMemoryResourceNotification,
20 HighMemoryResourceNotification
21 } MEMORY_RESOURCE_NOTIFICATION_TYPE;
22
23#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
24 typedef struct _WIN32_MEMORY_RANGE_ENTRY {
25 PVOID VirtualAddress;
26 SIZE_T NumberOfBytes;
27 } WIN32_MEMORY_RANGE_ENTRY, *PWIN32_MEMORY_RANGE_ENTRY;
28#endif
29#endif
30
31#if (WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP) && _WIN32_WINNT >= _WIN32_WINNT_WIN10) || WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
32 WINBASEAPI WINBOOL WINAPI VirtualFree (LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType);
33#endif
34
35#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP)
36
37#define FILE_MAP_WRITE SECTION_MAP_WRITE
38#define FILE_MAP_READ SECTION_MAP_READ
39#define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS
40#define FILE_MAP_COPY 0x1
41#define FILE_MAP_RESERVE 0x80000000
42#define FILE_MAP_TARGETS_INVALID 0x40000000
43#define FILE_MAP_LARGE_PAGES 0x20000000
44
45 WINBASEAPI SIZE_T WINAPI VirtualQuery (LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength);
46 WINBASEAPI WINBOOL WINAPI FlushViewOfFile (LPCVOID lpBaseAddress, SIZE_T dwNumberOfBytesToFlush);
47 WINBASEAPI WINBOOL WINAPI UnmapViewOfFile (LPCVOID lpBaseAddress);
48 WINBASEAPI WINBOOL WINAPI UnmapViewOfFile2(HANDLE Process, PVOID BaseAddress, ULONG UnmapFlags);
49 WINBASEAPI HANDLE WINAPI CreateFileMappingFromApp (HANDLE hFile, PSECURITY_ATTRIBUTES SecurityAttributes, ULONG PageProtection, ULONG64 MaximumSize, PCWSTR Name);
50 WINBASEAPI PVOID WINAPI MapViewOfFileFromApp (HANDLE hFileMappingObject, ULONG DesiredAccess, ULONG64 FileOffset, SIZE_T NumberOfBytesToMap);
51 WINBASEAPI WINBOOL WINAPI VirtualUnlockEx(HANDLE Process, LPVOID Address, SIZE_T Size);
52
53#if _WIN32_WINNT >= _WIN32_WINNT_WIN10
54 WINBASEAPI WINBOOL WINAPI SetProcessValidCallTargets(HANDLE hProcess, PVOID VirtualAddress, SIZE_T RegionSize, ULONG NumberOfOffsets, PCFG_CALL_TARGET_INFO OffsetInformation);
55 WINBASEAPI WINBOOL WINAPI SetProcessValidCallTargetsForMappedView(HANDLE Process, PVOID VirtualAddress, SIZE_T RegionSize, ULONG NumberOfOffsets, PCFG_CALL_TARGET_INFO OffsetInformation, HANDLE Section, ULONG64 ExpectedFileOffset);
56 WINBASEAPI PVOID WINAPI VirtualAllocFromApp(PVOID BaseAddress, SIZE_T Size, ULONG AllocationType, ULONG Protection);
57 WINBASEAPI WINBOOL WINAPI VirtualProtectFromApp (PVOID lpAddress, SIZE_T dwSize, ULONG flNewProtect, PULONG lpflOldProtect);
58 WINBASEAPI HANDLE WINAPI OpenFileMappingFromApp(ULONG DesiredAccess, WINBOOL InheritHandle, PCWSTR Name);
59#endif
60
61#if NTDDI_VERSION >= NTDDI_WIN10_RS4
62 WINBASEAPI PVOID WINAPI VirtualAlloc2FromApp(HANDLE Process, PVOID BaseAddress, SIZE_T Size, ULONG AllocationType, ULONG PageProtection, MEM_EXTENDED_PARAMETER* ExtendedParameters, ULONG ParameterCount);
63 WINBASEAPI PVOID WINAPI MapViewOfFile3FromApp(HANDLE FileMapping, HANDLE Process, PVOID BaseAddress, ULONG64 Offset, SIZE_T ViewSize, ULONG AllocationType, ULONG PageProtection, MEM_EXTENDED_PARAMETER* ExtendedParameters, ULONG ParameterCount);
64#endif
65
66#endif /* WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP) */
67
68#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) || defined(WINSTORECOMPAT)
69 WINBASEAPI WINBOOL WINAPI VirtualProtect (LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
70#endif
71
72#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
73#define FILE_MAP_EXECUTE SECTION_MAP_EXECUTE_EXPLICIT
74
75#define FILE_CACHE_FLAGS_DEFINED
76#define FILE_CACHE_MAX_HARD_ENABLE 0x00000001
77#define FILE_CACHE_MAX_HARD_DISABLE 0x00000002
78#define FILE_CACHE_MIN_HARD_ENABLE 0x00000004
79#define FILE_CACHE_MIN_HARD_DISABLE 0x00000008
80
81 WINBASEAPI LPVOID WINAPI VirtualAlloc (LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
82 WINBASEAPI LPVOID WINAPI VirtualAllocEx (HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
83 WINBASEAPI WINBOOL WINAPI VirtualProtectEx (HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
84 WINBASEAPI SIZE_T WINAPI VirtualQueryEx (HANDLE hProcess, LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength);
85 WINBASEAPI WINBOOL WINAPI ReadProcessMemory (HANDLE hProcess, LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesRead);
86 WINBASEAPI WINBOOL WINAPI WriteProcessMemory (HANDLE hProcess, LPVOID lpBaseAddress, LPCVOID lpBuffer, SIZE_T nSize, SIZE_T *lpNumberOfBytesWritten);
87 WINBASEAPI HANDLE WINAPI CreateFileMappingW (HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCWSTR lpName);
88 WINBASEAPI HANDLE WINAPI OpenFileMappingW (DWORD dwDesiredAccess, WINBOOL bInheritHandle, LPCWSTR lpName);
89 WINBASEAPI LPVOID WINAPI MapViewOfFile (HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap);
90 WINBASEAPI LPVOID WINAPI MapViewOfFileEx (HANDLE hFileMappingObject, DWORD dwDesiredAccess, DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, SIZE_T dwNumberOfBytesToMap, LPVOID lpBaseAddress);
91 WINBASEAPI WINBOOL WINAPI VirtualLock (LPVOID lpAddress, SIZE_T dwSize);
92 WINBASEAPI WINBOOL WINAPI VirtualUnlock (LPVOID lpAddress, SIZE_T dwSize);
93 WINBASEAPI HANDLE WINAPI CreateMemoryResourceNotification (MEMORY_RESOURCE_NOTIFICATION_TYPE NotificationType);
94 WINBASEAPI WINBOOL WINAPI QueryMemoryResourceNotification (HANDLE ResourceNotificationHandle, PBOOL ResourceState);
95 WINBASEAPI WINBOOL WINAPI GetSystemFileCacheSize (PSIZE_T lpMinimumFileCacheSize, PSIZE_T lpMaximumFileCacheSize, PDWORD lpFlags);
96 WINBASEAPI WINBOOL WINAPI SetSystemFileCacheSize (SIZE_T MinimumFileCacheSize, SIZE_T MaximumFileCacheSize, DWORD Flags);
97
98#ifdef UNICODE
99#define CreateFileMapping CreateFileMappingW
100#define OpenFileMapping OpenFileMappingW
101#endif
102
103#if _WIN32_WINNT >= _WIN32_WINNT_WINXP
104 WINBASEAPI WINBOOL WINAPI AllocateUserPhysicalPages(HANDLE hProcess, PULONG_PTR NumberOfPages, PULONG_PTR PageArray);
105 WINBASEAPI WINBOOL WINAPI FreeUserPhysicalPages(HANDLE hProcess, PULONG_PTR NumberOfPages, PULONG_PTR PageArray);
106 WINBASEAPI WINBOOL WINAPI MapUserPhysicalPages(PVOID VirtualAddress, ULONG_PTR NumberOfPages, PULONG_PTR PageArray);
107#endif
108
109#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
110 WINBASEAPI WINBOOL WINAPI AllocateUserPhysicalPagesNuma(HANDLE hProcess, PULONG_PTR NumberOfPages, PULONG_PTR PageArray, DWORD nndPreferred);
111 WINBASEAPI HANDLE WINAPI CreateFileMappingNumaW (HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCWSTR lpName, DWORD nndPreferred);
112 WINBASEAPI LPVOID WINAPI VirtualAllocExNuma(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect, DWORD nndPreferred);
113#ifdef UNICODE
114#define CreateFileMappingNuma CreateFileMappingNumaW
115#endif
116#endif
117
118#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
119#define MEHC_PATROL_SCRUBBER_PRESENT 0x1
120 WINBASEAPI WINBOOL WINAPI GetMemoryErrorHandlingCapabilities(PULONG Capabilities);
121 WINBASEAPI WINBOOL WINAPI PrefetchVirtualMemory (HANDLE hProcess, ULONG_PTR NumberOfEntries, PWIN32_MEMORY_RANGE_ENTRY VirtualAddresses, ULONG Flags);
122 typedef VOID WINAPI BAD_MEMORY_CALLBACK_ROUTINE(VOID);
123 typedef BAD_MEMORY_CALLBACK_ROUTINE *PBAD_MEMORY_CALLBACK_ROUTINE;
124 WINBASEAPI PVOID WINAPI RegisterBadMemoryNotification(PBAD_MEMORY_CALLBACK_ROUTINE Callback);
125 WINBASEAPI WINBOOL WINAPI UnregisterBadMemoryNotification(PVOID RegistrationHandle);
126#endif
127
128#if NTDDI_VERSION >= NTDDI_WIN10_RS1
129 typedef enum WIN32_MEMORY_INFORMATION_CLASS {
130 MemoryRegionInfo
131 } WIN32_MEMORY_INFORMATION_CLASS;
132
133 typedef struct WIN32_MEMORY_REGION_INFORMATION {
134 PVOID AllocationBase;
135 ULONG AllocationProtect;
136 __C89_NAMELESS union {
137 ULONG Flags;
138 __C89_NAMELESS struct {
139 ULONG Private : 1;
140 ULONG MappedDataFile : 1;
141 ULONG MappedImage : 1;
142 ULONG MappedPageFile : 1;
143 ULONG MappedPhysical : 1;
144 ULONG DirectMapped : 1;
145 ULONG Reserved : 26;
146 };
147 };
148 SIZE_T RegionSize;
149 SIZE_T CommitSize;
150 } WIN32_MEMORY_REGION_INFORMATION;
151
152 WINBASEAPI WINBOOL WINAPI QueryVirtualMemoryInformation(HANDLE Process, const VOID* VirtualAddress, WIN32_MEMORY_INFORMATION_CLASS MemoryInformationClass, PVOID MemoryInformation, SIZE_T MemoryInformationSize, PSIZE_T ReturnSize);
153
154#endif /* NTDDI_VERSION >= NTDDI_WIN10_RS1 */
155
156#if NTDDI_VERSION >= NTDDI_WIN10_RS2
157 WINBASEAPI PVOID WINAPI MapViewOfFileNuma2(HANDLE FileMappingHandle, HANDLE ProcessHandle, ULONG64 Offset, PVOID BaseAddress, SIZE_T ViewSize, ULONG AllocationType, ULONG PageProtection, ULONG PreferredNode);
158 WINBASEAPI PVOID MapViewOfFile2(HANDLE FileMappingHandle, HANDLE ProcessHandle, ULONG64 Offset, PVOID BaseAddress, SIZE_T ViewSize, ULONG AllocationType, ULONG PageProtection);
159#endif
160
161#if NTDDI_VERSION >= NTDDI_WIN10_RS4
162 WINBASEAPI PVOID WINAPI VirtualAlloc2(HANDLE Process, PVOID BaseAddress, SIZE_T Size, ULONG AllocationType, ULONG PageProtection, MEM_EXTENDED_PARAMETER* ExtendedParameters, ULONG ParameterCount);
163 WINBASEAPI PVOID WINAPI MapViewOfFile3(HANDLE FileMapping, HANDLE Process, PVOID BaseAddress, ULONG64 Offset, SIZE_T ViewSize, ULONG AllocationType, ULONG PageProtection, MEM_EXTENDED_PARAMETER* ExtendedParameters, ULONG ParameterCount);
164#endif
165
166#if NTDDI_VERSION >= NTDDI_WIN10_RS5
167 WINBASEAPI HANDLE WINAPI CreateFileMapping2(HANDLE File, SECURITY_ATTRIBUTES* SecurityAttributes, ULONG DesiredAccess, ULONG PageProtection, ULONG AllocationAttributes, ULONG64 MaximumSize, PCWSTR Name, MEM_EXTENDED_PARAMETER* ExtendedParameters, ULONG ParameterCount);
168#endif
169
170#endif /* WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) */
171
172#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP)
173 WINBASEAPI SIZE_T WINAPI GetLargePageMinimum (VOID);
174 WINBASEAPI WINBOOL WINAPI GetProcessWorkingSetSizeEx (HANDLE hProcess, PSIZE_T lpMinimumWorkingSetSize, PSIZE_T lpMaximumWorkingSetSize, PDWORD Flags);
175 WINBASEAPI WINBOOL WINAPI SetProcessWorkingSetSizeEx (HANDLE hProcess, SIZE_T dwMinimumWorkingSetSize, SIZE_T dwMaximumWorkingSetSize, DWORD Flags);
176 WINBASEAPI UINT WINAPI GetWriteWatch (DWORD dwFlags, PVOID lpBaseAddress, SIZE_T dwRegionSize, PVOID *lpAddresses, ULONG_PTR *lpdwCount, LPDWORD lpdwGranularity);
177 WINBASEAPI UINT WINAPI ResetWriteWatch (LPVOID lpBaseAddress, SIZE_T dwRegionSize);
178 WINBASEAPI WINBOOL WINAPI VirtualFreeEx (HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType);
179
180#if _WIN32_WINNT >= _WIN32_WINNT_WINBLUE
181 typedef enum _OFFER_PRIORITY {
182 VmOfferPriorityVeryLow = 1,
183 VmOfferPriorityLow,
184 VmOfferPriorityBelowNormal,
185 VmOfferPriorityNormal
186 } OFFER_PRIORITY;
187
188 WINBASEAPI DWORD WINAPI DiscardVirtualMemory (PVOID VirtualAddress, SIZE_T Size);
189 WINBASEAPI DWORD WINAPI OfferVirtualMemory (PVOID VirtualAddress, SIZE_T Size, OFFER_PRIORITY Priority);
190 WINBASEAPI DWORD WINAPI ReclaimVirtualMemory (PVOID VirtualAddress, SIZE_T Size);
191#endif
192
193#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
194 WINBASEAPI WINBOOL WINAPI UnmapViewOfFileEx (PVOID BaseAddress, ULONG UnmapFlags);
195#endif
196#endif /* WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP) */
197
198
199#ifdef __cplusplus
200}
201#endif
202#endif
Note: See TracBrowser for help on using the repository browser.