ReactOS  0.4.14-dev-317-g96040ec
msfs.h File Reference
#include <ntifs.h>
Include dependency graph for msfs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _MSFS_DEVICE_EXTENSION
 
struct  _MSFS_FCB
 
struct  _MSFS_DPC_CTX
 
struct  _MSFS_CCB
 
struct  _MSFS_MESSAGE
 

Macros

#define DEFAULTAPI   NTAPI
 
#define KeLockMutex(x)
 
#define KeUnlockMutex(x)   KeReleaseMutex(x, FALSE);
 

Typedefs

typedef struct _MSFS_DEVICE_EXTENSION MSFS_DEVICE_EXTENSION
 
typedef struct _MSFS_DEVICE_EXTENSIONPMSFS_DEVICE_EXTENSION
 
typedef struct _MSFS_FCB MSFS_FCB
 
typedef struct _MSFS_FCBPMSFS_FCB
 
typedef struct _MSFS_DPC_CTX MSFS_DPC_CTX
 
typedef struct _MSFS_DPC_CTXPMSFS_DPC_CTX
 
typedef struct _MSFS_CCB MSFS_CCB
 
typedef struct _MSFS_CCBPMSFS_CCB
 
typedef struct _MSFS_MESSAGE MSFS_MESSAGE
 
typedef struct _MSFS_MESSAGEPMSFS_MESSAGE
 

Functions

