f498a698b102032a82edc774fff9047d0e81a120
[reactos.git] / reactos / drivers / filesystems / npfs / create.c
1 /*
2 * PROJECT: ReactOS Named Pipe FileSystem
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: drivers/filesystems/npfs/create.c
5 * PURPOSE: Pipes Creation
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include "npfs.h"
12
13 // File ID number for NPFS bugchecking support
14 #define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_CREATE)
15
16 /* FUNCTIONS ******************************************************************/
17
18 VOID
19 NTAPI
20 NpCheckForNotify(IN PNP_DCB Dcb,
21 IN BOOLEAN SecondList,
22 IN PLIST_ENTRY List)
23 {
24 PLIST_ENTRY NextEntry, ListHead;
25 PIRP Irp;
26 ULONG i;
27 PAGED_CODE();
28
29 ListHead = &Dcb->NotifyList;
30 for (i = 0; i < 2; i++)
31 {
32 ASSERT(IsListEmpty(ListHead));
33 while (!IsListEmpty(ListHead))
34 {
35 NextEntry = RemoveHeadList(ListHead);
36
37 Irp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
38
39 if (IoSetCancelRoutine(Irp, NULL))
40 {
41 Irp->IoStatus.Status = STATUS_SUCCESS;
42 InsertTailList(List, NextEntry);
43 }
44 else
45 {
46 InitializeListHead(NextEntry);
47 }
48 }
49
50 if (!SecondList) break;
51 ListHead = &Dcb->NotifyList2;
52 }
53 }
54
55 IO_STATUS_BLOCK
56 NTAPI
57 NpOpenNamedPipeFileSystem(IN PFILE_OBJECT FileObject,
58 IN ACCESS_MASK DesiredAccess)
59 {
60 IO_STATUS_BLOCK Status;
61 PAGED_CODE();
62
63 NpSetFileObject(FileObject, NpVcb, NULL, FALSE);
64 ++NpVcb->ReferenceCount;
65
66 Status.Information = FILE_OPENED;
67 Status.Status = STATUS_SUCCESS;
68 return Status;
69 }
70
71 IO_STATUS_BLOCK
72 NTAPI
73 NpOpenNamedPipeRootDirectory(IN PNP_DCB Dcb,
74 IN PFILE_OBJECT FileObject,
75 IN ACCESS_MASK DesiredAccess,
76 IN PLIST_ENTRY List)
77 {
78 IO_STATUS_BLOCK IoStatus;
79 PNP_ROOT_DCB_FCB Ccb;
80 PAGED_CODE();
81
82 IoStatus.Status = NpCreateRootDcbCcb(&Ccb);
83 if (NT_SUCCESS(IoStatus.Status))
84 {
85 NpSetFileObject(FileObject, Dcb, Ccb, FALSE);
86 ++Dcb->CurrentInstances;
87
88 IoStatus.Information = FILE_OPENED;
89 IoStatus.Status = STATUS_SUCCESS;
90 }
91 else
92 {
93 IoStatus.Information = 0;
94 }
95
96 return IoStatus;
97 }
98
99 IO_STATUS_BLOCK
100 NTAPI
101 NpCreateClientEnd(IN PNP_FCB Fcb,
102 IN PFILE_OBJECT FileObject,
103 IN ACCESS_MASK DesiredAccess,
104 IN PSECURITY_QUALITY_OF_SERVICE SecurityQos,
105 IN PACCESS_STATE AccessState,
106 IN KPROCESSOR_MODE PreviousMode,
107 IN PETHREAD Thread,
108 IN PLIST_ENTRY List)
109 {
110 PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
111 BOOLEAN AccessGranted;
112 ACCESS_MASK GrantedAccess;
113 PPRIVILEGE_SET Privileges;
114 UNICODE_STRING ObjectTypeName;
115 IO_STATUS_BLOCK IoStatus;
116 USHORT NamedPipeConfiguration;
117 PLIST_ENTRY NextEntry, ListHead;
118 PNP_CCB Ccb = NULL;
119
120 IoStatus.Status = STATUS_SUCCESS;
121 IoStatus.Information = 0;
122 Privileges = NULL;
123
124 NamedPipeConfiguration = Fcb->NamedPipeConfiguration;
125
126 SubjectSecurityContext = &AccessState->SubjectSecurityContext;
127 SeLockSubjectContext(SubjectSecurityContext);
128
129 AccessGranted = SeAccessCheck(Fcb->SecurityDescriptor,
130 SubjectSecurityContext,
131 TRUE,
132 DesiredAccess & ~4,
133 0,
134 &Privileges,
135 IoGetFileObjectGenericMapping(),
136 PreviousMode,
137 &GrantedAccess,
138 &IoStatus.Status);
139
140 if (Privileges)
141 {
142 SeAppendPrivileges(AccessState, Privileges);
143 SeFreePrivileges(Privileges);
144 }
145
146 if (AccessGranted)
147 {
148 AccessState->PreviouslyGrantedAccess |= GrantedAccess;
149 AccessState->RemainingDesiredAccess &= ~(GrantedAccess | MAXIMUM_ALLOWED);
150 }
151
152 ObjectTypeName.Buffer = L"NamedPipe";
153 ObjectTypeName.Length = 18;
154 SeOpenObjectAuditAlarm(&ObjectTypeName,
155 NULL,
156 &FileObject->FileName,
157 Fcb->SecurityDescriptor,
158 AccessState,
159 FALSE,
160 AccessGranted,
161 PreviousMode,
162 &AccessState->GenerateOnClose);
163 SeUnlockSubjectContext(SubjectSecurityContext);
164 if (!AccessGranted) return IoStatus;
165
166 if (((GrantedAccess & FILE_READ_DATA) && (NamedPipeConfiguration == FILE_PIPE_INBOUND)) ||
167 ((GrantedAccess & FILE_WRITE_DATA) && (NamedPipeConfiguration == FILE_PIPE_OUTBOUND)))
168 {
169 IoStatus.Status = STATUS_ACCESS_DENIED;
170 return IoStatus;
171 }
172
173 if (!(GrantedAccess & (FILE_READ_DATA | FILE_WRITE_DATA))) SecurityQos = NULL;
174
175 ListHead = &Fcb->CcbList;
176 NextEntry = ListHead->Flink;
177 while (NextEntry != ListHead)
178 {
179 Ccb = CONTAINING_RECORD(NextEntry, NP_CCB, CcbEntry);
180 if (Ccb->NamedPipeState == FILE_PIPE_LISTENING_STATE) break;
181
182 NextEntry = NextEntry->Flink;
183 }
184
185 if (NextEntry == ListHead)
186 {
187 IoStatus.Status = STATUS_PIPE_NOT_AVAILABLE;
188 return IoStatus;
189 }
190
191 IoStatus.Status = NpInitializeSecurity(Ccb, SecurityQos, Thread);
192 if (!NT_SUCCESS(IoStatus.Status)) return IoStatus;
193
194 IoStatus.Status = NpSetConnectedPipeState(Ccb, FileObject, List);
195 if (!NT_SUCCESS(IoStatus.Status))
196 {
197 NpUninitializeSecurity(Ccb);
198 return IoStatus;
199 }
200
201 Ccb->ClientSession = NULL;
202 Ccb->Process = IoThreadToProcess(Thread);
203
204 IoStatus.Information = FILE_OPENED;
205 IoStatus.Status = STATUS_SUCCESS;
206 return IoStatus;
207 }
208
209 NTSTATUS
210 NTAPI
211 NpFsdCreate(IN PDEVICE_OBJECT DeviceObject,
212 IN PIRP Irp)
213 {
214 IO_STATUS_BLOCK IoStatus;
215 PEXTENDED_IO_STACK_LOCATION IoStack;
216 UNICODE_STRING FileName;
217 PFILE_OBJECT FileObject;
218 PFILE_OBJECT RelatedFileObject;
219 NODE_TYPE_CODE Type;
220 PNP_CCB Ccb;
221 PNP_FCB Fcb;
222 PNP_DCB Dcb;
223 ACCESS_MASK DesiredAccess;
224 LIST_ENTRY DeferredList;
225 UNICODE_STRING Prefix;
226
227 InitializeListHead(&DeferredList);
228 IoStack = (PEXTENDED_IO_STACK_LOCATION)IoGetCurrentIrpStackLocation(Irp);
229 FileObject = IoStack->FileObject;
230 RelatedFileObject = FileObject->RelatedFileObject;
231 FileName = FileObject->FileName;
232 DesiredAccess = IoStack->Parameters.CreatePipe.SecurityContext->DesiredAccess;
233
234 IoStatus.Information = 0;
235 IoStatus.Status = STATUS_SUCCESS;
236
237 FsRtlEnterFileSystem();
238 ExAcquireResourceExclusiveLite(&NpVcb->Lock, TRUE);
239
240 if (RelatedFileObject)
241 {
242 Type = NpDecodeFileObject(RelatedFileObject, (PVOID*)&Fcb, &Ccb, FALSE);
243 }
244 else
245 {
246 Type = 0;
247 Fcb = NULL;
248 Ccb = NULL;
249 }
250
251 if (FileName.Length)
252 {
253 if ((FileName.Length == sizeof(OBJ_NAME_PATH_SEPARATOR)) &&
254 (FileName.Buffer[0] == OBJ_NAME_PATH_SEPARATOR) &&
255 !(RelatedFileObject))
256 {
257 IoStatus = NpOpenNamedPipeRootDirectory(NpVcb->RootDcb,
258 FileObject,
259 DesiredAccess,
260 &DeferredList);
261 goto Quickie;
262 }
263 }
264 else if (!(RelatedFileObject) || (Type == NPFS_NTC_VCB))
265 {
266 IoStatus = NpOpenNamedPipeFileSystem(FileObject,
267 DesiredAccess);
268 goto Quickie;
269 }
270 else if (Type == NPFS_NTC_ROOT_DCB)
271 {
272 IoStatus = NpOpenNamedPipeRootDirectory(NpVcb->RootDcb,
273 FileObject,
274 DesiredAccess,
275 &DeferredList);
276 goto Quickie;
277 }
278
279 // Status = NpTranslateAlias(&FileName);; // ignore this for now
280 // if (!NT_SUCCESS(Status)) goto Quickie;
281 if (RelatedFileObject)
282 {
283 if (Type == NPFS_NTC_ROOT_DCB)
284 {
285 Dcb = (PNP_DCB)Ccb;
286 IoStatus.Status = NpFindRelativePrefix(Dcb,
287 &FileName,
288 1,
289 &Prefix,
290 &Fcb);
291 if (!NT_SUCCESS(IoStatus.Status))
292 {
293 goto Quickie;
294 }
295 }
296 else if ((Type != NPFS_NTC_CCB) || (FileName.Length))
297 {
298 IoStatus.Status = STATUS_OBJECT_NAME_INVALID;
299 goto Quickie;
300 }
301 else
302 {
303 Prefix.Length = 0;
304 }
305 }
306 else
307 {
308 if ((FileName.Length <= sizeof(OBJ_NAME_PATH_SEPARATOR)) ||
309 (FileName.Buffer[0] != OBJ_NAME_PATH_SEPARATOR))
310 {
311 IoStatus.Status = STATUS_OBJECT_NAME_INVALID;
312 goto Quickie;
313 }
314
315 Fcb = NpFindPrefix(&FileName, TRUE, &Prefix);
316 }
317
318 if (Prefix.Length)
319 {
320 IoStatus.Status = Fcb->NodeType != NPFS_NTC_FCB ?
321 STATUS_OBJECT_NAME_NOT_FOUND :
322 STATUS_OBJECT_NAME_INVALID;
323 goto Quickie;
324 }
325
326 if (Fcb->NodeType != NPFS_NTC_FCB)
327 {
328 IoStatus.Status = STATUS_OBJECT_NAME_INVALID;
329 goto Quickie;
330 }
331
332 if (!Fcb->ServerOpenCount)
333 {
334 IoStatus.Status = STATUS_OBJECT_NAME_NOT_FOUND;
335 goto Quickie;
336 }
337
338 IoStatus = NpCreateClientEnd(Fcb,
339 FileObject,
340 DesiredAccess,
341 IoStack->Parameters.CreatePipe.
342 SecurityContext->SecurityQos,
343 IoStack->Parameters.CreatePipe.
344 SecurityContext->AccessState,
345 IoStack->Flags &
346 SL_FORCE_ACCESS_CHECK ?
347 UserMode : Irp->RequestorMode,
348 Irp->Tail.Overlay.Thread,
349 &DeferredList);
350
351 Quickie:
352 ExReleaseResourceLite(&NpVcb->Lock);
353 NpCompleteDeferredIrps(&DeferredList);
354 FsRtlExitFileSystem();
355
356 Irp->IoStatus = IoStatus;
357 IoCompleteRequest(Irp, IO_NO_INCREMENT);
358 return IoStatus.Status;
359 }
360
361 IO_STATUS_BLOCK
362 NTAPI
363 NpCreateExistingNamedPipe(IN PNP_FCB Fcb,
364 IN PFILE_OBJECT FileObject,
365 IN ACCESS_MASK DesiredAccess,
366 IN PACCESS_STATE AccessState,
367 IN KPROCESSOR_MODE PreviousMode,
368 IN ULONG Disposition,
369 IN ULONG ShareAccess,
370 IN PNAMED_PIPE_CREATE_PARAMETERS Parameters,
371 IN PEPROCESS Process,
372 OUT PLIST_ENTRY List)
373 {
374 PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext;
375 IO_STATUS_BLOCK IoStatus;
376 UNICODE_STRING ObjectTypeName;
377 ACCESS_MASK GrantedAccess;
378 PNP_CCB Ccb;
379 PPRIVILEGE_SET Privileges;
380 USHORT NamedPipeConfiguration, CheckShareAccess;
381 BOOLEAN AccessGranted;
382 PAGED_CODE();
383
384 Privileges = NULL;
385
386 NamedPipeConfiguration = Fcb->NamedPipeConfiguration;
387
388 SubjectSecurityContext = &AccessState->SubjectSecurityContext;
389 SeLockSubjectContext(SubjectSecurityContext);
390
391 AccessGranted = SeAccessCheck(Fcb->SecurityDescriptor,
392 SubjectSecurityContext,
393 TRUE,
394 DesiredAccess | 4,
395 0,
396 &Privileges,
397 IoGetFileObjectGenericMapping(),
398 PreviousMode,
399 &GrantedAccess,
400 &IoStatus.Status);
401
402 if (Privileges)
403 {
404 SeAppendPrivileges(AccessState, Privileges);
405 SeFreePrivileges(Privileges);
406 }
407
408 if (AccessGranted)
409 {
410 AccessState->PreviouslyGrantedAccess |= GrantedAccess;
411 AccessState->RemainingDesiredAccess &= ~(GrantedAccess | 0x2000000);
412 }
413
414 ObjectTypeName.Buffer = L"NamedPipe";
415 ObjectTypeName.Length = 18;
416 SeOpenObjectAuditAlarm(&ObjectTypeName,
417 NULL,
418 &FileObject->FileName,
419 Fcb->SecurityDescriptor,
420 AccessState,
421 FALSE,
422 AccessGranted,
423 PreviousMode,
424 &AccessState->GenerateOnClose);
425
426 SeUnlockSubjectContext(SubjectSecurityContext);
427 if (!AccessGranted) return IoStatus;
428
429 if (Fcb->CurrentInstances >= Fcb->MaximumInstances)
430 {
431 IoStatus.Status = STATUS_INSTANCE_NOT_AVAILABLE;
432 return IoStatus;
433 }
434
435 if (Disposition == FILE_CREATE)
436 {
437 IoStatus.Status = STATUS_ACCESS_DENIED;
438 return IoStatus;
439 }
440
441 CheckShareAccess = 0;
442 if (NamedPipeConfiguration == FILE_PIPE_FULL_DUPLEX)
443 {
444 CheckShareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE;
445 }
446 else if (NamedPipeConfiguration == FILE_PIPE_OUTBOUND)
447 {
448 CheckShareAccess = FILE_SHARE_READ;
449 }
450 else if (NamedPipeConfiguration == FILE_PIPE_INBOUND)
451 {
452 CheckShareAccess = FILE_SHARE_WRITE;
453 }
454
455 if (CheckShareAccess != ShareAccess)
456 {
457 IoStatus.Status = STATUS_ACCESS_DENIED;
458 return IoStatus;
459 }
460
461 IoStatus.Status = NpCreateCcb(Fcb,
462 FileObject,
463 FILE_PIPE_LISTENING_STATE,
464 Parameters->ReadMode & 0xFF,
465 Parameters->CompletionMode & 0xFF,
466 Parameters->InboundQuota,
467 Parameters->OutboundQuota,
468 &Ccb);
469 if (!NT_SUCCESS(IoStatus.Status)) return IoStatus;
470
471 IoStatus.Status = NpCancelWaiter(&NpVcb->WaitQueue,
472 &Fcb->FullName,
473 FALSE,
474 List);
475 if (!NT_SUCCESS(IoStatus.Status))
476 {
477 --Ccb->Fcb->CurrentInstances;
478 NpDeleteCcb(Ccb, List);
479 return IoStatus;
480 }
481
482 NpSetFileObject(FileObject, Ccb, Ccb->NonPagedCcb, TRUE);
483 Ccb->FileObject[FILE_PIPE_SERVER_END] = FileObject;
484 NpCheckForNotify(Fcb->ParentDcb, 0, List);
485
486 IoStatus.Status = STATUS_SUCCESS;
487 IoStatus.Information = 1;
488 return IoStatus;
489 }
490
491 NTSTATUS
492 NTAPI
493 NpCreateNewNamedPipe(IN PNP_DCB Dcb,
494 IN PFILE_OBJECT FileObject,
495 IN UNICODE_STRING PipeName,
496 IN ACCESS_MASK DesiredAccess,
497 IN PACCESS_STATE AccessState,
498 IN USHORT Disposition,
499 IN USHORT ShareAccess,
500 IN PNAMED_PIPE_CREATE_PARAMETERS Parameters,
501 IN PEPROCESS Process,
502 IN PLIST_ENTRY List,
503 IN PIO_STATUS_BLOCK IoStatus)
504 {
505 NTSTATUS Status;
506 USHORT NamedPipeConfiguration;
507 PSECURITY_SUBJECT_CONTEXT SecurityContext;
508 PSECURITY_DESCRIPTOR SecurityDescriptor, CachedSecurityDescriptor;
509 PNP_CCB Ccb;
510 PNP_FCB Fcb;
511 PAGED_CODE();
512
513 if (!(Parameters->TimeoutSpecified) ||
514 !(Parameters->MaximumInstances) ||
515 (Parameters->DefaultTimeout.HighPart >= 0))
516 {
517 Status = STATUS_INVALID_PARAMETER;
518 goto Quickie;
519 }
520
521 if (Disposition == FILE_OPEN)
522 {
523 Status = STATUS_OBJECT_NAME_NOT_FOUND;
524 goto Quickie;
525 }
526
527 if (ShareAccess == (FILE_SHARE_READ | FILE_SHARE_WRITE))
528 {
529 NamedPipeConfiguration = FILE_PIPE_FULL_DUPLEX;
530 }
531 else if (ShareAccess == FILE_SHARE_READ)
532 {
533 NamedPipeConfiguration = FILE_PIPE_OUTBOUND;
534 }
535 else if (ShareAccess == FILE_SHARE_WRITE)
536 {
537 NamedPipeConfiguration = FILE_PIPE_INBOUND;
538 }
539 else
540 {
541 Status = STATUS_INVALID_PARAMETER;
542 goto Quickie;
543 }
544
545 if (!Parameters->NamedPipeType && Parameters->ReadMode == 1)
546 {
547 Status = STATUS_INVALID_PARAMETER;
548 goto Quickie;
549 }
550
551 Status = NpCreateFcb(Dcb,
552 &PipeName,
553 Parameters->MaximumInstances,
554 Parameters->DefaultTimeout,
555 NamedPipeConfiguration,
556 Parameters->NamedPipeType & 0xFFFF,
557 &Fcb);
558 if (!NT_SUCCESS(Status)) goto Quickie;
559
560 Status = NpCreateCcb(Fcb,
561 FileObject,
562 FILE_PIPE_LISTENING_STATE,
563 Parameters->ReadMode & 0xFF,
564 Parameters->CompletionMode & 0xFF,
565 Parameters->InboundQuota,
566 Parameters->OutboundQuota,
567 &Ccb);
568 if (!NT_SUCCESS(Status))
569 {
570 NpDeleteFcb(Fcb, List);
571 goto Quickie;
572 }
573
574 SecurityContext = &AccessState->SubjectSecurityContext;
575 SeLockSubjectContext(&AccessState->SubjectSecurityContext);
576
577 Status = SeAssignSecurity(0,
578 AccessState->SecurityDescriptor,
579 &SecurityDescriptor,
580 0,
581 SecurityContext,
582 IoGetFileObjectGenericMapping(),
583 PagedPool);
584 SeUnlockSubjectContext(SecurityContext);
585 if (!NT_SUCCESS(Status))
586 {
587 NpDeleteCcb(Ccb, List);
588 NpDeleteFcb(Fcb, List);
589 goto Quickie;
590 }
591
592 Status = ObLogSecurityDescriptor(SecurityDescriptor,
593 &CachedSecurityDescriptor,
594 1);
595 ExFreePool(SecurityDescriptor);
596
597 if (!NT_SUCCESS(Status))
598 {
599 NpDeleteCcb(Ccb, List);
600 NpDeleteFcb(Fcb, List);
601 goto Quickie;
602 }
603
604 Fcb->SecurityDescriptor = CachedSecurityDescriptor;
605
606 NpSetFileObject(FileObject, Ccb, Ccb->NonPagedCcb, TRUE);
607 Ccb->FileObject[FILE_PIPE_SERVER_END] = FileObject;
608
609 NpCheckForNotify(Dcb, TRUE, List);
610
611 IoStatus->Status = STATUS_SUCCESS;
612 IoStatus->Information = FILE_CREATED;
613
614 return STATUS_SUCCESS;
615
616 Quickie:
617 IoStatus->Information = 0;
618 IoStatus->Status = Status;
619 return Status;
620 }
621
622 NTSTATUS
623 NTAPI
624 NpFsdCreateNamedPipe(IN PDEVICE_OBJECT DeviceObject,
625 IN PIRP Irp)
626 {
627 PEXTENDED_IO_STACK_LOCATION IoStack;
628 PFILE_OBJECT FileObject;
629 PFILE_OBJECT RelatedFileObject;
630 USHORT Disposition, ShareAccess;
631 PEPROCESS Process;
632 LIST_ENTRY DeferredList;
633 UNICODE_STRING FileName;
634 PNP_FCB Fcb;
635 UNICODE_STRING Prefix;
636 PNAMED_PIPE_CREATE_PARAMETERS Parameters;
637 IO_STATUS_BLOCK IoStatus;
638
639 InitializeListHead(&DeferredList);
640 Process = IoGetRequestorProcess(Irp);
641
642 IoStack = (PEXTENDED_IO_STACK_LOCATION) IoGetCurrentIrpStackLocation(Irp);
643 FileObject = IoStack->FileObject;
644 RelatedFileObject = FileObject->RelatedFileObject;
645
646 Disposition = (IoStack->Parameters.CreatePipe.Options >> 24) & 0xFF;
647 ShareAccess = IoStack->Parameters.CreatePipe.ShareAccess & 0xFFFF;
648 Parameters = IoStack->Parameters.CreatePipe.Parameters;
649
650 FileName = FileObject->FileName;
651
652 IoStatus.Status = STATUS_SUCCESS;
653 IoStatus.Information = 0;
654
655 FsRtlEnterFileSystem();
656 NpAcquireExclusiveVcb();
657
658 if (RelatedFileObject)
659 {
660 Fcb = (PNP_FCB)((ULONG_PTR)RelatedFileObject->FsContext & ~1);
661 if (!(Fcb) ||
662 (Fcb->NodeType != NPFS_NTC_ROOT_DCB) ||
663 (FileName.Length < sizeof(WCHAR)) ||
664 (FileName.Buffer[0] == OBJ_NAME_PATH_SEPARATOR))
665 {
666 IoStatus.Status = STATUS_OBJECT_NAME_INVALID;
667 goto Quickie;
668 }
669
670 IoStatus.Status = NpFindRelativePrefix(RelatedFileObject->FsContext,
671 &FileName,
672 TRUE,
673 &Prefix,
674 &Fcb);
675 if (!NT_SUCCESS(IoStatus.Status))
676 {
677 goto Quickie;
678 }
679 }
680 else
681 {
682 if (FileName.Length <= sizeof(OBJ_NAME_PATH_SEPARATOR) ||
683 FileName.Buffer[0] != OBJ_NAME_PATH_SEPARATOR)
684 {
685 IoStatus.Status = STATUS_OBJECT_NAME_INVALID;
686 goto Quickie;
687 }
688
689 Fcb = NpFindPrefix(&FileName, TRUE, &Prefix);
690 }
691
692 if (Prefix.Length)
693 {
694 if (Fcb->NodeType == NPFS_NTC_ROOT_DCB)
695 {
696 IoStatus.Status = NpCreateNewNamedPipe((PNP_DCB)Fcb,
697 FileObject,
698 FileName,
699 IoStack->Parameters.CreatePipe.
700 SecurityContext->DesiredAccess,
701 IoStack->Parameters.CreatePipe.
702 SecurityContext->AccessState,
703 Disposition,
704 ShareAccess,
705 Parameters,
706 Process,
707 &DeferredList,
708 &IoStatus);
709 goto Quickie;
710 }
711 else
712 {
713 IoStatus.Status = STATUS_OBJECT_NAME_INVALID;
714 goto Quickie;
715 }
716 }
717
718 if (Fcb->NodeType != NPFS_NTC_FCB)
719 {
720 IoStatus.Status = STATUS_OBJECT_NAME_INVALID;
721 goto Quickie;
722 }
723
724 IoStatus = NpCreateExistingNamedPipe(Fcb,
725 FileObject,
726 IoStack->Parameters.CreatePipe.
727 SecurityContext->DesiredAccess,
728 IoStack->Parameters.CreatePipe.
729 SecurityContext->AccessState,
730 IoStack->Flags &
731 SL_FORCE_ACCESS_CHECK ?
732 UserMode : Irp->RequestorMode,
733 Disposition,
734 ShareAccess,
735 Parameters,
736 Process,
737 &DeferredList);
738
739 Quickie:
740 NpReleaseVcb();
741 NpCompleteDeferredIrps(&DeferredList);
742 FsRtlExitFileSystem();
743
744 Irp->IoStatus = IoStatus;
745 IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
746 return IoStatus.Status;
747 }
748
749 /* EOF */