ReactOS 0.4.17-dev-1190-g4c812f4
ZwAllocateVirtualMemory.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite ZwAllocateVirtualMemory/ZwFreeVirtualMemory
5 * PROGRAMMER: Nikolay Borisov <nib9@aber.ac.uk>
6 */
7
8#include <kmt_test.h>
9
10#define ROUND_DOWN(n,align) (((ULONG_PTR)n) & ~((align) - 1l))
11#define DEFAULT_ALLOC_SIZE 200
12#define IGNORE -1
13#define PAGE_NOPROT 0x0 //MEM_RESERVE has this type of "protection"
14
15/* These are being used in ZwMapViewOfSection as well */
16const char TestString[] = "TheLongBrownFoxJumpedTheWhiteRabbitTheLongBrownFoxJumpedTheWhiteRabbitTheLongBrownFoxJumpedTheWhiteRabbitTheLongBrownFoxJumpedTheWhiteRabbitTheLongBrownFoxJumpedTheWhiteRabbitTheLongBrownFoxJumpedThe";
18
20
21typedef struct _TEST_CONTEXT
22{
27 PVOID Bases[1024];
30
31
32#define ALLOC_MEMORY_WITH_FREE(ProcessHandle, BaseAddress, ZeroBits, RegionSize, AllocationType, Protect, RetStatus, FreeStatus) \
33 do { \
34 PVOID __BaseSave = BaseAddress; \
35 Status = ZwAllocateVirtualMemory(ProcessHandle, &BaseAddress, ZeroBits, &RegionSize, AllocationType, Protect); \
36 ok_eq_hex(Status, RetStatus); \
37 if (__BaseSave != NULL) \
38 ok_eq_pointer(BaseAddress, __BaseSave); \
39 else if (!NT_SUCCESS(Status)) \
40 ok_eq_pointer(BaseAddress, NULL); \
41 RegionSize = 0; \
42 Status = ZwFreeVirtualMemory(ProcessHandle, &BaseAddress, &RegionSize, MEM_RELEASE); \
43 if (FreeStatus != IGNORE) ok_eq_hex(Status, FreeStatus); \
44 BaseAddress = NULL; \
45 RegionSize = DEFAULT_ALLOC_SIZE; \
46 } while (0) \
47
48
49
50static
53{
54 PUCHAR Array = Buffer;
55 SIZE_T i;
56
57 for (i = 0; i < Size; i++)
58 {
59 if (Array[i] != Value)
60 {
61 trace("Expected %x, found %x at offset %lu\n", Value, Array[i], (ULONG)i);
62 return FALSE;
63 }
64 }
65 return TRUE;
66}
67
68static
71{
72 SIZE_T Match = 0;
73
76 KmtEndSeh(ExpectedStatus);
77
78 return Match;
79}
80
81static
82VOID
84{
85 //do a little bit of writing/reading to memory
86 SIZE_T Match = 0;
87
90 KmtEndSeh(ExpectedStatus);
91
92 Match = CheckBufferRead(Source, Destination, Length, ExpectedStatus);
93 if (ExpectedStatus == STATUS_SUCCESS) ok_eq_int(Match, Length);
94}
95
96
97static
98VOID
100{
102 PVOID Base = NULL;
104
105 //HANDLE TESTS
109
110 //BASE ADDRESS TESTS
111 Base = (PVOID) 0x60000000;
113
114 Base = (PVOID)((char *)MmSystemRangeStart + 200);
116
117 /* http://jira.reactos.org/browse/CORE-6814 */
118 RegionSize = 0x1000;
121
122 //ZERO BITS TESTS
126 // -1 is valid on x64, see ZeroBitsTest below
127#ifndef _WIN64
129#endif
130
131 //REGION SIZE TESTS
133 RegionSize = -1;
135 RegionSize = 0;
137
138 //Allocation type tests
153
154 //Memory protection tests
158 {
161 }
163}
164
165
166static
169{
171 PVOID Base = NULL;
173
175 //Normal operation
177 Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &RegionSize, MEM_COMMIT, PAGE_READWRITE);
178 ok_eq_size(RegionSize, 4096);
179
180 //check for the zero-filled pages
181 ok_bool_true(CheckBuffer(Base, RegionSize, 0), "The buffer is not zero-filled");
182
184
185 // try freeing
186 RegionSize = 0;
187 Status = ZwFreeVirtualMemory(NtCurrentProcess(), &Base, &RegionSize, MEM_RELEASE);
190
192 // COMMIT AND RESERVE SCENARIO AND STATE CHANGE
194 //reserve and then commit
195 Base = NULL;
197 Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &RegionSize, MEM_RESERVE, PAGE_READWRITE);
200
201
202 Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &RegionSize, MEM_COMMIT, PAGE_READWRITE);
205
206 RegionSize = 0;
207 ZwFreeVirtualMemory(NtCurrentProcess(), &Base, &RegionSize, MEM_RELEASE);
208
210 // TRY READING/WRITING TO INVALID PROTECTION PAGES
213 Base = NULL;
214 ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_NOACCESS);
215
219
222
223 RegionSize = 0;
224 ZwFreeVirtualMemory(NtCurrentProcess(), &Base, &RegionSize, MEM_RELEASE);
225
226 ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READONLY);
230
232
233 ok_bool_true(CheckBuffer(Base, TestStringSize, 0), "Couldn't read a read-only buffer");
234
235 RegionSize = 0;
236 ZwFreeVirtualMemory(NtCurrentProcess(), &Base, &RegionSize, MEM_RELEASE);
237
239 // GUARD PAGES
241
242 RegionSize = 1000;
243 Base = NULL;
244 ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &RegionSize, (MEM_COMMIT | MEM_RESERVE), (PAGE_GUARD | PAGE_READWRITE));
245
250
252
256
257 RegionSize = 0;
258 ZwFreeVirtualMemory(NtCurrentProcess(), &Base, &RegionSize, MEM_RELEASE);
259
260 return Status;
261}
262
263
264static
265VOID
267{
269 SIZE_T RegionSize = 200;
270 PVOID Base = (PVOID) 0x60025000;
271 PVOID ActualStartingAddress = (PVOID)ROUND_DOWN(Base, MM_ALLOCATION_GRANULARITY); //it is rounded down to the nearest allocation granularity (64k) address
272 PVOID EndingAddress = (PVOID)(((ULONG_PTR)Base + RegionSize - 1) | (PAGE_SIZE - 1));
273 SIZE_T ActualSize = BYTES_TO_PAGES((ULONG_PTR)EndingAddress - (ULONG_PTR)ActualStartingAddress) * PAGE_SIZE; //calculates the actual size based on the required pages
275
276 // allocate the memory
277 Status = ZwAllocateVirtualMemory(NtCurrentProcess(), (PVOID *)&Base, 0, &RegionSize, (MEM_COMMIT | MEM_RESERVE), PAGE_READWRITE);
279 ok_eq_size(RegionSize, ActualSize);
280 ok_eq_ulong(Base, ActualStartingAddress);
281 Test_NtQueryVirtualMemory(ActualStartingAddress, ActualSize, MEM_COMMIT, PAGE_READWRITE);
282
283 // try freeing
284 RegionSize = 0;
285 Status = ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *)&Base, &RegionSize, MEM_RELEASE);
287 ok_eq_ulong(RegionSize, ActualSize);
288
289 // try to use process memory as base address
291 if (NT_SUCCESS(Status))
292 {
293 PPEB Peb = pbi.PebBaseAddress;
294 Base = NULL;
296
300
301 if (Base)
302 {
304 }
305 }
306 else
307 {
309 }
310}
311
312static
315{
317 NTSTATUS ReturnStatus = STATUS_SUCCESS;
318 ULONG Index = 0;
319 PVOID Base = NULL;
320 PVOID *bases = NULL;
321 ULONG NumberOfElements;
323
324#ifdef _WIN64
325 // 256 TB total, large chunks keep the VAD count low
326 NumberOfElements = 4096;
327 RegionSize = 64ULL * 1024 * 1024 * 1024;
328#else
329 // 5 GB total
330 NumberOfElements = 1024;
331 RegionSize = 5 * 1024 * 1024;
332#endif
333
334 bases = ExAllocatePoolZero(PagedPool, NumberOfElements * sizeof(*bases), 'stts');
335 if (!bases)
336 {
337 trace("Failed to allocate memory for bases array\n");
339 }
340
341 for (Index = 0; Index < NumberOfElements && NT_SUCCESS(Status); Index++)
342 {
343 Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &RegionSize, AllocationType, PAGE_READWRITE);
344
345 bases[Index] = Base;
346 if ((Index % 10) == 0)
347 {
349 {
351 }
352 else
353 {
355 }
356 }
357
358 Base = NULL;
359 }
360
361 trace("Finished reserving. Error code %x. Chunks allocated: %d\n", Status, Index );
362
363 ReturnStatus = Status;
364
365 //free the allocated memory so that we can continue with the tests
367 Index = 0;
368 while (NT_SUCCESS(Status) && Index < NumberOfElements)
369 {
370 RegionSize = 0;
371 Status = ZwFreeVirtualMemory(NtCurrentProcess(), &bases[Index], &RegionSize, MEM_RELEASE);
372 bases[Index++] = NULL;
373 }
374
375 ExFreePoolWithTag(bases, 'stts');
376 return ReturnStatus;
377}
378
379static
380VOID
382{
384 PVOID Base = NULL;
385 SIZE_T RegionSize = 1;
386 ULONG_PTR MaxPtr = -1;
387
388 /* https://stackoverflow.com/a/50553691 */
389#ifdef _WIN64
391 {
392 for (ULONG_PTR ZeroBits = MaxPtr; Status == STATUS_SUCCESS && ZeroBits > 32; ZeroBits >>= 1)
393 {
395 trace("%p:%p - Status: %x\n", ZeroBits, Base, Status);
396 if ((ULONG_PTR)Base > ZeroBits)
397 {
398 ok_eq_pointer((ULONG_PTR)Base, (ZeroBits >> 16) << 16);
399 }
400 ZwFreeVirtualMemory(NtCurrentProcess(), &Base, &RegionSize, MEM_RELEASE);
401 Base = NULL;
402 RegionSize = 1;
403 }
404 ok(Status == STATUS_SUCCESS || Status == STATUS_NO_MEMORY, "ZeroBits mask test failed\n");
405 }
406#endif
407
409 for (ULONG_PTR ZeroBits = 0; Status == STATUS_SUCCESS && ZeroBits <= 32; ZeroBits += 1)
410 {
412 ok_bool_true((ULONG_PTR)Base < (MaxPtr >> ZeroBits), "Base must be < (MaxPtr >> ZeroBits)\n");
413 ZwFreeVirtualMemory(NtCurrentProcess(), &Base, &RegionSize, MEM_RELEASE);
414 Base = NULL;
415 RegionSize = 1;
416 }
417 ok(Status == STATUS_SUCCESS || Status == STATUS_NO_MEMORY, "ZeroBits test failed\n");
418}
419
420
421static
422VOID
423NTAPI
425{
427 PTEST_CONTEXT Context = (PTEST_CONTEXT)StartContext;
428 ULONG Index = 0;
429 PVOID Base = NULL;
430
431 PAGED_CODE();
432
433 RtlZeroMemory(Context->Bases, sizeof(Context->Bases));
434
435 Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &Context->RegionSize, Context->AllocationType, Context->Protect);
436 ZwFreeVirtualMemory(NtCurrentProcess(), &Base, &Context->RegionSize, MEM_RELEASE);
437 Base = NULL;
438
439 //if the previous allocation has failed there is no need to do the loop
440 while (NT_SUCCESS(Status) && Index < RTL_NUMBER_OF(Context->Bases))
441 {
442 Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &Base, 0, &Context->RegionSize, Context->AllocationType, Context->Protect);
443
444 Context->Bases[Index] = Base;
445 if ((Index % 10) == 0)
446 {
447 if (Context->AllocationType == MEM_COMMIT)
448 {
450 }
451 else
452 {
454 }
455 }
456
457 Base = NULL;
458 Index++;
459 }
460
461 trace("[SYSTEM THREAD %d]. Error code %x. Chunks allocated: %d\n", Context->ThreadId, Status, Index);
462
463 //free the allocated memory so that we can continue with the tests
465 Index = 0;
466 while (NT_SUCCESS(Status) && Index < RTL_NUMBER_OF(Context->Bases))
467 {
468 Context->RegionSize = 0;
469 Status = ZwFreeVirtualMemory(NtCurrentProcess(), &Context->Bases[Index], &Context->RegionSize, MEM_RELEASE);
470 Context->Bases[Index++] = NULL;
471 }
472
474}
475
476
477static
478VOID
480{
481 PAGED_CODE();
482
484 Ctx->Protect = Protect;
485 Ctx->RegionSize = RegionSize;
486 Ctx->ThreadId = ThreadId;
487}
488
489
490static
491VOID
493{
497 PVOID ThreadObjects[2] = { NULL };
499 PTEST_CONTEXT StartContext1;
500 PTEST_CONTEXT StartContext2;
501
502 PAGED_CODE();
503
504 StartContext1 = ExAllocatePoolWithTag(PagedPool, sizeof(TEST_CONTEXT), 'tXTC');
505 StartContext2 = ExAllocatePoolWithTag(PagedPool, sizeof(TEST_CONTEXT), 'tXTC');
506 if (StartContext1 == NULL || StartContext2 == NULL)
507 {
508 trace("Error allocating space for context structs\n");
509 goto cleanup;
510 }
511
512 KmtInitTestContext(StartContext1, 1, 1 * 1024 * 1024, MEM_COMMIT, PAGE_READWRITE);
513 KmtInitTestContext(StartContext2, 2, 3 * 1024 * 1024, MEM_COMMIT, PAGE_READWRITE);
515
517 if (!NT_SUCCESS(Status))
518 {
519 trace("Error creating thread1\n");
520 goto cleanup;
521 }
522
524 if (!NT_SUCCESS(Status))
525 {
526 trace("error referencing thread1\n");
527 goto cleanup;
528 }
529
531 if (!NT_SUCCESS(Status))
532 {
533 trace("Error creating thread2\n");
534 goto cleanup;
535 }
536
538 if (!NT_SUCCESS(Status))
539 {
540 trace("error referencing thread2\n");
541 goto cleanup;
542 }
543
544cleanup:
545
546 if (ThreadObjects[0])
548
549 if (StartContext1 != NULL)
550 ExFreePoolWithTag(StartContext1, 'tXTC');
551
552 if (ThreadObjects[1])
554
555 if (StartContext2 != NULL)
556 ExFreePoolWithTag(StartContext2, 'tXTC');
557
558 if (ThreadObjects[0] != NULL)
559 ObDereferenceObject(ThreadObjects[0]);
560
561 if (ThreadObjects[1] != NULL)
562 ObDereferenceObject(ThreadObjects[1]);
563
566
569}
570
571
572START_TEST(ZwAllocateVirtualMemory)
573{
575
577
579
581
583#ifdef _WIN64
585 "Expected STATUS_NO_MEMORY or STATUS_COMMITMENT_LIMIT, got 0x%lx\n", Status);
586#else
588#endif
589
591#ifdef _WIN64
593#else
595#endif
596
597 ZeroBitsTest();
598
600}
#define PAGED_CODE()
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static DWORD WINAPI Thread2(_Inout_opt_ PVOID Parameter)
static DWORD WINAPI Thread1(_Inout_opt_ PVOID Parameter)
static VOID SystemProcessTest(VOID)
struct _TEST_CONTEXT TEST_CONTEXT
static VOID CustomBaseAllocation(VOID)
#define ALLOC_MEMORY_WITH_FREE(ProcessHandle, BaseAddress, ZeroBits, RegionSize, AllocationType, Protect, RetStatus, FreeStatus)
#define PAGE_NOPROT
static VOID KmtInitTestContext(PTEST_CONTEXT Ctx, SHORT ThreadId, ULONG RegionSize, ULONG AllocationType, ULONG Protect)
static VOID NTAPI SystemProcessTestWorker(PVOID StartContext)
#define ROUND_DOWN(n, align)
static SIZE_T CheckBufferRead(CONST VOID *Source, CONST VOID *Destination, SIZE_T Length, NTSTATUS ExpectedStatus)
struct _TEST_CONTEXT * PTEST_CONTEXT
static VOID ZeroBitsTest(VOID)
static VOID CheckBufferReadWrite(PVOID Destination, CONST VOID *Source, SIZE_T Length, NTSTATUS ExpectedStatus)
const ULONG TestStringSize
#define DEFAULT_ALLOC_SIZE
static NTSTATUS StressTesting(ULONG AllocationType)
const char TestString[]
static VOID SimpleErrorChecks(VOID)
static NTSTATUS SimpleAllocation(VOID)
static BOOLEAN CheckBuffer(PVOID Buffer, SIZE_T Size, UCHAR Value)
unsigned char BOOLEAN
Definition: actypes.h:127
#define ok_eq_pointer(value, expected)
Definition: apitest.h:118
#define ok_eq_hex(value, expected)
Definition: apitest.h:136
#define ok_eq_ulong(value, expected)
Definition: apitest.h:122
#define GetNTVersion()
Definition: apitest.h:17
#define ok_bool_true(value, desc)
Definition: apitest.h:137
#define ok_eq_size(value, expected)
Definition: apitest.h:128
#define ok_eq_int(value, expected)
Definition: apitest.h:119
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
@ ProcessBasicInformation
Definition: cicbase.cpp:63
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PAGE_READONLY
Definition: compat.h:138
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
static void cleanup(void)
Definition: main.c:1335
PPEB Peb
Definition: dllmain.c:27
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PagedPool
Definition: env_spec_w32.h:308
#define STATUS_ACCESS_VIOLATION
Status
Definition: gdiplustypes.h:24
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define KmtStartSeh()
Definition: kmt_test.h:289
#define Test_NtQueryVirtualMemory(BaseAddress, Size, AllocationType, ProtectionType)
Definition: kmt_test.h:78
#define KmtEndSeh(ExpectedStatus)
Definition: kmt_test.h:295
BOOLEAN KmtIsCheckedBuild
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
#define MM_ALLOCATION_GRANULARITY
Definition: mmtypes.h:36
#define KernelMode
Definition: asm.h:38
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR ZeroBits
Definition: mmfuncs.h:409
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize _Pre_valid_ PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ ULONG AllocationType
Definition: mmfuncs.h:414
__kernel_entry _Inout_ _Inout_ PSIZE_T RegionSize
Definition: mmfuncs.h:176
#define MEM_PHYSICAL
Definition: mmtypes.h:87
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSYSAPI NTSTATUS NTAPI ZwQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3051
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2486
#define MEM_TOP_DOWN
Definition: nt_native.h:1324
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1342
#define PAGE_WRITECOPY
Definition: nt_native.h:1308
#define PAGE_READWRITE
Definition: nt_native.h:1307
#define MEM_RESET
Definition: nt_native.h:1323
#define NtCurrentProcess()
Definition: nt_native.h:1660
#define PAGE_EXECUTE_WRITECOPY
Definition: nt_native.h:1312
#define MEM_RESERVE
Definition: nt_native.h:1317
#define MEM_RELEASE
Definition: nt_native.h:1319
#define MEM_COMMIT
Definition: nt_native.h:1316
#define PAGE_NOACCESS
Definition: nt_native.h:1305
#define PAGE_GUARD
Definition: nt_native.h:1313
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define MmSystemRangeStart
Definition: mm.h:34
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1181
POBJECT_TYPE PsThreadType
Definition: thread.c:20
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:626
#define STATUS_UNABLE_TO_DELETE_SECTION
Definition: ntstatus.h:357
#define STATUS_MEMORY_NOT_ALLOCATED
Definition: ntstatus.h:490
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:572
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:570
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:354
#define STATUS_INVALID_PAGE_PROTECTION
Definition: ntstatus.h:399
#define STATUS_GUARD_PAGE_VIOLATION
Definition: ntstatus.h:262
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:571
#define STATUS_INVALID_PARAMETER_5
Definition: ntstatus.h:573
#define STATUS_COMMITMENT_LIMIT
Definition: ntstatus.h:631
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:493
#define CONST
Definition: pedump.c:81
short SHORT
Definition: pedump.c:59
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
KMT_TESTFUNC Test_ZwAllocateVirtualMemory
Definition: testlist.c:91
#define _WIN32_WINNT_WINBLUE
Definition: sdkddkver.h:30
#define STATUS_SUCCESS
Definition: shellext.h:65
PVOID ImageBaseAddress
Definition: ntddk_ex.h:245
EH_STD::basic_string< char, EH_STD::char_traits< char >, eh_allocator(char) > TestString
Definition: test_string.cpp:30
unsigned char UCHAR
Definition: typedefs.h:53
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static int Protect(const char **args)
Definition: vfdcmd.c:2132
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
@ Executive
Definition: ketypes.h:467
#define BYTES_TO_PAGES(Size)
#define PAGE_WRITECOMBINE
Definition: mmtypes.h:78
#define ObDereferenceObject
Definition: obfuncs.h:203