ReactOS 0.4.15-dev-7674-gc0b4db1
ZwCreateSection.c File Reference
#include <kmt_test.h>
Include dependency graph for ZwCreateSection.c:

Go to the source code of this file.

Macros

#define IGNORE   -999
 
#define NO_HANDLE_CLOSE   -998
 
#define _4mb   4194304
 
#define CREATE_SECTION(Handle, DesiredAccess, Attributes, Size, SectionPageProtection, AllocationAttributes, FileHandle, RetStatus, CloseRetStatus)
 
#define TestMapView(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus)
 
#define CheckObject(Handle, Pointers, Handles)
 
#define CheckSection(SectionHandle, SectionFlag, SectionSize, RetStatus)
 

Functions

static VOID FileSectionViewPermissionCheck (HANDLE ReadOnlyFile, HANDLE WriteOnlyFile, HANDLE ExecutableFile)
 
static VOID KmtInitTestFiles (PHANDLE ReadOnlyFile, PHANDLE WriteOnlyFile, PHANDLE ExecutableFile)
 
static VOID SimpleErrorChecks (HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly, HANDLE FileHandleExecuteOnly)
 
static VOID BasicBehaviorChecks (HANDLE FileHandle)
 
 START_TEST (ZwCreateSection)
 

Variables

const char TestString []
 
const ULONG TestStringSize
 
static UNICODE_STRING FileReadOnlyPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll")
 
static UNICODE_STRING WritableFilePath = RTL_CONSTANT_STRING(L"\\SystemRoot\\kmtest-MmSection.txt")
 
static UNICODE_STRING CalcImgPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\calc.exe")
 
static OBJECT_ATTRIBUTES NtdllObject
 
static OBJECT_ATTRIBUTES KmtestFileObject
 
static OBJECT_ATTRIBUTES CalcFileObject
 

Macro Definition Documentation

◆ _4mb

#define _4mb   4194304

Definition at line 12 of file ZwCreateSection.c.

◆ CheckObject

#define CheckObject (   Handle,
  Pointers,
  Handles 
)
Value:
do \
{ \
Status = ZwQueryObject(Handle, ObjectBasicInformation, \
&ObjectInfo, sizeof ObjectInfo, NULL); \
ok_eq_hex(Status, STATUS_SUCCESS); \
ok_eq_ulong(ObjectInfo.PointerCount, Pointers); \
ok_eq_ulong(ObjectInfo.HandleCount, Handles); \
} while (0)
@ ObjectBasicInformation
Definition: DriverTester.h:54
#define NULL
Definition: types.h:112
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65

Definition at line 50 of file ZwCreateSection.c.

◆ CheckSection

#define CheckSection (   SectionHandle,
  SectionFlag,
  SectionSize,
  RetStatus 
)
Value:
do \
{ \
&Sbi, sizeof Sbi, NULL); \
ok_eq_hex(Status, RetStatus); \
if (RetStatus == STATUS_SUCCESS && NT_SUCCESS(Status)) \
{ \
ok_eq_pointer(Sbi.BaseAddress, NULL); \
ok_eq_longlong(Sbi.Size.QuadPart, SectionSize); \
ok_eq_hex(Sbi.Attributes, SectionFlag | SEC_FILE); \
} \
} while (0)
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS NTAPI ZwQuerySection(_In_ HANDLE SectionHandle, _In_ SECTION_INFORMATION_CLASS SectionInformationClass, _Out_ PVOID SectionInformation, _In_ SIZE_T Length, _Out_opt_ PSIZE_T ResultLength)
#define SEC_FILE
Definition: mmtypes.h:96
@ SectionBasicInformation
Definition: mmtypes.h:195
LARGE_INTEGER Size
Definition: mmtypes.h:336
LONGLONG QuadPart
Definition: typedefs.h:114

Definition at line 61 of file ZwCreateSection.c.

◆ CREATE_SECTION

