ReactOS  0.4.14-dev-1252-g782ff23
seinfo.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Named Pipe FileSystem
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: drivers/filesystems/npfs/seinfo.c
5  * PURPOSE: Pipes Security Information
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_SEINFO)
15 
16 /* FUNCTIONS ******************************************************************/
17 
19 NTAPI
21  IN PIRP Irp)
22 {
23  NODE_TYPE_CODE NodeTypeCode;
24  PIO_STACK_LOCATION IoStack;
26  PNP_FCB Fcb;
27  PNP_CCB Ccb;
28  ULONG NamedPipeEnd;
29  PAGED_CODE();
30 
32 
33  NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
34  (PVOID*)&Fcb,
35  &Ccb,
36  &NamedPipeEnd);
37  if (!NodeTypeCode) return STATUS_PIPE_DISCONNECTED;
38  if (NodeTypeCode != NPFS_NTC_CCB) return STATUS_INVALID_PARAMETER;
39 
40  Status = SeQuerySecurityDescriptorInfo(&IoStack->Parameters.QuerySecurity.SecurityInformation,
41  Irp->UserBuffer,
42  &IoStack->Parameters.QuerySecurity.Length,
43  &Fcb->SecurityDescriptor);
45  {
46  Irp->IoStatus.Information = IoStack->Parameters.QuerySecurity.Length;
48  }
49 
50  return Status;
51 }
52 
54 NTAPI
56  IN PIRP Irp)
57 {
58  NODE_TYPE_CODE NodeTypeCode;
59  PIO_STACK_LOCATION IoStack;
61  PNP_FCB Fcb;
62  PNP_CCB Ccb;
63  ULONG NamedPipeEnd;
64  PSECURITY_DESCRIPTOR OldSecurityDescriptor;
65  PSECURITY_DESCRIPTOR TempSecurityDescriptor;
66  PSECURITY_DESCRIPTOR NewSecurityDescriptor;
67  PAGED_CODE();
68 
70 
71  NodeTypeCode = NpDecodeFileObject(IoStack->FileObject,
72  (PVOID*)&Fcb,
73  &Ccb,
74  &NamedPipeEnd);
75  if (!NodeTypeCode) return STATUS_PIPE_DISCONNECTED;
76  if (NodeTypeCode != NPFS_NTC_CCB) return STATUS_INVALID_PARAMETER;
77 
78  OldSecurityDescriptor = TempSecurityDescriptor = Fcb->SecurityDescriptor;
80  &IoStack->Parameters.SetSecurity.SecurityInformation,
81  IoStack->Parameters.SetSecurity.SecurityDescriptor,
82  &TempSecurityDescriptor,
83  TRUE,
85  if (!NT_SUCCESS(Status)) return Status;
86 
87  Status = ObLogSecurityDescriptor(TempSecurityDescriptor, &NewSecurityDescriptor, 1);
88  ASSERT(TempSecurityDescriptor != OldSecurityDescriptor);
89  ExFreePoolWithTag(TempSecurityDescriptor, 0);
90 
91  if (!NT_SUCCESS(Status)) return Status;
92 
93  Fcb->SecurityDescriptor = NewSecurityDescriptor;
94  ObDereferenceSecurityDescriptor(OldSecurityDescriptor, 1);
95  return Status;
96 }
97 
99 NTAPI
101  IN PIRP Irp)
102 {
104  PAGED_CODE();
105 
108 
110 
111  NpReleaseVcb();
113 
114  if (Status != STATUS_PENDING)
115  {
116  Irp->IoStatus.Status = Status;
118  }
119 
120  return Status;
121 }
122 
123 NTSTATUS
124 NTAPI
126  IN PIRP Irp)
127 {
129  PAGED_CODE();
130 
133 
135 
136  NpReleaseVcb();
138 
139  if (Status != STATUS_PENDING)
140  {
141  Irp->IoStatus.Status = Status;
143  }
144 
145  return Status;
146 }
147 
148 /* EOF */
PGENERIC_MAPPING NTAPI IoGetFileObjectGenericMapping(VOID)
Definition: file.c:3266
NTSTATUS NTAPI NpFsdQuerySecurityInfo(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: seinfo.c:100
NTSTATUS NTAPI NpFsdSetSecurityInfo(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: seinfo.c:125
#define IN
Definition: typedefs.h:39
#define TRUE
Definition: types.h:120
NTKERNELAPI NTSTATUS NTAPI SeSetSecurityDescriptorInfo(_In_opt_ PVOID Object, _In_ PSECURITY_INFORMATION SecurityInformation, _In_ PSECURITY_DESCRIPTOR SecurityDescriptor, _Inout_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor, _In_ POOL_TYPE PoolType, _In_ PGENERIC_MAPPING GenericMapping)
VOID NTAPI ObDereferenceSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN ULONG Count)
Definition: obsdcach.c:287
#define FsRtlEnterFileSystem
#define STATUS_PIPE_DISCONNECTED
Definition: ntstatus.h:398
#define FsRtlExitFileSystem
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define NPFS_NTC_CCB
Definition: npfs.h:115
#define PAGED_CODE()
Definition: video.h:57
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
NTSTATUS NTAPI NpCommonSetSecurityInfo(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: seinfo.c:55
Definition: npfs.h:228
Definition: npfs.h:258
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI NpCommonQuerySecurityInfo(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: seinfo.c:20
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IO_NAMED_PIPE_INCREMENT
Definition: iotypes.h:572
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI ObLogSecurityDescriptor(IN PSECURITY_DESCRIPTOR InputSecurityDescriptor, OUT PSECURITY_DESCRIPTOR *OutputSecurityDescriptor, IN ULONG RefBias)
Definition: obsdcach.c:364
_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
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
FORCEINLINE VOID NpReleaseVcb(VOID)
Definition: npfs.h:344
unsigned int ULONG
Definition: retypes.h:1
NODE_TYPE_CODE NTAPI NpDecodeFileObject(IN PFILE_OBJECT FileObject, OUT PVOID *PrimaryContext OPTIONAL, OUT PNP_CCB *Ccb, OUT PULONG NamedPipeEnd OPTIONAL)
Definition: fileobsup.c:20
FORCEINLINE VOID NpAcquireExclusiveVcb(VOID)
Definition: npfs.h:336
NTKERNELAPI NTSTATUS NTAPI SeQuerySecurityDescriptorInfo(_In_ PSECURITY_INFORMATION SecurityInformation, _Out_writes_bytes_(*Length) PSECURITY_DESCRIPTOR SecurityDescriptor, _Inout_ PULONG Length, _Inout_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor)
USHORT NODE_TYPE_CODE
Definition: nodetype.h:22
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151