ReactOS 0.4.15-dev-8096-ga0eec98
fileobsup.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/fileobsup.c
5 * PURPOSE: Pipes File Object Support
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_FILEOBSUP)
15
16/* FUNCTIONS ******************************************************************/
17
21 OUT PVOID* PrimaryContext OPTIONAL,
23 OUT PULONG NamedPipeEnd OPTIONAL)
24{
27 PAGED_CODE();
28
29 Context = (ULONG_PTR)FileObject->FsContext;
30 if ((Context) && (Context != 1))
31 {
32 if (NamedPipeEnd) *NamedPipeEnd = Context & 1;
33
34 Node = (PVOID)(Context & ~1);
35
36 switch (Node->NodeType)
37 {
38 case NPFS_NTC_VCB:
39 return NPFS_NTC_VCB;
40
42 *Ccb = FileObject->FsContext2;
43 if (PrimaryContext) *PrimaryContext = Node;
44 return NPFS_NTC_ROOT_DCB;
45
46 case NPFS_NTC_CCB:
47 *Ccb = Node;
48 if (PrimaryContext) *PrimaryContext = Node->Fcb;
49 return NPFS_NTC_CCB;
50
51 default:
52 NpBugCheck(Node->NodeType, 0, 0);
53 break;
54 }
55 }
56
57 return 0;
58}
59
60VOID
63 IN PVOID PrimaryContext,
64 IN PVOID Ccb,
65 IN ULONG NamedPipeEnd)
66{
67 BOOLEAN FileIsPipe;
68 PAGED_CODE();
69
70 if (!FileObject) return;
71
72 if ((PrimaryContext) && (((PNP_CCB)PrimaryContext)->NodeType == NPFS_NTC_CCB))
73 {
74 FileIsPipe = TRUE;
75 if (NamedPipeEnd == FILE_PIPE_SERVER_END)
76 {
77 PrimaryContext = (PVOID) ((ULONG_PTR) PrimaryContext | 1);
78 }
79 }
80 else
81 {
82 FileIsPipe = FALSE;
83 }
84
85 FileObject->FsContext = PrimaryContext;
86 FileObject->FsContext2 = Ccb;
87 FileObject->PrivateCacheMap = (PVOID)1;
88 if (FileIsPipe) FileObject->Flags |= FO_NAMED_PIPE;
89}
90
91/* EOF */
#define PAGED_CODE()
NodeType
Definition: Node.h:6
unsigned char BOOLEAN
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
union node Node
Definition: types.h:1255
USHORT NODE_TYPE_CODE
Definition: nodetype.h:22
#define NPFS_NTC_VCB
Definition: npfs.h:112
#define NPFS_NTC_ROOT_DCB
Definition: npfs.h:113
#define NpBugCheck(p1, p2, p3)
Definition: npfs.h:106
#define NPFS_NTC_CCB
Definition: npfs.h:115
#define ULONG_PTR
Definition: config.h:101
VOID NTAPI NpSetFileObject(IN PFILE_OBJECT FileObject, IN PVOID PrimaryContext, IN PVOID Ccb, IN ULONG NamedPipeEnd)
Definition: fileobsup.c:62
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
if(dx< 0)
Definition: linetemp.h:194
#define FILE_PIPE_SERVER_END
Definition: iotypes.h:85
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
ULONG Flags
Definition: ntfs.h:536
Definition: npfs.h:259
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
Definition: dlist.c:348
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
#define FO_NAMED_PIPE
Definition: iotypes.h:1782
* PFILE_OBJECT
Definition: iotypes.h:1998