ReactOS 0.4.16-dev-290-g89a3b8f
strucsup.c File Reference
#include "npfs.h"
Include dependency graph for strucsup.c:

Go to the source code of this file.

Macros

#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_STRUCSUP)
 

Functions

RTL_GENERIC_COMPARE_RESULTS NTAPI NpEventTableCompareRoutine (IN PRTL_GENERIC_TABLE Table, IN PVOID FirstStruct, IN PVOID SecondStruct)
 
PVOID NTAPI NpEventTableAllocate (IN PRTL_GENERIC_TABLE Table, IN CLONG ByteSize)
 
VOID NTAPI NpEventTableDeallocate (IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer)
 
BOOLEAN NTAPI NpDeleteEventTableEntry (IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer)
 
VOID NTAPI NpDeleteFcb (IN PNP_FCB Fcb, IN PLIST_ENTRY ListEntry)
 
VOID NTAPI NpDeleteCcb (IN PNP_CCB Ccb, IN PLIST_ENTRY ListEntry)
 
VOID NTAPI NpInitializeVcb (VOID)
 
NTSTATUS NTAPI NpCreateRootDcbCcb (IN PNP_ROOT_DCB_FCB *NewRootCcb)
 
NTSTATUS NTAPI NpCreateRootDcb (VOID)
 
NTSTATUS NTAPI NpCreateFcb (IN PNP_DCB Dcb, IN PUNICODE_STRING PipeName, IN ULONG MaximumInstances, IN LARGE_INTEGER Timeout, IN USHORT NamedPipeConfiguration, IN USHORT NamedPipeType, OUT PNP_FCB *NewFcb)
 
NTSTATUS NTAPI NpCreateCcb (IN PNP_FCB Fcb, IN PFILE_OBJECT FileObject, IN UCHAR State, IN UCHAR ReadMode, IN UCHAR CompletionMode, IN ULONG InQuota, IN ULONG OutQuota, OUT PNP_CCB *NewCcb)
 

Variables

WCHAR NpRootDCBName [] = L"\\"
 
PNP_VCB NpVcb
 

Macro Definition Documentation

◆ NPFS_BUGCHECK_FILE_ID

#define NPFS_BUGCHECK_FILE_ID   (NPFS_BUGCHECK_STRUCSUP)

Definition at line 14 of file strucsup.c.

Function Documentation

◆ NpCreateCcb()

NTSTATUS NTAPI NpCreateCcb ( IN PNP_FCB  Fcb,
IN PFILE_OBJECT  FileObject,
IN UCHAR  State,
IN UCHAR  ReadMode,
IN UCHAR  CompletionMode,
IN ULONG  InQuota,
IN ULONG  OutQuota,
OUT PNP_CCB NewCcb 
)

Definition at line 304 of file strucsup.c.

