ReactOS 0.4.15-dev-5664-g3bf4ef6
kmt_test.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Kernel-Mode Test Suite test framework declarations
5 * COPYRIGHT: Copyright 2011-2018 Thomas Faber <thomas.faber@reactos.org>
6 * Copyright 2013 Nikolay Borisov <nib9@aber.ac.uk>
7 * Copyright 2014-2016 Pierre Schweitzer <pierre@reactos.org>
8 * Copyright 2017 Ged Murphy <gedmurphy@reactos.org>
9 */
10
11/* Inspired by Wine C unit tests, Copyright (C) 2002 Alexandre Julliard
12 * Inspired by ReactOS kernel-mode regression tests,
13 * Copyright (C) Aleksey Bragin, Filip Navara
14 */
15
16#ifndef _KMTEST_TEST_H_
17#define _KMTEST_TEST_H_
18
19#include <kmt_platform.h>
20
23
24typedef struct
25{
26 const char *TestName;
29
31
32extern const KMT_TEST TestList[];
33
34typedef struct
35{
36 volatile LONG Successes;
37 volatile LONG Failures;
38 volatile LONG Skipped;
41 CHAR LogBuffer[ANYSIZE_ARRAY];
43
44#ifndef KMT_STANDALONE_DRIVER
45
46/* usermode call-back mechanism */
47
48/* list of supported operations */
50{
53
54/* TODO: "response" is a little generic */
55typedef union _KMT_RESPONSE
56{
59
60/* this struct is sent from driver to usermode */
62{
67
70
71//macro to simplify using the mechanism
72#define Test_NtQueryVirtualMemory(BaseAddress, Size, AllocationType, ProtectionType) \
73 do { \
74 PKMT_RESPONSE NtQueryTest = KmtUserModeCallback(QueryVirtualMemory, BaseAddress); \
75 if (NtQueryTest != NULL) \
76 { \
77 ok_eq_hex(NtQueryTest->MemInfo.Protect, ProtectionType); \
78 ok_eq_hex(NtQueryTest->MemInfo.State, AllocationType); \
79 ok_eq_size(NtQueryTest->MemInfo.RegionSize, Size); \
80 KmtFreeCallbackResponse(NtQueryTest); \
81 } \
82 } while (0) \
83
84#endif
85
86#ifdef KMT_STANDALONE_DRIVER
87#define KMT_KERNEL_MODE
88
89typedef NTSTATUS (KMT_IRP_HANDLER)(
91 IN PIRP Irp,
92 IN PIO_STACK_LOCATION IoStackLocation);
93typedef KMT_IRP_HANDLER *PKMT_IRP_HANDLER;
94
97
98typedef NTSTATUS (KMT_MESSAGE_HANDLER)(
102 IN SIZE_T InLength,
103 IN OUT PSIZE_T OutLength);
104typedef KMT_MESSAGE_HANDLER *PKMT_MESSAGE_HANDLER;
105
108
109typedef enum
110{
111 TESTENTRY_NO_CREATE_DEVICE = 1,
112 TESTENTRY_NO_REGISTER_DISPATCH = 2,
113 TESTENTRY_NO_REGISTER_UNLOAD = 4,
114 TESTENTRY_NO_EXCLUSIVE_DEVICE = 8,
115 TESTENTRY_NO_READONLY_DEVICE = 16,
116 TESTENTRY_BUFFERED_IO_DEVICE = 32,
117} KMT_TESTENTRY_FLAGS;
118
121#endif /* defined KMT_STANDALONE_DRIVER */
122
123#ifdef KMT_FILTER_DRIVER
124#ifndef KMT_KERNEL_MODE
125#define KMT_KERNEL_MODE
126#endif
127
129
130typedef enum
131{
132 TESTENTRY_NO_REGISTER_FILTER = 0x01,
133 TESTENTRY_NO_CREATE_COMMS_PORT = 0x02,
134 TESTENTRY_NO_START_FILTERING = 0x04,
135 TESTENTRY_NO_INSTANCE_SETUP = 0x08,
136 TESTENTRY_NO_QUERY_TEARDOWN = 0x10,
137 TESTENTRY_NO_ALL = 0xFF
138} KMT_MINIFILTER_FLAGS;
139
141NTSTATUS TestInstanceSetup(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType, _In_ PUNICODE_STRING VolumeName, _In_ ULONG RealSectorSize, _In_ ULONG SectorSize);
143
145
146#endif/* defined KMT_FILTER_DRIVER */
147
148
149#ifdef KMT_KERNEL_MODE
150/* Device Extension layout */
151typedef struct
152{
154 PMDL Mdl;
155} KMT_DEVICE_EXTENSION, *PKMT_DEVICE_EXTENSION;
156
160extern PDRIVER_OBJECT KmtDriverObject;
161
169#elif defined KMT_USER_MODE
171
178
184
185
186DWORD KmtFltCreateService(_In_z_ PCWSTR ServiceName, _In_z_ PCWSTR DisplayName, _Out_ SC_HANDLE *ServiceHandle);
189DWORD KmtFltLoadDriver(_In_ BOOLEAN EnableDriverLoadPrivlege, _In_ BOOLEAN RestartIfRunning, _In_ BOOLEAN ConnectComms, _Out_ HANDLE *hPort);
190DWORD KmtFltUnloadDriver(_In_ HANDLE *hPort, _In_ BOOLEAN DisonnectComms);
199
200#else /* if !defined KMT_KERNEL_MODE && !defined KMT_USER_MODE */
201#error either KMT_KERNEL_MODE or KMT_USER_MODE must be defined
202#endif /* !defined KMT_KERNEL_MODE && !defined KMT_USER_MODE */
203
205
206#ifdef __GNUC__
207/* TODO: GCC doesn't understand %wZ :( */
208#define KMT_FORMAT(type, fmt, first) /*__attribute__((__format__(type, fmt, first)))*/
209#elif !defined __GNUC__
210#define KMT_FORMAT(type, fmt, first)
211#endif /* !defined __GNUC__ */
212
213#define START_TEST(name) VOID Test_##name(VOID)
214
215#ifndef KMT_STRINGIZE
216#define KMT_STRINGIZE(x) #x
217#endif /* !defined KMT_STRINGIZE */
218#define ok(test, ...) ok_(test, __FILE__, __LINE__, __VA_ARGS__)
219#define trace(...) trace_( __FILE__, __LINE__, __VA_ARGS__)
220#define skip(test, ...) skip_(test, __FILE__, __LINE__, __VA_ARGS__)
221
222#define ok_(test, file, line, ...) KmtOk(test, file ":" KMT_STRINGIZE(line), __VA_ARGS__)
223#define trace_(file, line, ...) KmtTrace( file ":" KMT_STRINGIZE(line), __VA_ARGS__)
224#define skip_(test, file, line, ...) KmtSkip(test, file ":" KMT_STRINGIZE(line), __VA_ARGS__)
225
226BOOLEAN KmtVOk(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 3, 0);
227BOOLEAN KmtOk(INT Condition, PCSTR FileAndLine, PCSTR Format, ...) KMT_FORMAT(ms_printf, 3, 4);
228VOID KmtVTrace(PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 2, 0);
229VOID KmtTrace(PCSTR FileAndLine, PCSTR Format, ...) KMT_FORMAT(ms_printf, 2, 3);
230BOOLEAN KmtVSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 3, 0);
231BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, ...) KMT_FORMAT(ms_printf, 3, 4);
234
235#ifdef KMT_KERNEL_MODE
236#define ok_irql(irql) ok(KeGetCurrentIrql() == irql, "IRQL is %d, expected %d\n", KeGetCurrentIrql(), irql)
237#endif /* defined KMT_KERNEL_MODE */
238#define ok_eq_print(value, expected, spec) ok((value) == (expected), #value " = " spec ", expected " spec "\n", value, expected)
239#define ok_eq_pointer(value, expected) ok_eq_print(value, expected, "%p")
240#define ok_eq_int(value, expected) ok_eq_print(value, expected, "%d")
241#define ok_eq_uint(value, expected) ok_eq_print(value, expected, "%u")
242#define ok_eq_long(value, expected) ok_eq_print(value, expected, "%ld")
243#define ok_eq_ulong(value, expected) ok_eq_print(value, expected, "%lu")
244#define ok_eq_longlong(value, expected) ok_eq_print(value, expected, "%I64d")
245#define ok_eq_ulonglong(value, expected) ok_eq_print(value, expected, "%I64u")
246#define ok_eq_char(value, expected) ok_eq_print(value, expected, "%c")
247#define ok_eq_wchar(value, expected) ok_eq_print(value, expected, "%C")
248#ifndef _WIN64
249#define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected), "%lu")
250#define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected), "%ld")
251#define ok_eq_ulongptr(value, expected) ok_eq_print(value, (ULONG_PTR)(expected), "%lu")
252#elif defined _WIN64
253#define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected), "%I64u")
254#define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected), "%I64d")
255#define ok_eq_ulongptr(value, expected) ok_eq_print(value, (ULONG_PTR)(expected), "%I64u")
256#endif /* defined _WIN64 */
257#define ok_eq_hex(value, expected) ok_eq_print(value, expected, "0x%08lx")
258#define ok_bool_true(value, desc) ok((value) == TRUE, desc " FALSE, expected TRUE\n")
259#define ok_bool_false(value, desc) ok((value) == FALSE, desc " TRUE, expected FALSE\n")
260#define ok_eq_bool(value, expected) ok((value) == (expected), #value " = %s, expected %s\n", \
261 (value) ? "TRUE" : "FALSE", \
262 (expected) ? "TRUE" : "FALSE")
263#define ok_eq_str(value, expected) ok(!strcmp(value, expected), #value " = \"%s\", expected \"%s\"\n", value, expected)
264#define ok_eq_wstr(value, expected) ok(!wcscmp(value, expected), #value " = \"%ls\", expected \"%ls\"\n", value, expected)
265#define ok_eq_tag(value, expected) ok_eq_print(value, expected, "0x%08lx")
266
267#define KMT_MAKE_CODE(ControlCode) CTL_CODE(FILE_DEVICE_UNKNOWN, \
268 0xC00 + (ControlCode), \
269 METHOD_BUFFERED, \
270 FILE_ANY_ACCESS)
271
272#define MICROSECOND 10
273#define MILLISECOND (1000 * MICROSECOND)
274#define SECOND (1000 * MILLISECOND)
275
276/* See apitests/include/apitest.h */
277#define KmtInvalidPointer ((PVOID)0x5555555555555555ULL)
278
279#define KmtStartSeh() \
280{ \
281 NTSTATUS ExceptionStatus = STATUS_SUCCESS; \
282 _SEH2_TRY \
283 {
284
285#define KmtEndSeh(ExpectedStatus) \
286 } \
287 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) \
288 { \
289 ExceptionStatus = _SEH2_GetExceptionCode(); \
290 } \
291 _SEH2_END; \
292 ok_eq_hex(ExceptionStatus, (ExpectedStatus)); \
293}
294
295#define KmtGetSystemOrEmbeddedRoutineAddress(RoutineName) \
296 p##RoutineName = KmtGetSystemRoutineAddress(L ## #RoutineName); \
297 if (!p##RoutineName) \
298 { \
299 p##RoutineName = RoutineName; \
300 trace("Using embedded routine for " #RoutineName "\n"); \
301 } \
302 else \
303 trace("Using system routine for " #RoutineName "\n");
304
305#if defined KMT_DEFINE_TEST_FUNCTIONS
306
307#if defined KMT_KERNEL_MODE
308#include "kmt_test_kernel.h"
309#elif defined KMT_USER_MODE
310#include "kmt_test_user.h"
311#endif /* defined KMT_USER_MODE */
312
314
315static VOID KmtAddToLogBuffer(PKMT_RESULTBUFFER Buffer, PCSTR String, SIZE_T Length)
316{
317 LONG OldLength;
319
320 if (!Buffer)
321 return;
322
323 do
324 {
325 OldLength = Buffer->LogBufferLength;
326 NewLength = OldLength + (ULONG)Length;
327 if (NewLength > Buffer->LogBufferMaxLength)
328 return;
329 } while (InterlockedCompareExchange(&Buffer->LogBufferLength, NewLength, OldLength) != OldLength);
330
331 memcpy(&Buffer->LogBuffer[OldLength], String, Length);
332}
333
334KMT_FORMAT(ms_printf, 5, 0)
335static SIZE_T KmtXVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR FileAndLine, PCSTR Prepend, PCSTR Format, va_list Arguments)
336{
339
340 if (FileAndLine)
341 {
342 PCSTR Slash;
343 Slash = strrchr(FileAndLine, '\\');
344 if (Slash)
345 FileAndLine = Slash + 1;
346 Slash = strrchr(FileAndLine, '/');
347 if (Slash)
348 FileAndLine = Slash + 1;
349
350 Length = min(BufferMaxLength, strlen(FileAndLine));
351 memcpy(Buffer, FileAndLine, Length);
352 Buffer += Length;
354 BufferMaxLength -= Length;
355 }
356 if (Prepend)
357 {
358 Length = min(BufferMaxLength, strlen(Prepend));
359 memcpy(Buffer, Prepend, Length);
360 Buffer += Length;
362 BufferMaxLength -= Length;
363 }
364 if (Format)
365 {
366 Length = KmtVSNPrintF(Buffer, BufferMaxLength, Format, Arguments);
367 /* vsnprintf can return more than maxLength, we don't want to do that */
368 BufferLength += min(Length, BufferMaxLength);
369 }
370 return BufferLength;
371}
372
373KMT_FORMAT(ms_printf, 5, 6)
374static SIZE_T KmtXSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR FileAndLine, PCSTR Prepend, PCSTR Format, ...)
375{
377 va_list Arguments;
378 va_start(Arguments, Format);
379 BufferLength = KmtXVSNPrintF(Buffer, BufferMaxLength, FileAndLine, Prepend, Format, Arguments);
380 va_end(Arguments);
381 return BufferLength;
382}
383
384VOID KmtFinishTest(PCSTR TestName)
385{
386 CHAR MessageBuffer[512];
387 SIZE_T MessageLength;
388
389 if (!ResultBuffer)
390 return;
391
392 MessageLength = KmtXSNPrintF(MessageBuffer, sizeof MessageBuffer, NULL, NULL,
393 "%s: %ld tests executed (0 marked as todo, %ld failures), %ld skipped.\n",
394 TestName,
398 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
399}
400
401BOOLEAN KmtVOk(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments)
402{
403 CHAR MessageBuffer[512];
404 SIZE_T MessageLength;
405
406 if (!ResultBuffer)
407 return Condition != 0;
408
409 if (Condition)
410 {
412
413 if (0/*KmtReportSuccess*/)
414 {
415 MessageLength = KmtXSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": Test succeeded\n", NULL);
416 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
417 }
418 }
419 else
420 {
422 MessageLength = KmtXVSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": Test failed: ", Format, Arguments);
423 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
424 }
425
426 return Condition != 0;
427}
428
429BOOLEAN KmtOk(INT Condition, PCSTR FileAndLine, PCSTR Format, ...)
430{
431 BOOLEAN Ret;
432 va_list Arguments;
433 va_start(Arguments, Format);
434 Ret = KmtVOk(Condition, FileAndLine, Format, Arguments);
435 va_end(Arguments);
436 return Ret;
437}
438
439VOID KmtVTrace(PCSTR FileAndLine, PCSTR Format, va_list Arguments)
440{
441 CHAR MessageBuffer[512];
442 SIZE_T MessageLength;
443
444 MessageLength = KmtXVSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": ", Format, Arguments);
445 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
446}
447
448VOID KmtTrace(PCSTR FileAndLine, PCSTR Format, ...)
449{
450 va_list Arguments;
451 va_start(Arguments, Format);
452 KmtVTrace(FileAndLine, Format, Arguments);
453 va_end(Arguments);
454}
455
456BOOLEAN KmtVSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments)
457{
458 CHAR MessageBuffer[512];
459 SIZE_T MessageLength;
460
461 if (!ResultBuffer)
462 return !Condition;
463
464 if (!Condition)
465 {
467 MessageLength = KmtXVSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": Tests skipped: ", Format, Arguments);
468 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
469 }
470
471 return !Condition;
472}
473
474BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, ...)
475{
476 BOOLEAN Ret;
477 va_list Arguments;
478 va_start(Arguments, Format);
479 Ret = KmtVSkip(Condition, FileAndLine, Format, Arguments);
480 va_end(Arguments);
481 return Ret;
482}
483
484PVOID KmtAllocateGuarded(SIZE_T SizeRequested)
485{
487 SIZE_T Size = PAGE_ROUND_UP(SizeRequested + PAGE_SIZE);
488 PVOID VirtualMemory = NULL;
489 PCHAR StartOfBuffer;
490
491 Status = ZwAllocateVirtualMemory(ZwCurrentProcess(), &VirtualMemory, 0, &Size, MEM_RESERVE, PAGE_NOACCESS);
492
493 if (!NT_SUCCESS(Status))
494 return NULL;
495
496 Size -= PAGE_SIZE;
497 Status = ZwAllocateVirtualMemory(ZwCurrentProcess(), &VirtualMemory, 0, &Size, MEM_COMMIT, PAGE_READWRITE);
498 if (!NT_SUCCESS(Status))
499 {
500 Size = 0;
501 Status = ZwFreeVirtualMemory(ZwCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE);
503 return NULL;
504 }
505
506 StartOfBuffer = VirtualMemory;
507 StartOfBuffer += Size - SizeRequested;
508
509 return StartOfBuffer;
510}
511
513{
515 PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer);
516 SIZE_T Size = 0;
517
518 Status = ZwFreeVirtualMemory(ZwCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE);
520}
521
522#endif /* defined KMT_DEFINE_TEST_FUNCTIONS */
523
524#endif /* !defined _KMTEST_TEST_H_ */
VOID TestUnload(IN PDRIVER_OBJECT DriverObject)
Definition: Example_drv.c:93
static USHORT USHORT * NewLength
static void TestEntry(const ENTRY *pEntry)
unsigned char BOOLEAN
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define InterlockedIncrement
Definition: armddk.h:53
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR ServiceName[]
Definition: browser.c:19
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DEVICE_TYPE
Definition: guid.c:10
#define NTSTATUS
Definition: precomp.h:20
static const WCHAR Message[]
Definition: register.c:74
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PAGE_SIZE
Definition: env_spec_w32.h:49
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
ULONG FLT_INSTANCE_SETUP_FLAGS
Definition: fltkernel.h:527
VOID(FLTAPI * PFLT_DISCONNECT_NOTIFY)(_In_opt_ PVOID ConnectionCookie)
Definition: fltkernel.h:856
NTSTATUS(FLTAPI * PFLT_MESSAGE_NOTIFY)(_In_opt_ PVOID PortCookie, _In_reads_bytes_opt_(InputBufferLength) PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_writes_bytes_to_opt_(OutputBufferLength, *ReturnOutputBufferLength) PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _Out_ PULONG ReturnOutputBufferLength)
Definition: fltkernel.h:839
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback
Definition: fltkernel.h:1877
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
NTSTATUS(FLTAPI * PFLT_CONNECT_NOTIFY)(_In_ PFLT_PORT ClientPort, _In_opt_ PVOID ServerPortCookie, _In_reads_bytes_opt_(SizeOfContext) PVOID ConnectionContext, _In_ ULONG SizeOfContext, _Outptr_result_maybenull_ PVOID *ConnectionPortCookie)
Definition: fltkernel.h:848
ULONG FLT_INSTANCE_QUERY_TEARDOWN_FLAGS
Definition: fltkernel.h:552
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_ PCUNICODE_STRING Altitude
Definition: fltkernel.h:1173
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1875
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1876
VOID TestQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
Definition: fltmgr_create.c:92
NTSTATUS TestInstanceSetup(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_SETUP_FLAGS Flags, _In_ DEVICE_TYPE VolumeDeviceType, _In_ FLT_FILESYSTEM_TYPE VolumeFilesystemType, _In_ PUNICODE_STRING VolumeName, _In_ ULONG SectorSize, _In_ ULONG ReportedSectorSize)
VOID TestFilterUnload(IN ULONG Flags)
Definition: fltmgr_create.c:79
DWORD KmtFltSendToDriver(_In_ HANDLE hPort, _In_ DWORD Message)
Definition: fltsupport.c:281
DWORD KmtFltCreateService(_In_z_ PCWSTR ServiceName, _In_z_ PCWSTR DisplayName, _Out_ SC_HANDLE *ServiceHandle)
Definition: fltsupport.c:63
DWORD KmtFltRunKernelTest(_In_ HANDLE hPort, _In_z_ PCSTR TestName)
Definition: fltsupport.c:261
DWORD KmtFltSendUlongToDriver(_In_ HANDLE hPort, _In_ DWORD Message, _In_ DWORD Value)
Definition: fltsupport.c:353
DWORD KmtFltDisconnectComms(_In_ HANDLE hPort)
Definition: fltsupport.c:224
DWORD KmtFltSendBufferToDriver(_In_ HANDLE hPort, _In_ DWORD Message, _In_reads_bytes_(BufferSize) LPVOID InBuffer, _In_ DWORD BufferSize, _Out_writes_bytes_to_opt_(OutBufferSize, *BytesReturned) LPVOID OutBuffer, _In_ DWORD OutBufferSize, _Out_opt_ LPDWORD BytesReturned)
Definition: fltsupport.c:384
DWORD KmtFltSendStringToDriver(_In_ HANDLE hPort, _In_ DWORD Message, _In_ PCSTR String)
Definition: fltsupport.c:305
DWORD KmtFltAddAltitude(_In_z_ LPWSTR Altitude)
Definition: fltsupport.c:448
DWORD KmtFltUnloadDriver(_In_ HANDLE *hPort, _In_ BOOLEAN DisonnectComms)
Definition: fltsupport.c:169
DWORD KmtFltSendWStringToDriver(_In_ HANDLE hPort, _In_ DWORD Message, _In_ PCWSTR String)
Definition: fltsupport.c:330
DWORD KmtFltConnectComms(_Out_ HANDLE *hPort)
Definition: fltsupport.c:207
DWORD KmtFltLoadDriver(_In_ BOOLEAN EnableDriverLoadPrivlege, _In_ BOOLEAN RestartIfRunning, _In_ BOOLEAN ConnectComms, _Out_ HANDLE *hPort)
Definition: fltsupport.c:112
DWORD KmtFltDeleteService(_In_opt_z_ PCWSTR ServiceName, _Inout_ SC_HANDLE *ServiceHandle)
Definition: fltsupport.c:97
FP_OP Operation
Definition: fpcontrol.c:150
Status
Definition: gdiplustypes.h:25
#define InterlockedCompareExchange
Definition: interlocked.h:104
union _KMT_RESPONSE KMT_RESPONSE
PKMT_RESPONSE KmtUserModeCallback(KMT_CALLBACK_INFORMATION_CLASS Operation, PVOID Parameters)
#define ok_eq_hex(value, expected)
Definition: kmt_test.h:257
BOOLEAN BOOLEAN VOID VOID KmtTrace(PCSTR FileAndLine, PCSTR Format,...) KMT_FORMAT(ms_printf
const KMT_TEST * PCKMT_TEST
Definition: kmt_test.h:30
VOID KmtFreeGuarded(PVOID Pointer)
BOOLEAN BOOLEAN VOID VOID BOOLEAN KmtVSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf
union _KMT_RESPONSE * PKMT_RESPONSE
BOOLEAN BOOLEAN KmtOk(INT Condition, PCSTR FileAndLine, PCSTR Format,...) KMT_FORMAT(ms_printf
BOOLEAN BOOLEAN VOID KmtVTrace(PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf
VOID KMT_TESTFUNC(VOID)
Definition: kmt_test.h:21
BOOLEAN KmtVOk(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf
struct KMT_RESULTBUFFER * PKMT_RESULTBUFFER
struct _KMT_CALLBACK_REQUEST_PACKET * PKMT_CALLBACK_REQUEST_PACKET
struct _KMT_CALLBACK_REQUEST_PACKET KMT_CALLBACK_REQUEST_PACKET
BOOLEAN BOOLEAN VOID VOID BOOLEAN BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format,...) KMT_FORMAT(ms_printf
_KMT_CALLBACK_INFORMATION_CLASS
Definition: kmt_test.h:50
@ QueryVirtualMemory
Definition: kmt_test.h:51
VOID KmtFreeCallbackResponse(PKMT_RESPONSE Response)
Definition: kmtest_drv.c:606
enum _KMT_CALLBACK_INFORMATION_CLASS KMT_CALLBACK_INFORMATION_CLASS
const KMT_TEST CKMT_TEST
Definition: kmt_test.h:30
KMT_TESTFUNC * PKMT_TESTFUNC
Definition: kmt_test.h:22
PKMT_RESULTBUFFER ResultBuffer
#define KMT_FORMAT(type, fmt, first)
Definition: kmt_test.h:210
enum _KMT_CALLBACK_INFORMATION_CLASS * PKMT_CALLBACK_INFORMATION_CLASS
BOOLEAN BOOLEAN VOID VOID BOOLEAN BOOLEAN PVOID KmtAllocateGuarded(SIZE_T SizeRequested)
struct KMT_TEST * PKMT_TEST
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
PCSTR KmtMajorFunctionNames[]
PVOID KmtGetSystemRoutineAddress(IN PCWSTR RoutineName)
USHORT KmtGetPoolType(PVOID Memory)
ULONG KmtGetPoolTag(PVOID Memory)
VOID KmtSetIrql(IN KIRQL NewIrql)
BOOLEAN KmtAreInterruptsEnabled(VOID)
BOOLEAN KmtIsCheckedBuild
BOOLEAN KmtIsMultiProcessorBuild
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
#define KmtVSNPrintF
Definition: kmt_test_user.h:35
NTSTATUS KmtFilterRegisterCallbacks(_In_ CONST FLT_OPERATION_REGISTRATION *OperationRegistration)
NTSTATUS KmtFilterRegisterComms(_In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback, _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback, _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback, _In_ LONG MaxClientConnections)
NTSTATUS KmtRegisterMessageHandler(IN ULONG ControlCode OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_MESSAGE_HANDLER MessageHandler)
NTSTATUS KmtUnregisterMessageHandler(IN ULONG ControlCode OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_MESSAGE_HANDLER MessageHandler)
NTSTATUS KmtUnregisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
NTSTATUS KmtRegisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
signed char * PSTR
Definition: retypes.h:7
signed char * PCHAR
Definition: retypes.h:7
void * PVOID
Definition: retypes.h:9
unsigned int ULONG
Definition: retypes.h:1
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
#define _Out_opt_
Definition: ms_sal.h:346
#define _In_reads_bytes_(size)
Definition: ms_sal.h:321
#define _Inout_
Definition: ms_sal.h:378
#define _In_z_
Definition: ms_sal.h:313
#define _In_opt_z_
Definition: ms_sal.h:314
#define _Out_
Definition: ms_sal.h:345
#define _Out_writes_bytes_to_opt_(size, count)
Definition: ms_sal.h:361
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define PAGE_ROUND_UP(x)
Definition: mmtypes.h:38
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define MEM_RESERVE
Definition: nt_native.h:1314
#define MEM_RELEASE
Definition: nt_native.h:1316
#define MEM_COMMIT
Definition: nt_native.h:1313
#define PAGE_NOACCESS
Definition: nt_native.h:1302
IN ULONG IN UCHAR Condition
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define CONST
Definition: pedump.c:81
DWORD * PDWORD
Definition: pedump.c:68
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
#define STATUS_SUCCESS
Definition: shellext.h:65
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
volatile LONG Failures
Definition: kmt_test.h:37
volatile LONG Skipped
Definition: kmt_test.h:38
volatile LONG LogBufferLength
Definition: kmt_test.h:39
LONG LogBufferMaxLength
Definition: kmt_test.h:40
volatile LONG Successes
Definition: kmt_test.h:36
const char * TestName
Definition: kmt_test.h:26
KMT_TESTFUNC * TestFunction
Definition: kmt_test.h:27
Definition: ncftp.h:89
KMT_CALLBACK_INFORMATION_CLASS OperationClass
Definition: kmt_test.h:64
DWORD KmtRunKernelTest(IN PCSTR TestName)
Definition: support.c:95
DWORD KmtLoadAndOpenDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning)
Definition: support.c:213
DWORD KmtOpenDriver(VOID)
Definition: support.c:192
VOID KmtCloseDriver(VOID)
Definition: support.c:236
DWORD KmtSendBufferToDriver(IN DWORD ControlCode, IN OUT PVOID Buffer OPTIONAL, IN DWORD InLength, IN OUT PDWORD OutLength)
Definition: support.c:360
DWORD KmtSendUlongToDriver(IN DWORD ControlCode, IN DWORD Value)
Definition: support.c:333
DWORD KmtSendStringToDriver(IN DWORD ControlCode, IN PCSTR String)
Definition: support.c:283
DWORD KmtSendToDriver(IN DWORD ControlCode)
Definition: support.c:259
DWORD KmtLoadDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning)
Definition: support.c:128
VOID KmtUnloadDriverKeepService(VOID)
Definition: support.c:149
DWORD KmtSendWStringToDriver(IN DWORD ControlCode, IN PCWSTR String)
Definition: support.c:308
VOID KmtUnloadDriver(VOID)
Definition: support.c:167
EH_STD::__list__< TestClass, eh_allocator(TestClass) > TestList
Definition: test_list.cpp:31
ULONG_PTR * PSIZE_T
Definition: typedefs.h:80
#define OPTIONAL
Definition: typedefs.h:41
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define ANYSIZE_ARRAY
Definition: typedefs.h:46
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
MEMORY_BASIC_INFORMATION MemInfo
Definition: kmt_test.h:57
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ UCHAR MajorFunction
Definition: wdfdevice.h:1697
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1705
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG SectorSize
Definition: halfuncs.h:291
KSTART_ROUTINE * PKSTART_ROUTINE
Definition: ketypes.h:487
_In_ ULONG _In_opt_ POBJECT_ATTRIBUTES _In_opt_ HANDLE _Out_opt_ PCLIENT_ID _In_ PKSTART_ROUTINE StartRoutine
Definition: psfuncs.h:91
unsigned char UCHAR
Definition: xmlstorage.h:181
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175
#define ZwCurrentProcess()