ReactOS  0.4.14-dev-57-g333b8f1
ZwMapViewOfSection.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 ZwMapViewOfSection
5 * PROGRAMMER: Nikolay Borisov <nib9@aber.ac.uk>
6 */
7 
8 #include <kmt_test.h>
9 
10 #define IGNORE -99
11 #define NEW_CONTENT "NewContent"
12 #define NEW_CONTENT_LEN sizeof(NEW_CONTENT)
13 
14 static UNICODE_STRING FileReadOnlyPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll");
15 static UNICODE_STRING NtosImgPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntoskrnl.exe");
16 static UNICODE_STRING WritableFilePath = RTL_CONSTANT_STRING(L"\\SystemRoot\\kmtest-MmSection.txt");
17 static UNICODE_STRING SharedSectionName = RTL_CONSTANT_STRING(L"\\BaseNamedObjects\\kmtest-SharedSection");
18 extern const char TestString[];
19 extern const ULONG TestStringSize;
23 
24 #define TestMapView(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus) do \
25  { \
26  Status = ZwMapViewOfSection(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect); \
27  ok_eq_hex(Status, MapStatus); \
28  if (NT_SUCCESS(Status)) \
29  { \
30  Status = ZwUnmapViewOfSection(ProcessHandle, BaseAddress); \
31  if (UnmapStatus != IGNORE) ok_eq_hex(Status, UnmapStatus); \
32  *BaseAddress2 = NULL; \
33  *ViewSize2 = 0; \
34  } \
35  } while (0) \
36 
37 #define MmTestMapView(Object, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus) do \
38  { \
39  Status = MmMapViewOfSection(Object, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect); \
40  ok_eq_hex(Status, MapStatus); \
41  if (NT_SUCCESS(Status)) \
42  { \
43  Status = MmUnmapViewOfSection(ProcessHandle, BaseAddress); \
44  if (UnmapStatus != IGNORE) ok_eq_hex(Status, UnmapStatus); \
45  *BaseAddress2 = NULL; \
46  *ViewSize2 = 0; \
47  } \
48  } while (0) \
49 
50 #define CheckObject(Handle, Pointers, Handles) do \
51 { \
52  PUBLIC_OBJECT_BASIC_INFORMATION ObjectInfo; \
53  Status = ZwQueryObject(Handle, ObjectBasicInformation, \
54  &ObjectInfo, sizeof ObjectInfo, NULL); \
55  ok_eq_hex(Status, STATUS_SUCCESS); \
56  ok_eq_ulong(ObjectInfo.PointerCount, Pointers); \
57  ok_eq_ulong(ObjectInfo.HandleCount, Handles); \
58 } while (0) \
59 
60 static
61 VOID
62 KmtInitTestFiles(PHANDLE ReadOnlyFile, PHANDLE WriteOnlyFile, PHANDLE ExecutableFile)
63 {
67 
68  //INIT THE READ-ONLY FILE
71  ok(*ReadOnlyFile != NULL, "Couldn't acquire READONLY handle\n");
72 
73  //INIT THE EXECUTABLE FILE
76  ok(*ExecutableFile != NULL, "Couldn't acquire EXECUTE handle\n");
77 
78  //INIT THE WRITE-ONLY FILE
79  //TODO: Delete the file when the tests are all executed
83  ok(*WriteOnlyFile != NULL, "WriteOnlyFile is NULL\n");
84  if (!skip(*WriteOnlyFile != NULL, "No WriteOnlyFile\n"))
85  {
86  FileOffset.QuadPart = 0;
87  Status = ZwWriteFile(*WriteOnlyFile, NULL, NULL, NULL, &IoStatusBlock, (PVOID)TestString, TestStringSize, &FileOffset, NULL);
88  ok(Status == STATUS_SUCCESS || Status == STATUS_PENDING, "Status = 0x%08lx\n", Status);
89  Status = ZwWaitForSingleObject(*WriteOnlyFile, FALSE, NULL);
92  }
93 }
94 
95 static
96 VOID
97 SimpleErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly, HANDLE ExecutableImg)
98 {
100  HANDLE WriteSectionHandle;
101  HANDLE ReadOnlySection;
102  HANDLE PageFileSectionHandle;
105  SIZE_T AllocSize = TestStringSize;
106  SIZE_T ViewSize = 0;
108  PVOID AllocBase = NULL;
109  MaximumSize.QuadPart = TestStringSize;
110 
111  //Used for parameters working on file-based section
112  Status = ZwCreateSection(&WriteSectionHandle, SECTION_ALL_ACCESS, NULL, &MaximumSize, PAGE_READWRITE, SEC_COMMIT, FileHandleWriteOnly);
114 
115  Status = ZwCreateSection(&ReadOnlySection, SECTION_ALL_ACCESS, NULL, &MaximumSize, PAGE_READONLY, SEC_COMMIT, FileHandleReadOnly);
117 
118  //Used for parameters taking effect only on page-file backed section
119  MaximumSize.QuadPart = 5 * MM_ALLOCATION_GRANULARITY;
120  Status = ZwCreateSection(&PageFileSectionHandle, SECTION_ALL_ACCESS, NULL, &MaximumSize, PAGE_READWRITE, SEC_COMMIT, NULL);
122 
123  MaximumSize.QuadPart = TestStringSize;
124 
125  //section handle
130 
131  //process handle
132  TestMapView(WriteSectionHandle, (HANDLE)(ULONG_PTR)0xDEADBEEFDEADBEEFull, &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
134 
135  //base address
136  BaseAddress = (PVOID)(ULONG_PTR)0x00567A20;
138 
139  BaseAddress = (PVOID)(ULONG_PTR)0x60000000;
141 
142  BaseAddress = (PVOID)((char *)MmSystemRangeStart + 200);
144 
145  //invalid section handle AND unaligned base address
146  BaseAddress = (PVOID)(ULONG_PTR)0x00567A20;
148 
149  //invalid process handle AND unaligned base address
150  BaseAddress = (PVOID)(ULONG_PTR)0x00567A20;
151  TestMapView(WriteSectionHandle, (HANDLE)(ULONG_PTR)0xDEADBEEFDEADBEEFull, &BaseAddress, 0, 0, NULL, &ViewSize, ViewUnmap, 0, PAGE_READWRITE, STATUS_INVALID_HANDLE, IGNORE);
152 
153  //try mapping section to an already mapped address
154  Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &AllocBase, 0, &AllocSize, MEM_COMMIT, PAGE_READWRITE);
155  if (!skip(NT_SUCCESS(Status), "Cannot allocate memory\n"))
156  {
157  BaseAddress = AllocBase;
159  Status = ZwFreeVirtualMemory(NtCurrentProcess(), &AllocBase, &AllocSize, MEM_RELEASE);
161  }
162 
163  //zero bits
170 
171  //commit size
178 
179  //section offset
180  SectionOffset.QuadPart = 0;
182  ok_eq_ulonglong(SectionOffset.QuadPart, 0);
183 
184  SectionOffset.QuadPart = 0x00040211; //MSDN is wrong, in w2k3 the ZwMapViewOfSection doesn't align offsets automatically
186 
187  SectionOffset.QuadPart = -1;
189 
190  //View Size
192 
193  ViewSize = -1;
195 
199 
202 
205 
206  //allocation type
211 
212  //win32protect
224 
225  ZwClose(WriteSectionHandle);
226  ZwClose(PageFileSectionHandle);
227  ZwClose(ReadOnlySection);
228 }
229 
230 
231 static
232 VOID
233 AdvancedErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly)
234 {
237  HANDLE FileSectionHandle;
240  SIZE_T ViewSize = 0;
242 
243  MaximumSize.QuadPart = TestStringSize;
244  //Used for parameters working on file-based section
245  Status = ZwCreateSection(&FileSectionHandle, SECTION_ALL_ACCESS, NULL, &MaximumSize, PAGE_READWRITE, SEC_COMMIT, FileHandleWriteOnly);
247 
248  Status = ObReferenceObjectByHandle(FileSectionHandle,
250  NULL,
251  KernelMode,
252  &SectionObject,
253  NULL);
254 
256 
257  //Bypassing Zw function calls mean bypassing the alignment checks which are not crucial for the branches being tested here
258 
259  //test first conditional branch
260  ViewSize = -1;
262 
263  //test second conditional branch
264  ViewSize = 1;
265  SectionOffset.QuadPart = TestStringSize;
267 
269  ZwClose(FileSectionHandle);
270 }
271 
272 static
273 SIZE_T
275 {
279  PVOID FileContent;
280  SIZE_T Match;
281 
282  Match = 0;
283  ByteOffset.QuadPart = 0;
284 
285  FileContent = ExAllocatePoolWithTag(PagedPool, BufferLength, 'Test');
286  if (!skip((FileContent != NULL), "Error allocating memory for FileContent\n"))
287  {
288  Status = ZwReadFile(FileHandle, NULL, NULL, NULL, &IoStatusBlock, FileContent, BufferLength, &ByteOffset, NULL);
291 
292  Match = 0;
293  Match = RtlCompareMemory(FileContent, Buffer, BufferLength);
294  ExFreePoolWithTag(FileContent, 'Test');
295  }
296 
297  return Match;
298 }
299 
300 
301 static
302 VOID
303 NTAPI
305 {
308  HANDLE SectionHandle;
310  SIZE_T Match;
313 
314  UNREFERENCED_PARAMETER(StartContext);
315 
316  BaseAddress = NULL;
318  SectionOffset.QuadPart = 0;
319 
322  if (!skip(NT_SUCCESS(Status), "Error acquiring handle to section. Error = %p\n", Status))
323  {
324  CheckObject(SectionHandle, 4, 2);
325  Status = ZwMapViewOfSection(SectionHandle, NtCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE);
326 
327  //make sure ZwMapViewofSection doesn't touch the section ref counts.
328  CheckObject(SectionHandle, 4, 2);
329 
330  if (!skip(NT_SUCCESS(Status), "Error mapping page file view in system process. Error = %p\n", Status))
331  {
333  ok_eq_size(Match, TestStringSize);
334 
336  ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
337 
338  //make sure ZwMapViewofSection doesn't touch the section ref counts.
339  CheckObject(SectionHandle, 4, 2);
340  }
341 
342  ZwClose(SectionHandle);
343  }
344 
346 }
347 
348 
349 static
350 VOID
351 BehaviorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly)
352 {
356  HANDLE WriteSectionHandle;
357  HANDLE SysThreadHandle;
361  SIZE_T Match;
362  SIZE_T ViewSize = 0;
363 
365  MaximumSize.QuadPart = TestStringSize;
366  SectionOffset.QuadPart = 0;
367 
368  Status = ZwCreateSection(&WriteSectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes, &MaximumSize, PAGE_READWRITE, SEC_COMMIT, FileHandleWriteOnly);
369  CheckObject(WriteSectionHandle, 3, 1);
370  ok(NT_SUCCESS(Status), "Error creating write section from file. Error = %p\n", Status);
371 
372  //check for section reading/writing by comparing section content to a well-known value.
373  Status = ZwMapViewOfSection(WriteSectionHandle, NtCurrentProcess() ,&BaseAddress, 0, 0, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE);
374  CheckObject(WriteSectionHandle, 3, 1);
375  if (!skip(NT_SUCCESS(Status), "Error mapping view with READ/WRITE priv. Error = %p\n", Status))
376  {
378  ok_eq_size(Match, TestStringSize);
379 
380  //now check writing to section
382 
384  ok_eq_size(Match, NEW_CONTENT_LEN);
385 
386  //check to see if the contents have been flushed to the actual file on disk.
387  Match = CompareFileContents(FileHandleWriteOnly, NEW_CONTENT_LEN, NEW_CONTENT);
388  ok_eq_size(Match, NEW_CONTENT_LEN);
389 
390  //bring everything back to normal
392 
393  //Initiate an external thread to modify the file
396  if (!skip(NT_SUCCESS(Status), "Error creating System thread. Error = %p\n", Status))
397  {
399  if (!skip(NT_SUCCESS(Status), "Error getting reference to System thread when testing file-backed section\n"))
400  {
401  //wait until the system thread actually terminates
403 
404  //no longer need the thread object
406 
407  //test for bi-directional access to the shared page file
409  ok_eq_size(Match, NEW_CONTENT_LEN);
410 
411  //bring everything back to normal, again
413  }
414  }
415 
416  ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
417  }
418 
419  //Try to write to read-only mapped view
420  BaseAddress = NULL;
421  ViewSize = 0;
422  SectionOffset.QuadPart = 0;
423  Status = ZwMapViewOfSection(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READONLY);
424  if (!skip(NT_SUCCESS(Status), "Error mapping view with READ priv. Error = %p\n", Status))
425  {
427  ok_eq_size(Match, TestStringSize);
428 
429  KmtStartSeh()
432 
433  ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
434  }
435 
436  //try to access forbidden memory
437  BaseAddress = NULL;
438  ViewSize = 0;
439  SectionOffset.QuadPart = 0;
440  Status = ZwMapViewOfSection(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_NOACCESS);
441  if (!skip(NT_SUCCESS(Status), "Error mapping view with PAGE_NOACCESS priv. Error = %p\n", Status))
442  {
443  KmtStartSeh()
446 
447  ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
448  }
449 
450  //try to access guarded memory
451  BaseAddress = NULL;
452  ViewSize = 0;
453  SectionOffset.QuadPart = 0;
454  Status = ZwMapViewOfSection(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, 0, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_GUARD | PAGE_READWRITE);
455  if (!skip(NT_SUCCESS(Status), "Error mapping view with PAGE_GUARD priv. Error = %p\n", Status))
456  {
457  KmtStartSeh()
460 
461  KmtStartSeh()
464 
465  ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
466  }
467 
468  ZwClose(WriteSectionHandle);
469 
470  //section created with sec_reserve should not be commited.
471  BaseAddress = NULL;
472  ViewSize = 0;
473  SectionOffset.QuadPart = 0;
474  Status = ZwCreateSection(&WriteSectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes, &MaximumSize, PAGE_READWRITE, SEC_RESERVE, FileHandleWriteOnly);
475  if (!skip(NT_SUCCESS(Status), "Error creating page file section. Error = %p\n", Status))
476  {
477  Status = ZwMapViewOfSection(WriteSectionHandle, NtCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, MEM_RESERVE, PAGE_READWRITE);
478  if (!skip(NT_SUCCESS(Status), "Error mapping page file view. Error = %p\n", Status))
479  {
480  //check also the SEC_COMMIT flag
481  /* This test proves that MSDN is once again wrong
482  * msdn.microsoft.com/en-us/library/windows/hardware/aa366537.aspx states that SEC_RESERVE
483  * should cause the allocated memory for the view to be reserved but in fact it is always committed.
484  * It fails also on windows.
485  */
487  ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
488  }
489 
490  ZwClose(WriteSectionHandle);
491  }
492 }
493 
494 
495 static
496 VOID
498 {
500  LARGE_INTEGER MaxSectionSize;
502  HANDLE PageFileSectionHandle;
505  SIZE_T Match;
508 
509  MaxSectionSize.QuadPart = TestStringSize;
510  SectionOffset.QuadPart = 0;
511  PageFileSectionHandle = INVALID_HANDLE_VALUE;
512  BaseAddress = NULL;
515 
516  //test memory sharing between 2 different processes
517  Status = ZwCreateSection(&PageFileSectionHandle, SECTION_ALL_ACCESS, &ObjectAttributes, &MaxSectionSize, PAGE_READWRITE, SEC_COMMIT, NULL);
518  if (!skip(NT_SUCCESS(Status), "Error creating page file section. Error = %p\n", Status))
519  {
520  CheckObject(PageFileSectionHandle, 3, 1);
521  Status = ZwMapViewOfSection(PageFileSectionHandle, NtCurrentProcess(), &BaseAddress, 0, TestStringSize, &SectionOffset, &ViewSize, ViewUnmap, 0, PAGE_READWRITE);
522  if (!skip(NT_SUCCESS(Status), "Error mapping page file view. Error = %p\n", Status))
523  {
524  HANDLE SysThreadHandle;
525 
526  CheckObject(PageFileSectionHandle, 3, 1);
527 
528  //check also the SEC_COMMIT flag
530 
532 
535 
536  if (!skip(NT_SUCCESS(Status), "Error creating System thread. Error = %p\n", Status))
537  {
539  if (!skip(NT_SUCCESS(Status), "Error getting reference to System thread when testing pagefile-backed section\n"))
540  {
541  //wait until the system thread actually terminates
543 
544  //no longer need the thread object
546 
547  //test for bi-directional access to the shared page file
549  ok_eq_size(Match, NEW_CONTENT_LEN);
550  }
551  }
552  ZwUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
553  }
554  ZwClose(PageFileSectionHandle);
555  }
556 }
557 
558 
559 START_TEST(ZwMapViewOfSection)
560 {
561  HANDLE FileHandleReadOnly = NULL;
562  HANDLE FileHandleWriteOnly = NULL;
563  HANDLE ExecutableFileHandle = NULL;
564 
568 
569  KmtInitTestFiles(&FileHandleReadOnly, &FileHandleWriteOnly, &ExecutableFileHandle);
570 
571  SimpleErrorChecks(FileHandleReadOnly, FileHandleWriteOnly, ExecutableFileHandle);
572  AdvancedErrorChecks(FileHandleReadOnly, FileHandleWriteOnly);
573  BehaviorChecks(FileHandleReadOnly, FileHandleWriteOnly);
575 
576  if (FileHandleReadOnly)
577  ZwClose(FileHandleReadOnly);
578 
579  if (FileHandleWriteOnly)
580  ZwClose(FileHandleWriteOnly);
581 
582  if (ExecutableFileHandle)
583  ZwClose(ExecutableFileHandle);
584 }
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define MEM_LARGE_PAGES
Definition: nt_native.h:1322
#define TestMapView(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus)
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
static VOID NTAPI SystemProcessWorker(PVOID StartContext)
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define MmTestMapView(Object, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus)
EH_STD::basic_string< char, EH_STD::char_traits< char >, eh_allocator(char) > TestString
Definition: test_string.cpp:30
static UNICODE_STRING SharedSectionName
static SIZE_T CompareFileContents(HANDLE FileHandle, ULONG BufferLength, PVOID Buffer)
#define ok_eq_size(value, expected)
Definition: kmt_test.h:247
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define PAGE_GUARD
Definition: nt_native.h:1310
LONG NTSTATUS
Definition: precomp.h:26
#define KmtEndSeh(ExpectedStatus)
Definition: kmt_test.h:283
#define STATUS_INVALID_PARAMETER_9
Definition: ntstatus.h:469
#define STATUS_GUARD_PAGE_VIOLATION
Definition: ntstatus.h:170
#define ok_eq_ulongptr(value, expected)
Definition: kmt_test.h:249
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
static OBJECT_ATTRIBUTES KmtestFileObject
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define MEM_COMMIT
Definition: nt_native.h:1313
#define IGNORE
#define NEW_CONTENT
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
#define FILE_SHARE_READ
Definition: compat.h:125
uint32_t ULONG_PTR
Definition: typedefs.h:63
HANDLE FileHandle
Definition: stats.c:38
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
static VOID PageFileBehaviorChecks()
#define PAGE_EXECUTE_WRITECOPY
Definition: nt_native.h:1309
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:496
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:463
#define SEC_COMMIT
Definition: mmtypes.h:99
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ ULONG BufferLength
Definition: usbdlib.h:225
#define SEC_RESERVE
Definition: nt_native.h:1323
#define GENERIC_WRITE
Definition: nt_native.h:90
#define MEM_RESERVE
Definition: nt_native.h:1314
#define STATUS_MAPPED_ALIGNMENT
Definition: ntstatus.h:662
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define PAGE_NOACCESS
Definition: nt_native.h:1302
#define Test_NtQueryVirtualMemory(BaseAddress, Size, AllocationType, ProtectionType)
Definition: kmt_test.h:72
smooth NULL
Definition: ftsmooth.c:416
#define PAGE_EXECUTE
Definition: nt_native.h:1306
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:404
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define NEW_CONTENT_LEN
#define STATUS_INVALID_PARAMETER_5
Definition: ntstatus.h:465
static OBJECT_ATTRIBUTES NtoskrnlFileObject
#define FILE_DELETE_ON_CLOSE
Definition: constants.h:494
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:259
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static OBJECT_ATTRIBUTES NtdllObject
static VOID KmtInitTestFiles(PHANDLE ReadOnlyFile, PHANDLE WriteOnlyFile, PHANDLE ExecutableFile)
#define STATUS_SECTION_PROTECTION
Definition: ntstatus.h:300
START_TEST(ZwMapViewOfSection)
static VOID BehaviorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static UNICODE_STRING FileReadOnlyPath
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
POBJECT_TYPE PsThreadType
Definition: thread.c:20
static const WCHAR L[]
Definition: oid.c:1250
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define GENERIC_READ
Definition: compat.h:124
#define ok_eq_ulonglong(value, expected)
Definition: kmt_test.h:243
#define STATUS_INVALID_PAGE_PROTECTION
Definition: ntstatus.h:291
#define SYNCHRONIZE
Definition: nt_native.h:61
#define KmtStartSeh()
Definition: kmt_test.h:277
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define STATUS_INVALID_VIEW_SIZE
Definition: ntstatus.h:254
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:228
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
#define ok(value,...)
Definition: atltest.h:57
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1144
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
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:602
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
static VOID SimpleErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly, HANDLE ExecutableImg)
#define PAGE_READONLY
Definition: compat.h:127
const ULONG TestStringSize
#define PAGE_WRITECOPY
Definition: nt_native.h:1305
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
Definition: mmfuncs.h:360
#define FILE_CREATED
Definition: nt_native.h:770
static UNICODE_STRING WritableFilePath
#define CheckObject(Handle, Pointers, Handles)
#define skip(...)
Definition: atltest.h:64
#define MEM_RELEASE
Definition: nt_native.h:1316
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
static UNICODE_STRING NtosImgPath
unsigned int ULONG
Definition: retypes.h:1
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1307
#define ok_eq_hex(value, expected)
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
NTSYSAPI NTSTATUS NTAPI ZwOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:464
#define GENERIC_EXECUTE
Definition: nt_native.h:91
#define STATUS_CONFLICTING_ADDRESSES
Definition: ntstatus.h:247
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define MmSystemRangeStart
Definition: mm.h:32
#define MM_ALLOCATION_GRANULARITY
Definition: mmtypes.h:36
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
LONGLONG QuadPart
Definition: typedefs.h:112
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:716
static VOID AdvancedErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly)
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14