312{
313 PNP_CCB Ccb;
314 PNP_NONPAGED_CCB CcbNonPaged;
316 PAGED_CODE();
317
320
321 CcbNonPaged = ExAllocatePoolWithTag(NonPagedPool, sizeof(*CcbNonPaged), NPFS_CCB_TAG);
322 if (!CcbNonPaged)
323 {
326 }
327
328 RtlZeroMemory(CcbNonPaged, sizeof(*CcbNonPaged));
329 CcbNonPaged->NodeType = NPFS_NTC_NONPAGED_CCB;
330
331 RtlZeroMemory(Ccb, sizeof(*Ccb));
332 Ccb->NodeType = NPFS_NTC_CCB;
333 Ccb->NonPagedCcb = CcbNonPaged;
335 Ccb->Fcb = Fcb;
336 Ccb->NamedPipeState = State;
337 Ccb->ReadMode[FILE_PIPE_SERVER_END] = ReadMode;
338 Ccb->CompletionMode[FILE_PIPE_SERVER_END] = CompletionMode;
339
340 Status = NpInitializeDataQueue(&Ccb->DataQueue[FILE_PIPE_INBOUND], InQuota);
341 if (!NT_SUCCESS(Status))
342 {
343 ExFreePool(CcbNonPaged);
346 }
347
348 Status = NpInitializeDataQueue(&Ccb->DataQueue[FILE_PIPE_OUTBOUND], OutQuota);
349 if (!NT_SUCCESS(Status))
350 {
352 ExFreePool(CcbNonPaged);
355 }
356
357 InsertTailList(&Fcb->CcbList, &Ccb->CcbEntry);
358
359 Fcb->CurrentInstances++;
360 Fcb->ServerOpenCount++;
361 InitializeListHead(&Ccb->IrpList);
362 ExInitializeResourceLite(&Ccb->NonPagedCcb->Lock);
363 *NewCcb = Ccb;
364 return STATUS_SUCCESS;
365}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
_In_ PFCB Fcb
Definition: cdprocs.h:159
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
NTSTATUS NTAPI NpUninitializeDataQueue(IN PNP_DATA_QUEUE DataQueue)
Definition: datasup.c:20
NTSTATUS NTAPI NpInitializeDataQueue(IN PNP_DATA_QUEUE DataQueue, IN ULONG Quota)
Definition: datasup.c:32
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define NPFS_CCB_TAG
Definition: npfs.h:53
#define NPFS_NTC_NONPAGED_CCB
Definition: npfs.h:116
#define NPFS_NTC_CCB
Definition: npfs.h:115
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
#define FILE_PIPE_OUTBOUND
Definition: iotypes.h:82
#define FILE_PIPE_INBOUND
Definition: iotypes.h:81
#define FILE_PIPE_SERVER_END
Definition: iotypes.h:85
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _FCB::@729::@732 Fcb
PFILE_OBJECT FileObject
Definition: ntfs.h:520
Definition: npfs.h:259
NODE_TYPE_CODE NodeType
Definition: npfs.h:252
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550

Referenced by NpCreateExistingNamedPipe(), and NpCreateNewNamedPipe().

◆ NpCreateFcb()

NTSTATUS NTAPI NpCreateFcb ( IN PNP_DCB  Dcb,
IN PUNICODE_STRING  PipeName,
IN ULONG  MaximumInstances,
IN LARGE_INTEGER  Timeout,
IN USHORT  NamedPipeConfiguration,
IN USHORT  NamedPipeType,
OUT PNP_FCB NewFcb 
)

Definition at line 210 of file strucsup.c.

