ReactOS  0.4.13-dev-39-g8b6696f
NpfsHelpers.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS kernel-mode tests
3  * LICENSE: LGPLv2+ - See COPYING.LIB in the top level directory
4  * PURPOSE: Kernel-Mode Test Suite Helper functions for NPFS tests
5  * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6  */
7 
8 #include <kmt_test.h>
9 #include "npfs.h"
10 
13  OUT PHANDLE ServerHandle,
14  IN PCWSTR PipePath,
15  IN ULONG ReadMode,
16  IN ULONG CompletionMode,
17  IN ULONG NamedPipeType,
19  IN ULONG MaximumInstances,
20  IN ULONG InboundQuota,
21  IN ULONG OutboundQuota,
25  IN PLARGE_INTEGER DefaultTimeout OPTIONAL)
26 {
32 
33  RtlInitUnicodeString(&ObjectName, PipePath);
35  &ObjectName,
37  NULL,
38  NULL);
39 
40  Params.NamedPipeType = NamedPipeType;
41  Params.ReadMode = ReadMode;
42  Params.CompletionMode = CompletionMode;
43  Params.MaximumInstances = MaximumInstances;
44  Params.InboundQuota = InboundQuota;
45  Params.OutboundQuota = OutboundQuota;
46  if (DefaultTimeout)
47  {
48  Params.DefaultTimeout.QuadPart = DefaultTimeout->QuadPart;
49  Params.TimeoutSpecified = TRUE;
50  }
51  else
52  {
53  Params.DefaultTimeout.QuadPart = 0;
54  Params.TimeoutSpecified = FALSE;
55  }
56 
57  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
58  Status = IoCreateFile(ServerHandle,
62  NULL, /* AllocationSize */
63  0, /* FileAttributes */
67  NULL, /* EaBuffer */
68  0, /* EaLength */
70  &Params,
71  0);
72  if (NT_SUCCESS(Status))
73  {
76  }
77  else
78  {
79  ok_eq_hex(IoStatusBlock.Status, 0x55555555UL);
80  ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL);
81  }
82  return Status;
83 }
84 
87  OUT PHANDLE ServerHandle,
88  PCWSTR PipePath,
89  ULONG ReadMode,
90  ULONG CompletionMode,
91  ULONG NamedPipeType,
92  ULONG NamedPipeConfiguration,
93  ULONG MaximumInstances,
94  ULONG InboundQuota,
95  ULONG OutboundQuota)
96 {
98  LARGE_INTEGER DefaultTimeout;
99 
100  if (NamedPipeConfiguration == FILE_PIPE_INBOUND)
102  else if (NamedPipeConfiguration == FILE_PIPE_OUTBOUND)
104  else if (NamedPipeConfiguration == FILE_PIPE_FULL_DUPLEX)
106  else
107  {
108  ASSERTMSG("Invalid NamedPipeConfiguration parameter value!\n", FALSE);
110  }
111 
112  DefaultTimeout.QuadPart = -50 * 1000 * 10;
113 
114  return NpCreatePipeEx(ServerHandle,
115  PipePath,
116  ReadMode,
117  CompletionMode,
118  NamedPipeType,
119  ShareAccess,
120  MaximumInstances,
121  InboundQuota,
122  OutboundQuota,
124  FILE_OPEN_IF,
126  &DefaultTimeout);
127 }
128 
129 NTSTATUS
131  OUT PHANDLE ClientHandle,
132  IN PCWSTR PipePath,
137 {
142 
143  RtlInitUnicodeString(&ObjectName, PipePath);
145  &ObjectName,
147  NULL,
148  NULL);
149 
150  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
151  Status = IoCreateFile(ClientHandle,
154  &IoStatusBlock,
155  NULL, /* AllocationSize */
156  0, /* FileAttributes */
157  ShareAccess,
158  Disposition,
160  NULL, /* EaBuffer */
161  0, /* EaLength */
163  NULL,
164  0);
165  if (NT_SUCCESS(Status))
166  {
167  ok(Status != STATUS_PENDING, "IoCreateFile returned pending\n");
170  }
171  else
172  {
173  ok_eq_hex(IoStatusBlock.Status, 0x55555555UL);
174  ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL);
175  }
176  return Status;
177 }
178 
179 NTSTATUS
181  OUT PHANDLE ClientHandle,
182  IN PCWSTR PipePath,
183  IN ULONG NamedPipeConfiguration)
184 {
186 
187  if (NamedPipeConfiguration == FILE_PIPE_INBOUND)
189  else if (NamedPipeConfiguration == FILE_PIPE_OUTBOUND)
191  else if (NamedPipeConfiguration == FILE_PIPE_FULL_DUPLEX)
193  else
194  {
195  ASSERTMSG("Invalid NamedPipeConfiguration parameter value!\n", FALSE);
197  }
198 
199  return NpOpenPipeEx(ClientHandle,
200  PipePath,
202  ShareAccess,
203  FILE_OPEN,
205 }
206 
207 NTSTATUS
209  IN HANDLE ServerHandle,
213 {
216 
217  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
218  Status = ZwFsControlFile(ServerHandle,
219  NULL,
220  NULL,
221  NULL,
222  &IoStatusBlock,
224  InputBuffer,
226  NULL,
227  0);
228  if (Status == STATUS_PENDING)
229  {
230  Status = ZwWaitForSingleObject(ServerHandle,
231  FALSE,
232  NULL);
235  }
236  if (NT_SUCCESS(Status))
237  {
240  }
241  else
242  {
243  ok_eq_hex(IoStatusBlock.Status, 0x55555555UL);
244  ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL);
245  }
246  return Status;
247 }
248 
249 NTSTATUS
251  IN PCWSTR PipeName,
253 {
255  HANDLE RootHandle;
259  PFILE_PIPE_WAIT_FOR_BUFFER WaitForBuffer;
260  ULONG NameLength;
262 
264  &RootDirectoryName,
266  NULL,
267  NULL);
268 
269  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
270  Status = IoCreateFile(&RootHandle,
273  &IoStatusBlock,
274  NULL,
275  0,
277  FILE_OPEN,
279  NULL,
280  0,
282  NULL,
283  0);
284  if (!NT_SUCCESS(Status))
285  {
286  ok_eq_hex(IoStatusBlock.Status, 0x55555555UL);
287  ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL);
288  return Status;
289  }
290  ok(Status != STATUS_PENDING, "IoCreateFile returned pending\n");
293 
294  NameLength = wcslen(PipeName) * sizeof(WCHAR);
296  Name[NameLength / sizeof(WCHAR)]);
297  WaitForBuffer = ExAllocatePoolWithTag(NonPagedPool, BufferSize, 'WPmK');
298  if (WaitForBuffer == NULL)
300 
301  if (Timeout)
302  {
303  WaitForBuffer->Timeout.QuadPart = Timeout->QuadPart;
304  WaitForBuffer->TimeoutSpecified = TRUE;
305  }
306  else
307  {
308  WaitForBuffer->Timeout.QuadPart = 0;
309  WaitForBuffer->TimeoutSpecified = FALSE;
310  }
311  WaitForBuffer->NameLength = NameLength;
312  RtlCopyMemory(WaitForBuffer->Name, PipeName, NameLength);
313  Status = NpControlPipe(RootHandle,
315  WaitForBuffer,
316  BufferSize);
317  ExFreePoolWithTag(WaitForBuffer, 'WPmK');
318  return Status;
319 }
320 
321 NTSTATUS
324  OUT PVOID Buffer,
327 {
330  BOOLEAN PendingReturned = FALSE;
331 
332  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
333  Status = ZwReadFile(PipeHandle,
334  NULL,
335  NULL,
336  NULL,
337  &IoStatusBlock,
338  Buffer,
339  BufferSize,
340  NULL,
341  NULL);
342  if (Status == STATUS_PENDING)
343  {
344  Status = ZwWaitForSingleObject(PipeHandle,
345  FALSE,
346  NULL);
349  PendingReturned = TRUE;
350  }
351  if (NT_SUCCESS(Status))
352  {
355  }
356  else
357  {
358  if (PendingReturned)
359  {
362  }
363  else
364  {
365  ok_eq_hex(IoStatusBlock.Status, 0x55555555UL);
366  ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL);
367  }
368  *BytesRead = 0;
369  }
370  return Status;
371 }
372 
373 NTSTATUS
376  IN const VOID *Buffer,
379 {
382 
383  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
384  Status = ZwWriteFile(PipeHandle,
385  NULL,
386  NULL,
387  NULL,
388  &IoStatusBlock,
389  (PVOID)Buffer,
390  BufferSize,
391  NULL,
392  NULL);
393  if (Status == STATUS_PENDING)
394  {
395  Status = ZwWaitForSingleObject(PipeHandle,
396  FALSE,
397  NULL);
400  }
401  if (NT_SUCCESS(Status))
402  {
405  }
406  else
407  {
408  ok_eq_hex(IoStatusBlock.Status, 0x55555555UL);
409  ok_eq_ulongptr(IoStatusBlock.Information, 0x5555555555555555ULL);
410  *BytesWritten = 0;
411  }
412  return Status;
413 }
414 
415 static
416 BOOLEAN
418  PVOID Buffer,
419  SIZE_T Size,
420  UCHAR Value)
421 {
422  PUCHAR Array = Buffer;
423  SIZE_T i;
424 
425  for (i = 0; i < Size; i++)
426  if (Array[i] != Value)
427  {
428  trace("Expected %x, found %x at offset %lu\n", Value, Array[i], (ULONG)i);
429  return FALSE;
430  }
431  return TRUE;
432 }
433 
434 #define ok_eq_print_(value, expected, spec, FileAndLine) \
435  KmtOk((value) == (expected), FileAndLine, #value " = " spec ", expected " spec "\n", value, expected)
436 #define ok_eq_ulong_(value, expected) ok_eq_print_(value, expected, "%lu", FileAndLine)
437 #define ok_eq_ulonglong_(value, expected) ok_eq_print_(value, expected, "%I64u", FileAndLine)
438 #ifndef _WIN64
439 #define ok_eq_ulongptr_(value, expected) ok_eq_print_(value, (ULONG_PTR)(expected), "%lu", FileAndLine)
440 #elif defined _WIN64
441 #define ok_eq_ulongptr_(value, expected) ok_eq_print_(value, (ULONG_PTR)(expected), "%I64u", FileAndLine)
442 #endif
443 #define ok_eq_hex_(value, expected) ok_eq_print_(value, expected, "0x%08lx", FileAndLine)
444 
445 VOID
447  IN HANDLE ServerHandle,
448  /* PipeInformation */
449  IN ULONG ReadMode,
450  IN ULONG CompletionMode,
451  /* PipeLocalInformation */
452  IN ULONG NamedPipeType,
453  IN ULONG NamedPipeConfiguration,
454  IN ULONG MaximumInstances,
455  IN ULONG CurrentInstances,
456  IN ULONG InboundQuota,
457  IN ULONG ReadDataAvailable,
458  IN ULONG OutboundQuota,
459  IN ULONG WriteQuotaAvailable,
460  IN ULONG NamedPipeState,
461  /* PipeRemoteInformation */
462  /* */
463  IN PCSTR FileAndLine)
464 {
468  FILE_PIPE_LOCAL_INFORMATION PipeLocalInfo;
469  FILE_PIPE_REMOTE_INFORMATION PipeRemoteInfo;
470 
471  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
472  RtlFillMemory(&PipeInfo, sizeof(PipeInfo), 0x55);
473  Status = ZwQueryInformationFile(ServerHandle,
474  &IoStatusBlock,
475  &PipeInfo,
476  sizeof(PipeInfo),
481  ok_eq_ulong_(PipeInfo.ReadMode, ReadMode);
482  ok_eq_ulong_(PipeInfo.CompletionMode, CompletionMode);
483 
484  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
485  RtlFillMemory(&PipeLocalInfo, sizeof(PipeLocalInfo), 0x55);
486  Status = ZwQueryInformationFile(ServerHandle,
487  &IoStatusBlock,
488  &PipeLocalInfo,
489  sizeof(PipeLocalInfo),
493  ok_eq_ulongptr_(IoStatusBlock.Information, sizeof(PipeLocalInfo));
494  ok_eq_ulong_(PipeLocalInfo.NamedPipeType, NamedPipeType);
495  ok_eq_ulong_(PipeLocalInfo.NamedPipeConfiguration, NamedPipeConfiguration);
496  ok_eq_ulong_(PipeLocalInfo.MaximumInstances, MaximumInstances);
497  ok_eq_ulong_(PipeLocalInfo.CurrentInstances, CurrentInstances);
498  ok_eq_ulong_(PipeLocalInfo.InboundQuota, InboundQuota);
499  ok_eq_ulong_(PipeLocalInfo.ReadDataAvailable, ReadDataAvailable);
500  ok_eq_ulong_(PipeLocalInfo.OutboundQuota, OutboundQuota);
501  ok_eq_ulong_(PipeLocalInfo.WriteQuotaAvailable, WriteQuotaAvailable);
502  ok_eq_ulong_(PipeLocalInfo.NamedPipeState, NamedPipeState);
504 
505  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
506  RtlFillMemory(&PipeRemoteInfo, sizeof(PipeRemoteInfo), 0x55);
507  Status = ZwQueryInformationFile(ServerHandle,
508  &IoStatusBlock,
509  &PipeRemoteInfo,
510  sizeof(PipeRemoteInfo),
515  ok_eq_ulonglong_(PipeRemoteInfo.CollectDataTime.QuadPart, 0ULL);
516  ok_eq_ulong_(PipeRemoteInfo.MaximumCollectionCount, 0x55555555UL);
517 }
518 
519 VOID
521  IN HANDLE ClientHandle,
522  /* PipeInformation */
523  IN ULONG ReadMode,
524  IN ULONG CompletionMode,
525  /* PipeLocalInformation */
526  IN ULONG NamedPipeType,
527  IN ULONG NamedPipeConfiguration,
528  IN ULONG MaximumInstances,
529  IN ULONG CurrentInstances,
530  IN ULONG InboundQuota,
531  IN ULONG ReadDataAvailable,
532  IN ULONG OutboundQuota,
533  IN ULONG WriteQuotaAvailable,
534  IN ULONG NamedPipeState,
535  /* PipeRemoteInformation */
536  /* */
537  IN PCSTR FileAndLine)
538 {
542  FILE_PIPE_LOCAL_INFORMATION PipeLocalInfo;
543  FILE_PIPE_REMOTE_INFORMATION PipeRemoteInfo;
544 
545  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
546  RtlFillMemory(&PipeInfo, sizeof(PipeInfo), 0x55);
547  Status = ZwQueryInformationFile(ClientHandle,
548  &IoStatusBlock,
549  &PipeInfo,
550  sizeof(PipeInfo),
555  ok_eq_ulong_(PipeInfo.ReadMode, ReadMode);
556  ok_eq_ulong_(PipeInfo.CompletionMode, CompletionMode);
557 
558  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
559  RtlFillMemory(&PipeLocalInfo, sizeof(PipeLocalInfo), 0x55);
560  Status = ZwQueryInformationFile(ClientHandle,
561  &IoStatusBlock,
562  &PipeLocalInfo,
563  sizeof(PipeLocalInfo),
567  ok_eq_ulongptr_(IoStatusBlock.Information, sizeof(PipeLocalInfo));
568  ok_eq_ulong_(PipeLocalInfo.NamedPipeType, NamedPipeType);
569  ok_eq_ulong_(PipeLocalInfo.NamedPipeConfiguration, NamedPipeConfiguration);
570  ok_eq_ulong_(PipeLocalInfo.MaximumInstances, MaximumInstances);
571  ok_eq_ulong_(PipeLocalInfo.CurrentInstances, CurrentInstances);
572  ok_eq_ulong_(PipeLocalInfo.InboundQuota, InboundQuota);
573  ok_eq_ulong_(PipeLocalInfo.ReadDataAvailable, ReadDataAvailable);
574  ok_eq_ulong_(PipeLocalInfo.OutboundQuota, OutboundQuota);
575  ok_eq_ulong_(PipeLocalInfo.WriteQuotaAvailable, WriteQuotaAvailable);
576  ok_eq_ulong_(PipeLocalInfo.NamedPipeState, NamedPipeState);
578 
579  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
580  RtlFillMemory(&PipeRemoteInfo, sizeof(PipeRemoteInfo), 0x55);
581  Status = ZwQueryInformationFile(ClientHandle,
582  &IoStatusBlock,
583  &PipeRemoteInfo,
584  sizeof(PipeRemoteInfo),
589  ok_eq_ulonglong_(PipeRemoteInfo.CollectDataTime.QuadPart, 0ULL);
590  ok_eq_ulong_(PipeRemoteInfo.MaximumCollectionCount, 0x55555555UL);
591 }
592 
593 VOID
596  IN NTSTATUS ExpectedStatus,
597  IN PCSTR FileAndLine)
598 {
602  FILE_PIPE_LOCAL_INFORMATION PipeLocalInfo;
603  FILE_PIPE_REMOTE_INFORMATION PipeRemoteInfo;
604 
605  ASSERT(!NT_SUCCESS(ExpectedStatus));
606 
607  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
608  RtlFillMemory(&PipeInfo, sizeof(PipeInfo), 0x55);
609  Status = ZwQueryInformationFile(PipeHandle,
610  &IoStatusBlock,
611  &PipeInfo,
612  sizeof(PipeInfo),
614  ok_eq_hex_(Status, ExpectedStatus);
615  ok_bool_true(CheckBuffer(&IoStatusBlock, sizeof(IoStatusBlock), 0x55), "CheckBuffer returned");
616  ok_bool_true(CheckBuffer(&PipeInfo, sizeof(PipeInfo), 0x55), "CheckBuffer returned");
617 
618  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
619  RtlFillMemory(&PipeLocalInfo, sizeof(PipeLocalInfo), 0x55);
620  Status = ZwQueryInformationFile(PipeHandle,
621  &IoStatusBlock,
622  &PipeLocalInfo,
623  sizeof(PipeLocalInfo),
625  ok_eq_hex_(Status, ExpectedStatus);
626  ok_bool_true(CheckBuffer(&IoStatusBlock, sizeof(IoStatusBlock), 0x55), "CheckBuffer returned");
627  ok_bool_true(CheckBuffer(&PipeLocalInfo, sizeof(PipeLocalInfo), 0x55), "CheckBuffer returned");
628 
629  RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55);
630  RtlFillMemory(&PipeRemoteInfo, sizeof(PipeRemoteInfo), 0x55);
631  Status = ZwQueryInformationFile(PipeHandle,
632  &IoStatusBlock,
633  &PipeRemoteInfo,
634  sizeof(PipeRemoteInfo),
636  ok_eq_hex_(Status, ExpectedStatus);
637  ok_bool_true(CheckBuffer(&IoStatusBlock, sizeof(IoStatusBlock), 0x55), "CheckBuffer returned");
638  ok_bool_true(CheckBuffer(&PipeRemoteInfo, sizeof(PipeRemoteInfo), 0x55), "CheckBuffer returned");
639 }
640 
641 static KSTART_ROUTINE PipeWorkerThread;
642 static
643 VOID
644 NTAPI
646  IN PVOID ThreadContext)
647 {
648  PTHREAD_CONTEXT Context = ThreadContext;
649  PVOID WaitEvents[2] = { &Context->ThreadDoneEvent,
650  &Context->StartWorkEvent };
652 
653  while (TRUE)
654  {
656  WaitEvents,
657  WaitAny,
658  Executive,
659  KernelMode,
660  FALSE,
661  NULL,
662  NULL);
663  if (Status == STATUS_WAIT_0)
664  break;
666 
667  Context->Work(Context);
668 
669  KeSetEvent(&Context->WorkCompleteEvent, IO_NO_INCREMENT, TRUE);
670  }
671 }
672 
673 VOID
676 {
677  KeInitializeEvent(&Context->ThreadDoneEvent, NotificationEvent, FALSE);
679  KeInitializeEvent(&Context->WorkCompleteEvent, NotificationEvent, TRUE);
680 
682 }
683 
684 VOID
687 {
688  KmtFinishThread(Context->Thread, &Context->ThreadDoneEvent);
689 }
690 
691 BOOLEAN
694  IN ULONG MilliSeconds)
695 {
698 
699  Timeout.QuadPart = -10 * 1000 * (LONGLONG)MilliSeconds;
700  Status = KeWaitForSingleObject(&Context->WorkCompleteEvent,
701  Executive,
702  KernelMode,
703  FALSE,
704  &Timeout);
705  ok(Status == STATUS_SUCCESS || Status == STATUS_TIMEOUT, "Wait status %lx\n", Status);
706  return Status != STATUS_TIMEOUT;
707 }
708 
709 BOOLEAN
712  IN ULONG MilliSeconds)
713 {
715 
716  Status = KeWaitForSingleObject(&Context->WorkCompleteEvent,
717  Executive,
718  KernelMode,
719  FALSE,
720  NULL);
722  KeClearEvent(&Context->WorkCompleteEvent);
723  KeSetEvent(&Context->StartWorkEvent, IO_NO_INCREMENT, TRUE);
724  return WaitForWork(Context, MilliSeconds);
725 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
NTSTATUS NpWaitPipe(IN PCWSTR PipeName, IN PLARGE_INTEGER Timeout)
Definition: NpfsHelpers.c:250
LARGE_INTEGER Timeout
Definition: winioctl.h:457
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define trace(...)
Definition: kmt_test.h:217
#define IN
Definition: typedefs.h:38
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define FILE_OPEN_IF
Definition: from_kernel.h:56
BOOLEAN TriggerWork(IN PTHREAD_CONTEXT Context, IN ULONG MilliSeconds)
Definition: NpfsHelpers.c:710
NTSTATUS NpCreatePipeEx(OUT PHANDLE ServerHandle, IN PCWSTR PipePath, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG NamedPipeType, IN ULONG ShareAccess, IN ULONG MaximumInstances, IN ULONG InboundQuota, IN ULONG OutboundQuota, IN ACCESS_MASK DesiredAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PLARGE_INTEGER DefaultTimeout OPTIONAL)
Definition: NpfsHelpers.c:12
VOID NpCheckServerPipe_(IN HANDLE ServerHandle, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG NamedPipeType, IN ULONG NamedPipeConfiguration, IN ULONG MaximumInstances, IN ULONG CurrentInstances, IN ULONG InboundQuota, IN ULONG ReadDataAvailable, IN ULONG OutboundQuota, IN ULONG WriteQuotaAvailable, IN ULONG NamedPipeState, IN PCSTR FileAndLine)
Definition: NpfsHelpers.c:446
unsigned char * PUCHAR
Definition: retypes.h:3
NTSTATUS NpWritePipe(IN HANDLE PipeHandle, IN const VOID *Buffer, IN ULONG BufferSize, OUT PULONG_PTR BytesWritten)
Definition: NpfsHelpers.c:374
ULONG NamedPipeConfiguration
Definition: pipe.c:43
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_OPENED
Definition: nt_native.h:769
#define ok_eq_ulongptr(value, expected)
Definition: kmt_test.h:249
#define DEVICE_NAMED_PIPE
Definition: npfs.h:11
#define FILE_PIPE_CLIENT_END
Definition: iotypes.h:84
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:62
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
LARGE_INTEGER CollectDataTime
Definition: iotypes.h:5559
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
Definition: create.c:4157
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
CHAR InputBuffer[80]
Definition: conmgr.c:33
#define FILE_SHARE_READ
Definition: compat.h:125
VOID NpCheckClientPipe_(IN HANDLE ClientHandle, IN ULONG ReadMode, IN ULONG CompletionMode, IN ULONG NamedPipeType, IN ULONG NamedPipeConfiguration, IN ULONG MaximumInstances, IN ULONG CurrentInstances, IN ULONG InboundQuota, IN ULONG ReadDataAvailable, IN ULONG OutboundQuota, IN ULONG WriteQuotaAvailable, IN ULONG NamedPipeState, IN PCSTR FileAndLine)
Definition: NpfsHelpers.c:520
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_WAIT_1
Definition: ntstatus.h:71
#define ok_bool_true(value, desc)
Definition: kmt_test.h:256
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define STATUS_WAIT_0
Definition: ntstatus.h:223
#define ok_eq_ulong_(value, expected)
Definition: NpfsHelpers.c:436
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:463
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
VOID FinishWorkerThread(IN PTHREAD_CONTEXT Context)
Definition: NpfsHelpers.c:685
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define GENERIC_WRITE
Definition: nt_native.h:90
LARGE_INTEGER DefaultTimeout
Definition: iotypes.h:790
NTSYSAPI NTSTATUS NTAPI ZwFsControlFile(IN HANDLE DeviceHandle, IN HANDLE Event OPTIONAL, IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, IN PVOID ApcContext OPTIONAL, OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG IoControlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, OUT PVOID OutputBuffer, IN ULONG OutputBufferSize)
NTSTATUS NpOpenPipe(OUT PHANDLE ClientHandle, IN PCWSTR PipePath, IN ULONG NamedPipeConfiguration)
Definition: NpfsHelpers.c:180
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define ULL(a, b)
Definition: format_msg.c:27
static BOOLEAN CheckBuffer(PVOID Buffer, SIZE_T Size, UCHAR Value)
Definition: NpfsHelpers.c:417
#define ok(value,...)
Definition: CComObject.cpp:34
int64_t LONGLONG
Definition: typedefs.h:66
#define FSCTL_PIPE_WAIT
Definition: winioctl.h:199
_In_ PUSBD_PIPE_INFORMATION PipeInfo
Definition: hubbusif.h:294
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define BufferSize
Definition: classpnp.h:419
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG CreateOptions
Definition: fltkernel.h:1230
NTSTATUS NpOpenPipeEx(OUT PHANDLE ClientHandle, IN PCWSTR PipePath, IN ACCESS_MASK DesiredAccess, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions)
Definition: NpfsHelpers.c:130
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:679
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
Definition: wait.c:586
#define ok_eq_ulonglong_(value, expected)
Definition: NpfsHelpers.c:437
#define FILE_PIPE_SERVER_END
Definition: iotypes.h:85
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static KSTART_ROUTINE PipeWorkerThread
Definition: NpfsHelpers.c:641
unsigned char UCHAR
Definition: xmlstorage.h:181
NTSTATUS NpCreatePipe(OUT PHANDLE ServerHandle, PCWSTR PipePath, ULONG ReadMode, ULONG CompletionMode, ULONG NamedPipeType, ULONG NamedPipeConfiguration, ULONG MaximumInstances, ULONG InboundQuota, ULONG OutboundQuota)
Definition: NpfsHelpers.c:86
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define GENERIC_READ
Definition: compat.h:124
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define SYNCHRONIZE
Definition: nt_native.h:61
VOID NpQueryPipe_(IN HANDLE PipeHandle, IN NTSTATUS ExpectedStatus, IN PCSTR FileAndLine)
Definition: NpfsHelpers.c:594
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
VOID StartWorkerThread(OUT PTHREAD_CONTEXT Context)
Definition: NpfsHelpers.c:674
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
ULONG_PTR SIZE_T
Definition: typedefs.h:78
static ULONG Timeout
Definition: ping.c:61
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
NTSTATUS NpReadPipe(IN HANDLE PipeHandle, OUT PVOID Buffer, IN ULONG BufferSize, OUT PULONG_PTR BytesRead)
Definition: NpfsHelpers.c:322
#define FILE_PIPE_OUTBOUND
Definition: iotypes.h:82
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define STATUS_INVALID_PARAMETER_6
Definition: ntstatus.h:466
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
static HANDLE PipeHandle
Definition: dhcpcsvc.c:21
#define FILE_CREATED
Definition: nt_native.h:770
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG FsControlCode
Definition: fltkernel.h:1369
NTSTATUS NTAPI IoCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG Disposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength, IN CREATE_FILE_TYPE CreateFileType, IN PVOID ExtraCreateParameters OPTIONAL, IN ULONG Options)
Definition: file.c:3009
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define OUT
Definition: typedefs.h:39
#define ok_eq_ulongptr_(value, expected)
Definition: NpfsHelpers.c:439
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
BOOLEAN WaitForWork(IN PTHREAD_CONTEXT Context, IN ULONG MilliSeconds)
Definition: NpfsHelpers.c:692
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FILE_PIPE_INBOUND
Definition: iotypes.h:81
uint32_t * PULONG_PTR
Definition: typedefs.h:63
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define FILE_PIPE_FULL_DUPLEX
Definition: iotypes.h:83
const char * PCSTR
Definition: typedefs.h:51
#define ok_eq_hex(value, expected)
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
NTSTATUS NpControlPipe(IN HANDLE ServerHandle, IN ULONG FsControlCode, IN PVOID InputBuffer, IN ULONG InputBufferLength)
Definition: NpfsHelpers.c:208
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:593
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define ok_eq_hex_(value, expected)
Definition: NpfsHelpers.c:443
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
ULONG ACCESS_MASK
Definition: nt_native.h:40
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
LONGLONG QuadPart
Definition: typedefs.h:112
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68