#define CREATE_SECTION (   Handle,
  DesiredAccess,
  Attributes,
  Size,
  SectionPageProtection,
  AllocationAttributes,
  FileHandle,
  RetStatus,
  CloseRetStatus 
)
Value:
do \
{ \
ok_eq_hex(Status, RetStatus); \
{ \
if (CloseRetStatus != NO_HANDLE_CLOSE) \
{ \
Handle = NULL; \
if (CloseRetStatus != IGNORE) ok_eq_hex(Status, CloseRetStatus); \
} \
} \
} while (0)
#define IGNORE
#define NO_HANDLE_CLOSE
#define ok_eq_hex(value, expected)
Definition: apitest.h:76
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG SectionPageProtection
Definition: mmfuncs.h:363
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG AllocationAttributes
Definition: mmfuncs.h:364
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Definition at line 22 of file ZwCreateSection.c.

◆ IGNORE

#define IGNORE   -999

Definition at line 10 of file ZwCreateSection.c.

◆ NO_HANDLE_CLOSE

#define NO_HANDLE_CLOSE   -998

Definition at line 11 of file ZwCreateSection.c.

◆ TestMapView

#define TestMapView (   SectionHandle,
  ProcessHandle,
  BaseAddress2,
  ZeroBits,
  CommitSize,
  SectionOffset,
  ViewSize2,
  InheritDisposition,
  AllocationType,
  Win32Protect,
  MapStatus,
  UnmapStatus 
)
Value:
do \
{ \
Status = ZwMapViewOfSection(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect); \
ok_eq_hex(Status, MapStatus); \
{ \
Status = ZwUnmapViewOfSection(ProcessHandle, BaseAddress); \
if (UnmapStatus != IGNORE) ok_eq_hex(Status, UnmapStatus); \
*BaseAddress2 = NULL; \
*ViewSize2 = 0; \
} \
} while (0)
_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
_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
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR ZeroBits
Definition: mmfuncs.h:405
_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
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:407
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T CommitSize
Definition: mmfuncs.h:406

Definition at line 37 of file ZwCreateSection.c.

Function Documentation

◆ BasicBehaviorChecks()

static VOID BasicBehaviorChecks ( HANDLE  FileHandle)
static

Definition at line 454 of file ZwCreateSection.c.

455{
457 HANDLE Section = NULL;
460 Length.QuadPart = TestStringSize;
461
462 //mimic lack of section support for a particular file as well.
464 if (!skip(NT_SUCCESS(Status), "Cannot reference object by handle\n"))
465 {
466 PSECTION_OBJECT_POINTERS Pointers = FileObject->SectionObjectPointer;
467
468 FileObject->SectionObjectPointer = NULL;
470 FileObject->SectionObjectPointer = Pointers;
472 }
473
474 Length.QuadPart = TestStringSize;
476 CheckObject(Section, 2, 1);
477 CheckSection(Section, SEC_FILE, Length.QuadPart, STATUS_SUCCESS);
478 ZwClose(Section); //manually close it due to NO_HANDLE_CLOSE in CREATE_SECTION
479
480 //section length should be set to that of file
481 Length.QuadPart = 0;
484 ZwClose(Section);
485
486 //create a smaller section than file
487 Length.QuadPart = TestStringSize - 100;
490 ZwClose(Section);
491}
#define CheckSection(SectionHandle, SectionFlag, SectionSize, RetStatus)
#define CheckObject(Handle, Pointers, Handles)
const ULONG TestStringSize
#define CREATE_SECTION(Handle, DesiredAccess, Attributes, Size, SectionPageProtection, AllocationAttributes, FileHandle, RetStatus, CloseRetStatus)
#define skip(...)
Definition: atltest.h:64
#define PAGE_READONLY
Definition: compat.h:138
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define KernelMode
Definition: asm.h:34
#define SEC_COMMIT
Definition: mmtypes.h:100
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_INVALID_FILE_FOR_SECTION
Definition: ntstatus.h:269
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:494
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by START_TEST().

◆ FileSectionViewPermissionCheck()