217{
218 PNP_FCB Fcb;
219 BOOLEAN RootPipe;
220 PWCHAR NameBuffer;
222 PAGED_CODE();
223
224 Length = PipeName->Length;
226
227 if ((Length < sizeof(WCHAR)) || (MaximumLength < Length))
228 {
230 }
231
232 RootPipe = FALSE;
233 if (PipeName->Buffer[0] != OBJ_NAME_PATH_SEPARATOR)
234 {
237 RootPipe = TRUE;
238 if (MaximumLength < sizeof(WCHAR))
239 {
241 }
242 }
243
246
247 RtlZeroMemory(Fcb, sizeof(*Fcb));
248 Fcb->MaximumInstances = MaximumInstances;
249 Fcb->Timeout = Timeout;
250 Fcb->NodeType = NPFS_NTC_FCB;
251 Fcb->ParentDcb = Dcb;
252 InitializeListHead(&Fcb->CcbList);
253
254 NameBuffer = ExAllocatePoolWithTag(PagedPool,
257 if (!NameBuffer)
258 {
261 }
262
263 InsertTailList(&Dcb->FcbList, &Fcb->DcbEntry);
264
265 if (RootPipe)
266 {
267 NameBuffer[0] = OBJ_NAME_PATH_SEPARATOR;
268 RtlCopyMemory(NameBuffer + 1,
269 PipeName->Buffer,
270 PipeName->Length);
271 }
272 else
273 {
274 RtlCopyMemory(NameBuffer,
275 PipeName->Buffer,
276 PipeName->Length);
277 }
278
279 NameBuffer[Length / sizeof(WCHAR)] = UNICODE_NULL;
280
281 Fcb->FullName.Length = Length;
282 Fcb->FullName.MaximumLength = MaximumLength;
283 Fcb->FullName.Buffer = NameBuffer;
284
285 Fcb->ShortName.MaximumLength = Length;
286 Fcb->ShortName.Length = Length - sizeof(OBJ_NAME_PATH_SEPARATOR);
287 Fcb->ShortName.Buffer = NameBuffer + 1;
288
290 &Fcb->FullName,
291 &Fcb->PrefixTableEntry))
292 {
293 NpBugCheck(0, 0, 0);
294 }
295
296 Fcb->NamedPipeConfiguration = NamedPipeConfiguration;
297 Fcb->NamedPipeType = NamedPipeType;
298 *NewFcb = Fcb;
299 return STATUS_SUCCESS;
300}
unsigned char BOOLEAN
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4140
#define NPFS_FCB_TAG
Definition: npfs.h:56
#define NpBugCheck(p1, p2, p3)
Definition: npfs.h:106
#define NPFS_NAME_BLOCK_TAG
Definition: npfs.h:59
#define NPFS_NTC_FCB
Definition: npfs.h:114
PNP_VCB NpVcb
Definition: strucsup.c:19
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
unsigned short USHORT
Definition: pedump.c:61
static ULONG Timeout
Definition: ping.c:61
struct _FCB * ParentDcb
Definition: fatstruc.h:836
FILE_NAME_NODE ShortName
Definition: fatstruc.h:1115
Definition: npfs.h:229
UNICODE_PREFIX_TABLE PrefixTable
Definition: npfs.h:282
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
BOOLEAN NTAPI RtlInsertUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable, PUNICODE_STRING Prefix, PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry)
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by NpCreateNewNamedPipe().

◆ NpCreateRootDcb()

NTSTATUS NTAPI NpCreateRootDcb ( VOID  )

Definition at line 165 of file strucsup.c.

166{
167 PNP_DCB Dcb;
168 PAGED_CODE();
169
170 if (NpVcb->RootDcb)
171 {
172 NpBugCheck(0, 0, 0);
173 }
174
176 if (!NpVcb->RootDcb)
177 {
179 }
180
181 Dcb = NpVcb->RootDcb;
182 RtlZeroMemory(Dcb, sizeof(*Dcb));
183 Dcb->NodeType = NPFS_NTC_ROOT_DCB;
184
185 InitializeListHead(&Dcb->DcbEntry);
186 InitializeListHead(&Dcb->NotifyList);
187 InitializeListHead(&Dcb->NotifyList2);
188 InitializeListHead(&Dcb->FcbList);
189
190 Dcb->FullName.Buffer = NpRootDCBName;
191 Dcb->FullName.Length = sizeof(NpRootDCBName) - sizeof(UNICODE_NULL);
192 Dcb->FullName.MaximumLength = sizeof(NpRootDCBName);
193
194 Dcb->ShortName.Length = Dcb->FullName.Length;
195 Dcb->ShortName.MaximumLength = Dcb->FullName.MaximumLength;
196 Dcb->ShortName.Buffer = Dcb->FullName.Buffer;
197
199 &Dcb->FullName,
200 &Dcb->PrefixTableEntry))
201 {
202 NpBugCheck(0, 0, 0);
203 }
204
205 return STATUS_SUCCESS;
206}
#define NPFS_NTC_ROOT_DCB
Definition: npfs.h:113
#define NPFS_DCB_TAG
Definition: npfs.h:55
WCHAR NpRootDCBName[]
Definition: strucsup.c:18
Definition: npfs.h:211
PNP_DCB RootDcb
Definition: npfs.h:281

Referenced by DriverEntry().

◆ NpCreateRootDcbCcb()

NTSTATUS NTAPI NpCreateRootDcbCcb ( IN PNP_ROOT_DCB_FCB NewRootCcb)

Definition at line 149 of file strucsup.c.

