ReactOS 0.4.15-dev-7918-g2a2556c
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 ok_eq_hex64(value, expected) ok_eq_print(value, expected, "%I64x")
268#define ok_eq_xmm(value, expected) ok((value).Low == (expected).Low, #value " = %I64x'%08I64x, expected %I64x'%08I64x\n", (value).Low, (value).High, (expected).Low, (expected).High)
269
270#define KMT_MAKE_CODE(ControlCode) CTL_CODE(FILE_DEVICE_UNKNOWN, \
271 0xC00 + (ControlCode), \
272 METHOD_BUFFERED, \
273 FILE_ANY_ACCESS)
274
275#define MICROSECOND 10
276#define MILLISECOND (1000 * MICROSECOND)
277#define SECOND (1000 * MILLISECOND)
278
279/* See apitests/include/apitest.h */
280#define KmtInvalidPointer ((PVOID)0x5555555555555555ULL)
281
282#define KmtStartSeh() \
283{ \
284 NTSTATUS ExceptionStatus = STATUS_SUCCESS; \
285 _SEH2_TRY \
286 {
287
288#define KmtEndSeh(ExpectedStatus) \
289 } \
290 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) \
291 { \
292 ExceptionStatus = _SEH2_GetExceptionCode(); \
293 } \
294 _SEH2_END; \
295 ok_eq_hex(ExceptionStatus, (ExpectedStatus)); \
296}
297
298#define KmtGetSystemOrEmbeddedRoutineAddress(RoutineName) \
299 p##RoutineName = KmtGetSystemRoutineAddress(L ## #RoutineName); \
300 if (!p##RoutineName) \
301 { \
302 p##RoutineName = RoutineName; \
303 trace("Using embedded routine for " #RoutineName "\n"); \
304 } \
305 else \
306 trace("Using system routine for " #RoutineName "\n");
307
308#if defined KMT_DEFINE_TEST_FUNCTIONS
309
310#if defined KMT_KERNEL_MODE
311#include "kmt_test_kernel.h"
312#elif defined KMT_USER_MODE
313#include "kmt_test_user.h"
314#endif /* defined KMT_USER_MODE */
315
317
318static VOID KmtAddToLogBuffer(PKMT_RESULTBUFFER Buffer, PCSTR String, SIZE_T Length)
319{
320 LONG OldLength;
322
323 if (!Buffer)
324 return;
325
326 do
327 {
328 OldLength = Buffer->LogBufferLength;
329 NewLength = OldLength + (ULONG)Length;
330 if (NewLength > Buffer->LogBufferMaxLength)
331 return;
332 } while (InterlockedCompareExchange(&Buffer->LogBufferLength, NewLength, OldLength) != OldLength);
333
334 memcpy(&Buffer->LogBuffer[OldLength], String, Length);
335}
336
337KMT_FORMAT(ms_printf, 5, 0)
338static SIZE_T KmtXVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR FileAndLine, PCSTR Prepend, PCSTR Format, va_list Arguments)
339{
342
343 if (FileAndLine)
344 {
345 PCSTR Slash;
346 Slash = strrchr(FileAndLine, '\\');
347 if (Slash)
348 FileAndLine = Slash + 1;
349 Slash = strrchr(FileAndLine, '/');
350 if (Slash)
351 FileAndLine = Slash + 1;
352
353 Length = min(BufferMaxLength, strlen(FileAndLine));
354 memcpy(Buffer, FileAndLine, Length);
355 Buffer += Length;
357 BufferMaxLength -= Length;
358 }
359 if (Prepend)
360 {
361 Length = min(BufferMaxLength, strlen(Prepend));
362 memcpy(Buffer, Prepend, Length);
363 Buffer += Length;
365 BufferMaxLength -= Length;
366 }
367 if (Format)
368 {
369 Length = KmtVSNPrintF(Buffer, BufferMaxLength, Format, Arguments);
370 /* vsnprintf can return more than maxLength, we don't want to do that */
371 BufferLength += min(Length, BufferMaxLength);
372 }
373 return BufferLength;
374}
375
376KMT_FORMAT(ms_printf, 5, 6)
377static SIZE_T KmtXSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR FileAndLine, PCSTR Prepend, PCSTR Format, ...)
378{
380 va_list Arguments;
381 va_start(Arguments, Format);
382 BufferLength = KmtXVSNPrintF(Buffer, BufferMaxLength, FileAndLine, Prepend, Format, Arguments);
383 va_end(Arguments);
384 return BufferLength;
385}
386
387VOID KmtFinishTest(PCSTR TestName)
388{
389 CHAR MessageBuffer[512];
390 SIZE_T MessageLength;
391
392 if (!ResultBuffer)
393 return;
394
395 MessageLength = KmtXSNPrintF(MessageBuffer, sizeof MessageBuffer, NULL, NULL,
396 "%s: %ld tests executed (0 marked as todo, %ld failures), %ld skipped.\n",
397 TestName,
401 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
402}
403
404BOOLEAN KmtVOk(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments)
405{
406 CHAR MessageBuffer[512];
407 SIZE_T MessageLength;
408
409 if (!ResultBuffer)
410 return Condition != 0;
411
412 if (Condition)
413 {
415
416 if (0/*KmtReportSuccess*/)
417 {
418 MessageLength = KmtXSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": Test succeeded\n", NULL);
419 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
420 }
421 }
422 else
423 {
425 MessageLength = KmtXVSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": Test failed: ", Format, Arguments);
426 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
427 }
428
429 return Condition != 0;
430}
431
432BOOLEAN KmtOk(INT Condition, PCSTR FileAndLine, PCSTR Format, ...)
433{
434 BOOLEAN Ret;
435 va_list Arguments;
436 va_start(Arguments, Format);
437 Ret = KmtVOk(Condition, FileAndLine, Format, Arguments);
438 va_end(Arguments);
439 return Ret;
440}
441
442VOID KmtVTrace(PCSTR FileAndLine, PCSTR Format, va_list Arguments)
443{
444 CHAR MessageBuffer[512];
445 SIZE_T MessageLength;
446
447 MessageLength = KmtXVSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": ", Format, Arguments);
448 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
449}
450
451VOID KmtTrace(PCSTR FileAndLine, PCSTR Format, ...)
452{
453 va_list Arguments;
454 va_start(Arguments, Format);
455 KmtVTrace(FileAndLine, Format, Arguments);
456 va_end(Arguments);
457}
458
459BOOLEAN KmtVSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments)
460{
461 CHAR MessageBuffer[512];
462 SIZE_T MessageLength;
463
464 if (!ResultBuffer)
465 return !Condition;
466
467 if (!Condition)
468 {
470 MessageLength = KmtXVSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": Tests skipped: ", Format, Arguments);
471 KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
472 }
473
474 return !Condition;
475}
476
477BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, ...)
478{
479 BOOLEAN Ret;
480 va_list Arguments;
481 va_start(Arguments, Format);
482 Ret = KmtVSkip(Condition, FileAndLine, Format, Arguments);
483 va_end(Arguments);
484 return Ret;
485}
486
487PVOID KmtAllocateGuarded(SIZE_T SizeRequested)
488{
490 SIZE_T Size = PAGE_ROUND_UP(SizeRequested + PAGE_SIZE);
491 PVOID VirtualMemory = NULL;
492 PCHAR StartOfBuffer;
493
494 Status = ZwAllocateVirtualMemory(ZwCurrentProcess(), &VirtualMemory, 0, &Size, MEM_RESERVE, PAGE_NOACCESS);
495
496 if (!NT_SUCCESS(Status))
497 return NULL;
498
499 Size -= PAGE_SIZE;
500 Status = ZwAllocateVirtualMemory(ZwCurrentProcess(), &VirtualMemory, 0, &Size, MEM_COMMIT, PAGE_READWRITE);
501 if (!NT_SUCCESS(Status))
502 {
503 Size = 0;
504 Status = ZwFreeVirtualMemory(ZwCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE);
506 return NULL;
507 }
508
509 StartOfBuffer = VirtualMemory;
510 StartOfBuffer += Size - SizeRequested;
511
512 return StartOfBuffer;
513}
514
516{
518 PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer);
519 SIZE_T Size = 0;
520
521 Status = ZwFreeVirtualMemory(ZwCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE);
523}
524
525#endif /* defined KMT_DEFINE_TEST_FUNCTIONS */
526
527#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:21
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)
#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
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define ANYSIZE_ARRAY
Definition: typedefs.h:46
void * PVOID
Definition: typedefs.h:50
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
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
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:499
_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()