[RTL/NDK]
[reactos.git] / reactos / include / ndk / mmfuncs.h
1 /*++ NDK Version: 0098
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 mmfuncs.h
8
9 Abstract:
10
11 Functions definitions for the Memory Manager.
12
13 Author:
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 //
33 NTSTATUS
34 NTAPI
35 MmCreateSection(
36 OUT PVOID *SectionObject,
37 IN ACCESS_MASK DesiredAccess,
38 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
39 IN PLARGE_INTEGER MaximumSize,
40 IN ULONG SectionPageProtection,
41 IN ULONG AllocationAttributes,
42 IN HANDLE FileHandle OPTIONAL,
43 IN PFILE_OBJECT File OPTIONAL
44 );
45
46 NTSTATUS
47 NTAPI
48 MmMapViewOfSection(
49 IN PVOID SectionObject,
50 IN PEPROCESS Process,
51 IN OUT PVOID *BaseAddress,
52 IN ULONG_PTR ZeroBits,
53 IN SIZE_T CommitSize,
54 IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
55 IN OUT PSIZE_T ViewSize,
56 IN SECTION_INHERIT InheritDisposition,
57 IN ULONG AllocationType,
58 IN ULONG Protect
59 );
60
61 NTSTATUS
62 NTAPI
63 MmUnmapViewOfSection(
64 struct _EPROCESS* Process,
65 PVOID BaseAddress
66 );
67
68 #endif
69
70 //
71 // Native calls
72 //
73 NTSYSCALLAPI
74 NTSTATUS
75 NTAPI
76 NtAreMappedFilesTheSame(
77 IN PVOID File1MappedAsAnImage,
78 IN PVOID File2MappedAsFile
79 );
80
81 NTSTATUS
82 NTAPI
83 NtAllocateUserPhysicalPages(
84 IN HANDLE ProcessHandle,
85 IN OUT PULONG_PTR NumberOfPages,
86 IN OUT PULONG_PTR UserPfnArray
87 );
88
89 NTSYSCALLAPI
90 NTSTATUS
91 NTAPI
92 NtAllocateVirtualMemory(
93 IN HANDLE ProcessHandle,
94 IN OUT PVOID *BaseAddress,
95 IN ULONG_PTR ZeroBits,
96 IN OUT PSIZE_T RegionSize,
97 IN ULONG AllocationType,
98 IN ULONG Protect
99 );
100
101 NTSYSCALLAPI
102 NTSTATUS
103 NTAPI
104 NtCreatePagingFile(
105 IN PUNICODE_STRING FileName,
106 IN PLARGE_INTEGER InitialSize,
107 IN PLARGE_INTEGER MaxiumSize,
108 IN ULONG Reserved
109 );
110
111 NTSYSCALLAPI
112 NTSTATUS
113 NTAPI
114 NtCreateSection(
115 OUT PHANDLE SectionHandle,
116 IN ACCESS_MASK DesiredAccess,
117 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
118 IN PLARGE_INTEGER MaximumSize OPTIONAL,
119 IN ULONG SectionPageProtection OPTIONAL,
120 IN ULONG AllocationAttributes,
121 IN HANDLE FileHandle OPTIONAL
122 );
123
124 NTSYSCALLAPI
125 NTSTATUS
126 NTAPI
127 NtExtendSection(
128 IN HANDLE SectionHandle,
129 IN PLARGE_INTEGER NewMaximumSize
130 );
131
132 NTSYSCALLAPI
133 NTSTATUS
134 NTAPI
135 NtFlushVirtualMemory(
136 IN HANDLE ProcessHandle,
137 IN OUT PVOID *BaseAddress,
138 IN OUT PSIZE_T RegionSize,
139 OUT PIO_STATUS_BLOCK IoStatus
140 );
141
142 NTSTATUS
143 NTAPI
144 NtFreeUserPhysicalPages(
145 IN HANDLE ProcessHandle,
146 IN OUT PULONG_PTR NumberOfPages,
147 IN OUT PULONG_PTR UserPfnArray
148 );
149
150 NTSYSCALLAPI
151 NTSTATUS
152 NTAPI
153 NtFreeVirtualMemory(
154 IN HANDLE ProcessHandle,
155 IN PVOID *BaseAddress,
156 IN PSIZE_T RegionSize,
157 IN ULONG FreeType
158 );
159
160
161 NTSTATUS
162 NTAPI
163 NtGetWriteWatch(
164 IN HANDLE ProcessHandle,
165 IN ULONG Flags,
166 IN PVOID BaseAddress,
167 IN SIZE_T RegionSize,
168 IN PVOID *UserAddressArray,
169 OUT PULONG_PTR EntriesInUserAddressArray,
170 OUT PULONG Granularity
171 );
172
173 NTSYSCALLAPI
174 NTSTATUS
175 NTAPI
176 NtLockVirtualMemory(
177 IN HANDLE ProcessHandle,
178 IN OUT PVOID *BaseAddress,
179 IN OUT PSIZE_T NumberOfBytesToLock,
180 IN ULONG MapType
181 );
182
183 NTSTATUS
184 NTAPI
185 NtMapUserPhysicalPages(
186 IN PVOID VirtualAddresses,
187 IN ULONG_PTR NumberOfPages,
188 IN OUT PULONG_PTR UserPfnArray
189 );
190
191 NTSTATUS
192 NTAPI
193 NtMapUserPhysicalPagesScatter(
194 IN PVOID *VirtualAddresses,
195 IN ULONG_PTR NumberOfPages,
196 IN OUT PULONG_PTR UserPfnArray
197 );
198
199 NTSYSCALLAPI
200 NTSTATUS
201 NTAPI
202 NtMapViewOfSection(
203 IN HANDLE SectionHandle,
204 IN HANDLE ProcessHandle,
205 IN OUT PVOID *BaseAddress,
206 IN ULONG_PTR ZeroBits,
207 IN SIZE_T CommitSize,
208 IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
209 IN OUT PSIZE_T ViewSize,
210 IN SECTION_INHERIT InheritDisposition,
211 IN ULONG AllocationType,
212 IN ULONG AccessProtection
213 );
214
215 NTSYSCALLAPI
216 NTSTATUS
217 NTAPI
218 NtOpenSection(
219 OUT PHANDLE SectionHandle,
220 IN ACCESS_MASK DesiredAccess,
221 IN POBJECT_ATTRIBUTES ObjectAttributes
222 );
223
224 NTSYSCALLAPI
225 NTSTATUS
226 NTAPI
227 NtProtectVirtualMemory(
228 IN HANDLE ProcessHandle,
229 IN PVOID *BaseAddress,
230 IN SIZE_T *NumberOfBytesToProtect,
231 IN ULONG NewAccessProtection,
232 OUT PULONG OldAccessProtection
233 );
234
235 NTSYSCALLAPI
236 NTSTATUS
237 NTAPI
238 NtQuerySection(
239 IN HANDLE SectionHandle,
240 IN SECTION_INFORMATION_CLASS SectionInformationClass,
241 OUT PVOID SectionInformation,
242 IN SIZE_T Length,
243 OUT PSIZE_T ResultLength
244 );
245
246 NTSYSCALLAPI
247 NTSTATUS
248 NTAPI
249 NtQueryVirtualMemory(
250 IN HANDLE ProcessHandle,
251 IN PVOID Address,
252 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass,
253 OUT PVOID VirtualMemoryInformation,
254 IN SIZE_T Length,
255 OUT PSIZE_T ResultLength
256 );
257
258 NTSYSCALLAPI
259 NTSTATUS
260 NTAPI
261 NtReadVirtualMemory(
262 IN HANDLE ProcessHandle,
263 IN PVOID BaseAddress,
264 OUT PVOID Buffer,
265 IN SIZE_T NumberOfBytesToRead,
266 OUT PSIZE_T NumberOfBytesRead
267 );
268
269 NTSTATUS
270 NTAPI
271 NtResetWriteWatch(
272 IN HANDLE ProcessHandle,
273 IN PVOID BaseAddress,
274 IN SIZE_T RegionSize
275 );
276
277 NTSYSCALLAPI
278 NTSTATUS
279 NTAPI
280 NtUnlockVirtualMemory(
281 IN HANDLE ProcessHandle,
282 IN OUT PVOID *BaseAddress,
283 IN OUT PSIZE_T NumberOfBytesToUnlock,
284 IN ULONG MapType
285 );
286
287 NTSYSCALLAPI
288 NTSTATUS
289 NTAPI
290 NtUnmapViewOfSection(
291 IN HANDLE ProcessHandle,
292 IN PVOID BaseAddress
293 );
294
295 NTSYSCALLAPI
296 NTSTATUS
297 NTAPI
298 NtWriteVirtualMemory(
299 IN HANDLE ProcessHandle,
300 IN PVOID BaseAddress,
301 IN PVOID Buffer,
302 IN SIZE_T NumberOfBytesToWrite,
303 OUT PSIZE_T NumberOfBytesWritten
304 );
305
306 NTSYSAPI
307 NTSTATUS
308 NTAPI
309 ZwAreMappedFilesTheSame(
310 IN PVOID File1MappedAsAnImage,
311 IN PVOID File2MappedAsFile
312 );
313
314 NTSYSAPI
315 NTSTATUS
316 NTAPI
317 ZwAllocateVirtualMemory(
318 IN HANDLE ProcessHandle,
319 IN OUT PVOID *BaseAddress,
320 IN ULONG_PTR ZeroBits,
321 IN OUT PSIZE_T RegionSize,
322 IN ULONG AllocationType,
323 IN ULONG Protect
324 );
325
326 NTSYSAPI
327 NTSTATUS
328 NTAPI
329 ZwCreatePagingFile(
330 IN PUNICODE_STRING FileName,
331 IN PLARGE_INTEGER InitialSize,
332 IN PLARGE_INTEGER MaxiumSize,
333 IN ULONG Reserved
334 );
335
336 NTSYSAPI
337 NTSTATUS
338 NTAPI
339 ZwCreateSection(
340 OUT PHANDLE SectionHandle,
341 IN ACCESS_MASK DesiredAccess,
342 IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
343 IN PLARGE_INTEGER MaximumSize OPTIONAL,
344 IN ULONG SectionPageProtection OPTIONAL,
345 IN ULONG AllocationAttributes,
346 IN HANDLE FileHandle OPTIONAL
347 );
348
349 NTSYSAPI
350 NTSTATUS
351 NTAPI
352 ZwExtendSection(
353 IN HANDLE SectionHandle,
354 IN PLARGE_INTEGER NewMaximumSize
355 );
356
357 NTSYSAPI
358 NTSTATUS
359 NTAPI
360 ZwFreeVirtualMemory(
361 IN HANDLE ProcessHandle,
362 IN PVOID *BaseAddress,
363 IN PSIZE_T RegionSize,
364 IN ULONG FreeType
365 );
366
367 NTSYSAPI
368 NTSTATUS
369 NTAPI
370 ZwLockVirtualMemory(
371 IN HANDLE ProcessHandle,
372 IN OUT PVOID *BaseAddress,
373 IN OUT PSIZE_T NumberOfBytesToLock,
374 IN ULONG MapType
375 );
376
377 NTSYSAPI
378 NTSTATUS
379 NTAPI
380 ZwMapViewOfSection(
381 IN HANDLE SectionHandle,
382 IN HANDLE ProcessHandle,
383 IN OUT PVOID *BaseAddress,
384 IN ULONG_PTR ZeroBits,
385 IN SIZE_T CommitSize,
386 IN OUT PLARGE_INTEGER SectionOffset OPTIONAL,
387 IN OUT PSIZE_T ViewSize,
388 IN SECTION_INHERIT InheritDisposition,
389 IN ULONG AllocationType,
390 IN ULONG AccessProtection
391 );
392
393 NTSYSAPI
394 NTSTATUS
395 NTAPI
396 ZwOpenSection(
397 OUT PHANDLE SectionHandle,
398 IN ACCESS_MASK DesiredAccess,
399 IN POBJECT_ATTRIBUTES ObjectAttributes
400 );
401
402 NTSYSAPI
403 NTSTATUS
404 NTAPI
405 ZwProtectVirtualMemory(
406 IN HANDLE ProcessHandle,
407 IN PVOID *BaseAddress,
408 IN SIZE_T *NumberOfBytesToProtect,
409 IN ULONG NewAccessProtection,
410 OUT PULONG OldAccessProtection
411 );
412
413 NTSYSAPI
414 NTSTATUS
415 NTAPI
416 ZwQuerySection(
417 IN HANDLE SectionHandle,
418 IN SECTION_INFORMATION_CLASS SectionInformationClass,
419 OUT PVOID SectionInformation,
420 IN SIZE_T Length,
421 OUT PSIZE_T ResultLength
422 );
423
424 NTSYSAPI
425 NTSTATUS
426 NTAPI
427 ZwQueryVirtualMemory(
428 IN HANDLE ProcessHandle,
429 IN PVOID Address,
430 IN MEMORY_INFORMATION_CLASS VirtualMemoryInformationClass,
431 OUT PVOID VirtualMemoryInformation,
432 IN SIZE_T Length,
433 OUT PSIZE_T ResultLength
434 );
435
436 NTSYSAPI
437 NTSTATUS
438 NTAPI
439 ZwReadVirtualMemory(
440 IN HANDLE ProcessHandle,
441 IN PVOID BaseAddress,
442 OUT PVOID Buffer,
443 IN SIZE_T NumberOfBytesToRead,
444 OUT PSIZE_T NumberOfBytesRead
445 );
446
447 NTSYSAPI
448 NTSTATUS
449 NTAPI
450 ZwUnlockVirtualMemory(
451 IN HANDLE ProcessHandle,
452 IN OUT PVOID *BaseAddress,
453 IN OUT PSIZE_T NumberOfBytesToUnlock,
454 IN ULONG MapType
455 );
456
457 NTSYSAPI
458 NTSTATUS
459 NTAPI
460 ZwUnmapViewOfSection(
461 IN HANDLE ProcessHandle,
462 IN PVOID BaseAddress
463 );
464
465 NTSYSAPI
466 NTSTATUS
467 NTAPI
468 ZwWriteVirtualMemory(
469 IN HANDLE ProcessHandle,
470 IN PVOID BaseAddress,
471 IN PVOID Buffer,
472 IN SIZE_T NumberOfBytesToWrite,
473 OUT PSIZE_T NumberOfBytesWritten
474 );
475
476 #endif