static VOID FileSectionViewPermissionCheck ( HANDLE  ReadOnlyFile,
HANDLE  WriteOnlyFile,
HANDLE  ExecutableFile 
)
static

Definition at line 78 of file ZwCreateSection.c.

79{
81 HANDLE SectionHandle = NULL;
83 SIZE_T ViewSize = 0;
85
86 MaximumSize.QuadPart = TestStringSize;
87
88 //READ-ONLY FILE COMBINATIONS
93 ZwClose(SectionHandle);
94
99 ZwClose(SectionHandle);
100
105 ZwClose(SectionHandle);
106
111 ZwClose(SectionHandle);
112
117 ZwClose(SectionHandle);
118
123 ZwClose(SectionHandle);
124
129 ZwClose(SectionHandle);
130
135 ZwClose(SectionHandle);
136
141 ZwClose(SectionHandle);
142
147 ZwClose(SectionHandle);
148
153 ZwClose(SectionHandle);
154
159 ZwClose(SectionHandle);
160
161 //WRITE-ONLY FILE COMBINATIONS
166 ZwClose(SectionHandle);
167
172 ZwClose(SectionHandle);
173
178 ZwClose(SectionHandle);
179
184 ZwClose(SectionHandle);
185
190 ZwClose(SectionHandle);
191
196 ZwClose(SectionHandle);
197
202 ZwClose(SectionHandle);
203
208 ZwClose(SectionHandle);
209
214 ZwClose(SectionHandle);
215
220 ZwClose(SectionHandle);
221
226 ZwClose(SectionHandle);
227
232 ZwClose(SectionHandle);
233
234 //EXECUTE ONLY FILE
239
244
249}
#define TestMapView(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus)
#define SECTION_MAP_READ
Definition: compat.h:139
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
Definition: mmfuncs.h:362
_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
#define SECTION_MAP_EXECUTE
Definition: nt_native.h:1290
#define PAGE_WRITECOPY
Definition: nt_native.h:1305
#define SECTION_MAP_WRITE
Definition: nt_native.h:1288
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define PAGE_EXECUTE
Definition: nt_native.h:1306
@ ViewUnmap
Definition: nt_native.h:1279
#define STATUS_SECTION_PROTECTION
Definition: ntstatus.h:314
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define ZwCurrentProcess()

Referenced by START_TEST().

◆ KmtInitTestFiles()

static VOID KmtInitTestFiles ( PHANDLE  ReadOnlyFile,
PHANDLE  WriteOnlyFile,
PHANDLE  ExecutableFile 
)
static

Definition at line 253 of file ZwCreateSection.c.

254{
258
259 //INIT THE READ-ONLY FILE
262 ok(*ReadOnlyFile != NULL, "Couldn't acquire READONLY handle\n");
263
264 //INIT THE EXECUTABLE FILE
267 ok(*ExecutableFile != NULL, "Couldn't acquire EXECUTE handle\n");
268
269 //INIT THE WRITE-ONLY FILE
270 //NB: this file is deleted at the end of basic behavior checks
274 ok(*WriteOnlyFile != NULL, "WriteOnlyFile is NULL\n");
275 if (!skip(*WriteOnlyFile != NULL, "No WriteOnlyFile\n"))
276 {
277 FileOffset.QuadPart = 0;
278 Status = ZwWriteFile(*WriteOnlyFile, NULL, NULL, NULL, &IoStatusBlock, (PVOID)TestString, TestStringSize, &FileOffset, NULL);
279 ok(Status == STATUS_SUCCESS || Status == STATUS_PENDING, "Status = 0x%08lx\n", Status);
280 Status = ZwWaitForSingleObject(*WriteOnlyFile, FALSE, NULL);
283 }
284}
static OBJECT_ATTRIBUTES CalcFileObject
static OBJECT_ATTRIBUTES KmtestFileObject
static OBJECT_ATTRIBUTES NtdllObject
#define ok_eq_ulongptr(value, expected)
Definition: apitest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
#define FALSE
Definition: types.h:117
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_OPEN
Definition: from_kernel.h:54
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_CREATED
Definition: nt_native.h:770
#define GENERIC_WRITE
Definition: nt_native.h:90
#define GENERIC_EXECUTE
Definition: nt_native.h:91
#define STATUS_PENDING
Definition: ntstatus.h:82
EH_STD::basic_string< char, EH_STD::char_traits< char >, eh_allocator(char) > TestString
Definition: test_string.cpp:30

