11#define NEW_CONTENT "NewContent"
12#define NEW_CONTENT_LEN sizeof(NEW_CONTENT)
24#define TestMapView(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus) do \
26 Status = ZwMapViewOfSection(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect); \
27 ok_eq_hex(Status, MapStatus); \
28 if (NT_SUCCESS(Status)) \
30 Status = ZwUnmapViewOfSection(ProcessHandle, BaseAddress); \
31 if (UnmapStatus != IGNORE) ok_eq_hex(Status, UnmapStatus); \
32 *BaseAddress2 = NULL; \
37#define MmTestMapView(Object, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus) do \
39 Status = MmMapViewOfSection(Object, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect); \
40 ok_eq_hex(Status, MapStatus); \
41 if (NT_SUCCESS(Status)) \
43 Status = MmUnmapViewOfSection(ProcessHandle, BaseAddress); \
44 if (UnmapStatus != IGNORE) ok_eq_hex(Status, UnmapStatus); \
45 *BaseAddress2 = NULL; \
50#define CheckObject(Handle, Pointers, Handles) do \
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); \
69 Status = ZwCreateFile(ReadOnlyFile,
GENERIC_READ, &
NtdllObject, &
IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE,
NULL, 0);
71 ok(*ReadOnlyFile !=
NULL,
"Couldn't acquire READONLY handle\n");
74 Status = ZwCreateFile(ExecutableFile,
GENERIC_EXECUTE, &
NtdllObject, &
IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE,
NULL, 0);
76 ok(*ExecutableFile !=
NULL,
"Couldn't acquire EXECUTE handle\n");
80 Status = ZwCreateFile(WriteOnlyFile, (
GENERIC_WRITE |
SYNCHRONIZE), &
KmtestFileObject, &
IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_WRITE,
FILE_SUPERSEDE, (
FILE_NON_DIRECTORY_FILE |
FILE_DELETE_ON_CLOSE),
NULL, 0);
83 ok(*WriteOnlyFile !=
NULL,
"WriteOnlyFile is NULL\n");
84 if (!
skip(*WriteOnlyFile !=
NULL,
"No WriteOnlyFile\n"))
100 HANDLE WriteSectionHandle;
102 HANDLE PageFileSectionHandle;
126 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
127 TestMapView((
HANDLE)(
ULONG_PTR)0xDEADBEEFDEADBEEFull,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_HANDLE,
IGNORE);
128 TestMapView(
INVALID_HANDLE_VALUE,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_OBJECT_TYPE_MISMATCH,
IGNORE);
129 TestMapView(
NULL,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_HANDLE,
IGNORE);
132 TestMapView(WriteSectionHandle, (
HANDLE)(
ULONG_PTR)0xDEADBEEFDEADBEEFull, &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_HANDLE,
IGNORE);
133 TestMapView(WriteSectionHandle, (
HANDLE)
NULL, &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_HANDLE,
IGNORE);
137 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_MAPPED_ALIGNMENT,
IGNORE);
140 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
143 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_PARAMETER_3,
IGNORE);
147 TestMapView((
HANDLE)(
ULONG_PTR)0xDEADBEEFDEADBEEFull,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_HANDLE,
IGNORE);
151 TestMapView(WriteSectionHandle, (
HANDLE)(
ULONG_PTR)0xDEADBEEFDEADBEEFull, &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_HANDLE,
IGNORE);
158 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_CONFLICTING_ADDRESSES,
IGNORE);
164 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 1, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
165 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 5, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
166 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, -1, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_PARAMETER_4,
IGNORE);
167 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 20, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_NO_MEMORY,
IGNORE);
168 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 21, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_NO_MEMORY,
IGNORE);
169 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 22, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_PARAMETER_4,
IGNORE);
172 TestMapView(PageFileSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 500,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
173 TestMapView(PageFileSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
174 TestMapView(PageFileSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, -1,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_PARAMETER_5,
IGNORE);
175 TestMapView(PageFileSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0x10000000,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_PARAMETER_5,
IGNORE);
176 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 500,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_PARAMETER_5,
IGNORE);
177 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 500,
NULL, &
ViewSize,
ViewUnmap,
MEM_RESERVE,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
181 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0, &
SectionOffset, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
185 TestMapView(PageFileSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 500, &
SectionOffset, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_MAPPED_ALIGNMENT,
IGNORE);
188 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0, &
SectionOffset, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_MAPPED_ALIGNMENT,
IGNORE);
191 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
194 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_PARAMETER_3,
IGNORE);
197 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_VIEW_SIZE,
IGNORE);
198 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap,
MEM_RESERVE,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
201 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
204 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
207 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap,
MEM_RESERVE,
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
208 TestMapView(PageFileSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap,
MEM_RESERVE,
PAGE_READWRITE,
STATUS_INVALID_PARAMETER_9,
STATUS_SUCCESS);
209 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, (
MEM_RESERVE |
MEM_COMMIT),
PAGE_READWRITE,
STATUS_INVALID_PARAMETER_9,
IGNORE);
210 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, (
MEM_LARGE_PAGES |
MEM_RESERVE),
PAGE_READWRITE,
STATUS_SUCCESS,
STATUS_SUCCESS);
213 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READONLY,
STATUS_SUCCESS,
STATUS_SUCCESS);
214 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_NOACCESS,
STATUS_SUCCESS,
STATUS_SUCCESS);
215 TestMapView(WriteSectionHandle,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_EXECUTE_WRITECOPY,
STATUS_SECTION_PROTECTION,
IGNORE);
216 TestMapView(ReadOnlySection,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_SECTION_PROTECTION,
IGNORE);
217 TestMapView(ReadOnlySection,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_WRITECOPY,
STATUS_SUCCESS,
STATUS_SUCCESS);
218 TestMapView(ReadOnlySection,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_EXECUTE_READ,
STATUS_SECTION_PROTECTION,
IGNORE);
219 TestMapView(ReadOnlySection,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_EXECUTE,
STATUS_SECTION_PROTECTION,
IGNORE);
220 TestMapView(ReadOnlySection,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_READONLY,
STATUS_SUCCESS,
STATUS_SUCCESS);
221 TestMapView(ReadOnlySection,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0,
PAGE_NOACCESS,
STATUS_SUCCESS,
STATUS_SUCCESS);
222 TestMapView(ReadOnlySection,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap, 0, (
PAGE_READWRITE |
PAGE_READONLY),
STATUS_INVALID_PAGE_PROTECTION,
IGNORE);
223 TestMapView(ReadOnlySection,
NtCurrentProcess(), &
BaseAddress, 0, 0,
NULL, &
ViewSize,
ViewUnmap,
MEM_RESERVE,
PAGE_READONLY,
STATUS_SECTION_PROTECTION,
IGNORE);
226 ZwClose(PageFileSectionHandle);
261 MmTestMapView(
SectionObject,
PsGetCurrentProcess(), &
BaseAddress, 0,
TestStringSize, &
SectionOffset, &
ViewSize,
ViewUnmap,
MEM_RESERVE,
PAGE_READWRITE,
STATUS_INVALID_VIEW_SIZE,
IGNORE);
266 MmTestMapView(
SectionObject,
PsGetCurrentProcess(), &
BaseAddress, 0,
TestStringSize, &
SectionOffset, &
ViewSize,
ViewUnmap, 0,
PAGE_READWRITE,
STATUS_INVALID_VIEW_SIZE,
IGNORE);
286 if (!
skip((FileContent !=
NULL),
"Error allocating memory for FileContent\n"))
356 HANDLE WriteSectionHandle;
399 if (!
skip(
NT_SUCCESS(
Status),
"Error getting reference to System thread when testing file-backed section\n"))
502 HANDLE PageFileSectionHandle;
539 if (!
skip(
NT_SUCCESS(
Status),
"Error getting reference to System thread when testing pagefile-backed section\n"))
554 ZwClose(PageFileSectionHandle);
569 KmtInitTestFiles(&FileHandleReadOnly, &FileHandleWriteOnly, &ExecutableFileHandle);
571 SimpleErrorChecks(FileHandleReadOnly, FileHandleWriteOnly, ExecutableFileHandle);
576 if (FileHandleReadOnly)
579 if (FileHandleWriteOnly)
582 if (ExecutableFileHandle)
#define MmTestMapView(Object, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus)
static OBJECT_ATTRIBUTES NtoskrnlFileObject
static VOID KmtInitTestFiles(PHANDLE ReadOnlyFile, PHANDLE WriteOnlyFile, PHANDLE ExecutableFile)
static VOID NTAPI SystemProcessWorker(PVOID StartContext)
static UNICODE_STRING FileReadOnlyPath
static VOID AdvancedErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly)
static SIZE_T CompareFileContents(HANDLE FileHandle, ULONG BufferLength, PVOID Buffer)
static UNICODE_STRING SharedSectionName
#define TestMapView(SectionHandle, ProcessHandle, BaseAddress2, ZeroBits, CommitSize, SectionOffset, ViewSize2, InheritDisposition, AllocationType, Win32Protect, MapStatus, UnmapStatus)
static VOID SimpleErrorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly, HANDLE ExecutableImg)
#define CheckObject(Handle, Pointers, Handles)
static UNICODE_STRING WritableFilePath
static VOID BehaviorChecks(HANDLE FileHandleReadOnly, HANDLE FileHandleWriteOnly)
const ULONG TestStringSize
static VOID PageFileBehaviorChecks()
static OBJECT_ATTRIBUTES KmtestFileObject
static OBJECT_ATTRIBUTES NtdllObject
static UNICODE_STRING NtosImgPath
#define ok_eq_hex(value, expected)
#define ok_eq_size(value, expected)
#define ok_eq_ulongptr(value, expected)
#define ok_eq_ulonglong(value, expected)
#define FILE_NON_DIRECTORY_FILE
#define FILE_DELETE_ON_CLOSE
_In_ PFCB _In_ LONGLONG FileOffset
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
#define INVALID_HANDLE_VALUE
#define FILE_ATTRIBUTE_NORMAL
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define RtlCompareMemory(s1, s2, l)
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
#define Test_NtQueryVirtualMemory(BaseAddress, Size, AllocationType, ProtectionType)
#define KmtEndSeh(ExpectedStatus)
#define ExFreePoolWithTag(_P, _T)
static OUT PIO_STATUS_BLOCK IoStatusBlock
#define InitializeObjectAttributes(p, n, a, r, s)
#define MM_ALLOCATION_GRANULARITY
NTSYSAPI NTSTATUS NTAPI ZwOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER MaximumSize
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define THREAD_ALL_ACCESS
#define PAGE_EXECUTE_READ
#define SECTION_ALL_ACCESS
#define NtCurrentProcess()
#define STANDARD_RIGHTS_ALL
#define PAGE_EXECUTE_WRITECOPY
#define UNREFERENCED_PARAMETER(P)
#define MmSystemRangeStart
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
POBJECT_TYPE PsThreadType
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)
#define STATUS_INVALID_VIEW_SIZE
#define STATUS_MAPPED_ALIGNMENT
#define STATUS_INVALID_HANDLE
#define STATUS_SECTION_PROTECTION
#define STATUS_INVALID_PARAMETER_9
#define STATUS_INVALID_PARAMETER_4
#define STATUS_ACCESS_VIOLATION
#define STATUS_CONFLICTING_ADDRESSES
#define STATUS_INVALID_PAGE_PROTECTION
#define STATUS_GUARD_PAGE_VIOLATION
#define STATUS_INVALID_PARAMETER_3
#define STATUS_INVALID_PARAMETER_5
#define STATUS_OBJECT_TYPE_MISMATCH
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)
EH_STD::basic_string< char, EH_STD::char_traits< char >, eh_allocator(char) > TestString
#define RTL_CONSTANT_STRING(s)
#define RtlCopyMemory(Destination, Source, Length)
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
#define ObDereferenceObject
#define PsGetCurrentProcess