ReactOS 0.4.15-dev-5672-gf73ac17
mmfuncs.h
Go to the documentation of this file.
1/*++ NDK Version: 0098
2
3Copyright (c) Alex Ionescu. All rights reserved.
4
5Header Name:
6
7 mmfuncs.h
8
9Abstract:
10
11 Functions definitions for the Memory Manager.
12
13Author:
14
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16
17--*/
18
19#ifndef _MMFUNCS_H
20#define _MMFUNCS_H
21
22//
23// Dependencies
24//
25#include <umtypes.h>
26#include <mmtypes.h>
27
28#ifndef NTOS_MODE_USER
29
30//
31// Section Functions
32//
44);
45
59);
60
64 _In_ struct _EPROCESS* Process,
66);
67
68#endif
69
70//
71// Native calls
72//
77 _In_ PVOID File1MappedAsAnImage,
78 _In_ PVOID File2MappedAsFile
79);
80
85 _Inout_ PULONG_PTR NumberOfPages,
86 _Inout_ PULONG_PTR UserPfnArray
87);
88
102);
103
106NTAPI
109 _In_ PLARGE_INTEGER MinimumSize,
112);
113
118NTAPI
120 _Out_ PHANDLE SectionHandle,
127);
128
131NTAPI
133 _In_ HANDLE SectionHandle,
134 _In_ PLARGE_INTEGER NewMaximumSize
135);
136
139NTAPI
143 _In_ SIZE_T NumberOfBytesToFlush
144);
145
148NTAPI
154);
155
157NTAPI
160 _Inout_ PULONG_PTR NumberOfPages,
161 _Inout_ PULONG_PTR UserPfnArray
162);
163
168NTAPI
174);
175
177NTAPI
183 _In_ PVOID *UserAddressArray,
184 _Out_ PULONG_PTR EntriesInUserAddressArray,
185 _Out_ PULONG Granularity
186);
187
190NTAPI
194 _Inout_ PSIZE_T NumberOfBytesToLock,
195 _In_ ULONG MapType
196);
197
199NTAPI
201 _In_ PVOID VirtualAddresses,
202 _In_ ULONG_PTR NumberOfPages,
203 _Inout_ PULONG_PTR UserPfnArray
204);
205
207NTAPI
209 _In_ PVOID *VirtualAddresses,
210 _In_ ULONG_PTR NumberOfPages,
211 _Inout_ PULONG_PTR UserPfnArray
212);
213
216NTAPI
218 _In_ HANDLE SectionHandle,
227 _In_ ULONG AccessProtection
228);
229
232NTAPI
234 _Out_ PHANDLE SectionHandle,
237);
238
241NTAPI
245 _In_ SIZE_T *NumberOfBytesToProtect,
246 _In_ ULONG NewAccessProtection,
247 _Out_ PULONG OldAccessProtection
248);
249
252NTAPI
254 _In_ HANDLE SectionHandle,
255 _In_ SECTION_INFORMATION_CLASS SectionInformationClass,
256 _Out_ PVOID SectionInformation,
259);
260
263NTAPI
267 _In_ MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass,
268 _Out_ PVOID VirtualMemoryInformation,
271);
272
275NTAPI
280 _In_ SIZE_T NumberOfBytesToRead,
281 _Out_opt_ PSIZE_T NumberOfBytesRead
282);
283
285NTAPI
290);
291
294NTAPI
298 _Inout_ PSIZE_T NumberOfBytesToUnlock,
299 _In_ ULONG MapType
300);
301
304NTAPI
308);
309
312NTAPI
317 _In_ SIZE_T NumberOfBytesToWrite,
318 _Out_opt_ PSIZE_T NumberOfBytesWritten
319);
320
323NTAPI
325 _In_ PVOID File1MappedAsAnImage,
326 _In_ PVOID File2MappedAsFile
327);
328
334NTAPI
335ZwAllocateVirtualMemory(
342);
343
346NTAPI
349 _In_ PLARGE_INTEGER MinimumSize,
352);
353
357NTAPI
358ZwCreateSection(
359 _Out_ PHANDLE SectionHandle,
366);
367
370NTAPI
372 _In_ HANDLE SectionHandle,
373 _In_ PLARGE_INTEGER NewMaximumSize
374);
375
379NTAPI
380ZwFreeVirtualMemory(
385);
386
389NTAPI
393 _Inout_ PSIZE_T NumberOfBytesToLock,
394 _In_ ULONG MapType
395);
396
400NTAPI
401ZwMapViewOfSection(
402 _In_ HANDLE SectionHandle,
412);
413
416NTAPI
418 _Out_ PHANDLE SectionHandle,
421);
422
425NTAPI
429 _In_ SIZE_T *NumberOfBytesToProtect,
430 _In_ ULONG NewAccessProtection,
431 _Out_ PULONG OldAccessProtection
432);
433
436NTAPI
438 _In_ HANDLE SectionHandle,
439 _In_ SECTION_INFORMATION_CLASS SectionInformationClass,
440 _Out_ PVOID SectionInformation,
443);
444
447NTAPI
451 _In_ MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass,
452 _Out_ PVOID VirtualMemoryInformation,
455);
456
459NTAPI
464 _In_ SIZE_T NumberOfBytesToRead,
465 _Out_opt_ PSIZE_T NumberOfBytesRead
466);
467
470NTAPI
474 _Inout_ PSIZE_T NumberOfBytesToUnlock,
475 _In_ ULONG MapType
476);
477
481NTAPI
482ZwUnmapViewOfSection(
485);
486
489NTAPI
494 _In_ SIZE_T NumberOfBytesToWrite,
495 _Out_opt_ PSIZE_T NumberOfBytesWritten
496);
497
498#endif
LONG NTSTATUS
Definition: precomp.h:26
#define NTSYSAPI
Definition: ntoskrnl.h:12
Definition: bufpool.h:45
Definition: File.h:16
#define __drv_freesMem(kind)
Definition: driverspecs.h:271
#define _IRQL_requires_max_(irql)
Definition: driverspecs.h:230
#define __drv_allocatesMem(kind)
Definition: driverspecs.h:256
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define APC_LEVEL
Definition: env_spec_w32.h:695
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
#define _Outptr_result_bytebuffer_(size)
Definition: ms_sal.h:472
#define _Out_opt_
Definition: ms_sal.h:346
#define _Inout_
Definition: ms_sal.h:378
#define _At_(target, annos)
Definition: ms_sal.h:244
#define _Inout_opt_
Definition: ms_sal.h:379
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define _Outptr_result_buffer_(size)
Definition: ms_sal.h:456
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT InheritDisposition
Definition: mmfuncs.h:409
NTSYSCALLAPI NTSTATUS NTAPI NtUnmapViewOfSection(_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress)
NTSYSCALLAPI NTSTATUS NTAPI NtWriteVirtualMemory(_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _In_ PVOID Buffer, _In_ SIZE_T NumberOfBytesToWrite, _Out_opt_ PSIZE_T NumberOfBytesWritten)
NTSYSAPI NTSTATUS NTAPI ZwOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
NTSYSAPI NTSTATUS NTAPI ZwQueryVirtualMemory(_In_ HANDLE ProcessHandle, _In_ PVOID Address, _In_ MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass, _Out_ PVOID VirtualMemoryInformation, _In_ SIZE_T Length, _Out_opt_ PSIZE_T ResultLength)
NTSYSAPI NTSTATUS NTAPI ZwUnlockVirtualMemory(_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T NumberOfBytesToUnlock, _In_ ULONG MapType)
NTSYSCALLAPI NTSTATUS NTAPI NtExtendSection(_In_ HANDLE SectionHandle, _In_ PLARGE_INTEGER NewMaximumSize)
NTSYSCALLAPI NTSTATUS NTAPI NtAreMappedFilesTheSame(_In_ PVOID File1MappedAsAnImage, _In_ PVOID File2MappedAsFile)
NTSYSAPI NTSTATUS NTAPI ZwQuerySection(_In_ HANDLE SectionHandle, _In_ SECTION_INFORMATION_CLASS SectionInformationClass, _Out_ PVOID SectionInformation, _In_ SIZE_T Length, _Out_opt_ PSIZE_T ResultLength)
NTSYSAPI NTSTATUS NTAPI ZwCreatePagingFile(_In_ PUNICODE_STRING FileName, _In_ PLARGE_INTEGER MinimumSize, _In_ PLARGE_INTEGER MaximumSize, _In_ ULONG Reserved)
NTSTATUS NTAPI NtFreeUserPhysicalPages(_In_ HANDLE ProcessHandle, _Inout_ PULONG_PTR NumberOfPages, _Inout_ PULONG_PTR UserPfnArray)
NTSYSAPI NTSTATUS NTAPI ZwReadVirtualMemory(_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _Out_ PVOID Buffer, _In_ SIZE_T NumberOfBytesToRead, _Out_opt_ PSIZE_T NumberOfBytesRead)
NTSTATUS NTAPI NtGetWriteWatch(_In_ HANDLE ProcessHandle, _In_ ULONG Flags, _In_ PVOID BaseAddress, _In_ SIZE_T RegionSize, _In_ PVOID *UserAddressArray, _Out_ PULONG_PTR EntriesInUserAddressArray, _Out_ PULONG Granularity)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Win32Protect
Definition: mmfuncs.h:412
NTSYSCALLAPI NTSTATUS NTAPI NtProtectVirtualMemory(_In_ HANDLE ProcessHandle, _In_ PVOID *BaseAddress, _In_ SIZE_T *NumberOfBytesToProtect, _In_ ULONG NewAccessProtection, _Out_ PULONG OldAccessProtection)
NTSYSCALLAPI NTSTATUS NTAPI NtFlushVirtualMemory(_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T RegionSize, _Out_ PIO_STATUS_BLOCK IoStatus)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
Definition: mmfuncs.h:362
_Must_inspect_result_ __kernel_entry NTSYSCALLAPI NTSTATUS NTAPI NtCreateSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, _In_opt_ PLARGE_INTEGER MaximumSize, _In_ ULONG SectionPageProtection, _In_ ULONG AllocationAttributes, _In_opt_ HANDLE FileHandle)
NTSTATUS NTAPI NtResetWriteWatch(_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _In_ SIZE_T RegionSize)
NTSTATUS NTAPI NtMapUserPhysicalPages(_In_ PVOID VirtualAddresses, _In_ ULONG_PTR NumberOfPages, _Inout_ PULONG_PTR UserPfnArray)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _In_opt_ HANDLE FileHandle
Definition: mmfuncs.h:366
NTSTATUS NTAPI NtAllocateUserPhysicalPages(_In_ HANDLE ProcessHandle, _Inout_ PULONG_PTR NumberOfPages, _Inout_ PULONG_PTR UserPfnArray)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG SectionPageProtection
Definition: mmfuncs.h:363
NTSYSCALLAPI NTSTATUS NTAPI NtReadVirtualMemory(_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _Out_ PVOID Buffer, _In_ SIZE_T NumberOfBytesToRead, _Out_opt_ PSIZE_T NumberOfBytesRead)
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
NTSYSAPI NTSTATUS NTAPI ZwLockVirtualMemory(_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T NumberOfBytesToLock, _In_ ULONG MapType)
NTSYSCALLAPI NTSTATUS NTAPI NtCreatePagingFile(_In_ PUNICODE_STRING FileName, _In_ PLARGE_INTEGER MinimumSize, _In_ PLARGE_INTEGER MaximumSize, _In_ ULONG Reserved)
Definition: pagefile.c:366
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR ZeroBits
Definition: mmfuncs.h:405
NTSYSAPI NTSTATUS NTAPI ZwWriteVirtualMemory(_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _In_ PVOID Buffer, _In_ SIZE_T NumberOfBytesToWrite, _Out_opt_ PSIZE_T NumberOfBytesWritten)
NTSYSAPI NTSTATUS NTAPI ZwAreMappedFilesTheSame(_In_ PVOID File1MappedAsAnImage, _In_ PVOID File2MappedAsFile)
NTSYSCALLAPI NTSTATUS NTAPI NtMapViewOfSection(_In_ HANDLE SectionHandle, _In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _In_ ULONG_PTR ZeroBits, _In_ SIZE_T CommitSize, _Inout_opt_ PLARGE_INTEGER SectionOffset, _Inout_ PSIZE_T ViewSize, _In_ SECTION_INHERIT InheritDisposition, _In_ ULONG AllocationType, _In_ ULONG AccessProtection)
NTSYSCALLAPI NTSTATUS NTAPI NtFlushInstructionCache(_In_ HANDLE ProcessHandle, _In_ PVOID BaseAddress, _In_ SIZE_T NumberOfBytesToFlush)
NTSYSCALLAPI NTSTATUS NTAPI NtQueryVirtualMemory(_In_ HANDLE ProcessHandle, _In_ PVOID Address, _In_ MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass, _Out_ PVOID VirtualMemoryInformation, _In_ SIZE_T Length, _Out_opt_ PSIZE_T ResultLength)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG AllocationAttributes
Definition: mmfuncs.h:364
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG AllocationType
Definition: mmfuncs.h:410
NTSYSAPI NTSTATUS NTAPI ZwExtendSection(_In_ HANDLE SectionHandle, _In_ PLARGE_INTEGER NewMaximumSize)
NTSTATUS NTAPI MmMapViewOfSection(_In_ PVOID SectionObject, _In_ PEPROCESS Process, _Inout_ PVOID *BaseAddress, _In_ ULONG_PTR ZeroBits, _In_ SIZE_T CommitSize, _Inout_opt_ PLARGE_INTEGER SectionOffset, _Inout_ PSIZE_T ViewSize, _In_ SECTION_INHERIT InheritDisposition, _In_ ULONG AllocationType, _In_ ULONG Protect)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:407
NTSYSCALLAPI NTSTATUS NTAPI NtUnlockVirtualMemory(_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T NumberOfBytesToUnlock, _In_ ULONG MapType)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T CommitSize
Definition: mmfuncs.h:406
NTSTATUS NTAPI MmUnmapViewOfSection(_In_ struct _EPROCESS *Process, _In_ PVOID BaseAddress)
NTSTATUS NTAPI NtMapUserPhysicalPagesScatter(_In_ PVOID *VirtualAddresses, _In_ ULONG_PTR NumberOfPages, _Inout_ PULONG_PTR UserPfnArray)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:408
NTSYSCALLAPI NTSTATUS NTAPI NtLockVirtualMemory(_In_ HANDLE ProcessHandle, _Inout_ PVOID *BaseAddress, _Inout_ PSIZE_T NumberOfBytesToLock, _In_ ULONG MapType)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes
Definition: mmfuncs.h:361
__kernel_entry _Inout_ _Inout_ PSIZE_T RegionSize
Definition: mmfuncs.h:172
NTSYSCALLAPI NTSTATUS NTAPI NtQuerySection(_In_ HANDLE SectionHandle, _In_ SECTION_INFORMATION_CLASS SectionInformationClass, _Out_ PVOID SectionInformation, _In_ SIZE_T Length, _Out_ PSIZE_T ResultLength)
NTSYSCALLAPI NTSTATUS NTAPI NtOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
NTSTATUS NTAPI MmCreateSection(_Out_ PVOID *SectionObject, _In_ ACCESS_MASK DesiredAccess, _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, _In_ PLARGE_INTEGER MaximumSize, _In_ ULONG SectionPageProtection, _In_ ULONG AllocationAttributes, _In_opt_ HANDLE FileHandle, _In_opt_ PFILE_OBJECT File)
NTSYSAPI NTSTATUS NTAPI ZwProtectVirtualMemory(_In_ HANDLE ProcessHandle, _In_ PVOID *BaseAddress, _In_ SIZE_T *NumberOfBytesToProtect, _In_ ULONG NewAccessProtection, _Out_ PULONG OldAccessProtection)
__kernel_entry _Inout_ _Inout_ PSIZE_T _In_ ULONG FreeType
Definition: mmfuncs.h:174
enum _SECTION_INFORMATION_CLASS SECTION_INFORMATION_CLASS
enum _MEMORY_INFORMATION_CLASS MEMORY_INFORMATION_CLASS
ULONG ACCESS_MASK
Definition: nt_native.h:40
enum _SECTION_INHERIT SECTION_INHERIT
#define NTSYSCALLAPI
Definition: ntbasedef.h:204
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI NtFreeVirtualMemory(IN HANDLE ProcessHandle, IN PVOID *UBaseAddress, IN PSIZE_T URegionSize, IN ULONG FreeType)
Definition: virtual.c:5224
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4486
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
static WCHAR Address[46]
Definition: ping.c:68
#define __kernel_entry
Definition: specstrings.h:355
ULONG_PTR * PSIZE_T
Definition: typedefs.h:80
uint32_t * PULONG_PTR
Definition: typedefs.h:65
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
* PFILE_OBJECT
Definition: iotypes.h:1998
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:221