ReactOS  0.4.14-dev-554-g2f8d847
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 
24 typedef struct
25 {
26  const char *TestName;
29 
30 typedef const KMT_TEST CKMT_TEST, *PCKMT_TEST;
31 
32 extern const KMT_TEST TestList[];
33 
34 typedef 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 */
55 typedef 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 
89 typedef NTSTATUS (KMT_IRP_HANDLER)(
91  IN PIRP Irp,
92  IN PIO_STACK_LOCATION IoStackLocation);
93 typedef KMT_IRP_HANDLER *PKMT_IRP_HANDLER;
94 
95 NTSTATUS KmtRegisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler);
96 NTSTATUS KmtUnregisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler);
97 
98 typedef NTSTATUS (KMT_MESSAGE_HANDLER)(
102  IN SIZE_T InLength,
103  IN OUT PSIZE_T OutLength);
104 typedef KMT_MESSAGE_HANDLER *PKMT_MESSAGE_HANDLER;
105 
108 
109 typedef 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 
130 typedef 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 
141 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 RealSectorSize, _In_ ULONG SectorSize);
143 
145 
146 #endif/* defined KMT_FILTER_DRIVER */
147 
148 
149 #ifdef KMT_KERNEL_MODE
150 /* Device Extension layout */
151 typedef struct
152 {
154  PMDL Mdl;
155 } KMT_DEVICE_EXTENSION, *PKMT_DEVICE_EXTENSION;
156 
160 extern PDRIVER_OBJECT KmtDriverObject;
161 
169 #elif defined KMT_USER_MODE
170 DWORD KmtRunKernelTest(IN PCSTR TestName);
171 
172 VOID KmtLoadDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning);
176 
182 
183 
184 DWORD KmtFltCreateService(_In_z_ PCWSTR ServiceName, _In_z_ PCWSTR DisplayName, _Out_ SC_HANDLE *ServiceHandle);
185 DWORD KmtFltDeleteService(_In_opt_z_ PCWSTR ServiceName, _Inout_ SC_HANDLE *ServiceHandle);
187 DWORD KmtFltLoadDriver(_In_ BOOLEAN EnableDriverLoadPrivlege, _In_ BOOLEAN RestartIfRunning, _In_ BOOLEAN ConnectComms, _Out_ HANDLE *hPort);
188 DWORD KmtFltUnloadDriver(_In_ HANDLE *hPort, _In_ BOOLEAN DisonnectComms);
197 
198 #else /* if !defined KMT_KERNEL_MODE && !defined KMT_USER_MODE */
199 #error either KMT_KERNEL_MODE or KMT_USER_MODE must be defined
200 #endif /* !defined KMT_KERNEL_MODE && !defined KMT_USER_MODE */
201 
203 
204 #ifdef __GNUC__
205 /* TODO: GCC doesn't understand %wZ :( */
206 #define KMT_FORMAT(type, fmt, first) /*__attribute__((__format__(type, fmt, first)))*/
207 #elif !defined __GNUC__
208 #define KMT_FORMAT(type, fmt, first)
209 #endif /* !defined __GNUC__ */
210 
211 #define START_TEST(name) VOID Test_##name(VOID)
212 
213 #ifndef KMT_STRINGIZE
214 #define KMT_STRINGIZE(x) #x
215 #endif /* !defined KMT_STRINGIZE */
216 #define ok(test, ...) ok_(test, __FILE__, __LINE__, __VA_ARGS__)
217 #define trace(...) trace_( __FILE__, __LINE__, __VA_ARGS__)
218 #define skip(test, ...) skip_(test, __FILE__, __LINE__, __VA_ARGS__)
219 
220 #define ok_(test, file, line, ...) KmtOk(test, file ":" KMT_STRINGIZE(line), __VA_ARGS__)
221 #define trace_(file, line, ...) KmtTrace( file ":" KMT_STRINGIZE(line), __VA_ARGS__)
222 #define skip_(test, file, line, ...) KmtSkip(test, file ":" KMT_STRINGIZE(line), __VA_ARGS__)
223 
224 BOOLEAN KmtVOk(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 3, 0);
225 BOOLEAN KmtOk(INT Condition, PCSTR FileAndLine, PCSTR Format, ...) KMT_FORMAT(ms_printf, 3, 4);
226 VOID KmtVTrace(PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 2, 0);
227 VOID KmtTrace(PCSTR FileAndLine, PCSTR Format, ...) KMT_FORMAT(ms_printf, 2, 3);
228 BOOLEAN KmtVSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 3, 0);
229 BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, ...) KMT_FORMAT(ms_printf, 3, 4);
230 PVOID KmtAllocateGuarded(SIZE_T SizeRequested);
231 VOID KmtFreeGuarded(PVOID Pointer);
232 
233 #ifdef KMT_KERNEL_MODE
234 #define ok_irql(irql) ok(KeGetCurrentIrql() == irql, "IRQL is %d, expected %d\n", KeGetCurrentIrql(), irql)
235 #endif /* defined KMT_KERNEL_MODE */
236 #define ok_eq_print(value, expected, spec) ok((value) == (expected), #value " = " spec ", expected " spec "\n", value, expected)
237 #define ok_eq_pointer(value, expected) ok_eq_print(value, expected, "%p")
238 #define ok_eq_int(value, expected) ok_eq_print(value, expected, "%d")
239 #define ok_eq_uint(value, expected) ok_eq_print(value, expected, "%u")
240 #define ok_eq_long(value, expected) ok_eq_print(value, expected, "%ld")
241 #define ok_eq_ulong(value, expected) ok_eq_print(value, expected, "%lu")
242 #define ok_eq_longlong(value, expected) ok_eq_print(value, expected, "%I64d")
243 #define ok_eq_ulonglong(value, expected) ok_eq_print(value, expected, "%I64u")
244 #define ok_eq_char(value, expected) ok_eq_print(value, expected, "%c")
245 #define ok_eq_wchar(value, expected) ok_eq_print(value, expected, "%C")
246 #ifndef _WIN64
247 #define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected), "%lu")
248 #define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected), "%ld")
249 #define ok_eq_ulongptr(value, expected) ok_eq_print(value, (ULONG_PTR)(expected), "%lu")
250 #elif defined _WIN64
251 #define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected), "%I64u")
252 #define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected), "%I64d")
253 #define ok_eq_ulongptr(value, expected) ok_eq_print(value, (ULONG_PTR)(expected), "%I64u")
254 #endif /* defined _WIN64 */
255 #define ok_eq_hex(value, expected) ok_eq_print(value, expected, "0x%08lx")
256 #define ok_bool_true(value, desc) ok((value) == TRUE, desc " FALSE, expected TRUE\n")
257 #define ok_bool_false(value, desc) ok((value) == FALSE, desc " TRUE, expected FALSE\n")
258 #define ok_eq_bool(value, expected) ok((value) == (expected), #value " = %s, expected %s\n", \
259  (value) ? "TRUE" : "FALSE", \
260  (expected) ? "TRUE" : "FALSE")
261 #define ok_eq_str(value, expected) ok(!strcmp(value, expected), #value " = \"%s\", expected \"%s\"\n", value, expected)
262 #define ok_eq_wstr(value, expected) ok(!wcscmp(value, expected), #value " = \"%ls\", expected \"%ls\"\n", value, expected)
263 #define ok_eq_tag(value, expected) ok_eq_print(value, expected, "0x%08lx")
264 
265 #define KMT_MAKE_CODE(ControlCode) CTL_CODE(FILE_DEVICE_UNKNOWN, \
266  0xC00 + (ControlCode), \
267  METHOD_BUFFERED, \
268  FILE_ANY_ACCESS)
269 
270 #define MICROSECOND 10
271 #define MILLISECOND (1000 * MICROSECOND)
272 #define SECOND (1000 * MILLISECOND)
273 
274 /* See apitests/include/apitest.h */
275 #define KmtInvalidPointer ((PVOID)0x5555555555555555ULL)
276 
277 #define KmtStartSeh() \
278 { \
279  NTSTATUS ExceptionStatus = STATUS_SUCCESS; \
280  _SEH2_TRY \
281  {
282 
283 #define KmtEndSeh(ExpectedStatus) \
284  } \
285  _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) \
286  { \
287  ExceptionStatus = _SEH2_GetExceptionCode(); \
288  } \
289  _SEH2_END; \
290  ok_eq_hex(ExceptionStatus, (ExpectedStatus)); \
291 }
292 
293 #define KmtGetSystemOrEmbeddedRoutineAddress(RoutineName) \
294  p##RoutineName = KmtGetSystemRoutineAddress(L ## #RoutineName); \
295  if (!p##RoutineName) \
296  { \
297  p##RoutineName = RoutineName; \
298  trace("Using embedded routine for " #RoutineName "\n"); \
299  } \
300  else \
301  trace("Using system routine for " #RoutineName "\n");
302 
303 #if defined KMT_DEFINE_TEST_FUNCTIONS
304 
305 #if defined KMT_KERNEL_MODE
306 #include "kmt_test_kernel.h"
307 #elif defined KMT_USER_MODE
308 #include "kmt_test_user.h"
309 #endif /* defined KMT_USER_MODE */
310 
312 
313 static VOID KmtAddToLogBuffer(PKMT_RESULTBUFFER Buffer, PCSTR String, SIZE_T Length)
314 {
315  LONG OldLength;
316  LONG NewLength;
317 
318  if (!Buffer)
319  return;
320 
321  do
322  {
323  OldLength = Buffer->LogBufferLength;
324  NewLength = OldLength + (ULONG)Length;
325  if (NewLength > Buffer->LogBufferMaxLength)
326  return;
327  } while (InterlockedCompareExchange(&Buffer->LogBufferLength, NewLength, OldLength) != OldLength);
328 
329  memcpy(&Buffer->LogBuffer[OldLength], String, Length);
330 }
331 
332 KMT_FORMAT(ms_printf, 5, 0)
333 static SIZE_T KmtXVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR FileAndLine, PCSTR Prepend, PCSTR Format, va_list Arguments)
334 {
335  SIZE_T BufferLength = 0;
336  SIZE_T Length;
337 
338  if (FileAndLine)
339  {
340  PCSTR Slash;
341  Slash = strrchr(FileAndLine, '\\');
342  if (Slash)
343  FileAndLine = Slash + 1;
344  Slash = strrchr(FileAndLine, '/');
345  if (Slash)
346  FileAndLine = Slash + 1;
347 
348  Length = min(BufferMaxLength, strlen(FileAndLine));
349  memcpy(Buffer, FileAndLine, Length);
350  Buffer += Length;
351  BufferLength += Length;
352  BufferMaxLength -= Length;
353  }
354  if (Prepend)
355  {
356  Length = min(BufferMaxLength, strlen(Prepend));
357  memcpy(Buffer, Prepend, Length);
358  Buffer += Length;
359  BufferLength += Length;
360  BufferMaxLength -= Length;
361  }
362  if (Format)
363  {
364  Length = KmtVSNPrintF(Buffer, BufferMaxLength, Format, Arguments);
365  /* vsnprintf can return more than maxLength, we don't want to do that */
366  BufferLength += min(Length, BufferMaxLength);
367  }
368  return BufferLength;
369 }
370 
371 KMT_FORMAT(ms_printf, 5, 6)
372 static SIZE_T KmtXSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR FileAndLine, PCSTR Prepend, PCSTR Format, ...)
373 {
375  va_list Arguments;
376  va_start(Arguments, Format);
377  BufferLength = KmtXVSNPrintF(Buffer, BufferMaxLength, FileAndLine, Prepend, Format, Arguments);
378  va_end(Arguments);
379  return BufferLength;
380 }
381 
382 VOID KmtFinishTest(PCSTR TestName)
383 {
384  CHAR MessageBuffer[512];
385  SIZE_T MessageLength;
386 
387  if (!ResultBuffer)
388  return;
389 
390  MessageLength = KmtXSNPrintF(MessageBuffer, sizeof MessageBuffer, NULL, NULL,
391  "%s: %ld tests executed (0 marked as todo, %ld failures), %ld skipped.\n",
392  TestName,
396  KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
397 }
398 
399 BOOLEAN KmtVOk(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments)
400 {
401  CHAR MessageBuffer[512];
402  SIZE_T MessageLength;
403 
404  if (!ResultBuffer)
405  return Condition != 0;
406 
407  if (Condition)
408  {
410 
411  if (0/*KmtReportSuccess*/)
412  {
413  MessageLength = KmtXSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": Test succeeded\n", NULL);
414  KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
415  }
416  }
417  else
418  {
420  MessageLength = KmtXVSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": Test failed: ", Format, Arguments);
421  KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
422  }
423 
424  return Condition != 0;
425 }
426 
427 BOOLEAN KmtOk(INT Condition, PCSTR FileAndLine, PCSTR Format, ...)
428 {
429  BOOLEAN Ret;
430  va_list Arguments;
431  va_start(Arguments, Format);
432  Ret = KmtVOk(Condition, FileAndLine, Format, Arguments);
433  va_end(Arguments);
434  return Ret;
435 }
436 
437 VOID KmtVTrace(PCSTR FileAndLine, PCSTR Format, va_list Arguments)
438 {
439  CHAR MessageBuffer[512];
440  SIZE_T MessageLength;
441 
442  MessageLength = KmtXVSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": ", Format, Arguments);
443  KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
444 }
445 
446 VOID KmtTrace(PCSTR FileAndLine, PCSTR Format, ...)
447 {
448  va_list Arguments;
449  va_start(Arguments, Format);
450  KmtVTrace(FileAndLine, Format, Arguments);
451  va_end(Arguments);
452 }
453 
454 BOOLEAN KmtVSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments)
455 {
456  CHAR MessageBuffer[512];
457  SIZE_T MessageLength;
458 
459  if (!ResultBuffer)
460  return !Condition;
461 
462  if (!Condition)
463  {
465  MessageLength = KmtXVSNPrintF(MessageBuffer, sizeof MessageBuffer, FileAndLine, ": Tests skipped: ", Format, Arguments);
466  KmtAddToLogBuffer(ResultBuffer, MessageBuffer, MessageLength);
467  }
468 
469  return !Condition;
470 }
471 
472 BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, ...)
473 {
474  BOOLEAN Ret;
475  va_list Arguments;
476  va_start(Arguments, Format);
477  Ret = KmtVSkip(Condition, FileAndLine, Format, Arguments);
478  va_end(Arguments);
479  return Ret;
480 }
481 
482 PVOID KmtAllocateGuarded(SIZE_T SizeRequested)
483 {
485  SIZE_T Size = PAGE_ROUND_UP(SizeRequested + PAGE_SIZE);
486  PVOID VirtualMemory = NULL;
487  PCHAR StartOfBuffer;
488 
489  Status = ZwAllocateVirtualMemory(ZwCurrentProcess(), &VirtualMemory, 0, &Size, MEM_RESERVE, PAGE_NOACCESS);
490 
491  if (!NT_SUCCESS(Status))
492  return NULL;
493 
494  Size -= PAGE_SIZE;
495  Status = ZwAllocateVirtualMemory(ZwCurrentProcess(), &VirtualMemory, 0, &Size, MEM_COMMIT, PAGE_READWRITE);
496  if (!NT_SUCCESS(Status))
497  {
498  Size = 0;
499  Status = ZwFreeVirtualMemory(ZwCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE);
501  return NULL;
502  }
503 
504  StartOfBuffer = VirtualMemory;
505  StartOfBuffer += Size - SizeRequested;
506 
507  return StartOfBuffer;
508 }
509 
510 VOID KmtFreeGuarded(PVOID Pointer)
511 {
513  PVOID VirtualMemory = (PVOID)PAGE_ROUND_DOWN((SIZE_T)Pointer);
514  SIZE_T Size = 0;
515 
516  Status = ZwFreeVirtualMemory(ZwCurrentProcess(), &VirtualMemory, &Size, MEM_RELEASE);
518 }
519 
520 #endif /* defined KMT_DEFINE_TEST_FUNCTIONS */
521 
522 #endif /* !defined _KMTEST_TEST_H_ */
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
signed char * PCHAR
Definition: retypes.h:7
BOOLEAN BOOLEAN VOID VOID BOOLEAN BOOLEAN PVOID KmtAllocateGuarded(SIZE_T SizeRequested)
struct KMT_RESULTBUFFER * PKMT_RESULTBUFFER
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
#define _In_opt_z_
Definition: no_sal2.h:221
ULONG FLT_INSTANCE_QUERY_TEARDOWN_FLAGS
Definition: fltkernel.h:552
PCSTR KmtMajorFunctionNames[]
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
DWORD KmtFltRunKernelTest(_In_ HANDLE hPort, _In_z_ PCSTR TestName)
Definition: fltsupport.c:261
#define _Out_writes_bytes_to_opt_(size, count)
Definition: no_sal2.h:375
#define ANYSIZE_ARRAY
Definition: typedefs.h:45
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_In_ ULONG _In_opt_ POBJECT_ATTRIBUTES _In_opt_ HANDLE _Out_opt_ PCLIENT_ID _In_ PKSTART_ROUTINE StartRoutine
Definition: psfuncs.h:87
_In_ PIRP Irp
Definition: csq.h:116
#define ZwCurrentProcess()
NTSTATUS KmtUnregisterMessageHandler(IN ULONG ControlCode OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_MESSAGE_HANDLER MessageHandler)
KMT_CALLBACK_INFORMATION_CLASS OperationClass
Definition: kmt_test.h:64
DWORD KmtFltUnloadDriver(_In_ HANDLE *hPort, _In_ BOOLEAN DisonnectComms)
Definition: fltsupport.c:169
#define ok_eq_hex(value, expected)
Definition: kmt_test.h:255
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS KmtFilterRegisterCallbacks(_In_ CONST FLT_OPERATION_REGISTRATION *OperationRegistration)
#define PAGE_ROUND_DOWN(x)
Definition: mmtypes.h:36
static ULONGLONG Memory
Definition: CcMapData_drv.c:35
VOID KmtFreeCallbackResponse(PKMT_RESPONSE Response)
Definition: kmtest_drv.c:606
#define InterlockedCompareExchange
Definition: interlocked.h:104
static WCHAR String[]
Definition: stringtable.c:55
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
WCHAR DeviceName[]
Definition: adapter.cpp:21
BOOLEAN BOOLEAN VOID VOID BOOLEAN BOOLEAN KmtSkip(INT Condition, PCSTR FileAndLine, PCSTR Format,...) KMT_FORMAT(ms_printf
DWORD KmtSendStringToDriver(IN DWORD ControlCode, IN PCSTR String)
Definition: support.c:248
BOOLEAN KmtVOk(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf
#define MEM_COMMIT
Definition: nt_native.h:1313
int32_t INT
Definition: typedefs.h:56
#define PAGE_ROUND_UP(x)
Definition: scsiport_int.h:13
DWORD KmtFltCreateService(_In_z_ PCWSTR ServiceName, _In_z_ PCWSTR DisplayName, _Out_ SC_HANDLE *ServiceHandle)
Definition: fltsupport.c:63
#define _In_opt_
Definition: no_sal2.h:213
NTSTATUS KmtUnregisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
static USHORT USHORT * NewLength
static void TestEntry(const ENTRY *pEntry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
BOOLEAN KmtIsCheckedBuild
BOOLEAN BOOLEAN KmtOk(INT Condition, PCSTR FileAndLine, PCSTR Format,...) KMT_FORMAT(ms_printf
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_KMT_CALLBACK_INFORMATION_CLASS
Definition: kmt_test.h:49
ULONG_PTR * PSIZE_T
Definition: typedefs.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
MEMORY_BASIC_INFORMATION MemInfo
Definition: kmt_test.h:57
KSTART_ROUTINE * PKSTART_ROUTINE
Definition: ketypes.h:487
DWORD KmtFltDeleteService(_In_opt_z_ PCWSTR ServiceName, _Inout_ SC_HANDLE *ServiceHandle)
Definition: fltsupport.c:97
long LONG
Definition: pedump.c:60
_In_ ULONG BufferLength
Definition: usbdlib.h:225
#define MEM_RESERVE
Definition: nt_native.h:1314
#define PAGE_NOACCESS
Definition: nt_native.h:1302
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
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
VOID KmtSetIrql(IN KIRQL NewIrql)
#define _Out_
Definition: no_sal2.h:323
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
BOOLEAN KmtIsMultiProcessorBuild
DWORD KmtSendBufferToDriver(IN DWORD ControlCode, IN OUT PVOID Buffer OPTIONAL, IN DWORD InLength, IN OUT PDWORD OutLength)
Definition: support.c:325
char * va_list
Definition: acmsvcex.h:78
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
Definition: bufpool.h:45
BOOLEAN BOOLEAN VOID VOID BOOLEAN KmtVSkip(INT Condition, PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf
void * PVOID
Definition: retypes.h:9
IN ULONG IN UCHAR Condition
struct _KMT_CALLBACK_REQUEST_PACKET * PKMT_CALLBACK_REQUEST_PACKET
EH_STD::__list__< TestClass, eh_allocator(TestClass) > TestList
Definition: test_list.cpp:31
NTSTATUS KmtRegisterIrpHandler(IN UCHAR MajorFunction, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_IRP_HANDLER IrpHandler)
const KMT_TEST CKMT_TEST
Definition: kmt_test.h:30
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_ PCUNICODE_STRING Altitude
Definition: fltkernel.h:1172
DWORD KmtFltSendUlongToDriver(_In_ HANDLE hPort, _In_ DWORD Message, _In_ DWORD Value)
Definition: fltsupport.c:353
#define _Out_opt_
Definition: no_sal2.h:339
enum _KMT_CALLBACK_INFORMATION_CLASS * PKMT_CALLBACK_INFORMATION_CLASS
VOID KmtCloseDriver(VOID)
Definition: support.c:200
LONG LogBufferMaxLength
Definition: kmt_test.h:40
DWORD KmtFltAddAltitude(_In_z_ LPWSTR Altitude)
Definition: fltsupport.c:448
DWORD KmtRunKernelTest(IN PCSTR TestName)
Definition: support.c:94
LPTSTR ServiceName
Definition: ServiceMain.c:15
NTSTATUS KmtRegisterMessageHandler(IN ULONG ControlCode OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PKMT_MESSAGE_HANDLER MessageHandler)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback
Definition: fltkernel.h:1873
NTSTATUS KmtFilterRegisterComms(_In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback, _In_ PFLT_DISCONNECT_NOTIFY DisconnectNotifyCallback, _In_opt_ PFLT_MESSAGE_NOTIFY MessageNotifyCallback, _In_ LONG MaxClientConnections)
#define KMT_FORMAT(type, fmt, first)
Definition: kmt_test.h:208
#define BufferSize
Definition: classpnp.h:419
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
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
DWORD KmtFltDisconnectComms(_In_ HANDLE hPort)
Definition: fltsupport.c:224
PVOID KmtGetSystemRoutineAddress(IN PCWSTR RoutineName)
#define _Inout_
Definition: no_sal2.h:244
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID TestFilterUnload(IN ULONG Flags)
Definition: fltmgr_create.c:79
Definition: ncftp.h:89
union _KMT_RESPONSE * PKMT_RESPONSE
CHAR Message[80]
Definition: alive.c:5
DWORD KmtFltSendWStringToDriver(_In_ HANDLE hPort, _In_ DWORD Message, _In_ PCWSTR String)
Definition: fltsupport.c:330
unsigned char UCHAR
Definition: xmlstorage.h:181
KMT_TESTFUNC * TestFunction
Definition: kmt_test.h:27
USHORT KmtGetPoolType(PVOID Memory)
DWORD KmtSendWStringToDriver(IN DWORD ControlCode, IN PCWSTR String)
Definition: support.c:273
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
#define NTSTATUS
Definition: precomp.h:20
VOID TestQueryTeardown(_In_ PCFLT_RELATED_OBJECTS FltObjects, _In_ FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags)
Definition: fltmgr_create.c:92
const char * TestName
Definition: kmt_test.h:26
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOLEAN BOOLEAN VOID KmtVTrace(PCSTR FileAndLine, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf
#define PAGE_SIZE
Definition: env_spec_w32.h:49
DWORD KmtFltSendToDriver(_In_ HANDLE hPort, _In_ DWORD Message)
Definition: fltsupport.c:281
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
volatile LONG Failures
Definition: kmt_test.h:37
_Must_inspect_result_ _Outptr_ PFLT_PORT _In_ POBJECT_ATTRIBUTES _In_opt_ PVOID _In_ PFLT_CONNECT_NOTIFY ConnectNotifyCallback
Definition: fltkernel.h:1873
#define _In_reads_bytes_(size)
Definition: no_sal2.h:229
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
volatile LONG Skipped
Definition: kmt_test.h:38
Status
Definition: gdiplustypes.h:24
PKMT_RESPONSE KmtUserModeCallback(KMT_CALLBACK_INFORMATION_CLASS Operation, PVOID Parameters)
BOOLEAN KmtAreInterruptsEnabled(VOID)
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
#define _In_
Definition: no_sal2.h:204
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG_PTR SIZE_T
Definition: typedefs.h:78
DWORD KmtSendToDriver(IN DWORD ControlCode)
Definition: support.c:224
enum _KMT_CALLBACK_INFORMATION_CLASS KMT_CALLBACK_INFORMATION_CLASS
VOID KmtUnloadDriver(VOID)
Definition: support.c:155
#define InterlockedIncrement
Definition: armddk.h:53
VOID TestUnload(IN PDRIVER_OBJECT DriverObject)
Definition: Example_drv.c:93
ULONG FLT_INSTANCE_SETUP_FLAGS
Definition: fltkernel.h:527
unsigned short USHORT
Definition: pedump.c:61
#define _In_z_
Definition: no_sal2.h:239
ULONG KmtGetPoolTag(PVOID Memory)
signed char * PSTR
Definition: retypes.h:7
#define DEVICE_TYPE
Definition: guid.c:10
DWORD KmtFltLoadDriver(_In_ BOOLEAN EnableDriverLoadPrivlege, _In_ BOOLEAN RestartIfRunning, _In_ BOOLEAN ConnectComms, _Out_ HANDLE *hPort)
Definition: fltsupport.c:112
#define OPTIONAL
Definition: typedefs.h:40
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define min(a, b)
Definition: monoChain.cc:55
volatile LONG Successes
Definition: kmt_test.h:36
DWORD KmtFltConnectComms(_Out_ HANDLE *hPort)
Definition: fltsupport.c:207
volatile LONG LogBufferLength
Definition: kmt_test.h:39
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1704
VOID(FLTAPI * PFLT_DISCONNECT_NOTIFY)(_In_opt_ PVOID ConnectionCookie)
Definition: fltkernel.h:856
DWORD * PDWORD
Definition: pedump.c:68
struct KMT_TEST * PKMT_TEST
union _KMT_RESPONSE KMT_RESPONSE
const KMT_TEST * PCKMT_TEST
Definition: kmt_test.h:30
#define KmtVSNPrintF
Definition: kmt_test_user.h:35
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
#define MEM_RELEASE
Definition: nt_native.h:1316
#define OUT
Definition: typedefs.h:39
uint32_t * LPDWORD
Definition: typedefs.h:57
unsigned int ULONG
Definition: retypes.h:1
VOID KmtFreeGuarded(PVOID Pointer)
VOID KMT_TESTFUNC(VOID)
Definition: kmt_test.h:21
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
struct _KMT_CALLBACK_REQUEST_PACKET KMT_CALLBACK_REQUEST_PACKET
const char * PCSTR
Definition: typedefs.h:51
KMT_TESTFUNC * PKMT_TESTFUNC
Definition: kmt_test.h:22
_In_ ULONG SectorSize
Definition: halfuncs.h:291
VOID KmtLoadDriver(IN PCWSTR ServiceName, IN BOOLEAN RestartIfRunning)
Definition: support.c:127
WCHAR * LPWSTR
Definition: xmlstorage.h:184
BOOLEAN BOOLEAN VOID VOID KmtTrace(PCSTR FileAndLine, PCSTR Format,...) KMT_FORMAT(ms_printf
VOID KmtOpenDriver(VOID)
Definition: support.c:174
return STATUS_SUCCESS
Definition: btrfs.c:2938
PKMT_RESULTBUFFER ResultBuffer
_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:1873
DWORD KmtSendUlongToDriver(IN DWORD ControlCode, IN DWORD Value)
Definition: support.c:298
#define CONST
Definition: pedump.c:81
DWORD KmtFltSendStringToDriver(_In_ HANDLE hPort, _In_ DWORD Message, _In_ PCSTR String)
Definition: fltsupport.c:305
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
#define PAGE_READWRITE
Definition: nt_native.h:1304
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)
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68