150{
151 PNP_ROOT_DCB_FCB RootCcb;
152 PAGED_CODE();
153
154 RootCcb = ExAllocatePoolWithTag(PagedPool, sizeof(*RootCcb), NPFS_ROOT_DCB_CCB_TAG);
155 if (!RootCcb) return STATUS_INSUFFICIENT_RESOURCES;
156
157 RtlZeroMemory(RootCcb, sizeof(*RootCcb));
159 *NewRootCcb = RootCcb;
160 return STATUS_SUCCESS;
161}
#define NPFS_NTC_ROOT_DCB_CCB
Definition: npfs.h:117
#define NPFS_ROOT_DCB_CCB_TAG
Definition: npfs.h:54
NODE_TYPE_CODE NodeType
Definition: npfs.h:185

Referenced by NpOpenNamedPipeRootDirectory().

◆ NpDeleteCcb()

VOID NTAPI NpDeleteCcb ( IN PNP_CCB  Ccb,
IN PLIST_ENTRY  ListEntry 
)

Definition at line 92 of file strucsup.c.

94{
95 PNP_ROOT_DCB_FCB RootDcbCcb;
96 PAGED_CODE();
97
98 RootDcbCcb = (PNP_ROOT_DCB_FCB)Ccb;
99 if (Ccb->NodeType == NPFS_NTC_CCB)
100 {
101 RemoveEntryList(&Ccb->CcbEntry);
102 --Ccb->Fcb->CurrentInstances;
103
105 Ccb->NonPagedCcb->EventBuffer[FILE_PIPE_CLIENT_END]);
107 Ccb->NonPagedCcb->EventBuffer[FILE_PIPE_SERVER_END]);
110 NpCheckForNotify(Ccb->Fcb->ParentDcb, FALSE, ListEntry);
111 ExDeleteResourceLite(&Ccb->NonPagedCcb->Lock);
113 if (Ccb->ClientSession)
114 {
115 ExFreePool(Ccb->ClientSession);
116 Ccb->ClientSession = NULL;
117 }
118 ExFreePool(Ccb->NonPagedCcb);
119 }
120 else if (RootDcbCcb->NodeType == NPFS_NTC_ROOT_DCB_CCB && RootDcbCcb->Unknown)
121 {
122 ExFreePool(RootDcbCcb->Unknown);
123 }
124
126}
#define NULL
Definition: types.h:112
VOID NTAPI NpCheckForNotify(IN PNP_DCB Dcb, IN BOOLEAN SecondList, IN PLIST_ENTRY List)
Definition: create.c:20
struct _NP_ROOT_DCB_CCB * PNP_ROOT_DCB_FCB
VOID NTAPI NpUninitializeSecurity(IN PNP_CCB Ccb)
Definition: secursup.c:72
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExDeleteResourceLite(res)
Definition: env_spec_w32.h:647
#define FILE_PIPE_CLIENT_END
Definition: iotypes.h:84
BOOLEAN NTAPI NpDeleteEventTableEntry(IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer)
Definition: strucsup.c:52
PVOID Unknown
Definition: npfs.h:186
RTL_GENERIC_TABLE EventTable
Definition: npfs.h:284

Referenced by NpCommonClose(), NpCreateExistingNamedPipe(), NpCreateNewNamedPipe(), and NpSetClosingPipeState().

◆ NpDeleteEventTableEntry()

BOOLEAN NTAPI NpDeleteEventTableEntry ( IN PRTL_GENERIC_TABLE  Table,
IN PVOID  Buffer 
)

Definition at line 52 of file strucsup.c.

54{
55 if (!Buffer) return FALSE;
56
59}
Definition: bufpool.h:45
ASMGENDATA Table[]
Definition: genincdata.c:61
#define ObDereferenceObject
Definition: obfuncs.h:203
NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)

Referenced by NpDeleteCcb(), and NpSetDisconnectedPipeState().

◆ NpDeleteFcb()

VOID NTAPI NpDeleteFcb ( IN PNP_FCB  Fcb,
IN PLIST_ENTRY  ListEntry 
)

Definition at line 63 of file strucsup.c.