Referenced by START_TEST().

◆ SimpleErrorChecks()

static VOID SimpleErrorChecks ( HANDLE  FileHandleReadOnly,
HANDLE  FileHandleWriteOnly,
HANDLE  FileHandleExecuteOnly 
)
static

Definition at line 288 of file ZwCreateSection.c.

289{
291 HANDLE Section = NULL;
292 OBJECT_ATTRIBUTES ObjectAttributesReadOnly;
293 OBJECT_ATTRIBUTES ObjectAttributesWriteOnly;
294 OBJECT_ATTRIBUTES InvalidObjectAttributes;
296 FILE_STANDARD_INFORMATION FileStandardInfo;
298 UNICODE_STRING SectReadOnly = RTL_CONSTANT_STRING(L"\\BaseNamedObjects\\KmtTestReadSect");
299 UNICODE_STRING SectWriteOnly = RTL_CONSTANT_STRING(L"\\BaseNamedObjects\\KmtTestWriteSect");
300 UNICODE_STRING InvalidObjectString = RTL_CONSTANT_STRING(L"THIS/IS/INVALID");
301
302 MaximumSize.QuadPart = TestStringSize;
303
304 InitializeObjectAttributes(&ObjectAttributesReadOnly, &SectReadOnly, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
305 InitializeObjectAttributes(&ObjectAttributesWriteOnly, &SectWriteOnly, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
306 InitializeObjectAttributes(&InvalidObjectAttributes, &InvalidObjectString, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL);
307
309 //PAGE FILE BACKED SECTION
310 //DESIRED ACCESS TESTS
314
315 //OBJECT ATTRIBUTES
318
319 //MAXIMUM SIZE
320 MaximumSize.QuadPart = -1;
322
323 MaximumSize.QuadPart = 0;
325
326 //division by zero in ROS
327 if (!skip(SharedUserData->LargePageMinimum > 0, "LargePageMinimum is 0\n"))
328 {
329 MaximumSize.QuadPart = (_4mb / SharedUserData->LargePageMinimum) * SharedUserData->LargePageMinimum; //4mb
331 }
332
333 MaximumSize.QuadPart = TestStringSize;
334
335 //SECTION PAGE PROTECTION
345
346 //ALLOCATION ATTRIBUTES
359
361 //NORMAL FILE-BACKED SECTION
362
363 //DESIRED ACCESS TESTS
364 CREATE_SECTION(Section, SECTION_ALL_ACCESS, &ObjectAttributesReadOnly, MaximumSize, PAGE_READONLY, SEC_COMMIT, FileHandleReadOnly, STATUS_SUCCESS, STATUS_SUCCESS);
365 CREATE_SECTION(Section, SECTION_ALL_ACCESS, &ObjectAttributesWriteOnly, MaximumSize, PAGE_WRITECOPY, SEC_COMMIT, FileHandleWriteOnly, STATUS_SUCCESS, STATUS_SUCCESS);
366 CREATE_SECTION(Section, SECTION_MAP_WRITE, &ObjectAttributesReadOnly, MaximumSize, PAGE_READONLY, SEC_COMMIT, FileHandleReadOnly, STATUS_SUCCESS, STATUS_SUCCESS);
367 CREATE_SECTION(Section, SECTION_MAP_READ, &ObjectAttributesWriteOnly, MaximumSize, PAGE_WRITECOPY, SEC_COMMIT, FileHandleWriteOnly, STATUS_SUCCESS, STATUS_SUCCESS);
368
369 //Object Attributes
371 CREATE_SECTION(Section, SECTION_ALL_ACCESS, &InvalidObjectAttributes, MaximumSize, PAGE_READONLY, SEC_COMMIT, FileHandleReadOnly, STATUS_OBJECT_PATH_SYNTAX_BAD, IGNORE);
372
373 //MAXIMUM SIZE
374 MaximumSize.QuadPart = TestStringSize - 100;
376
377 MaximumSize.QuadPart = -1;
379
380 MaximumSize.QuadPart = TestStringSize + 1;
382
383 MaximumSize.QuadPart = 0;
385
386 //SECTION PAGE PROTECTION
396
397 //allocation type
410
412 //EXECUTABLE IMAGE
413 CREATE_SECTION(Section, SECTION_MAP_READ, &ObjectAttributesWriteOnly, MaximumSize, PAGE_WRITECOPY, SEC_IMAGE, FileHandleExecuteOnly, STATUS_SUCCESS, STATUS_SUCCESS);
414 CREATE_SECTION(Section, SECTION_MAP_EXECUTE, &ObjectAttributesWriteOnly, MaximumSize, PAGE_WRITECOPY, SEC_IMAGE, FileHandleExecuteOnly, STATUS_SUCCESS, STATUS_SUCCESS);
415
416 //DESIRED ACCESS TESTS
417 CREATE_SECTION(Section, SECTION_ALL_ACCESS, &ObjectAttributesReadOnly, MaximumSize, PAGE_READONLY, SEC_COMMIT, FileHandleExecuteOnly, STATUS_SUCCESS, STATUS_SUCCESS);
418 CREATE_SECTION(Section, SECTION_ALL_ACCESS, &ObjectAttributesWriteOnly, MaximumSize, PAGE_WRITECOPY, SEC_COMMIT, FileHandleExecuteOnly, STATUS_SUCCESS, STATUS_SUCCESS);
419 CREATE_SECTION(Section, SECTION_MAP_WRITE, &ObjectAttributesReadOnly, MaximumSize, PAGE_READONLY, SEC_COMMIT, FileHandleExecuteOnly, STATUS_SUCCESS, STATUS_SUCCESS);
420 CREATE_SECTION(Section, SECTION_MAP_READ, &ObjectAttributesWriteOnly, MaximumSize, PAGE_WRITECOPY, SEC_COMMIT, FileHandleExecuteOnly, STATUS_SUCCESS, STATUS_SUCCESS);
421
422 //Object Attributes
424 CREATE_SECTION(Section, SECTION_ALL_ACCESS, &InvalidObjectAttributes, MaximumSize, PAGE_READONLY, SEC_COMMIT, FileHandleExecuteOnly, STATUS_OBJECT_PATH_SYNTAX_BAD, IGNORE);
425
426 //MaximumSize
427 Status = ZwQueryInformationFile(FileHandleExecuteOnly, &IoStatusBlock, &FileStandardInfo, sizeof(FILE_STANDARD_INFORMATION), FileStandardInformation);
428 if (!skip(NT_SUCCESS(Status), "Cannot query file information\n"))
429 {
430 //as big as file
431 MaximumSize = FileStandardInfo.EndOfFile;
433
434 //less than file
435 MaximumSize.QuadPart = FileStandardInfo.EndOfFile.QuadPart - 2;
437
438 //larger than file
439 MaximumSize.QuadPart = FileStandardInfo.EndOfFile.QuadPart + 2;
441
442 //0
443 MaximumSize.QuadPart = 0;
445
446 //-1 (very big number)
447 MaximumSize.QuadPart = -1;
449 }
450}
#define _4mb
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define SEC_NOCACHE
Definition: mmtypes.h:101
#define SEC_IMAGE
Definition: mmtypes.h:97
#define SEC_LARGE_PAGES
Definition: mmtypes.h:103
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1307
#define SEC_RESERVE
Definition: nt_native.h:1323
#define PAGE_EXECUTE_WRITECOPY
Definition: nt_native.h:1309
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:295
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:478
#define STATUS_INVALID_IMAGE_NOT_MZ
Definition: ntstatus.h:539
#define STATUS_INVALID_PARAMETER_6
Definition: ntstatus.h:480
#define STATUS_INVALID_PAGE_PROTECTION
Definition: ntstatus.h:305
#define STATUS_SECTION_TOO_BIG
Definition: ntstatus.h:300
#define L(x)
Definition: ntvdm.h:50
#define FileStandardInformation
Definition: propsheet.cpp:61
#define SharedUserData
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( ZwCreateSection  )

Definition at line 494 of file ZwCreateSection.c.

495{
496 HANDLE FileHandleReadOnly = NULL;
497 HANDLE FileHandleWriteOnly = NULL;
498 HANDLE FileHandleExecuteOnly = NULL;
499
503
504 KmtInitTestFiles(&FileHandleReadOnly, &FileHandleWriteOnly, &FileHandleExecuteOnly);
505
506 if (!skip(FileHandleReadOnly && FileHandleWriteOnly && FileHandleExecuteOnly, "Missing one or more file handles\n"))
507 {
508 FileSectionViewPermissionCheck(FileHandleReadOnly, FileHandleWriteOnly, FileHandleExecuteOnly);
509 SimpleErrorChecks(FileHandleReadOnly, FileHandleWriteOnly, FileHandleExecuteOnly);
510 BasicBehaviorChecks(FileHandleWriteOnly);
511 }
512
513 if (FileHandleReadOnly)
514 ZwClose(FileHandleReadOnly);
515
516 if (FileHandleWriteOnly)
517 {
518 ZwClose(FileHandleWriteOnly);
520 }
521
522 if (FileHandleExecuteOnly)
523 ZwClose(FileHandleExecuteOnly);
524}
static VOID KmtInitTestFiles(PHANDLE ReadOnlyFile, PHANDLE WriteOnlyFile, PHANDLE ExecutableFile)
static UNICODE_STRING FileReadOnlyPath
static VOID BasicBehaviorChecks(HANDLE FileHandle)
static VOID SimpleErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly, HANDLE FileHandleExecuteOnly)
static UNICODE_STRING WritableFilePath
static UNICODE_STRING CalcImgPath
static VOID FileSectionViewPermissionCheck(HANDLE ReadOnlyFile, HANDLE WriteOnlyFile, HANDLE ExecutableFile)
NTSYSAPI NTSTATUS NTAPI ZwDeleteFile(_In_ POBJECT_ATTRIBUTES ObjectAttributes)

Variable Documentation

◆ CalcFileObject

OBJECT_ATTRIBUTES CalcFileObject
static

Definition at line 20 of file ZwCreateSection.c.

Referenced by KmtInitTestFiles(), and START_TEST().

◆ CalcImgPath

UNICODE_STRING CalcImgPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\calc.exe")
static

Definition at line 17 of file ZwCreateSection.c.

Referenced by START_TEST().

◆ FileReadOnlyPath

UNICODE_STRING FileReadOnlyPath = RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll")
static

Definition at line 15 of file ZwCreateSection.c.

Referenced by START_TEST().

◆ KmtestFileObject

OBJECT_ATTRIBUTES KmtestFileObject
static

Definition at line 19 of file ZwCreateSection.c.

Referenced by DriverEntry(), KmtInitTestFiles(), and START_TEST().

◆ NtdllObject

OBJECT_ATTRIBUTES NtdllObject
static

Definition at line 18 of file ZwCreateSection.c.

Referenced by KmtInitTestFiles(), and START_TEST().

◆ TestString

const char TestString[]
extern

Definition at line 16 of file ZwAllocateVirtualMemory.c.

◆ TestStringSize

◆ WritableFilePath

UNICODE_STRING WritableFilePath = RTL_CONSTANT_STRING(L"\\SystemRoot\\kmtest-MmSection.txt")
static

Definition at line 16 of file ZwCreateSection.c.

Referenced by START_TEST().