NTSTATUS DEFAULTAPI MsfsCreate (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS DEFAULTAPI MsfsCreateMailslot (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS DEFAULTAPI MsfsClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS DEFAULTAPI MsfsQueryInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS DEFAULTAPI MsfsSetInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS DEFAULTAPI MsfsRead (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS DEFAULTAPI MsfsWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS DEFAULTAPI MsfsFileSystemControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 
VOID NTAPI MsfsInsertIrp (PIO_CSQ Csq, PIRP Irp)
 
VOID NTAPI MsfsRemoveIrp (PIO_CSQ Csq, PIRP Irp)
 
PIRP NTAPI MsfsPeekNextIrp (PIO_CSQ Csq, PIRP Irp, PVOID PeekContext)
 
VOID NTAPI MsfsAcquireLock (PIO_CSQ Csq, PKIRQL Irql)
 
VOID NTAPI MsfsReleaseLock (PIO_CSQ Csq, KIRQL Irql)
 
VOID NTAPI MsfsCompleteCanceledIrp (PIO_CSQ pCsq, PIRP Irp)
 
VOID NTAPI MsfsTimeout (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
 

Variables

DRIVER_DISPATCH MsfsCreate
 
DRIVER_DISPATCH MsfsCreateMailslot
 
DRIVER_DISPATCH MsfsClose
 
DRIVER_DISPATCH MsfsQueryInformation
 
DRIVER_DISPATCH MsfsSetInformation
 
DRIVER_DISPATCH MsfsRead
 
DRIVER_DISPATCH MsfsWrite
 
DRIVER_DISPATCH MsfsFileSystemControl
 
IO_CSQ_INSERT_IRP MsfsInsertIrp
 
IO_CSQ_REMOVE_IRP MsfsRemoveIrp
 
IO_CSQ_PEEK_NEXT_IRP MsfsPeekNextIrp
 
IO_CSQ_ACQUIRE_LOCK MsfsAcquireLock
 
IO_CSQ_RELEASE_LOCK MsfsReleaseLock
 
IO_CSQ_COMPLETE_CANCELED_IRP MsfsCompleteCanceledIrp
 
KDEFERRED_ROUTINE MsfsTimeout
 

Macro Definition Documentation

◆ DEFAULTAPI

#define DEFAULTAPI   NTAPI

Definition at line 15 of file msfs.h.

◆ KeLockMutex

#define KeLockMutex (   x)
Value:
FALSE, \
NULL);
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
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
smooth NULL
Definition: ftsmooth.c:416

Definition at line 69 of file msfs.h.

◆ KeUnlockMutex

#define KeUnlockMutex (   x)    KeReleaseMutex(x, FALSE);

Definition at line 75 of file msfs.h.

Typedef Documentation

◆ MSFS_CCB

◆ MSFS_DEVICE_EXTENSION

◆ MSFS_DPC_CTX

◆ MSFS_FCB

◆ MSFS_MESSAGE

◆ PMSFS_CCB

◆ PMSFS_DEVICE_EXTENSION

◆ PMSFS_DPC_CTX

◆ PMSFS_FCB

◆ PMSFS_MESSAGE

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 16 of file battc.c.

18 {
19  DPRINT("Battery class driver initialized\n");
20 
21  return STATUS_SUCCESS;
22 }
void DPRINT(...)
Definition: polytest.cpp:61
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ MsfsAcquireLock()

VOID NTAPI MsfsAcquireLock ( PIO_CSQ  Csq,
PKIRQL  Irql 
)

Definition at line 80 of file msfssup.c.

81 {
82  PMSFS_FCB Fcb;
83 
84  Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
85  KeAcquireSpinLock(&Fcb->QueueLock, Irql);
86 }
_Out_ PKIRQL Irql
Definition: csq.h:179
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
IO_CSQ Csq
Definition: csqrtns.c:46
Definition: msfs.h:24
_In_ PFCB Fcb
Definition: cdprocs.h:151

◆ MsfsClose()

NTSTATUS DEFAULTAPI MsfsClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 253 of file create.c.

255 {
256  PIO_STACK_LOCATION IoStack;
258  PMSFS_DEVICE_EXTENSION DeviceExtension;
259  PMSFS_FCB Fcb;
260  PMSFS_CCB Ccb;
262  KIRQL oldIrql;
263 
264  DPRINT("MsfsClose(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
265 
267  DeviceExtension = DeviceObject->DeviceExtension;
268  FileObject = IoStack->FileObject;
269 
270  KeLockMutex(&DeviceExtension->FcbListLock);
271 
272  if (DeviceExtension->FcbListHead.Flink == &DeviceExtension->FcbListHead)
273  {
274  KeUnlockMutex(&DeviceExtension->FcbListLock);
275 
276  Irp->IoStatus.Status = STATUS_SUCCESS;
277  Irp->IoStatus.Information = 0;
278 
280 
281  return STATUS_SUCCESS;
282  }
283 
284  Fcb = FileObject->FsContext;
285  Ccb = FileObject->FsContext2;
286 
287  DPRINT("Mailslot name: %wZ\n", &Fcb->Name);
288 
289  Fcb->ReferenceCount--;
290  if (Fcb->ServerCcb == Ccb)
291  {
292  /* delete all messages from message-list */
293  KeAcquireSpinLock(&Fcb->MessageListLock, &oldIrql);
294 
295  while (Fcb->MessageListHead.Flink != &Fcb->MessageListHead)
296  {
297  Message = CONTAINING_RECORD(Fcb->MessageListHead.Flink,
298  MSFS_MESSAGE,
299  MessageListEntry);
300  RemoveEntryList(Fcb->MessageListHead.Flink);
301  ExFreePoolWithTag(Message, 'rFsM');
302  }
303 
304  Fcb->MessageCount = 0;
305 
306  KeReleaseSpinLock(&Fcb->MessageListLock, oldIrql);
307  Fcb->ServerCcb = NULL;
308  }
309 
310  KeAcquireSpinLock(&Fcb->CcbListLock, &oldIrql);
311  RemoveEntryList(&Ccb->CcbListEntry);
312  KeReleaseSpinLock(&Fcb->CcbListLock, oldIrql);
313  ExFreePoolWithTag(Ccb, 'cFsM');
314  FileObject->FsContext2 = NULL;
315 
316  if (Fcb->ReferenceCount == 0)
317  {
318  DPRINT("ReferenceCount == 0: Deleting mailslot data\n");
320  ExFreePoolWithTag(Fcb->Name.Buffer, 'NFsM');
321  ExFreePoolWithTag(Fcb, 'fFsM');
322  }
323 
324  KeUnlockMutex(&DeviceExtension->FcbListLock);
325 
326  Irp->IoStatus.Status = STATUS_SUCCESS;
327  Irp->IoStatus.Information = 0;
328 
330 
331  return STATUS_SUCCESS;
332 }
#define KeLockMutex(x)
Definition: msfs.h:69
LIST_ENTRY FcbListEntry
Definition: ntfs.h:526
KMUTEX FcbListLock
Definition: msfs.h:20
_In_ PIRP Irp
Definition: csq.h:116
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT FileObject
Definition: create.c:4157
PVOID DeviceExtension
Definition: env_spec_w32.h:418
LIST_ENTRY FcbListHead
Definition: msfs.h:19
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
* PFILE_OBJECT
Definition: iotypes.h:1955
CHAR Message[80]
Definition: alive.c:5
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define KeUnlockMutex(x)
Definition: msfs.h:75
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
Definition: msfs.h:24
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2938
Definition: msfs.h:54

◆ MsfsCompleteCanceledIrp()

VOID NTAPI MsfsCompleteCanceledIrp ( PIO_CSQ  pCsq,
PIRP  Irp 
)

Definition at line 99 of file msfssup.c.

100 {
101 
103 
104  Irp->IoStatus.Status = STATUS_CANCELLED;
105  Irp->IoStatus.Information = 0;
107 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
IO_CSQ Csq
Definition: csqrtns.c:46
#define IO_NO_INCREMENT
Definition: iotypes.h:566

◆ MsfsCreate()

NTSTATUS DEFAULTAPI MsfsCreate ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 23 of file create.c.

25 {
26  PIO_STACK_LOCATION IoStack;
28  PMSFS_DEVICE_EXTENSION DeviceExtension;
29  PMSFS_FCB Fcb;
30  PMSFS_CCB Ccb;
32  PLIST_ENTRY current_entry;
33  KIRQL oldIrql;
34 
35  DPRINT("MsfsCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
36 
38  DeviceExtension = DeviceObject->DeviceExtension;
39  FileObject = IoStack->FileObject;
40 
41  DPRINT("Mailslot name: %wZ\n", &FileObject->FileName);
42 
43  Ccb = ExAllocatePoolWithTag(NonPagedPool, sizeof(MSFS_CCB), 'cFsM');
44  if (Ccb == NULL)
45  {
46  Irp->IoStatus.Status = STATUS_NO_MEMORY;
47  Irp->IoStatus.Information = 0;
48 
50  return STATUS_NO_MEMORY;
51  }
52 
53  KeLockMutex(&DeviceExtension->FcbListLock);
54  current_entry = DeviceExtension->FcbListHead.Flink;
55  while (current_entry != &DeviceExtension->FcbListHead)
56  {
57  current = CONTAINING_RECORD(current_entry,
58  MSFS_FCB,
59  FcbListEntry);
60 
62  break;
63 
64  current_entry = current_entry->Flink;
65  }
66 
67  if (current_entry == &DeviceExtension->FcbListHead)
68  {
69  ExFreePoolWithTag(Ccb, 'cFsM');
70  KeUnlockMutex(&DeviceExtension->FcbListLock);
71 
72  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
73  Irp->IoStatus.Information = 0;
74 
76 
77  return STATUS_UNSUCCESSFUL;
78  }
79 
80  Fcb = current;
81 
82  KeAcquireSpinLock(&Fcb->CcbListLock, &oldIrql);
83  InsertTailList(&Fcb->CcbListHead, &Ccb->CcbListEntry);
84  KeReleaseSpinLock(&Fcb->CcbListLock, oldIrql);
85 
86  Fcb->ReferenceCount++;
87 
88  Ccb->Fcb = Fcb;
89 
90  KeUnlockMutex(&DeviceExtension->FcbListLock);
91 
92  FileObject->FsContext = Fcb;
93  FileObject->FsContext2 = Ccb;
95 
96  Irp->IoStatus.Status = STATUS_SUCCESS;
97  Irp->IoStatus.Information = 0;
98 
100 
101  return STATUS_SUCCESS;
102 }
#define KeLockMutex(x)
Definition: msfs.h:69
#define TRUE
Definition: types.h:120
struct _FCB::@710::@713 Fcb
KMUTEX FcbListLock
Definition: msfs.h:20
_In_ PIRP Irp
Definition: csq.h:116
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT FileObject
Definition: create.c:4157
PVOID DeviceExtension
Definition: env_spec_w32.h:418
LIST_ENTRY FcbListHead
Definition: msfs.h:19
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
* PFILE_OBJECT
Definition: iotypes.h:1955
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
PUNICODE_STRING FileName
Definition: iotypes.h:2793
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
Definition: typedefs.h:117
#define KeUnlockMutex(x)
Definition: msfs.h:75
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
Definition: msfs.h:24
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2938
Definition: msfs.h:54
#define FO_MAILSLOT
Definition: iotypes.h:1741
struct task_struct * current
Definition: linux.c:32

◆ MsfsCreateMailslot()

NTSTATUS DEFAULTAPI MsfsCreateMailslot ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 107 of file create.c.

109 {
110  PIO_STACK_LOCATION IoStack;
112  PMSFS_DEVICE_EXTENSION DeviceExtension;
113  PMSFS_FCB Fcb;
114  PMSFS_CCB Ccb;
115  KIRQL oldIrql;
116  PLIST_ENTRY current_entry;
119 
120  DPRINT("MsfsCreateMailslot(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
121 
123  DeviceExtension = DeviceObject->DeviceExtension;
124  FileObject = IoStack->FileObject;
125  Buffer = IoStack->Parameters.CreateMailslot.Parameters;
126 
127  DPRINT("Mailslot name: %wZ\n", &FileObject->FileName);
128 
129  Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(MSFS_FCB), 'fFsM');
130  if (Fcb == NULL)
131  {
132  Irp->IoStatus.Status = STATUS_NO_MEMORY;
133  Irp->IoStatus.Information = 0;
134 
136 
137  return STATUS_NO_MEMORY;
138  }
139 
140  Fcb->Name.Length = FileObject->FileName.Length;
141  Fcb->Name.MaximumLength = Fcb->Name.Length + sizeof(UNICODE_NULL);
142  Fcb->Name.Buffer = ExAllocatePoolWithTag(NonPagedPool,
143  Fcb->Name.MaximumLength,
144  'NFsM');
145  if (Fcb->Name.Buffer == NULL)
146  {
147  ExFreePoolWithTag(Fcb, 'fFsM');
148 
149  Irp->IoStatus.Status = STATUS_NO_MEMORY;
150  Irp->IoStatus.Information = 0;
151 
153 
154  return STATUS_NO_MEMORY;
155  }
156 
158 
159  Ccb = ExAllocatePoolWithTag(NonPagedPool, sizeof(MSFS_CCB), 'cFsM');
160  if (Ccb == NULL)
161  {
162  ExFreePoolWithTag(Fcb->Name.Buffer, 'NFsM');
163  ExFreePoolWithTag(Fcb, 'fFsM');
164 
165  Irp->IoStatus.Status = STATUS_NO_MEMORY;
166  Irp->IoStatus.Information = 0;
167 
169 
170  return STATUS_NO_MEMORY;
171  }
172 
173  Fcb->ReferenceCount = 0;
174  InitializeListHead(&Fcb->CcbListHead);
175  KeInitializeSpinLock(&Fcb->CcbListLock);
176 
177  Fcb->MaxMessageSize = Buffer->MaximumMessageSize;
178  Fcb->MessageCount = 0;
179  Fcb->TimeOut = Buffer->ReadTimeout;
180 
181  InitializeListHead(&Fcb->MessageListHead);
182  KeInitializeSpinLock(&Fcb->MessageListLock);
183 
184  KeInitializeSpinLock(&Fcb->QueueLock);
185  InitializeListHead(&Fcb->PendingIrpQueue);
186  IoCsqInitialize(&Fcb->CancelSafeQueue,
193 
194  KeLockMutex(&DeviceExtension->FcbListLock);
195  current_entry = DeviceExtension->FcbListHead.Flink;
196  while (current_entry != &DeviceExtension->FcbListHead)
197  {
198  current = CONTAINING_RECORD(current_entry,
199  MSFS_FCB,
200  FcbListEntry);
201 
202  if (!RtlCompareUnicodeString(&Fcb->Name, &current->Name, TRUE))
203  break;
204 
205  current_entry = current_entry->Flink;
206  }
207 
208  if (current_entry != &DeviceExtension->FcbListHead)
209  {
210  ExFreePoolWithTag(Fcb->Name.Buffer, 'NFsM');
211  ExFreePoolWithTag(Fcb, 'fFsM');
212  ExFreePoolWithTag(Ccb, 'cFsM');
213 
214  KeUnlockMutex(&DeviceExtension->FcbListLock);
215 
216  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
217  Irp->IoStatus.Information = 0;
218 
220 
221  return STATUS_UNSUCCESSFUL;
222  }
223  else
224  {
225  InsertTailList(&DeviceExtension->FcbListHead,
226  &Fcb->FcbListEntry);
227  }
228 
229  KeAcquireSpinLock(&Fcb->CcbListLock, &oldIrql);
230  InsertTailList(&Fcb->CcbListHead, &Ccb->CcbListEntry);
231  KeReleaseSpinLock(&Fcb->CcbListLock, oldIrql);
232 
233  Fcb->ReferenceCount++;
234  Fcb->ServerCcb = Ccb;
235  Ccb->Fcb = Fcb;
236 
237  KeUnlockMutex(&DeviceExtension->FcbListLock);
238 
239  FileObject->FsContext = Fcb;
240  FileObject->FsContext2 = Ccb;
242 
243  Irp->IoStatus.Status = STATUS_SUCCESS;
244  Irp->IoStatus.Information = 0;
245 
247 
248  return STATUS_SUCCESS;
249 }
#define KeLockMutex(x)
Definition: msfs.h:69
LIST_ENTRY FcbListEntry
Definition: ntfs.h:526
#define TRUE
Definition: types.h:120
IO_CSQ_ACQUIRE_LOCK MsfsAcquireLock
Definition: msfs.h:117
struct _FCB::@710::@713 Fcb
KMUTEX FcbListLock
Definition: msfs.h:20
_In_ PIRP Irp
Definition: csq.h:116
IO_CSQ_COMPLETE_CANCELED_IRP MsfsCompleteCanceledIrp
Definition: msfs.h:125
#define InsertTailList(ListHead, Entry)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define UNICODE_NULL
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT FileObject
Definition: create.c:4157
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
LIST_ENTRY FcbListHead
Definition: msfs.h:19
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
IO_CSQ_RELEASE_LOCK MsfsReleaseLock
Definition: msfs.h:121
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
* PFILE_OBJECT
Definition: iotypes.h:1955
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
PUNICODE_STRING FileName
Definition: iotypes.h:2793
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
Definition: typedefs.h:117
IO_CSQ_INSERT_IRP MsfsInsertIrp
Definition: msfs.h:105
#define KeUnlockMutex(x)
Definition: msfs.h:75
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
IO_CSQ_PEEK_NEXT_IRP MsfsPeekNextIrp
Definition: msfs.h:113
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
IO_CSQ_REMOVE_IRP MsfsRemoveIrp
Definition: msfs.h:109
#define IO_NO_INCREMENT
Definition: iotypes.h:566
NTKERNELAPI NTSTATUS NTAPI IoCsqInitialize(_Out_ PIO_CSQ Csq, _In_ PIO_CSQ_INSERT_IRP CsqInsertIrp, _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp, _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock, _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp)
Set up a CSQ struct to initialize the queue.
Definition: csq.c:103
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
Definition: msfs.h:24
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
Definition: msfs.h:54
#define FO_MAILSLOT
Definition: iotypes.h:1741
struct task_struct * current
Definition: linux.c:32

◆ MsfsFileSystemControl()

NTSTATUS DEFAULTAPI MsfsFileSystemControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 19 of file fsctrl.c.

21 {
22  PIO_STACK_LOCATION IoStack;
24  PMSFS_FCB Fcb;
26 
27  DPRINT1("MsfsFileSystemControl(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
28 
30  FileObject = IoStack->FileObject;
31  Fcb = FileObject->FsContext;
32 
33  DPRINT1("Mailslot name: %wZ\n", &Fcb->Name);
34 
35  switch (IoStack->Parameters.FileSystemControl.FsControlCode)
36  {
37  default:
39  }
40 
41  Irp->IoStatus.Status = Status;
42  Irp->IoStatus.Information = 0;
44 
45  return Status;
46 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define IoCompleteRequest
Definition: irp.c:1240
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
* PFILE_OBJECT
Definition: iotypes.h:1955
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:566
Definition: msfs.h:24
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151

◆ MsfsInsertIrp()

VOID NTAPI MsfsInsertIrp ( PIO_CSQ  Csq,
PIRP  Irp 
)

Definition at line 18 of file msfssup.c.

19 {
20  PMSFS_FCB Fcb;
21 
22  Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
23  InsertTailList(&Fcb->PendingIrpQueue, &Irp->Tail.Overlay.ListEntry);
24 }
_In_ PIRP Irp
Definition: csq.h:116
#define InsertTailList(ListHead, Entry)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
IO_CSQ Csq
Definition: csqrtns.c:46
Definition: msfs.h:24
_In_ PFCB Fcb
Definition: cdprocs.h:151

◆ MsfsPeekNextIrp()

PIRP NTAPI MsfsPeekNextIrp ( PIO_CSQ  Csq,
PIRP  Irp,
PVOID  PeekContext 
)

Definition at line 35 of file msfssup.c.

36 {
37  PMSFS_FCB Fcb;
38  PIRP NextIrp = NULL;
39  PLIST_ENTRY NextEntry, ListHead;
40  PIO_STACK_LOCATION Stack;
41 
42  Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
43 
44  ListHead = &Fcb->PendingIrpQueue;
45 
46  if (Irp == NULL)
47  {
48  NextEntry = ListHead->Flink;
49  }
50  else
51  {
52  NextEntry = Irp->Tail.Overlay.ListEntry.Flink;
53  }
54 
55  for (; NextEntry != ListHead; NextEntry = NextEntry->Flink)
56  {
57  NextIrp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
58 
59  Stack = IoGetCurrentIrpStackLocation(NextIrp);
60 
61  if (PeekContext)
62  {
63  if (Stack->FileObject == (PFILE_OBJECT)PeekContext)
64  {
65  break;
66  }
67  }
68  else
69  {
70  break;
71  }
72 
73  NextIrp = NULL;
74  }
75 
76  return NextIrp;
77 }
_In_ PIRP Irp
Definition: csq.h:116
IRP
Definition: iotypes.h:2463
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
* PFILE_OBJECT
Definition: iotypes.h:1955
Definition: typedefs.h:117
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
_In_opt_ PIRP _In_opt_ PVOID PeekContext
Definition: csq.h:159
IO_CSQ Csq
Definition: csqrtns.c:46
Definition: msfs.h:24
_In_ PFCB Fcb
Definition: cdprocs.h:151

◆ MsfsQueryInformation()

NTSTATUS DEFAULTAPI MsfsQueryInformation ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 72 of file finfo.c.

74 {
75  PIO_STACK_LOCATION IoStack;
78  PMSFS_FCB Fcb;
79  PMSFS_CCB Ccb;
80  PVOID SystemBuffer;
83 
84  DPRINT("MsfsQueryInformation(DeviceObject %p Irp %p)\n",
85  DeviceObject, Irp);
86 
88  FileInformationClass = IoStack->Parameters.QueryFile.FileInformationClass;
89  FileObject = IoStack->FileObject;
90  Fcb = (PMSFS_FCB)FileObject->FsContext;
91  Ccb = (PMSFS_CCB)FileObject->FsContext2;
92 
93  DPRINT("Mailslot name: %wZ\n", &Fcb->Name);
94 
95  /* querying information is not permitted on client side */
96  if (Fcb->ServerCcb != Ccb)
97  {
99 
100  Irp->IoStatus.Status = Status;
101  Irp->IoStatus.Information = 0;
102 
104 
105  return Status;
106  }
107 
108  SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
109  BufferLength = IoStack->Parameters.QueryFile.Length;
110 
111  switch (FileInformationClass)
112  {
115  SystemBuffer,
116  &BufferLength);
117  break;
118 
119  default:
121  }
122 
123  Irp->IoStatus.Status = Status;
124  if (NT_SUCCESS(Status))
125  Irp->IoStatus.Information =
126  IoStack->Parameters.QueryFile.Length - BufferLength;
127  else
128  Irp->IoStatus.Information = 0;
130 
131  return Status;
132 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
_In_ ULONG BufferLength
Definition: usbdlib.h:225
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
struct _MSFS_FCB * PMSFS_FCB
static NTSTATUS MsfsQueryMailslotInformation(PMSFS_FCB Fcb, PFILE_MAILSLOT_QUERY_INFORMATION Buffer, PULONG BufferLength)
Definition: finfo.c:24
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
* PFILE_OBJECT
Definition: iotypes.h:1955
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
Definition: msfs.h:24
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
Definition: msfs.h:54

◆ MsfsRead()

NTSTATUS DEFAULTAPI MsfsRead ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 20 of file rw.c.

22 {
23  PIO_STACK_LOCATION IoStack;
25  PMSFS_FCB Fcb;
26  PMSFS_CCB Ccb;
28  KIRQL oldIrql;
29  ULONG Length;
30  ULONG LengthRead = 0;
31  PVOID Buffer;
33  PKTIMER Timer;
35  PKDPC Dpc;
37 
38  DPRINT("MsfsRead(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
39 
41  FileObject = IoStack->FileObject;
42  Fcb = (PMSFS_FCB)FileObject->FsContext;
43  Ccb = (PMSFS_CCB)FileObject->FsContext2;
44 
45  DPRINT("MailslotName: %wZ\n", &Fcb->Name);
46 
47  /* reading is not permitted on client side */
48  if (Fcb->ServerCcb != Ccb)
49  {
50  Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
51  Irp->IoStatus.Information = 0;
52 
54 
55  return STATUS_ACCESS_DENIED;
56  }
57 
58  Length = IoStack->Parameters.Read.Length;
59  if (Irp->MdlAddress)
61  else
62  Buffer = Irp->UserBuffer;
63 
64 
65  KeAcquireSpinLock(&Fcb->MessageListLock, &oldIrql);
66  if (Fcb->MessageCount > 0)
67  {
68  Entry = RemoveHeadList(&Fcb->MessageListHead);
69  Fcb->MessageCount--;
70  KeReleaseSpinLock(&Fcb->MessageListLock, oldIrql);
71 
72  /* copy current message into buffer */
73  Message = CONTAINING_RECORD(Entry, MSFS_MESSAGE, MessageListEntry);
74  memcpy(Buffer, &Message->Buffer, min(Message->Size,Length));
75  LengthRead = Message->Size;
76 
77  ExFreePoolWithTag(Message, 'rFsM');
78 
79  Irp->IoStatus.Status = STATUS_SUCCESS;
80  Irp->IoStatus.Information = LengthRead;
82 
83  return STATUS_SUCCESS;
84  }
85  else
86  {
87  KeReleaseSpinLock(&Fcb->MessageListLock, oldIrql);
88  }
89 
90  Timeout = Fcb->TimeOut;
91  if (Timeout.HighPart == 0 && Timeout.LowPart == 0)
92  {
93  Irp->IoStatus.Status = STATUS_IO_TIMEOUT;
94  Irp->IoStatus.Information = 0;
96 
97  return STATUS_IO_TIMEOUT;
98  }
99 
101  if (Context == NULL)
102  {
103  Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
104  Irp->IoStatus.Information = 0;
106 
108  }
109 
111  IoCsqInsertIrp(&Fcb->CancelSafeQueue, Irp, &Context->CsqContext);
112  Timer = &Context->Timer;
113  Dpc = &Context->Dpc;
114  Context->Csq = &Fcb->CancelSafeQueue;
115  Irp->Tail.Overlay.DriverContext[0] = Context;
116 
117  /* No timer for INFINITY_WAIT */
118  if (Timeout.QuadPart != -1)
119  {
123  }
124 
126 
127  return STATUS_PENDING;
128 }
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _Entry Entry
Definition: kefuncs.h:640
_In_ PIRP Irp
Definition: csq.h:116
NTKERNELAPI VOID NTAPI IoCsqInsertIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIRP Irp, _Out_opt_ PIO_CSQ_IRP_CONTEXT Context)
Insert an IRP into the CSQ.
Definition: csq.c:177
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
struct _MSFS_FCB * PMSFS_FCB
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:524
#define STATUS_PENDING
Definition: ntstatus.h:82
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1955
CHAR Message[80]
Definition: alive.c:5
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: ketypes.h:687
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
Definition: typedefs.h:117
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
UINT Timer
Definition: capclock.c:11
static ULONG Timeout
Definition: ping.c:61
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define min(a, b)
Definition: monoChain.cc:55
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
KDEFERRED_ROUTINE MsfsTimeout
Definition: msfs.h:129
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
Definition: msfs.h:24
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
IoMarkIrpPending(Irp)
Definition: msfs.h:54
base of all file and directory entries
Definition: entries.h:82

Referenced by MsfsWrite().

◆ MsfsReleaseLock()

VOID NTAPI MsfsReleaseLock ( PIO_CSQ  Csq,
KIRQL  Irql 
)

Definition at line 90 of file msfssup.c.

91 {
92  PMSFS_FCB Fcb;
93 
94  Fcb = CONTAINING_RECORD(Csq, MSFS_FCB, CancelSafeQueue);
95  KeReleaseSpinLock(&Fcb->QueueLock, Irql);
96 }
_Out_ PKIRQL Irql
Definition: csq.h:179
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
IO_CSQ Csq
Definition: csqrtns.c:46
Definition: msfs.h:24
_In_ PFCB Fcb
Definition: cdprocs.h:151

◆ MsfsRemoveIrp()

VOID NTAPI MsfsRemoveIrp ( PIO_CSQ  Csq,
PIRP  Irp 
)

Definition at line 27 of file msfssup.c.

28 {
30 
31  RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
32 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
IO_CSQ Csq
Definition: csqrtns.c:46

◆ MsfsSetInformation()

NTSTATUS DEFAULTAPI MsfsSetInformation ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 136 of file finfo.c.

138 {
139  PIO_STACK_LOCATION IoStack;
142  PMSFS_FCB Fcb;
143  PMSFS_CCB Ccb;
144  PVOID SystemBuffer;
147 
148  DPRINT("MsfsSetInformation(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
149 
150  IoStack = IoGetCurrentIrpStackLocation (Irp);
151  FileInformationClass = IoStack->Parameters.QueryFile.FileInformationClass;
152  FileObject = IoStack->FileObject;
153  Fcb = (PMSFS_FCB)FileObject->FsContext;
154  Ccb = (PMSFS_CCB)FileObject->FsContext2;
155 
156  DPRINT("Mailslot name: %wZ\n", &Fcb->Name);
157 
158  /* setting information is not permitted on client side */
159  if (Fcb->ServerCcb != Ccb)
160  {
162 
163  Irp->IoStatus.Status = Status;
164  Irp->IoStatus.Information = 0;
165 
167 
168  return Status;
169  }
170 
171  SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
172  BufferLength = IoStack->Parameters.QueryFile.Length;
173 
174  DPRINT("FileInformationClass %d\n", FileInformationClass);
175  DPRINT("SystemBuffer %p\n", SystemBuffer);
176 
177  switch (FileInformationClass)
178  {
181  SystemBuffer,
182  &BufferLength);
183  break;
184 
185  default:
187  }
188 
189  Irp->IoStatus.Status = Status;
190  Irp->IoStatus.Information = 0;
192 
193  return Status;
194 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
_In_ ULONG BufferLength
Definition: usbdlib.h:225
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
struct _MSFS_FCB * PMSFS_FCB
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
static NTSTATUS MsfsSetMailslotInformation(PMSFS_FCB Fcb, PFILE_MAILSLOT_SET_INFORMATION Buffer, PULONG BufferLength)
Definition: finfo.c:58
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
* PFILE_OBJECT
Definition: iotypes.h:1955
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
Definition: msfs.h:24
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
Definition: msfs.h:54

◆ MsfsTimeout()

VOID NTAPI MsfsTimeout ( PKDPC  Dpc,
PVOID  DeferredContext,
PVOID  SystemArgument1,
PVOID  SystemArgument2 
)

Definition at line 110 of file msfssup.c.

114 {
116  PIRP Irp;
117 
119 
120  /* Try to get the IRP */
121  Irp = IoCsqRemoveIrp(Context->Csq, &Context->CsqContext);
122  if (Irp != NULL)
123  {
124  /* It timed out, complete it (it's ours) and free context */
125  Irp->IoStatus.Status = STATUS_IO_TIMEOUT;
127  ExFreePoolWithTag(Context, 'NFsM');
128  }
129  else
130  {
131  /* We were racing with writing and failed, signal we're done */
133  }
134 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
struct _MSFS_DPC_CTX * PMSFS_DPC_CTX
struct tagContext Context
Definition: acpixf.h:1024
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
NTKERNELAPI PIRP NTAPI IoCsqRemoveIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIO_CSQ_IRP_CONTEXT Context)
Remove anb IRP from the queue.
Definition: csq.c:326
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675

◆ MsfsWrite()

NTSTATUS DEFAULTAPI MsfsWrite ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 132 of file rw.c.

134 {
135  PIO_STACK_LOCATION IoStack;
137  PMSFS_FCB Fcb;
138  PMSFS_CCB Ccb;
140  KIRQL oldIrql;
141  ULONG Length;
142  PVOID Buffer;
143  PIRP CsqIrp;
145 
146  DPRINT("MsfsWrite(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
147 
148  IoStack = IoGetCurrentIrpStackLocation (Irp);
149  FileObject = IoStack->FileObject;
150  Fcb = (PMSFS_FCB)FileObject->FsContext;
151  Ccb = (PMSFS_CCB)FileObject->FsContext2;
152 
153  DPRINT("MailslotName: %wZ\n", &Fcb->Name);
154 
155  /* writing is not permitted on server side */
156  if (Fcb->ServerCcb == Ccb)
157  {
158  Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
159  Irp->IoStatus.Information = 0;
160 
162 
163  return STATUS_ACCESS_DENIED;
164  }
165 
166  Length = IoStack->Parameters.Write.Length;
167  if (Irp->MdlAddress)
169  else
170  Buffer = Irp->UserBuffer;
171 
172  DPRINT("Length: %lu Message: %s\n", Length, (PUCHAR)Buffer);
173 
174  /* Allocate new message */
176  sizeof(MSFS_MESSAGE) + Length,
177  'rFsM');
178  if (Message == NULL)
179  {
180  Irp->IoStatus.Status = STATUS_NO_MEMORY;
181  Irp->IoStatus.Information = 0;
182 
184 
185  return STATUS_NO_MEMORY;
186  }
187 
188  Message->Size = Length;
189  memcpy(&Message->Buffer, Buffer, Length);
190 
191  KeAcquireSpinLock(&Fcb->MessageListLock, &oldIrql);
192  InsertTailList(&Fcb->MessageListHead, &Message->MessageListEntry);
193  Fcb->MessageCount++;
194  KeReleaseSpinLock(&Fcb->MessageListLock, oldIrql);
195 
196  CsqIrp = IoCsqRemoveNextIrp(&Fcb->CancelSafeQueue, NULL);
197  if (CsqIrp != NULL)
198  {
199  /* Get the context */
200  Context = CsqIrp->Tail.Overlay.DriverContext[0];
201  /* DPC was queued, wait for it to fail (IRP is ours) */
202  if (Fcb->TimeOut.QuadPart != -1 && !KeCancelTimer(&Context->Timer))
203  {
205  }
206 
207  /* Free context & attempt read */
208  ExFreePoolWithTag(Context, 'NFsM');
209  MsfsRead(DeviceObject, CsqIrp);
210  }
211 
212  Irp->IoStatus.Status = STATUS_SUCCESS;
213  Irp->IoStatus.Information = Length;
214 
216 
217  return STATUS_SUCCESS;
218 }
NTKERNELAPI PIRP NTAPI IoCsqRemoveNextIrp(_Inout_ PIO_CSQ Csq, _In_opt_ PVOID PeekContext)
IoCsqRemoveNextIrp - Removes the next IRP from the queue.
Definition: csq.c:398
_In_ PIRP Irp
Definition: csq.h:116
unsigned char * PUCHAR
Definition: retypes.h:3
NTSTATUS DEFAULTAPI MsfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: rw.c:20
#define InsertTailList(ListHead, Entry)
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
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
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
struct _MSFS_FCB * PMSFS_FCB
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1955
CHAR Message[80]
Definition: alive.c:5
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
Definition: msfs.h:24
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
Definition: msfs.h:54

Variable Documentation

◆ MsfsAcquireLock

IO_CSQ_ACQUIRE_LOCK MsfsAcquireLock

Definition at line 117 of file msfs.h.

Referenced by MsfsCreateMailslot().

◆ MsfsClose

DRIVER_DISPATCH MsfsClose

Definition at line 83 of file msfs.h.

Referenced by DriverEntry().

◆ MsfsCompleteCanceledIrp

IO_CSQ_COMPLETE_CANCELED_IRP MsfsCompleteCanceledIrp

Definition at line 125 of file msfs.h.

Referenced by MsfsCreateMailslot().

◆ MsfsCreate

DRIVER_DISPATCH MsfsCreate

Definition at line 77 of file msfs.h.

Referenced by DriverEntry().

◆ MsfsCreateMailslot

DRIVER_DISPATCH MsfsCreateMailslot

Definition at line 80 of file msfs.h.

Referenced by DriverEntry().

◆ MsfsFileSystemControl

DRIVER_DISPATCH MsfsFileSystemControl

Definition at line 98 of file msfs.h.

Referenced by DriverEntry().

◆ MsfsInsertIrp

IO_CSQ_INSERT_IRP MsfsInsertIrp

Definition at line 105 of file msfs.h.

Referenced by MsfsCreateMailslot().

◆ MsfsPeekNextIrp

IO_CSQ_PEEK_NEXT_IRP MsfsPeekNextIrp

Definition at line 113 of file msfs.h.

Referenced by MsfsCreateMailslot().

◆ MsfsQueryInformation

DRIVER_DISPATCH MsfsQueryInformation

Definition at line 86 of file msfs.h.

Referenced by DriverEntry().

◆ MsfsRead

DRIVER_DISPATCH MsfsRead

Definition at line 92 of file msfs.h.

Referenced by DriverEntry().

◆ MsfsReleaseLock

IO_CSQ_RELEASE_LOCK MsfsReleaseLock

Definition at line 121 of file msfs.h.

Referenced by MsfsCreateMailslot().

◆ MsfsRemoveIrp

IO_CSQ_REMOVE_IRP MsfsRemoveIrp

Definition at line 109 of file msfs.h.

Referenced by MsfsCreateMailslot().

◆ MsfsSetInformation

DRIVER_DISPATCH MsfsSetInformation

Definition at line 89 of file msfs.h.

Referenced by DriverEntry().

◆ MsfsTimeout

KDEFERRED_ROUTINE MsfsTimeout

Definition at line 129 of file msfs.h.

Referenced by MsfsRead().

◆ MsfsWrite

DRIVER_DISPATCH MsfsWrite

Definition at line 95 of file msfs.h.

Referenced by DriverEntry().