65{
67 PAGED_CODE();
68
69 Dcb = Fcb->ParentDcb;
70 if (Fcb->CurrentInstances) NpBugCheck(0, 0, 0);
71
73 &Fcb->FullName,
75 ListEntry);
76
77 RemoveEntryList(&Fcb->DcbEntry);
78
79 if (Fcb->SecurityDescriptor)
80 {
81 ObDereferenceSecurityDescriptor(Fcb->SecurityDescriptor, 1);
82 }
83
84 RtlRemoveUnicodePrefix(&NpVcb->PrefixTable, &Fcb->PrefixTableEntry);
85 ExFreePool(Fcb->FullName.Buffer);
87 NpCheckForNotify(Dcb, TRUE, ListEntry);
88}
NTSTATUS NTAPI NpCancelWaiter(IN PNP_WAIT_QUEUE WaitQueue, IN PUNICODE_STRING PipeName, IN NTSTATUS Status, IN PLIST_ENTRY ListEntry)
Definition: waitsup.c:120
VOID NTAPI ObDereferenceSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN ULONG Count)
Definition: obsdcach.c:287
NP_WAIT_QUEUE WaitQueue
Definition: npfs.h:285
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
VOID NTAPI RtlRemoveUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable, PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry)

Referenced by NpCreateNewNamedPipe(), and NpSetClosingPipeState().

◆ NpEventTableAllocate()

PVOID NTAPI NpEventTableAllocate ( IN PRTL_GENERIC_TABLE  Table,
IN CLONG  ByteSize 
)

Definition at line 35 of file strucsup.c.

37{
39 return NULL;
40}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15

Referenced by NpInitializeVcb().

◆ NpEventTableCompareRoutine()

RTL_GENERIC_COMPARE_RESULTS NTAPI NpEventTableCompareRoutine ( IN PRTL_GENERIC_TABLE  Table,
IN PVOID  FirstStruct,
IN PVOID  SecondStruct 
)

Definition at line 25 of file strucsup.c.

28{
30 return GenericEqual;
31}
@ GenericEqual
Definition: rtltypes.h:391

Referenced by NpInitializeVcb().

◆ NpEventTableDeallocate()

VOID NTAPI NpEventTableDeallocate ( IN PRTL_GENERIC_TABLE  Table,
IN PVOID  Buffer 
)

Definition at line 44 of file strucsup.c.

46{
48}

Referenced by NpInitializeVcb().

◆ NpInitializeVcb()

VOID NTAPI NpInitializeVcb ( VOID  )

Definition at line 130 of file strucsup.c.

131{
132 PAGED_CODE();
133
134 RtlZeroMemory(NpVcb, sizeof(*NpVcb));
135
143 0);
145}
#define NPFS_NTC_VCB
Definition: npfs.h:112
VOID NTAPI NpInitializeWaitQueue(IN PNP_WAIT_QUEUE WaitQueue)
Definition: waitsup.c:96
VOID NTAPI RtlInitializeGenericTable(IN PRTL_GENERIC_TABLE Table, IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, IN PVOID TableContext)
Definition: generictable.c:100
RTL_GENERIC_COMPARE_RESULTS NTAPI NpEventTableCompareRoutine(IN PRTL_GENERIC_TABLE Table, IN PVOID FirstStruct, IN PVOID SecondStruct)
Definition: strucsup.c:25
PVOID NTAPI NpEventTableAllocate(IN PRTL_GENERIC_TABLE Table, IN CLONG ByteSize)
Definition: strucsup.c:35
VOID NTAPI NpEventTableDeallocate(IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer)
Definition: strucsup.c:44
ERESOURCE Lock
Definition: npfs.h:283
NODE_TYPE_CODE NodeType
Definition: npfs.h:279
VOID NTAPI RtlInitializeUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable)

Referenced by DriverEntry().

Variable Documentation

◆ NpRootDCBName

WCHAR NpRootDCBName[] = L"\\"

Definition at line 18 of file strucsup.c.

Referenced by NpCreateRootDcb().

◆ NpVcb