ReactOS 0.4.16-dev-287-g2d3f3a1
npfs.h File Reference
#include <ntifs.h>
#include <ndk/obfuncs.h>
#include <pseh/pseh2.h>
#include <debug.h>
Include dependency graph for npfs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _NP_DATA_QUEUE
 
struct  _NP_DATA_QUEUE_ENTRY
 
struct  _NP_WAIT_QUEUE
 
struct  _NP_WAIT_QUEUE_ENTRY
 
struct  _NP_EVENT_BUFFER
 
struct  _NP_ROOT_DCB_CCB
 
struct  _NP_CB_HEADER
 
struct  _NP_CB_FOOTER
 
struct  _NP_DCB
 
struct  _NP_FCB
 
struct  _NP_NONPAGED_CCB
 
struct  _NP_CCB
 
struct  _NP_VCB
 
struct  _NPFS_ALIAS
 
struct  _NPFS_QUERY_VALUE_CONTEXT
 
struct  _NP_CLIENT_PROCESS
 

Macros

#define NDEBUG
 
#define TRACE(...)   /* DPRINT1("%s: ", __FUNCTION__); DbgPrint(__VA_ARGS__) */
 
#define MIN_INDEXED_LENGTH   5
 
#define MAX_INDEXED_LENGTH   9
 
#define NPFS_CCB_TAG   'cFpN'
 
#define NPFS_ROOT_DCB_CCB_TAG   'CFpN'
 
#define NPFS_DCB_TAG   'DFpN'
 
#define NPFS_FCB_TAG   'fFpN'
 
#define NPFS_GLOBAL_TAG   'gFpN'
 
#define NPFS_CLIENT_INFO_TAG   'iFpN'
 
#define NPFS_NAME_BLOCK_TAG   'nFpN'
 
#define NPFS_QUERY_TEMPLATE_TAG   'qFpN'
 
#define NPFS_DATA_ENTRY_TAG   'rFpN'
 
#define NPFS_CLIENT_SEC_CTX_TAG   'sFpN'
 
#define NPFS_WAIT_BLOCK_TAG   'tFpN'
 
#define NPFS_WRITE_BLOCK_TAG   'wFpN'
 
#define NPFS_BUGCHECK_CLEANUP   0x0001
 
#define NPFS_BUGCHECK_CLOSE   0x0002
 
#define NPFS_BUGCHECK_CREATE   0x0003
 
#define NPFS_BUGCHECK_DATASUP   0x0004
 
#define NPFS_BUGCHECK_FILEINFO   0x0005
 
#define NPFS_BUGCHECK_FILEOBSUP   0x0006
 
#define NPFS_BUGCHECK_FLUSHBUF   0x0007
 
#define NPFS_BUGCHECK_FSCTRL   0x0008
 
#define NPFS_BUGCHECK_MAIN   0x0009
 
#define NPFS_BUGCHECK_PREFXSUP   0x000a
 
#define NPFS_BUGCHECK_READ   0x000b
 
#define NPFS_BUGCHECK_READSUP   0x000c
 
#define NPFS_BUGCHECK_SECURSUP   0x000d
 
#define NPFS_BUGCHECK_SEINFO   0x000e
 
#define NPFS_BUGCHECK_STATESUP   0x000f
 
#define NPFS_BUGCHECK_STRUCSUP   0x0010
 
#define NPFS_BUGCHECK_VOLINFO   0x0011
 
#define NPFS_BUGCHECK_WAITSUP   0x0012
 
#define NPFS_BUGCHECK_WRITE   0x0013
 
#define NPFS_BUGCHECK_WRITESUP   0x0014
 
#define NpBugCheck(p1, p2, p3)
 
#define NPFS_NTC_VCB   1
 
#define NPFS_NTC_ROOT_DCB   2
 
#define NPFS_NTC_FCB   4
 
#define NPFS_NTC_CCB   6
 
#define NPFS_NTC_NONPAGED_CCB   7
 
#define NPFS_NTC_ROOT_DCB_CCB   8
 

Typedefs

typedef USHORT NODE_TYPE_CODE
 
typedef USHORTPNODE_TYPE_CODE
 
typedef enum _NP_DATA_QUEUE_STATE NP_DATA_QUEUE_STATE
 
typedef enum _NP_DATA_QUEUE_ENTRY_TYPE NP_DATA_QUEUE_ENTRY_TYPE
 
typedef struct _NP_DATA_QUEUE NP_DATA_QUEUE
 
typedef struct _NP_DATA_QUEUEPNP_DATA_QUEUE
 
typedef struct _NP_DATA_QUEUE_ENTRY NP_DATA_QUEUE_ENTRY
 
typedef struct _NP_DATA_QUEUE_ENTRYPNP_DATA_QUEUE_ENTRY
 
typedef struct _NP_WAIT_QUEUE NP_WAIT_QUEUE
 
typedef struct _NP_WAIT_QUEUEPNP_WAIT_QUEUE
 
typedef struct _NP_WAIT_QUEUE_ENTRY NP_WAIT_QUEUE_ENTRY
 
typedef struct _NP_WAIT_QUEUE_ENTRYPNP_WAIT_QUEUE_ENTRY
 
typedef struct _NP_EVENT_BUFFER NP_EVENT_BUFFER
 
typedef struct _NP_EVENT_BUFFERPNP_EVENT_BUFFER
 
typedef struct _NP_ROOT_DCB_CCB NP_ROOT_DCB_CCB
 
typedef struct _NP_ROOT_DCB_CCBPNP_ROOT_DCB_FCB
 
typedef struct _NP_CB_HEADER NP_CB_HEADER
 
typedef struct _NP_CB_HEADERPNP_CB_HEADER
 
typedef struct _NP_CB_FOOTER NP_CB_FOOTER
 
typedef struct _NP_DCB NP_DCB
 
typedef struct _NP_DCBPNP_DCB
 
typedef struct _NP_FCB NP_FCB
 
typedef struct _NP_FCBPNP_FCB
 
typedef struct _NP_NONPAGED_CCB NP_NONPAGED_CCB
 
typedef struct _NP_NONPAGED_CCBPNP_NONPAGED_CCB
 
typedef struct _NP_CCB NP_CCB
 
typedef struct _NP_CCBPNP_CCB
 
typedef struct _NP_VCB NP_VCB
 
typedef struct _NP_VCBPNP_VCB
 
typedef struct _NPFS_ALIAS NPFS_ALIAS
 
typedef struct _NPFS_ALIASPNPFS_ALIAS
 
typedef struct _NPFS_QUERY_VALUE_CONTEXT NPFS_QUERY_VALUE_CONTEXT
 
typedef struct _NPFS_QUERY_VALUE_CONTEXTPNPFS_QUERY_VALUE_CONTEXT
 
typedef struct _NP_CLIENT_PROCESS NP_CLIENT_PROCESS
 
typedef struct _NP_CLIENT_PROCESSPNP_CLIENT_PROCESS
 

Enumerations

enum  _NP_DATA_QUEUE_STATE { ReadEntries = 0 , WriteEntries = 1 , Empty = 2 }
 
enum  _NP_DATA_QUEUE_ENTRY_TYPE { Buffered = 0 , Unbuffered }
 

Functions

 C_ASSERT (FIELD_OFFSET(NP_FCB, PrefixTableEntry)==FIELD_OFFSET(NP_DCB, PrefixTableEntry))
 
FORCEINLINE VOID NpAcquireSharedVcb (VOID)
 
FORCEINLINE VOID NpAcquireExclusiveVcb (VOID)
 
FORCEINLINE VOID NpReleaseVcb (VOID)
 
FORCEINLINE VOID NpCompleteDeferredIrps (IN PLIST_ENTRY DeferredList)
 
LONG NTAPI NpCompareAliasNames (_In_ PCUNICODE_STRING String1, _In_ PCUNICODE_STRING String2)
 
BOOLEAN NTAPI NpDeleteEventTableEntry (IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer)
 
VOID NTAPI NpInitializeWaitQueue (IN PNP_WAIT_QUEUE WaitQueue)
 
NTSTATUS NTAPI NpUninitializeDataQueue (IN PNP_DATA_QUEUE DataQueue)
 
PLIST_ENTRY NTAPI NpGetNextRealDataQueueEntry (IN PNP_DATA_QUEUE DataQueue, IN PLIST_ENTRY List)
 
PIRP NTAPI NpRemoveDataQueueEntry (IN PNP_DATA_QUEUE DataQueue, IN BOOLEAN Flag, IN PLIST_ENTRY List)
 
NTSTATUS NTAPI NpAddDataQueueEntry (IN ULONG NamedPipeEnd, IN PNP_CCB Ccb, IN PNP_DATA_QUEUE DataQueue, IN ULONG Who, IN ULONG Type, IN ULONG DataSize, IN PIRP Irp, IN PVOID Buffer, IN ULONG ByteOffset)
 
VOID NTAPI NpCompleteStalledWrites (IN PNP_DATA_QUEUE DataQueue, IN PLIST_ENTRY List)
 
NTSTATUS NTAPI NpInitializeDataQueue (IN PNP_DATA_QUEUE DataQueue, IN ULONG Quota)
 
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)
 
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 NpCreateRootDcb (VOID)
 
NTSTATUS NTAPI NpCreateRootDcbCcb (IN PNP_ROOT_DCB_FCB *NewRootCcb)
 
VOID NTAPI NpInitializeVcb (VOID)
 
VOID NTAPI NpDeleteCcb (IN PNP_CCB Ccb, IN PLIST_ENTRY ListEntry)
 
VOID NTAPI NpDeleteFcb (IN PNP_FCB Fcb, IN PLIST_ENTRY ListEntry)
 
NTSTATUS NTAPI NpFsdCreateNamedPipe (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdCreate (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdCleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdFileSystemControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpSetConnectedPipeState (IN PNP_CCB Ccb, IN PFILE_OBJECT FileObject, IN PLIST_ENTRY List)
 
NTSTATUS NTAPI NpSetListeningPipeState (IN PNP_CCB Ccb, IN PIRP Irp, IN PLIST_ENTRY List)
 
NTSTATUS NTAPI NpSetDisconnectedPipeState (IN PNP_CCB Ccb, IN PLIST_ENTRY List)
 
NTSTATUS NTAPI NpSetClosingPipeState (IN PNP_CCB Ccb, IN PIRP Irp, IN ULONG NamedPipeEnd, IN PLIST_ENTRY List)
 
VOID NTAPI NpFreeClientSecurityContext (IN PSECURITY_CLIENT_CONTEXT ClientContext)
 
NTSTATUS NTAPI NpImpersonateClientContext (IN PNP_CCB Ccb)
 
VOID NTAPI NpCopyClientContext (IN PNP_CCB Ccb, IN PNP_DATA_QUEUE_ENTRY DataQueueEntry)
 
VOID NTAPI NpUninitializeSecurity (IN PNP_CCB Ccb)
 
NTSTATUS NTAPI NpInitializeSecurity (IN PNP_CCB Ccb, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, IN PETHREAD Thread)
 
NTSTATUS NTAPI NpGetClientSecurityContext (IN ULONG NamedPipeEnd, IN PNP_CCB Ccb, IN PETHREAD Thread, IN PSECURITY_CLIENT_CONTEXT *Context)
 
VOID NTAPI NpSetFileObject (IN PFILE_OBJECT FileObject, IN PVOID PrimaryContext, IN PVOID Ccb, IN ULONG NamedPipeEnd)
 
NODE_TYPE_CODE NTAPI NpDecodeFileObject (IN PFILE_OBJECT FileObject, OUT PVOID *PrimaryContext OPTIONAL, OUT PNP_CCB *Ccb, OUT PULONG NamedPipeEnd OPTIONAL)
 
PNP_FCB NTAPI NpFindPrefix (IN PUNICODE_STRING Name, IN ULONG CaseInsensitiveIndex, IN PUNICODE_STRING Prefix)
 
NTSTATUS NTAPI NpFindRelativePrefix (IN PNP_DCB Dcb, IN PUNICODE_STRING Name, IN ULONG CaseInsensitiveIndex, IN PUNICODE_STRING Prefix, OUT PNP_FCB *FoundFcb)
 
VOID NTAPI NpCheckForNotify (IN PNP_DCB Dcb, IN BOOLEAN SecondList, IN PLIST_ENTRY List)
 
NTSTATUS NTAPI NpAddWaiter (IN PNP_WAIT_QUEUE WaitQueue, IN LARGE_INTEGER WaitTime, IN PIRP Irp, IN PUNICODE_STRING AliasName)
 
NTSTATUS NTAPI NpCancelWaiter (IN PNP_WAIT_QUEUE WaitQueue, IN PUNICODE_STRING PipeName, IN NTSTATUS Status, IN PLIST_ENTRY ListEntry)
 
IO_STATUS_BLOCK NTAPI NpReadDataQueue (IN PNP_DATA_QUEUE DataQueue, IN BOOLEAN Peek, IN BOOLEAN ReadOverflowOperation, IN PVOID Buffer, IN ULONG BufferSize, IN ULONG Mode, IN PNP_CCB Ccb, IN PLIST_ENTRY List)
 
NTSTATUS NTAPI NpWriteDataQueue (IN PNP_DATA_QUEUE WriteQueue, IN ULONG Mode, IN PVOID OutBuffer, IN ULONG OutBufferSize, IN ULONG PipeType, OUT PULONG BytesWritten, IN PNP_CCB Ccb, IN ULONG NamedPipeEnd, IN PETHREAD Thread, IN PLIST_ENTRY List)
 
NTSTATUS NTAPI NpFsdRead (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
 _Function_class_ (FAST_IO_READ) _IRQL_requires_same_ BOOLEAN NTAPI NpFastRead(_In_ PFILE_OBJECT FileObject
 
 _Function_class_ (FAST_IO_WRITE) _IRQL_requires_same_ BOOLEAN NTAPI NpFastWrite(_In_ PFILE_OBJECT FileObject
 
NTSTATUS NTAPI NpFsdWrite (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdFlushBuffers (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdSetInformation (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdQueryInformation (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdQuerySecurityInfo (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdSetSecurityInfo (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI NpFsdQueryVolumeInformation (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Variables

PNP_VCB NpVcb
 
PNPFS_ALIAS NpAliasList
 
PNPFS_ALIAS NpAliasListByLength [MAX_INDEXED_LENGTH+1 - MIN_INDEXED_LENGTH]
 
_In_ PLARGE_INTEGER FileOffset
 
_In_ PLARGE_INTEGER _In_ ULONG Length
 
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN Wait
 
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG LockKey
 
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID Buffer
 
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK IoStatus
 
_In_ PLARGE_INTEGER _In_ ULONG _In_ BOOLEAN _In_ ULONG _Out_ PVOID _Out_ PIO_STATUS_BLOCK _In_ PDEVICE_OBJECT DeviceObject
 

Macro Definition Documentation

◆ MAX_INDEXED_LENGTH

#define MAX_INDEXED_LENGTH   9

Definition at line 33 of file npfs.h.

◆ MIN_INDEXED_LENGTH

#define MIN_INDEXED_LENGTH   5

Definition at line 32 of file npfs.h.

◆ NDEBUG

#define NDEBUG

Definition at line 21 of file npfs.h.

◆ NpBugCheck

#define NpBugCheck (   p1,
  p2,
  p3 
)
Value:
KeBugCheckEx(NPFS_FILE_SYSTEM, \
(NPFS_BUGCHECK_FILE_ID << 16) | __LINE__, \
(p1), (p2), (p3))
#define NPFS_BUGCHECK_FILE_ID
Definition: cleanup.c:14
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

Definition at line 106 of file npfs.h.

◆ NPFS_BUGCHECK_CLEANUP

#define NPFS_BUGCHECK_CLEANUP   0x0001

Definition at line 85 of file npfs.h.

◆ NPFS_BUGCHECK_CLOSE

#define NPFS_BUGCHECK_CLOSE   0x0002

Definition at line 86 of file npfs.h.

◆ NPFS_BUGCHECK_CREATE

#define NPFS_BUGCHECK_CREATE   0x0003

Definition at line 87 of file npfs.h.

◆ NPFS_BUGCHECK_DATASUP

#define NPFS_BUGCHECK_DATASUP   0x0004

Definition at line 88 of file npfs.h.

◆ NPFS_BUGCHECK_FILEINFO

#define NPFS_BUGCHECK_FILEINFO   0x0005

Definition at line 89 of file npfs.h.

◆ NPFS_BUGCHECK_FILEOBSUP

#define NPFS_BUGCHECK_FILEOBSUP   0x0006

Definition at line 90 of file npfs.h.

◆ NPFS_BUGCHECK_FLUSHBUF

#define NPFS_BUGCHECK_FLUSHBUF   0x0007

Definition at line 91 of file npfs.h.

◆ NPFS_BUGCHECK_FSCTRL

#define NPFS_BUGCHECK_FSCTRL   0x0008

Definition at line 92 of file npfs.h.

◆ NPFS_BUGCHECK_MAIN

#define NPFS_BUGCHECK_MAIN   0x0009

Definition at line 93 of file npfs.h.

◆ NPFS_BUGCHECK_PREFXSUP

#define NPFS_BUGCHECK_PREFXSUP   0x000a

Definition at line 94 of file npfs.h.

◆ NPFS_BUGCHECK_READ

#define NPFS_BUGCHECK_READ   0x000b

Definition at line 95 of file npfs.h.

◆ NPFS_BUGCHECK_READSUP

#define NPFS_BUGCHECK_READSUP   0x000c

Definition at line 96 of file npfs.h.

◆ NPFS_BUGCHECK_SECURSUP

#define NPFS_BUGCHECK_SECURSUP   0x000d

Definition at line 97 of file npfs.h.

◆ NPFS_BUGCHECK_SEINFO

#define NPFS_BUGCHECK_SEINFO   0x000e

Definition at line 98 of file npfs.h.

◆ NPFS_BUGCHECK_STATESUP

#define NPFS_BUGCHECK_STATESUP   0x000f

Definition at line 99 of file npfs.h.

◆ NPFS_BUGCHECK_STRUCSUP

#define NPFS_BUGCHECK_STRUCSUP   0x0010

Definition at line 100 of file npfs.h.

◆ NPFS_BUGCHECK_VOLINFO

#define NPFS_BUGCHECK_VOLINFO   0x0011

Definition at line 101 of file npfs.h.

◆ NPFS_BUGCHECK_WAITSUP

#define NPFS_BUGCHECK_WAITSUP   0x0012

Definition at line 102 of file npfs.h.

◆ NPFS_BUGCHECK_WRITE

#define NPFS_BUGCHECK_WRITE   0x0013

Definition at line 103 of file npfs.h.

◆ NPFS_BUGCHECK_WRITESUP

#define NPFS_BUGCHECK_WRITESUP   0x0014

Definition at line 104 of file npfs.h.

◆ NPFS_CCB_TAG

#define NPFS_CCB_TAG   'cFpN'

Definition at line 53 of file npfs.h.

◆ NPFS_CLIENT_INFO_TAG

#define NPFS_CLIENT_INFO_TAG   'iFpN'

Definition at line 58 of file npfs.h.

◆ NPFS_CLIENT_SEC_CTX_TAG

#define NPFS_CLIENT_SEC_CTX_TAG   'sFpN'

Definition at line 62 of file npfs.h.

◆ NPFS_DATA_ENTRY_TAG

#define NPFS_DATA_ENTRY_TAG   'rFpN'

Definition at line 61 of file npfs.h.

◆ NPFS_DCB_TAG

#define NPFS_DCB_TAG   'DFpN'

Definition at line 55 of file npfs.h.

◆ NPFS_FCB_TAG

#define NPFS_FCB_TAG   'fFpN'

Definition at line 56 of file npfs.h.

◆ NPFS_GLOBAL_TAG

#define NPFS_GLOBAL_TAG   'gFpN'

Definition at line 57 of file npfs.h.

◆ NPFS_NAME_BLOCK_TAG

#define NPFS_NAME_BLOCK_TAG   'nFpN'

Definition at line 59 of file npfs.h.

◆ NPFS_NTC_CCB

#define NPFS_NTC_CCB   6

Definition at line 115 of file npfs.h.

◆ NPFS_NTC_FCB

#define NPFS_NTC_FCB   4

Definition at line 114 of file npfs.h.

◆ NPFS_NTC_NONPAGED_CCB

#define NPFS_NTC_NONPAGED_CCB   7

Definition at line 116 of file npfs.h.

◆ NPFS_NTC_ROOT_DCB

#define NPFS_NTC_ROOT_DCB   2

Definition at line 113 of file npfs.h.

◆ NPFS_NTC_ROOT_DCB_CCB

#define NPFS_NTC_ROOT_DCB_CCB   8

Definition at line 117 of file npfs.h.

◆ NPFS_NTC_VCB

#define NPFS_NTC_VCB   1

Definition at line 112 of file npfs.h.

◆ NPFS_QUERY_TEMPLATE_TAG

#define NPFS_QUERY_TEMPLATE_TAG   'qFpN'

Definition at line 60 of file npfs.h.

◆ NPFS_ROOT_DCB_CCB_TAG

#define NPFS_ROOT_DCB_CCB_TAG   'CFpN'

Definition at line 54 of file npfs.h.

◆ NPFS_WAIT_BLOCK_TAG

#define NPFS_WAIT_BLOCK_TAG   'tFpN'

Definition at line 63 of file npfs.h.

◆ NPFS_WRITE_BLOCK_TAG

#define NPFS_WRITE_BLOCK_TAG   'wFpN'

Definition at line 64 of file npfs.h.

◆ TRACE

#define TRACE (   ...)    /* DPRINT1("%s: ", __FUNCTION__); DbgPrint(__VA_ARGS__) */

Definition at line 23 of file npfs.h.

Typedef Documentation

◆ NODE_TYPE_CODE

Definition at line 118 of file npfs.h.

◆ NP_CB_FOOTER

◆ NP_CB_HEADER

◆ NP_CCB

◆ NP_CLIENT_PROCESS

◆ NP_DATA_QUEUE

◆ NP_DATA_QUEUE_ENTRY

◆ NP_DATA_QUEUE_ENTRY_TYPE

◆ NP_DATA_QUEUE_STATE

◆ NP_DCB

◆ NP_EVENT_BUFFER

◆ NP_FCB

◆ NP_NONPAGED_CCB

◆ NP_ROOT_DCB_CCB

◆ NP_VCB

◆ NP_WAIT_QUEUE

◆ NP_WAIT_QUEUE_ENTRY

◆ NPFS_ALIAS

◆ NPFS_QUERY_VALUE_CONTEXT

◆ PNODE_TYPE_CODE

Definition at line 118 of file npfs.h.

◆ PNP_CB_HEADER

◆ PNP_CCB

typedef struct _NP_CCB * PNP_CCB

◆ PNP_CLIENT_PROCESS

◆ PNP_DATA_QUEUE

◆ PNP_DATA_QUEUE_ENTRY

◆ PNP_DCB

typedef struct _NP_DCB * PNP_DCB

◆ PNP_EVENT_BUFFER

◆ PNP_FCB

typedef struct _NP_FCB * PNP_FCB

◆ PNP_NONPAGED_CCB

◆ PNP_ROOT_DCB_FCB

◆ PNP_VCB

typedef struct _NP_VCB * PNP_VCB

◆ PNP_WAIT_QUEUE

◆ PNP_WAIT_QUEUE_ENTRY

◆ PNPFS_ALIAS

◆ PNPFS_QUERY_VALUE_CONTEXT

Enumeration Type Documentation

◆ _NP_DATA_QUEUE_ENTRY_TYPE

Enumerator
Buffered 
Unbuffered 

Definition at line 129 of file npfs.h.

130{
131 Buffered = 0,
@ Buffered
Definition: npfs.h:131
@ Unbuffered
Definition: npfs.h:132
enum _NP_DATA_QUEUE_ENTRY_TYPE NP_DATA_QUEUE_ENTRY_TYPE

◆ _NP_DATA_QUEUE_STATE

Enumerator
ReadEntries 
WriteEntries 
Empty 

Definition at line 121 of file npfs.h.

122{
123 ReadEntries = 0,
124 WriteEntries = 1,
125 Empty = 2
enum _NP_DATA_QUEUE_STATE NP_DATA_QUEUE_STATE
@ ReadEntries
Definition: npfs.h:123
@ Empty
Definition: npfs.h:125
@ WriteEntries
Definition: npfs.h:124

Function Documentation

◆ _Function_class_() [1/2]

_Function_class_ ( FAST_IO_READ  )

◆ _Function_class_() [2/2]

_Function_class_ ( FAST_IO_WRITE  )

◆ C_ASSERT()

◆ NpAcquireExclusiveVcb()

FORCEINLINE VOID NpAcquireExclusiveVcb ( VOID  )

Definition at line 336 of file npfs.h.

337{
338 /* Acquire the lock in exclusive mode */
340}
#define TRUE
Definition: types.h:120
PNP_VCB NpVcb
Definition: strucsup.c:19
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
ERESOURCE Lock
Definition: npfs.h:283

Referenced by NpCancelDataQueueIrp(), NpCancelListeningQueueIrp(), NpCommonCleanup(), NpCommonClose(), NpCommonFileSystemControl(), NpFsdCreate(), NpFsdCreateNamedPipe(), NpFsdQuerySecurityInfo(), NpFsdSetInformation(), and NpFsdSetSecurityInfo().

◆ NpAcquireSharedVcb()

FORCEINLINE VOID NpAcquireSharedVcb ( VOID  )

Definition at line 328 of file npfs.h.

329{
330 /* Acquire the lock in shared mode */
332}
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621

Referenced by _Function_class_(), NpCommonFileSystemControl(), NpFsdFlushBuffers(), NpFsdQueryInformation(), NpFsdQueryVolumeInformation(), NpFsdRead(), and NpFsdWrite().

◆ NpAddDataQueueEntry()

NTSTATUS NTAPI NpAddDataQueueEntry ( IN ULONG  NamedPipeEnd,
IN PNP_CCB  Ccb,
IN PNP_DATA_QUEUE  DataQueue,
IN ULONG  Who,
IN ULONG  Type,
IN ULONG  DataSize,
IN PIRP  Irp,
IN PVOID  Buffer,
IN ULONG  ByteOffset 
)

Definition at line 295 of file datasup.c.

304{
306 PNP_DATA_QUEUE_ENTRY DataEntry;
308 ULONG QuotaInEntry;
310 BOOLEAN HasSpace;
311
313 ASSERT((DataQueue->QueueState == Empty) || (DataQueue->QueueState == Who));
314
316
317 if ((Type != 2) && (Who == WriteEntries))
318 {
319 Status = NpGetClientSecurityContext(NamedPipeEnd,
320 Ccb,
321 Irp ? Irp->Tail.Overlay.Thread :
324 if (!NT_SUCCESS(Status))
325 {
326 return Status;
327 }
328 }
329
330 switch (Type)
331 {
332 case Unbuffered:
333 case 2:
334 case 3:
335
336 ASSERT(Irp != NULL);
338 sizeof(*DataEntry),
340 if (!DataEntry)
341 {
344 }
345
346 DataEntry->DataEntryType = Type;
347 DataEntry->QuotaInEntry = 0;
348 DataEntry->Irp = Irp;
349 DataEntry->DataSize = DataSize;
351 ASSERT((DataQueue->QueueState == Empty) || (DataQueue->QueueState == Who));
353 break;
354
355 case Buffered:
356
357 EntrySize = sizeof(*DataEntry);
358 if (Who != ReadEntries)
359 {
361 if (EntrySize < DataSize)
362 {
365 }
366 }
367
368 QuotaInEntry = DataSize - ByteOffset;
369 if (DataQueue->Quota - DataQueue->QuotaUsed < QuotaInEntry)
370 {
371 QuotaInEntry = DataQueue->Quota - DataQueue->QuotaUsed;
372 HasSpace = TRUE;
373 }
374 else
375 {
376 HasSpace = FALSE;
377 }
378
380 EntrySize,
382 if (!DataEntry)
383 {
386 }
387
388 DataEntry->QuotaInEntry = QuotaInEntry;
389 DataEntry->Irp = Irp;
390 DataEntry->DataEntryType = Buffered;
392 DataEntry->DataSize = DataSize;
393
394 if (Who == ReadEntries)
395 {
396 ASSERT(Irp);
397
399 ASSERT((DataQueue->QueueState == Empty) ||
400 (DataQueue->QueueState == Who));
401 }
402 else
403 {
405 {
406 RtlCopyMemory(DataEntry + 1,
407 Irp ? Irp->UserBuffer: Buffer,
408 DataSize);
409 }
411 {
414 }
415 _SEH2_END;
416
417 if (HasSpace && Irp)
418 {
420 }
421 else
422 {
423 DataEntry->Irp = NULL;
425 }
426
427 ASSERT((DataQueue->QueueState == Empty) ||
428 (DataQueue->QueueState == Who));
429 }
430 break;
431
432 default:
433 ASSERT(FALSE);
436 }
437
438 ASSERT((DataQueue->QueueState == Empty) || (DataQueue->QueueState == Who));
439 if (DataQueue->QueueState == Empty)
440 {
441 ASSERT(DataQueue->BytesInQueue == 0);
442 ASSERT(DataQueue->EntriesInQueue == 0);
443 ASSERT(IsListEmpty(&DataQueue->Queue));
444 }
445 else
446 {
447 ASSERT(DataQueue->QueueState == Who);
448 ASSERT(DataQueue->QueueState != Empty);
449 ASSERT(DataQueue->EntriesInQueue != 0);
450 }
451
452 DataQueue->QuotaUsed += DataEntry->QuotaInEntry;
453 DataQueue->QueueState = Who;
454 DataQueue->BytesInQueue += DataEntry->DataSize;
455 DataQueue->EntriesInQueue++;
456
457 if (ByteOffset)
458 {
459 DataQueue->ByteOffset = ByteOffset;
460 ASSERT(Who == WriteEntries);
461 ASSERT(ByteOffset < DataEntry->DataSize);
462 ASSERT(DataQueue->EntriesInQueue == 1);
463 }
464
465 InsertTailList(&DataQueue->Queue, &DataEntry->QueueEntry);
466
467 if (Status == STATUS_PENDING)
468 {
470 Irp->Tail.Overlay.DriverContext[2] = DataQueue;
471 Irp->Tail.Overlay.DriverContext[3] = DataEntry;
472
474
475 if ((Irp->Cancel) && (IoSetCancelRoutine(Irp, NULL)))
476 {
478 }
479 }
480
481 return Status;
482}
unsigned char BOOLEAN
Type
Definition: Type.h:7
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
VOID NTAPI NpCancelDataQueueIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: datasup.c:207
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS NTAPI NpGetClientSecurityContext(IN ULONG NamedPipeEnd, IN PNP_CCB Ccb, IN PETHREAD Thread, IN PSECURITY_CLIENT_CONTEXT *Context)
Definition: secursup.c:129
#define NPFS_DATA_ENTRY_TAG
Definition: npfs.h:61
VOID NTAPI NpFreeClientSecurityContext(IN PSECURITY_CLIENT_CONTEXT ClientContext)
Definition: secursup.c:40
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define NonPagedPool
Definition: env_spec_w32.h:307
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:732
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
IoMarkIrpPending(Irp)
IoSetCancelRoutine(Irp, CancelRoutine)
#define ASSERT(a)
Definition: mode.c:44
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
_In_ PVOID ClientContext
Definition: netioddk.h:55
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: npfs.h:149
ULONG DataSize
Definition: npfs.h:155
PSECURITY_CLIENT_CONTEXT ClientSecurityContext
Definition: npfs.h:154
ULONG QuotaInEntry
Definition: npfs.h:153
ULONG DataEntryType
Definition: npfs.h:151
LIST_ENTRY QueueEntry
Definition: npfs.h:150
PIRP Irp
Definition: npfs.h:152
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define ExAllocatePoolWithQuotaTag(a, b, c)
Definition: exfuncs.h:530
_In_ UCHAR EntrySize
Definition: iofuncs.h:642
#define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE

Referenced by NpCommonFlushBuffers(), NpCommonRead(), NpCommonWrite(), and NpTransceive().

◆ NpAddWaiter()

NTSTATUS NTAPI NpAddWaiter ( IN PNP_WAIT_QUEUE  WaitQueue,
IN LARGE_INTEGER  WaitTime,
IN PIRP  Irp,
IN PUNICODE_STRING  AliasName 
)

Definition at line 221 of file waitsup.c.

225{
226 PIO_STACK_LOCATION IoStack;
229 PNP_WAIT_QUEUE_ENTRY WaitEntry;
232 ULONG i;
233
235
237 sizeof(*WaitEntry),
239 if (!WaitEntry)
240 {
242 }
243
244 KeInitializeDpc(&WaitEntry->Dpc, NpTimerDispatch, WaitEntry);
245 KeInitializeTimer(&WaitEntry->Timer);
246
247 if (AliasName)
248 {
249 WaitEntry->AliasName = *AliasName;
250 }
251 else
252 {
253 WaitEntry->AliasName.Length = 0;
254 WaitEntry->AliasName.Buffer = NULL;
255 }
256
257 WaitEntry->WaitQueue = WaitQueue;
258 WaitEntry->Irp = Irp;
259
260 WaitBuffer = Irp->AssociatedIrp.SystemBuffer;
261 if (WaitBuffer->TimeoutSpecified)
262 {
263 DueTime = WaitBuffer->Timeout;
264 }
265 else
266 {
267 DueTime = WaitTime;
268 }
269
270 for (i = 0; i < WaitBuffer->NameLength / sizeof(WCHAR); i++)
271 {
272 WaitBuffer->Name[i] = RtlUpcaseUnicodeChar(WaitBuffer->Name[i]);
273 }
274
275 Irp->Tail.Overlay.DriverContext[0] = WaitQueue;
276 Irp->Tail.Overlay.DriverContext[1] = WaitEntry;
277
278 KeAcquireSpinLock(&WaitQueue->WaitLock, &OldIrql);
279
281
282 if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
283 {
285 }
286 else
287 {
288 InsertTailList(&WaitQueue->WaitList, &Irp->Tail.Overlay.ListEntry);
289
292
293 WaitEntry->FileObject = IoStack->FileObject;
294 ObReferenceObject(WaitEntry->FileObject);
295
296 KeSetTimer(&WaitEntry->Timer, DueTime, &WaitEntry->Dpc);
297 WaitEntry = NULL;
298 }
299
300 KeReleaseSpinLock(&WaitQueue->WaitLock, OldIrql);
301 if (WaitEntry) ExFreePool(WaitEntry);
302
303 return Status;
304}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
#define NPFS_WRITE_BLOCK_TAG
Definition: npfs.h:64
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
WCHAR NTAPI RtlUpcaseUnicodeChar(_In_ WCHAR Source)
Definition: nlsboot.c:176
LARGE_INTEGER Timeout
Definition: winioctl.h:457
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
Definition: npfs.h:167
KDPC Dpc
Definition: npfs.h:169
PNP_WAIT_QUEUE WaitQueue
Definition: npfs.h:171
UNICODE_STRING AliasName
Definition: npfs.h:172
PIRP Irp
Definition: npfs.h:168
PFILE_OBJECT FileObject
Definition: npfs.h:173
KTIMER Timer
Definition: npfs.h:170
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
VOID NTAPI NpCancelWaitQueueIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: waitsup.c:20
VOID NTAPI NpTimerDispatch(IN PKDPC Dpc, IN PVOID Context, IN PVOID Argument1, IN PVOID Argument2)
Definition: waitsup.c:59
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:190
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
#define ObReferenceObject
Definition: obfuncs.h:204
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by NpWaitForNamedPipe().

◆ NpCancelWaiter()

NTSTATUS NTAPI NpCancelWaiter ( IN PNP_WAIT_QUEUE  WaitQueue,
IN PUNICODE_STRING  PipeName,
IN NTSTATUS  Status,
IN PLIST_ENTRY  ListEntry 
)

Definition at line 120 of file waitsup.c.

124{
125 UNICODE_STRING PipePathUpper;
128 PLIST_ENTRY NextEntry;
129 PNP_WAIT_QUEUE_ENTRY WaitEntry, Linkage;
130 PIRP WaitIrp;
132 UNICODE_STRING WaitName, PipeName;
133
134 Linkage = NULL;
135
137 PipePath->Length,
140
141 RtlInitEmptyUnicodeString(&PipePathUpper, Buffer, PipePath->Length);
142 RtlUpcaseUnicodeString(&PipePathUpper, PipePath, FALSE);
143
144 KeAcquireSpinLock(&WaitQueue->WaitLock, &OldIrql);
145
146 NextEntry = WaitQueue->WaitList.Flink;
147 while (NextEntry != &WaitQueue->WaitList)
148 {
149 WaitIrp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
150 NextEntry = NextEntry->Flink;
151 WaitEntry = WaitIrp->Tail.Overlay.DriverContext[1];
152
153 if (WaitEntry->AliasName.Length)
154 {
155 ASSERT(FALSE);
156 /* We have an alias. Use that for comparison */
157 WaitName = WaitEntry->AliasName;
158 PipeName = PipePathUpper;
159 }
160 else
161 {
162 /* Use the name from the wait buffer to compare */
163 WaitBuffer = WaitIrp->AssociatedIrp.SystemBuffer;
164 WaitName.Buffer = WaitBuffer->Name;
165 WaitName.Length = WaitBuffer->NameLength;
166 WaitName.MaximumLength = WaitName.Length;
167
168 /* WaitName doesn't have a leading backslash,
169 * so skip the one in PipePathUpper for the comparison */
170 PipeName.Buffer = PipePathUpper.Buffer + 1;
171 PipeName.Length = PipePathUpper.Length - sizeof(WCHAR);
172 PipeName.MaximumLength = PipeName.Length;
173 }
174
175 /* Can't use RtlEqualUnicodeString with a spinlock held */
176 if (NpEqualUnicodeString(&WaitName, &PipeName))
177 {
178 /* Found a matching wait. Cancel it */
179 RemoveEntryList(&WaitIrp->Tail.Overlay.ListEntry);
180 if (KeCancelTimer(&WaitEntry->Timer))
181 {
182 WaitEntry->WaitQueue = (PNP_WAIT_QUEUE)Linkage;
183 Linkage = WaitEntry;
184 }
185 else
186 {
187 WaitEntry->Irp = NULL;
188 WaitIrp->Tail.Overlay.DriverContext[1] = NULL;
189 }
190
191 if (IoSetCancelRoutine(WaitIrp, NULL))
192 {
193 WaitIrp->IoStatus.Information = 0;
194 WaitIrp->IoStatus.Status = Status;
195 InsertTailList(List, &WaitIrp->Tail.Overlay.ListEntry);
196 }
197 else
198 {
199 WaitIrp->Tail.Overlay.DriverContext[1] = NULL;
200 }
201 }
202 }
203
204 KeReleaseSpinLock(&WaitQueue->WaitLock, OldIrql);
205
207
208 while (Linkage)
209 {
210 WaitEntry = Linkage;
211 Linkage = (PNP_WAIT_QUEUE_ENTRY)Linkage->WaitQueue;
213 ExFreePool(WaitEntry);
214 }
215
216 return STATUS_SUCCESS;
217}
#define NPFS_WAIT_BLOCK_TAG
Definition: npfs.h:63
struct _NP_WAIT_QUEUE_ENTRY * PNP_WAIT_QUEUE_ENTRY
struct _NP_WAIT_QUEUE * PNP_WAIT_QUEUE
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
PVOID SystemBuffer
union _IRP::@1581 AssociatedIrp
IO_STATUS_BLOCK IoStatus
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
USHORT MaximumLength
Definition: env_spec_w32.h:370
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
static BOOLEAN NpEqualUnicodeString(IN PCUNICODE_STRING String1, IN PCUNICODE_STRING String2)
Definition: waitsup.c:104
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by NpCreateExistingNamedPipe(), NpDeleteFcb(), and NpSetListeningPipeState().

◆ NpCheckForNotify()

VOID NTAPI NpCheckForNotify ( IN PNP_DCB  Dcb,
IN BOOLEAN  SecondList,
IN PLIST_ENTRY  List 
)

Definition at line 20 of file create.c.

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
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}
#define PAGED_CODE()
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4140
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944

Referenced by NpCreateExistingNamedPipe(), NpCreateNewNamedPipe(), NpDeleteCcb(), NpDeleteFcb(), and NpSetPipeInfo().

◆ NpCompareAliasNames()

LONG NTAPI NpCompareAliasNames ( _In_ PCUNICODE_STRING  String1,
_In_ PCUNICODE_STRING  String2 
)

Definition at line 152 of file main.c.

155{
156 ULONG Count;
157 PWCHAR P1, P2;
158
159 /* First check if the string sizes match */
160 if (String1->Length != String2->Length)
161 {
162 /* They don't, return positive if the first is longer, negative otherwise */
163 return String1->Length - String2->Length;
164 }
165
166 /* Now loop all characters */
167 Count = String1->Length / sizeof(WCHAR);
168 P1 = String1->Buffer;
169 P2 = String2->Buffer;
170 while (Count)
171 {
172 /* Check if they don't match */
173 if (*P1 != *P2)
174 {
175 /* Return positive if the first char is greater, negative otherwise */
176 return *P1 - *P2;
177 }
178
179 /* Go to the next buffer position */
180 P1++;
181 P2++;
182 Count--;
183 }
184
185 /* All characters matched, return 0 */
186 return 0;
187}
_In_ const STRING * String2
Definition: rtlfuncs.h:2369
int Count
Definition: noreturn.cpp:7

Referenced by NpInitializeAliases(), and NpTranslateAlias().

◆ NpCompleteDeferredIrps()

FORCEINLINE VOID NpCompleteDeferredIrps ( IN PLIST_ENTRY  DeferredList)

Definition at line 356 of file npfs.h.

357{
358 PLIST_ENTRY ThisEntry, NextEntry;
359 PIRP Irp;
360
361 /* Loop the list */
362 ThisEntry = DeferredList->Flink;
363 while (ThisEntry != DeferredList)
364 {
365 /* Remember the next entry, but don't switch to it yet */
366 NextEntry = ThisEntry->Flink;
367
368 /* Complete the IRP for this entry */
369 Irp = CONTAINING_RECORD(ThisEntry, IRP, Tail.Overlay.ListEntry);
371
372 /* And now switch to the next one */
373 ThisEntry = NextEntry;
374 }
375}
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NAMED_PIPE_INCREMENT
Definition: iotypes.h:604

Referenced by _Function_class_(), NpCancelDataQueueIrp(), NpCommonCleanup(), NpCommonClose(), NpCommonFileSystemControl(), NpFsdCreate(), NpFsdCreateNamedPipe(), NpFsdRead(), NpFsdSetInformation(), and NpFsdWrite().

◆ NpCompleteStalledWrites()

VOID NTAPI NpCompleteStalledWrites ( IN PNP_DATA_QUEUE  DataQueue,
IN PLIST_ENTRY  List 
)

Definition at line 49 of file datasup.c.

51{
52 ULONG QuotaLeft, ByteOffset, DataLeft, NewQuotaLeft;
53 PNP_DATA_QUEUE_ENTRY DataQueueEntry;
54 PIRP Irp;
55 PLIST_ENTRY NextEntry;
56
57 QuotaLeft = DataQueue->Quota - DataQueue->QuotaUsed;
58 ByteOffset = DataQueue->ByteOffset;
59
60 NextEntry = DataQueue->Queue.Flink;
61 while (NextEntry != &DataQueue->Queue)
62 {
63 if (!QuotaLeft) break;
64
65 DataQueueEntry = CONTAINING_RECORD(NextEntry,
67 QueueEntry);
68
69 Irp = DataQueueEntry->Irp;
70
71 if ((DataQueueEntry->DataEntryType == Buffered) && (Irp))
72 {
73 DataLeft = DataQueueEntry->DataSize - ByteOffset;
74
75 if (DataQueueEntry->QuotaInEntry < DataLeft)
76 {
77 NewQuotaLeft = DataLeft - DataQueueEntry->QuotaInEntry;
78 if (NewQuotaLeft > QuotaLeft) NewQuotaLeft = QuotaLeft;
79
80 QuotaLeft -= NewQuotaLeft;
81 DataQueueEntry->QuotaInEntry += NewQuotaLeft;
82
83 if (DataQueueEntry->QuotaInEntry == DataLeft &&
85 {
86 DataQueueEntry->Irp = NULL;
87
88 Irp->IoStatus.Status = STATUS_SUCCESS;
89 Irp->IoStatus.Information = DataQueueEntry->DataSize;
90
91 InsertTailList(List, &Irp->Tail.Overlay.ListEntry);
92 }
93 }
94 }
95
96 NextEntry = NextEntry->Flink;
97 ByteOffset = 0;
98 }
99
100 DataQueue->QuotaUsed = DataQueue->Quota - QuotaLeft;
101}

Referenced by NpCancelDataQueueIrp(), NpReadDataQueue(), and NpRemoveDataQueueEntry().

◆ NpCopyClientContext()

VOID NTAPI NpCopyClientContext ( IN PNP_CCB  Ccb,
IN PNP_DATA_QUEUE_ENTRY  DataQueueEntry 
)

Definition at line 58 of file secursup.c.

60{
61 PAGED_CODE();
62
63 if (!DataQueueEntry->ClientSecurityContext) return;
64
65 NpFreeClientSecurityContext(Ccb->ClientContext);
66 Ccb->ClientContext = DataQueueEntry->ClientSecurityContext;
67 DataQueueEntry->ClientSecurityContext = NULL;
68}
VOID NTAPI NpFreeClientSecurityContext(IN PSECURITY_CLIENT_CONTEXT ClientContext)
Definition: secursup.c:40

Referenced by NpReadDataQueue().

◆ 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}
_In_ PFCB Fcb
Definition: cdprocs.h:159
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 NPFS_CCB_TAG
Definition: npfs.h:53
#define NPFS_NTC_NONPAGED_CCB
Definition: npfs.h:116
#define NPFS_NTC_CCB
Definition: npfs.h:115
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define PagedPool
Definition: env_spec_w32.h:308
#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
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
_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}
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
#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
BOOLEAN NTAPI RtlInsertUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable, PUNICODE_STRING Prefix, PUNICODE_PREFIX_TABLE_ENTRY PrefixTableEntry)
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength

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().

◆ NpDecodeFileObject()

NODE_TYPE_CODE NTAPI NpDecodeFileObject ( IN PFILE_OBJECT  FileObject,
OUT PVOID *PrimaryContext  OPTIONAL,
OUT PNP_CCB Ccb,
OUT PULONG NamedPipeEnd  OPTIONAL 
)

Definition at line 20 of file fileobsup.c.

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}
union node Node
Definition: types.h:1255
#define NPFS_NTC_VCB
Definition: npfs.h:112
#define ULONG_PTR
Definition: config.h:101
if(dx< 0)
Definition: linetemp.h:194
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
Definition: dlist.c:348

Referenced by NpCommonCleanup(), NpCommonClose(), NpCommonFlushBuffers(), NpCommonQueryInformation(), NpCommonQuerySecurityInfo(), NpCommonRead(), NpCommonSetInformation(), NpCommonSetSecurityInfo(), NpCommonWrite(), NpDisconnect(), NpFsdCreate(), NpImpersonate(), NpListen(), NpPeek(), NpQueryClientProcess(), NpSetClientProcess(), NpTransceive(), and NpWaitForNamedPipe().

◆ 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}
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 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}
ASMGENDATA Table[]
Definition: genincdata.c:61
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().

◆ NpFindPrefix()

PNP_FCB NTAPI NpFindPrefix ( IN PUNICODE_STRING  Name,
IN ULONG  CaseInsensitiveIndex,
IN PUNICODE_STRING  Prefix 
)

Definition at line 20 of file prefxsup.c.

23{
26 PAGED_CODE();
27
29 Name,
31 if (!Entry) NpBugCheck(0, 0, 0);
32
34
35 Prefix->Length = Name->Length - Fcb->FullName.Length;
37 Prefix->Buffer = &Name->Buffer[Fcb->FullName.Length / sizeof(WCHAR)];
38
40 {
41 Prefix->Length -= sizeof(WCHAR);
42 Prefix->MaximumLength -= sizeof(WCHAR);
43 ++Prefix->Buffer;
44 }
45
46 return Fcb;
47}
base of all file and directory entries
Definition: entries.h:83
unsigned short Length
Definition: sprintf.c:451
void * Buffer
Definition: sprintf.c:453
unsigned short MaximumLength
Definition: sprintf.c:452
Definition: rtltypes.h:640
PUNICODE_PREFIX_TABLE_ENTRY NTAPI RtlFindUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable, PUNICODE_STRING FullName, ULONG CaseInsensitiveIndex)
_In_ PUNICODE_STRING _In_ ULONG CaseInsensitiveIndex
Definition: rtlfuncs.h:1699
_In_ __drv_aliasesMem PSTRING Prefix
Definition: rtlfuncs.h:1647
_In_ __drv_aliasesMem PSTRING _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry
Definition: rtlfuncs.h:1648

Referenced by NpFindRelativePrefix(), NpFsdCreate(), NpFsdCreateNamedPipe(), and NpWaitForNamedPipe().

◆ NpFindRelativePrefix()

NTSTATUS NTAPI NpFindRelativePrefix ( IN PNP_DCB  Dcb,
IN PUNICODE_STRING  Name,
IN ULONG  CaseInsensitiveIndex,
IN PUNICODE_STRING  Prefix,
OUT PNP_FCB FoundFcb 
)

Definition at line 51 of file prefxsup.c.

56{
59 UNICODE_STRING RootName;
61 PAGED_CODE();
62
63 Length = Name->Length;
66
67 ASSERT(Dcb->NodeType == NPFS_NTC_ROOT_DCB);
68
70 if (!Buffer)
71 {
73 }
74
76 RtlCopyMemory(Buffer + 1, Name->Buffer, Length);
77 Buffer[(Length / sizeof(WCHAR)) + 1] = UNICODE_NULL;
78
79 RootName.Length = Length + sizeof(OBJ_NAME_PATH_SEPARATOR);
81 RootName.Buffer = Buffer;
82
84
86
87 Prefix->Buffer = &Name->Buffer[(Length - Prefix->Length) / sizeof(WCHAR)];
88 *FoundFcb = Fcb;
89
90 return STATUS_SUCCESS;
91}
PNP_FCB NTAPI NpFindPrefix(IN PUNICODE_STRING Name, IN ULONG CaseInsensitiveIndex, IN PUNICODE_STRING Prefix)
Definition: prefxsup.c:20

Referenced by NpFsdCreate(), and NpFsdCreateNamedPipe().

◆ NpFreeClientSecurityContext()

VOID NTAPI NpFreeClientSecurityContext ( IN PSECURITY_CLIENT_CONTEXT  ClientContext)

Definition at line 40 of file secursup.c.

41{
43 PVOID ClientToken;
44
45 if (!ClientContext) return;
46
47 TokenType = SeTokenType(ClientContext->ClientToken);
48 ClientToken = ClientContext->ClientToken;
49 if ((TokenType == TokenPrimary) || (ClientToken))
50 {
51 ObDereferenceObject(ClientToken);
52 }
54}
TOKEN_TYPE
Definition: asmpp.cpp:29
@ TokenPrimary
Definition: imports.h:273
NTKERNELAPI TOKEN_TYPE NTAPI SeTokenType(IN PACCESS_TOKEN Token)
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ BOOLEAN _In_ TOKEN_TYPE TokenType
Definition: sefuncs.h:411

Referenced by NpAddDataQueueEntry(), NpCancelDataQueueIrp(), NpCopyClientContext(), NpRemoveDataQueueEntry(), NpUninitializeSecurity(), and NpWriteDataQueue().

◆ NpFsdCleanup()

NTSTATUS NTAPI NpFsdCleanup ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 58 of file cleanup.c.

60{
62 PAGED_CODE();
63
65
67
69
71 {
72 Irp->IoStatus.Status = Status;
74 }
75
76 return Status;
77}
NTSTATUS NTAPI NpCommonCleanup(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: cleanup.c:20
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by DriverEntry().

◆ NpFsdClose()

NTSTATUS NTAPI NpFsdClose ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 59 of file close.c.

61{
63 PAGED_CODE();
64
66
68
70
71 return Status;
72}
NTSTATUS NTAPI NpCommonClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: close.c:20

Referenced by DriverEntry().

◆ NpFsdCreate()

NTSTATUS NTAPI NpFsdCreate ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 360 of file create.c.

362{
364 PIO_STACK_LOCATION IoStack;
367 PFILE_OBJECT RelatedFileObject;
369 PNP_CCB Ccb;
370 PNP_FCB Fcb;
371 PNP_DCB Dcb;
373 LIST_ENTRY DeferredList;
375 TRACE("Entered\n");
376
377 InitializeListHead(&DeferredList);
379 FileObject = IoStack->FileObject;
380 RelatedFileObject = FileObject->RelatedFileObject;
381 FileName = FileObject->FileName;
382 DesiredAccess = IoStack->Parameters.CreatePipe.SecurityContext->DesiredAccess;
383
384 IoStatus.Information = 0;
385
388
389 if (RelatedFileObject)
390 {
391 Type = NpDecodeFileObject(RelatedFileObject, (PVOID*)&Fcb, &Ccb, FALSE);
392 }
393 else
394 {
395 Type = 0;
396 Fcb = NULL;
397 Ccb = NULL;
398 }
399
400 if (FileName.Length)
401 {
402 if ((FileName.Length == sizeof(OBJ_NAME_PATH_SEPARATOR)) &&
403 (FileName.Buffer[0] == OBJ_NAME_PATH_SEPARATOR) &&
404 !(RelatedFileObject))
405 {
409 &DeferredList);
410 goto Quickie;
411 }
412 }
413 else if (!(RelatedFileObject) || (Type == NPFS_NTC_VCB))
414 {
417 goto Quickie;
418 }
419 else if (Type == NPFS_NTC_ROOT_DCB)
420 {
424 &DeferredList);
425 goto Quickie;
426 }
427
429 if (!NT_SUCCESS(IoStatus.Status)) goto Quickie;
430
431 if (RelatedFileObject)
432 {
433 if (Type == NPFS_NTC_ROOT_DCB)
434 {
435 Dcb = (PNP_DCB)Ccb;
437 &FileName,
438 1,
439 &Prefix,
440 &Fcb);
441 if (!NT_SUCCESS(IoStatus.Status))
442 {
443 goto Quickie;
444 }
445 }
446 else if ((Type != NPFS_NTC_CCB) || (FileName.Length))
447 {
449 goto Quickie;
450 }
451 else
452 {
453 Prefix.Length = 0;
454 }
455 }
456 else
457 {
458 if ((FileName.Length <= sizeof(OBJ_NAME_PATH_SEPARATOR)) ||
459 (FileName.Buffer[0] != OBJ_NAME_PATH_SEPARATOR))
460 {
462 goto Quickie;
463 }
464
466 }
467
468 if (Prefix.Length)
469 {
470 IoStatus.Status = Fcb->NodeType != NPFS_NTC_FCB ?
473 goto Quickie;
474 }
475
476 if (Fcb->NodeType != NPFS_NTC_FCB)
477 {
479 goto Quickie;
480 }
481
482 if (!Fcb->ServerOpenCount)
483 {
485 goto Quickie;
486 }
487
491 IoStack->Parameters.CreatePipe.
492 SecurityContext->SecurityQos,
493 IoStack->Parameters.CreatePipe.
494 SecurityContext->AccessState,
495 IoStack->Flags &
497 UserMode : Irp->RequestorMode,
498 Irp->Tail.Overlay.Thread,
499 &DeferredList);
500
501Quickie:
502 NpReleaseVcb();
503 NpCompleteDeferredIrps(&DeferredList);
505
506 Irp->IoStatus = IoStatus;
508 TRACE("Leaving, IoStatus.Status = %lx\n", IoStatus.Status);
509 return IoStatus.Status;
510}
USHORT NODE_TYPE_CODE
Definition: nodetype.h:22
IO_STATUS_BLOCK NTAPI NpOpenNamedPipeRootDirectory(IN PNP_DCB Dcb, IN PFILE_OBJECT FileObject, IN ACCESS_MASK DesiredAccess, IN PLIST_ENTRY List)
Definition: create.c:75
IO_STATUS_BLOCK NTAPI NpOpenNamedPipeFileSystem(IN PFILE_OBJECT FileObject, IN ACCESS_MASK DesiredAccess)
Definition: create.c:57
NTSTATUS NTAPI NpTranslateAlias(PUNICODE_STRING PipeName)
Definition: create.c:219
IO_STATUS_BLOCK NTAPI NpCreateClientEnd(IN PNP_FCB Fcb, IN PFILE_OBJECT FileObject, IN ACCESS_MASK DesiredAccess, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, IN PACCESS_STATE AccessState, IN KPROCESSOR_MODE PreviousMode, IN PETHREAD Thread, IN PLIST_ENTRY List)
Definition: create.c:105
NTSTATUS NTAPI NpFindRelativePrefix(IN PNP_DCB Dcb, IN PUNICODE_STRING Name, IN ULONG CaseInsensitiveIndex, IN PUNICODE_STRING Prefix, OUT PNP_FCB *FoundFcb)
Definition: prefxsup.c:51
struct _NP_DCB * PNP_DCB
FORCEINLINE VOID NpAcquireExclusiveVcb(VOID)
Definition: npfs.h:336
FORCEINLINE VOID NpReleaseVcb(VOID)
Definition: npfs.h:344
FORCEINLINE VOID NpCompleteDeferredIrps(IN PLIST_ENTRY DeferredList)
Definition: npfs.h:356
PNP_FCB NTAPI NpFindPrefix(IN PUNICODE_STRING Name, IN ULONG CaseInsensitiveIndex, IN PUNICODE_STRING Prefix)
Definition: prefxsup.c:20
struct _FileName FileName
Definition: fatprocs.h:897
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
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define UserMode
Definition: asm.h:35
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define TRACE(s)
Definition: solgame.cpp:4
struct _IO_STACK_LOCATION::@3978::@3980 CreatePipe
union _IO_STACK_LOCATION::@1579 Parameters
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define SL_FORCE_ACCESS_CHECK
Definition: iotypes.h:1816
* PFILE_OBJECT
Definition: iotypes.h:1998

Referenced by DriverEntry().

◆ NpFsdCreateNamedPipe()

NTSTATUS NTAPI NpFsdCreateNamedPipe ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 791 of file create.c.

793{
794 PIO_STACK_LOCATION IoStack;
796 PFILE_OBJECT RelatedFileObject;
799 LIST_ENTRY DeferredList;
801 PNP_FCB Fcb;
805 TRACE("Entered\n");
806
807 InitializeListHead(&DeferredList);
809
811 FileObject = IoStack->FileObject;
812 RelatedFileObject = FileObject->RelatedFileObject;
813
814 Disposition = (IoStack->Parameters.CreatePipe.Options >> 24) & 0xFF;
815 ShareAccess = IoStack->Parameters.CreatePipe.ShareAccess & 0xFFFF;
816 Parameters = IoStack->Parameters.CreatePipe.Parameters;
817
818 FileName = FileObject->FileName;
819
820 IoStatus.Information = 0;
821
824
825 if (RelatedFileObject)
826 {
827 Fcb = (PNP_FCB)((ULONG_PTR)RelatedFileObject->FsContext & ~1);
828 if (!(Fcb) ||
829 (Fcb->NodeType != NPFS_NTC_ROOT_DCB) ||
830 (FileName.Length < sizeof(WCHAR)) ||
831 (FileName.Buffer[0] == OBJ_NAME_PATH_SEPARATOR))
832 {
834 goto Quickie;
835 }
836
837 IoStatus.Status = NpFindRelativePrefix(RelatedFileObject->FsContext,
838 &FileName,
839 TRUE,
840 &Prefix,
841 &Fcb);
842 if (!NT_SUCCESS(IoStatus.Status))
843 {
844 goto Quickie;
845 }
846 }
847 else
848 {
849 if (FileName.Length <= sizeof(OBJ_NAME_PATH_SEPARATOR) ||
851 {
853 goto Quickie;
854 }
855
857 }
858
859 if (Prefix.Length)
860 {
861 if (Fcb->NodeType == NPFS_NTC_ROOT_DCB)
862 {
865 FileName,
866 IoStack->Parameters.CreatePipe.
867 SecurityContext->DesiredAccess,
868 IoStack->Parameters.CreatePipe.
869 SecurityContext->AccessState,
873 Process,
874 &DeferredList,
875 &IoStatus);
876 goto Quickie;
877 }
878 else
879 {
881 goto Quickie;
882 }
883 }
884
885 if (Fcb->NodeType != NPFS_NTC_FCB)
886 {
888 goto Quickie;
889 }
890
893 IoStack->Parameters.CreatePipe.
894 SecurityContext->DesiredAccess,
895 IoStack->Parameters.CreatePipe.
896 SecurityContext->AccessState,
897 IoStack->Flags &
899 UserMode : Irp->RequestorMode,
903 Process,
904 &DeferredList);
905
906Quickie:
907 NpReleaseVcb();
908 NpCompleteDeferredIrps(&DeferredList);
910
911 TRACE("Leaving, IoStatus.Status = %lx\n", IoStatus.Status);
912 Irp->IoStatus = IoStatus;
914 return IoStatus.Status;
915}
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
Definition: create.c:4147
IO_STATUS_BLOCK NTAPI NpCreateExistingNamedPipe(IN PNP_FCB Fcb, IN PFILE_OBJECT FileObject, IN ACCESS_MASK DesiredAccess, IN PACCESS_STATE AccessState, IN KPROCESSOR_MODE PreviousMode, IN ULONG Disposition, IN ULONG ShareAccess, IN PNAMED_PIPE_CREATE_PARAMETERS Parameters, IN PEPROCESS Process, OUT PLIST_ENTRY List)
Definition: create.c:514
NTSTATUS NTAPI NpCreateNewNamedPipe(IN PNP_DCB Dcb, IN PFILE_OBJECT FileObject, IN UNICODE_STRING PipeName, IN ACCESS_MASK DesiredAccess, IN PACCESS_STATE AccessState, IN USHORT Disposition, IN USHORT ShareAccess, IN PNAMED_PIPE_CREATE_PARAMETERS Parameters, IN PEPROCESS Process, IN PLIST_ENTRY List, OUT PIO_STATUS_BLOCK IoStatus)
Definition: create.c:656
struct _NP_FCB * PNP_FCB
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
PEPROCESS NTAPI IoGetRequestorProcess(IN PIRP Irp)
Definition: irp.c:1782
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869

Referenced by DriverEntry().

◆ NpFsdFileSystemControl()

NTSTATUS NTAPI NpFsdFileSystemControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 857 of file fsctrl.c.

859{
861 PAGED_CODE();
862
864
866
868
869 if (Status != STATUS_PENDING)
870 {
871 Irp->IoStatus.Status = Status;
873 }
874
875 return Status;
876}
NTSTATUS NTAPI NpCommonFileSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fsctrl.c:755

Referenced by DriverEntry().

◆ NpFsdFlushBuffers()

NTSTATUS NTAPI NpFsdFlushBuffers ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 70 of file flushbuf.c.

72{
74 PAGED_CODE();
75
78
80
83
85 {
86 Irp->IoStatus.Status = Status;
88 }
89
90 return Status;
91}
FORCEINLINE VOID NpAcquireSharedVcb(VOID)
Definition: npfs.h:328
NTSTATUS NTAPI NpCommonFlushBuffers(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: flushbuf.c:20

Referenced by DriverEntry().

◆ NpFsdQueryInformation()

NTSTATUS NTAPI NpFsdQueryInformation ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 461 of file fileinfo.c.

463{
465 PAGED_CODE();
466
469
471
472 NpReleaseVcb();
474
475 if (Status != STATUS_PENDING)
476 {
477 Irp->IoStatus.Status = Status;
479 }
480
481 return Status;
482}
NTSTATUS NTAPI NpCommonQueryInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fileinfo.c:370

Referenced by DriverEntry().

◆ NpFsdQuerySecurityInfo()

NTSTATUS NTAPI NpFsdQuerySecurityInfo ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 100 of file seinfo.c.

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}
NTSTATUS NTAPI NpCommonQuerySecurityInfo(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: seinfo.c:20

Referenced by DriverEntry().

◆ NpFsdQueryVolumeInformation()

NTSTATUS NTAPI NpFsdQueryVolumeInformation ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 181 of file volinfo.c.

183{
185 PAGED_CODE();
186 TRACE("Entered\n");
187
190
192
193 NpReleaseVcb();
195
196 if (Status != STATUS_PENDING)
197 {
198 Irp->IoStatus.Status = Status;
200 }
201
202 TRACE("Leaving, Status = %lx\n", Status);
203 return Status;
204}
NTSTATUS NTAPI NpCommonQueryVolumeInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volinfo.c:134

Referenced by DriverEntry().

◆ NpFsdRead()

NTSTATUS NTAPI NpFsdRead ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 159 of file read.c.

161{
162 PIO_STACK_LOCATION IoStack;
164 LIST_ENTRY DeferredList;
165 PAGED_CODE();
167
168 InitializeListHead(&DeferredList);
170
173
174 NpCommonRead(IoStack->FileObject,
175 Irp->UserBuffer,
176 IoStack->Parameters.Read.Length,
177 &IoStatus,
178 Irp,
179 &DeferredList);
180
181 NpReleaseVcb();
182 NpCompleteDeferredIrps(&DeferredList);
184
185 if (IoStatus.Status != STATUS_PENDING)
186 {
187 Irp->IoStatus.Information = IoStatus.Information;
188 Irp->IoStatus.Status = IoStatus.Status;
190 }
191
192 return IoStatus.Status;
193}
LONG NpSlowReadCalls
Definition: read.c:18
BOOLEAN NTAPI NpCommonRead(IN PFILE_OBJECT FileObject, IN PVOID Buffer, IN ULONG BufferSize, OUT PIO_STATUS_BLOCK IoStatus, IN PIRP Irp, IN PLIST_ENTRY List)
Definition: read.c:26
struct _IO_STACK_LOCATION::@3978::@3982 Read

Referenced by DriverEntry().

◆ NpFsdSetInformation()

NTSTATUS NTAPI NpFsdSetInformation ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 114 of file fileinfo.c.

116{
118 LIST_ENTRY DeferredList;
119 PAGED_CODE();
120
121 InitializeListHead(&DeferredList);
122
125
127
128 NpReleaseVcb();
129 NpCompleteDeferredIrps(&DeferredList);
131
132 if (Status != STATUS_PENDING)
133 {
134 Irp->IoStatus.Status = Status;
136 }
137
138 return Status;
139}
NTSTATUS NTAPI NpCommonSetInformation(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PLIST_ENTRY List)
Definition: fileinfo.c:80

Referenced by DriverEntry().

◆ NpFsdSetSecurityInfo()

NTSTATUS NTAPI NpFsdSetSecurityInfo ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 125 of file seinfo.c.

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}
NTSTATUS NTAPI NpCommonSetSecurityInfo(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: seinfo.c:55

Referenced by DriverEntry().

◆ NpFsdWrite()

NTSTATUS NTAPI NpFsdWrite ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 175 of file write.c.

177{
178 PIO_STACK_LOCATION IoStack;
180 LIST_ENTRY DeferredList;
181 PAGED_CODE();
183
184 InitializeListHead(&DeferredList);
186
189
190 NpCommonWrite(IoStack->FileObject,
191 Irp->UserBuffer,
192 IoStack->Parameters.Write.Length,
193 Irp->Tail.Overlay.Thread,
194 &IoStatus,
195 Irp,
196 &DeferredList);
197
198 NpReleaseVcb();
199 NpCompleteDeferredIrps(&DeferredList);
201
202 if (IoStatus.Status != STATUS_PENDING)
203 {
204 Irp->IoStatus.Information = IoStatus.Information;
205 Irp->IoStatus.Status = IoStatus.Status;
207 }
208
209 return IoStatus.Status;
210}
BOOLEAN NTAPI NpCommonWrite(IN PFILE_OBJECT FileObject, IN PVOID Buffer, IN ULONG DataSize, IN PETHREAD Thread, IN PIO_STATUS_BLOCK IoStatus, IN PIRP Irp, IN PLIST_ENTRY List)
Definition: write.c:26
LONG NpSlowWriteCalls
Definition: write.c:18
struct _IO_STACK_LOCATION::@3978::@3983 Write

Referenced by DriverEntry().

◆ NpGetClientSecurityContext()

NTSTATUS NTAPI NpGetClientSecurityContext ( IN ULONG  NamedPipeEnd,
IN PNP_CCB  Ccb,
IN PETHREAD  Thread,
IN PSECURITY_CLIENT_CONTEXT Context 
)

Definition at line 129 of file secursup.c.

133{
136 PAGED_CODE();
137
138 if (NamedPipeEnd == FILE_PIPE_SERVER_END || Ccb->ClientQos.ContextTrackingMode != SECURITY_DYNAMIC_TRACKING)
139 {
142 }
143 else
144 {
146 sizeof(*NewContext),
149
151 if (!NT_SUCCESS(Status))
152 {
155 }
156 }
158 return Status;
159}
#define NPFS_CLIENT_SEC_CTX_TAG
Definition: npfs.h:62
_In_ FLT_SET_CONTEXT_OPERATION _In_ PFLT_CONTEXT NewContext
Definition: fltkernel.h:1468
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
NTKERNELAPI NTSTATUS NTAPI SeCreateClientSecurity(IN PETHREAD Thread, IN PSECURITY_QUALITY_OF_SERVICE QualityOfService, IN BOOLEAN RemoteClient, OUT PSECURITY_CLIENT_CONTEXT ClientContext)
#define SECURITY_DYNAMIC_TRACKING
Definition: setypes.h:103

Referenced by NpAddDataQueueEntry(), and NpWriteDataQueue().

◆ NpGetNextRealDataQueueEntry()

PLIST_ENTRY NTAPI NpGetNextRealDataQueueEntry ( IN PNP_DATA_QUEUE  DataQueue,
IN PLIST_ENTRY  List 
)

Definition at line 174 of file datasup.c.

176{
177 PNP_DATA_QUEUE_ENTRY DataEntry;
178 ULONG Type;
179 PIRP Irp;
180 PLIST_ENTRY NextEntry;
181 PAGED_CODE();
182
183 for (NextEntry = DataQueue->Queue.Flink;
184 NextEntry != &DataQueue->Queue;
185 NextEntry = DataQueue->Queue.Flink)
186 {
187 DataEntry = CONTAINING_RECORD(NextEntry,
189 QueueEntry);
190
191 Type = DataEntry->DataEntryType;
192 if (Type == Buffered || Type == Unbuffered) break;
193
194 Irp = NpRemoveDataQueueEntry(DataQueue, FALSE, List);
195 if (Irp)
196 {
197 Irp->IoStatus.Status = STATUS_SUCCESS;
198 InsertTailList(List, &Irp->Tail.Overlay.ListEntry);
199 }
200 }
201
202 return NextEntry;
203}
PIRP NTAPI NpRemoveDataQueueEntry(IN PNP_DATA_QUEUE DataQueue, IN BOOLEAN Flag, IN PLIST_ENTRY List)
Definition: datasup.c:105

Referenced by NpCancelDataQueueIrp(), NpReadDataQueue(), NpRemoveDataQueueEntry(), and NpWriteDataQueue().

◆ NpImpersonateClientContext()

NTSTATUS NTAPI NpImpersonateClientContext ( IN PNP_CCB  Ccb)

Definition at line 20 of file secursup.c.

21{
24 PAGED_CODE();
25
26 ClientContext = Ccb->ClientContext;
27 if (ClientContext)
28 {
30 }
31 else
32 {
34 }
35 return Status;
36}
NTSTATUS NTAPI SeImpersonateClientEx(_In_ PSECURITY_CLIENT_CONTEXT ClientContext, _In_opt_ PETHREAD ServerThread)
Extended function that impersonates a client.
Definition: client.c:276
#define STATUS_CANNOT_IMPERSONATE
Definition: ntstatus.h:505

Referenced by NpImpersonate().

◆ NpInitializeDataQueue()

NTSTATUS NTAPI NpInitializeDataQueue ( IN PNP_DATA_QUEUE  DataQueue,
IN ULONG  Quota 
)

Definition at line 32 of file datasup.c.

34{
35 PAGED_CODE();
36
37 DataQueue->BytesInQueue = 0;
38 DataQueue->EntriesInQueue = 0;
39 DataQueue->QuotaUsed = 0;
40 DataQueue->ByteOffset = 0;
41 DataQueue->QueueState = Empty;
42 DataQueue->Quota = Quota;
43 InitializeListHead(&DataQueue->Queue);
44 return STATUS_SUCCESS;
45}

Referenced by NpCreateCcb().

◆ NpInitializeSecurity()

NTSTATUS NTAPI NpInitializeSecurity ( IN PNP_CCB  Ccb,
IN PSECURITY_QUALITY_OF_SERVICE  SecurityQos,
IN PETHREAD  Thread 
)

Definition at line 82 of file secursup.c.

85{
88 PAGED_CODE();
89
90 if (SecurityQos)
91 {
92 Ccb->ClientQos = *SecurityQos;
93 }
94 else
95 {
96 Ccb->ClientQos.Length = sizeof(Ccb->ClientQos);
97 Ccb->ClientQos.ImpersonationLevel = SecurityImpersonation;
98 Ccb->ClientQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
99 Ccb->ClientQos.EffectiveOnly = TRUE;
100 }
101
103
104 if (Ccb->ClientQos.ContextTrackingMode == SECURITY_DYNAMIC_TRACKING)
105 {
107 Ccb->ClientContext = NULL;
108 return Status;
109 }
110
112 sizeof(*ClientContext),
114 Ccb->ClientContext = ClientContext;
116
118 if (!NT_SUCCESS(Status))
119 {
120 ExFreePool(Ccb->ClientContext);
121 Ccb->ClientContext = NULL;
122 }
123
124 return Status;
125}
@ SecurityImpersonation
Definition: lsa.idl:57
VOID NTAPI NpUninitializeSecurity(IN PNP_CCB Ccb)
Definition: secursup.c:72

Referenced by NpCreateClientEnd().

◆ 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}
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
NODE_TYPE_CODE NodeType
Definition: npfs.h:279
VOID NTAPI RtlInitializeUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable)

Referenced by DriverEntry().

◆ NpInitializeWaitQueue()

VOID NTAPI NpInitializeWaitQueue ( IN PNP_WAIT_QUEUE  WaitQueue)

Definition at line 96 of file waitsup.c.

97{
98 InitializeListHead(&WaitQueue->WaitList);
99 KeInitializeSpinLock(&WaitQueue->WaitLock);
100}
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604

Referenced by NpInitializeVcb().

◆ NpReadDataQueue()

IO_STATUS_BLOCK NTAPI NpReadDataQueue ( IN PNP_DATA_QUEUE  DataQueue,
IN BOOLEAN  Peek,
IN BOOLEAN  ReadOverflowOperation,
IN PVOID  Buffer,
IN ULONG  BufferSize,
IN ULONG  Mode,
IN PNP_CCB  Ccb,
IN PLIST_ENTRY  List 
)

Definition at line 20 of file readsup.c.

28{
29 PNP_DATA_QUEUE_ENTRY DataEntry, TempDataEntry;
30 PVOID DataBuffer;
31 ULONG DataSize, DataLength, TotalBytesCopied, RemainingSize, Offset;
32 PIRP Irp;
34 BOOLEAN CompleteWrites = FALSE;
35 PAGED_CODE();
36
37 if (ReadOverflowOperation) Peek = TRUE;
38
39 RemainingSize = BufferSize;
40 IoStatus.Status = STATUS_SUCCESS;
41 TotalBytesCopied = 0;
42
43 if (Peek)
44 {
45 DataEntry = CONTAINING_RECORD(DataQueue->Queue.Flink,
47 QueueEntry);
48 }
49 else
50 {
53 QueueEntry);
54 }
55
56 while ((&DataEntry->QueueEntry != &DataQueue->Queue) && (RemainingSize))
57 {
58 if (!Peek ||
59 DataEntry->DataEntryType == Buffered ||
60 DataEntry->DataEntryType == Unbuffered)
61 {
62 if (DataEntry->DataEntryType == Unbuffered)
63 {
64 DataBuffer = DataEntry->Irp->AssociatedIrp.SystemBuffer;
65 }
66 else
67 {
68 DataBuffer = &DataEntry[1];
69 }
70
71 DataSize = DataEntry->DataSize;
73
74 if (&DataEntry->QueueEntry == DataQueue->Queue.Flink)
75 {
76 Offset -= DataQueue->ByteOffset;
77 }
78
80 if (DataLength >= RemainingSize) DataLength = RemainingSize;
81
83 {
84 RtlCopyMemory((PVOID)((ULONG_PTR)Buffer + BufferSize - RemainingSize),
85 (PVOID)((ULONG_PTR)DataBuffer + DataSize - Offset),
87 }
89 {
91 }
93
94
95 RemainingSize -= DataLength;
97 TotalBytesCopied += DataLength;
98
99 if (!Peek)
100 {
101 DataEntry->QuotaInEntry -= DataLength;
102 DataQueue->QuotaUsed -= DataLength;
103 DataQueue->ByteOffset += DataLength;
104 CompleteWrites = TRUE;
105 }
106
107 NpCopyClientContext(Ccb, DataEntry);
108
109 if ((Offset) || (ReadOverflowOperation && !TotalBytesCopied))
110 {
112 {
114 break;
115 }
116 }
117 else
118 {
119 if (!Peek || ReadOverflowOperation)
120 {
121 if (ReadOverflowOperation)
122 {
123 TempDataEntry = CONTAINING_RECORD(NpGetNextRealDataQueueEntry(DataQueue, List),
125 QueueEntry);
126 ASSERT(TempDataEntry == DataEntry);
127 }
128
129 Irp = NpRemoveDataQueueEntry(DataQueue, TRUE, List);
130 if (Irp)
131 {
132 Irp->IoStatus.Information = DataSize;
133 Irp->IoStatus.Status = STATUS_SUCCESS;
134 InsertTailList(List, &Irp->Tail.Overlay.ListEntry);
135 }
136 }
137
139 {
140 IoStatus.Status = STATUS_SUCCESS;
141 break;
142 }
143
144 ASSERT(!ReadOverflowOperation);
145 }
146 }
147
148 if (Peek)
149 {
150 DataEntry = CONTAINING_RECORD(DataEntry->QueueEntry.Flink,
152 QueueEntry);
153 }
154 else
155 {
156 DataEntry = CONTAINING_RECORD(NpGetNextRealDataQueueEntry(DataQueue, List),
158 QueueEntry);
159 }
160 }
161
162 IoStatus.Information = TotalBytesCopied;
163 if (CompleteWrites) NpCompleteStalledWrites(DataQueue, List);
164 return IoStatus;
165}
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
VOID NTAPI NpCompleteStalledWrites(IN PNP_DATA_QUEUE DataQueue, IN PLIST_ENTRY List)
Definition: datasup.c:49
PLIST_ENTRY NTAPI NpGetNextRealDataQueueEntry(IN PNP_DATA_QUEUE DataQueue, IN PLIST_ENTRY List)
Definition: datasup.c:174
#define BufferSize
Definition: mmc.h:75
static VOID Peek(_In_ PUCHAR ReadDataPort, _Out_writes_bytes_all_opt_(Length) PVOID Buffer, _In_ USHORT Length)
Definition: hardware.c:379
VOID NTAPI NpCopyClientContext(IN PNP_CCB Ccb, IN PNP_DATA_QUEUE_ENTRY DataQueueEntry)
Definition: secursup.c:58
_In_ ULONG Mode
Definition: hubbusif.h:303
#define FILE_PIPE_MESSAGE_MODE
Definition: iotypes.h:78
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by NpCommonRead(), and NpPeek().

◆ NpReleaseVcb()

◆ NpRemoveDataQueueEntry()

PIRP NTAPI NpRemoveDataQueueEntry ( IN PNP_DATA_QUEUE  DataQueue,
IN BOOLEAN  Flag,
IN PLIST_ENTRY  List 
)

Definition at line 105 of file datasup.c.

108{
109 PIRP Irp;
110 PNP_DATA_QUEUE_ENTRY QueueEntry;
111 BOOLEAN HasWrites;
112
113 if (DataQueue->QueueState == Empty)
114 {
115 Irp = NULL;
116 ASSERT(IsListEmpty(&DataQueue->Queue));
117 ASSERT(DataQueue->EntriesInQueue == 0);
118 ASSERT(DataQueue->BytesInQueue == 0);
119 ASSERT(DataQueue->QuotaUsed == 0);
120 }
121 else
122 {
123 QueueEntry = CONTAINING_RECORD(RemoveHeadList(&DataQueue->Queue),
125 QueueEntry);
126
127 DataQueue->BytesInQueue -= QueueEntry->DataSize;
128 --DataQueue->EntriesInQueue;
129
130 HasWrites = TRUE;
131 if (DataQueue->QueueState != WriteEntries ||
132 DataQueue->QuotaUsed < DataQueue->Quota ||
133 !QueueEntry->QuotaInEntry)
134 {
135 HasWrites = FALSE;
136 }
137
138 DataQueue->QuotaUsed -= QueueEntry->QuotaInEntry;
139
140 if (IsListEmpty(&DataQueue->Queue))
141 {
142 DataQueue->QueueState = Empty;
143 HasWrites = FALSE;
144 }
145
146 Irp = QueueEntry->Irp;
148
149 if (Irp && !IoSetCancelRoutine(Irp, NULL))
150 {
151 Irp->Tail.Overlay.DriverContext[3] = NULL;
152 Irp = NULL;
153 }
154
155 ExFreePool(QueueEntry);
156
157 if (Flag)
158 {
160 }
161
162 if (HasWrites)
163 {
164 NpCompleteStalledWrites(DataQueue, List);
165 }
166 }
167
168 DataQueue->ByteOffset = 0;
169 return Irp;
170}
Definition: xml2sdb.h:80

Referenced by NpGetNextRealDataQueueEntry(), NpReadDataQueue(), NpSetClosingPipeState(), NpSetDisconnectedPipeState(), and NpWriteDataQueue().

◆ NpSetClosingPipeState()

NTSTATUS NTAPI NpSetClosingPipeState ( IN PNP_CCB  Ccb,
IN PIRP  Irp,
IN ULONG  NamedPipeEnd,
IN PLIST_ENTRY  List 
)

Definition at line 245 of file statesup.c.

249{
250 PNP_NONPAGED_CCB NonPagedCcb;
251 PNP_FCB Fcb;
252 PLIST_ENTRY NextEntry;
253 PNP_DATA_QUEUE ReadQueue, WriteQueue, DataQueue;
254 PNP_EVENT_BUFFER EventBuffer;
255 PIRP ListIrp;
256
257 NonPagedCcb = Ccb->NonPagedCcb;
258 Fcb = Ccb->Fcb;
259
260 switch (Ccb->NamedPipeState)
261 {
263
264 ASSERT(NamedPipeEnd == FILE_PIPE_SERVER_END);
265
266 while (!IsListEmpty(&Ccb->IrpList))
267 {
268 NextEntry = RemoveHeadList(&Ccb->IrpList);
269
270 ListIrp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
271
272 if (IoSetCancelRoutine(ListIrp, NULL))
273 {
275 InsertTailList(List, NextEntry);
276 }
277 else
278 {
279 InitializeListHead(NextEntry);
280 }
281 }
282
283 // Drop on purpose
284
286
287 ASSERT(NamedPipeEnd == FILE_PIPE_SERVER_END);
288
291
294
296 if (!Fcb->CurrentInstances) NpDeleteFcb(Fcb, List);
297 break;
298
300
301 if (NamedPipeEnd == FILE_PIPE_SERVER_END)
302 {
303 DataQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
304 }
305 else
306 {
307 DataQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
308 }
309
312
315
316 while (DataQueue->QueueState != Empty)
317 {
318 ListIrp = NpRemoveDataQueueEntry(DataQueue, FALSE, List);
319 if (ListIrp)
320 {
322 InsertTailList(List, &ListIrp->Tail.Overlay.ListEntry);
323 }
324 }
325
327
328 if (Ccb->ClientSession)
329 {
330 ExFreePool(Ccb->ClientSession);
331 Ccb->ClientSession = NULL;
332 }
333
335 if (!Fcb->CurrentInstances) NpDeleteFcb(Fcb, List);
336 break;
337
339
340 if (NamedPipeEnd == FILE_PIPE_SERVER_END)
341 {
342 ReadQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
343 WriteQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
344
347 }
348 else
349 {
350 ReadQueue = &Ccb->DataQueue[FILE_PIPE_OUTBOUND];
351 WriteQueue = &Ccb->DataQueue[FILE_PIPE_INBOUND];
352
355 }
356
357 EventBuffer = NonPagedCcb->EventBuffer[NamedPipeEnd];
358
359 Ccb->NamedPipeState = FILE_PIPE_CLOSING_STATE;
360
361 while (ReadQueue->QueueState != Empty)
362 {
363 ListIrp = NpRemoveDataQueueEntry(ReadQueue, FALSE, List);
364 if (ListIrp)
365 {
367 InsertTailList(List, &ListIrp->Tail.Overlay.ListEntry);
368 }
369 }
370
371 while (WriteQueue->QueueState == ReadEntries)
372 {
373 ListIrp = NpRemoveDataQueueEntry(WriteQueue, FALSE, List);
374 if (ListIrp)
375 {
377 InsertTailList(List, &ListIrp->Tail.Overlay.ListEntry);
378 }
379 }
380
381 if (EventBuffer) KeSetEvent(EventBuffer->Event, IO_NO_INCREMENT, FALSE);
382 break;
383
384 default:
385 NpBugCheck(Ccb->NamedPipeState, 0, 0);
386 break;
387 }
388 return STATUS_SUCCESS;
389}
VOID NTAPI NpDeleteFcb(IN PNP_FCB Fcb, IN PLIST_ENTRY ListEntry)
Definition: strucsup.c:63
VOID NTAPI NpDeleteCcb(IN PNP_CCB Ccb, IN PLIST_ENTRY ListEntry)
Definition: strucsup.c:92
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
VOID NTAPI NpSetFileObject(IN PFILE_OBJECT FileObject, IN PVOID PrimaryContext, IN PVOID Ccb, IN ULONG NamedPipeEnd)
Definition: fileobsup.c:62
#define FILE_PIPE_DISCONNECTED_STATE
Definition: winternl.h:790
#define FILE_PIPE_LISTENING_STATE
Definition: winternl.h:791
#define FILE_PIPE_CONNECTED_STATE
Definition: winternl.h:792
#define FILE_PIPE_CLOSING_STATE
Definition: winternl.h:793
#define STATUS_PIPE_BROKEN
Definition: ntstatus.h:567
ULONG QueueState
Definition: npfs.h:139
PKEVENT Event
Definition: npfs.h:179
PNP_EVENT_BUFFER EventBuffer[2]
Definition: npfs.h:253

Referenced by NpCommonCleanup().

◆ NpSetConnectedPipeState()

NTSTATUS NTAPI NpSetConnectedPipeState ( IN PNP_CCB  Ccb,
IN PFILE_OBJECT  FileObject,
IN PLIST_ENTRY  List 
)

Definition at line 39 of file statesup.c.

42{
43 PLIST_ENTRY NextEntry;
44 PIRP Irp;
45
46 ASSERT(Ccb->NamedPipeState == FILE_PIPE_LISTENING_STATE);
47
50 Ccb->NamedPipeState = FILE_PIPE_CONNECTED_STATE;
52
53 NpSetFileObject(FileObject, Ccb, Ccb->NonPagedCcb, FALSE);
54
55 while (!IsListEmpty(&Ccb->IrpList))
56 {
57 NextEntry = RemoveHeadList(&Ccb->IrpList);
58
59 Irp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
60
62 {
63 Irp->IoStatus.Status = STATUS_SUCCESS;
64 InsertTailList(List, NextEntry);
65 }
66 else
67 {
68 InitializeListHead(NextEntry);
69 }
70 }
71
72 return STATUS_SUCCESS;
73}
#define FILE_PIPE_BYTE_STREAM_MODE
Definition: iotypes.h:77
#define FILE_PIPE_QUEUE_OPERATION
Definition: iotypes.h:79

Referenced by NpCreateClientEnd().

◆ NpSetDisconnectedPipeState()

NTSTATUS NTAPI NpSetDisconnectedPipeState ( IN PNP_CCB  Ccb,
IN PLIST_ENTRY  List 
)

Definition at line 77 of file statesup.c.

79{
80 PIRP Irp;
81 PNP_NONPAGED_CCB NonPagedCcb;
83 PLIST_ENTRY NextEntry;
84 PNP_EVENT_BUFFER EventBuffer;
85
86 NonPagedCcb = Ccb->NonPagedCcb;
87
88 switch (Ccb->NamedPipeState)
89 {
92 break;
93
95 while (!IsListEmpty(&Ccb->IrpList))
96 {
97 NextEntry = RemoveHeadList(&Ccb->IrpList);
98
99 Irp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
100
102 {
103 Irp->IoStatus.Status = STATUS_PIPE_DISCONNECTED;
104 InsertTailList(List, NextEntry);
105 }
106 else
107 {
108 InitializeListHead(NextEntry);
109 }
110 }
111
113 break;
114
116
117 EventBuffer = NonPagedCcb->EventBuffer[FILE_PIPE_CLIENT_END];
118
119 while (Ccb->DataQueue[FILE_PIPE_INBOUND].QueueState != Empty)
120 {
122 if (Irp)
123 {
124 Irp->IoStatus.Status = STATUS_PIPE_DISCONNECTED;
125 InsertTailList(List, &Irp->Tail.Overlay.ListEntry);
126 }
127 }
128
129 while (Ccb->DataQueue[FILE_PIPE_OUTBOUND].QueueState != Empty)
130 {
132 if (Irp)
133 {
134 Irp->IoStatus.Status = STATUS_PIPE_DISCONNECTED;
135 InsertTailList(List, &Irp->Tail.Overlay.ListEntry);
136 }
137 }
138
139 if (EventBuffer) KeSetEvent(EventBuffer->Event, IO_NO_INCREMENT, FALSE);
140
141 // drop down on purpose... queue will be empty so flush code is nop
142 ASSERT(Ccb->DataQueue[FILE_PIPE_OUTBOUND].QueueState == Empty);
143
145
146 EventBuffer = NonPagedCcb->EventBuffer[FILE_PIPE_CLIENT_END];
147
148 while (Ccb->DataQueue[FILE_PIPE_INBOUND].QueueState != Empty)
149 {
151 if (Irp)
152 {
153 Irp->IoStatus.Status = STATUS_PIPE_DISCONNECTED;
154 InsertTailList(List, &Irp->Tail.Overlay.ListEntry);
155 }
156 }
157
158 ASSERT(Ccb->DataQueue[FILE_PIPE_OUTBOUND].QueueState == Empty);
159
161 NonPagedCcb->EventBuffer[FILE_PIPE_CLIENT_END] = NULL;
162
165
167
168 if (Ccb->ClientSession)
169 {
170 ExFreePool(Ccb->ClientSession);
171 Ccb->ClientSession = NULL;
172 }
173
175 break;
176
177 default:
178 NpBugCheck(Ccb->NamedPipeState, 0, 0);
179 break;
180 }
181
182 Ccb->NamedPipeState = FILE_PIPE_DISCONNECTED_STATE;
183 return Status;
184}
BOOLEAN NTAPI NpDeleteEventTableEntry(IN PRTL_GENERIC_TABLE Table, IN PVOID Buffer)
Definition: strucsup.c:52
#define STATUS_PIPE_DISCONNECTED
Definition: ntstatus.h:412

Referenced by NpDisconnect().

◆ NpSetFileObject()

VOID NTAPI NpSetFileObject ( IN PFILE_OBJECT  FileObject,
IN PVOID  PrimaryContext,
IN PVOID  Ccb,
IN ULONG  NamedPipeEnd 
)

Definition at line 62 of file fileobsup.c.

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}
NodeType
Definition: Node.h:6
ULONG Flags
Definition: ntfs.h:536
#define FO_NAMED_PIPE
Definition: iotypes.h:1782

Referenced by NpCreateExistingNamedPipe(), NpCreateNewNamedPipe(), NpOpenNamedPipeFileSystem(), NpOpenNamedPipeRootDirectory(), NpSetClosingPipeState(), NpSetConnectedPipeState(), and NpSetDisconnectedPipeState().

◆ NpSetListeningPipeState()

NTSTATUS NTAPI NpSetListeningPipeState ( IN PNP_CCB  Ccb,
IN PIRP  Irp,
IN PLIST_ENTRY  List 
)

Definition at line 188 of file statesup.c.

191{
193
194 switch (Ccb->NamedPipeState)
195 {
197
199 &Ccb->Fcb->FullName,
201 List);
202 if (!NT_SUCCESS(Status)) return Status;
203
204 //
205 // Drop down on purpose
206 //
207
209
211 {
212 Ccb->NamedPipeState = FILE_PIPE_LISTENING_STATE;
214 }
215
217 if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
218 {
219 return STATUS_CANCELLED;
220 }
221
222 Ccb->NamedPipeState = FILE_PIPE_LISTENING_STATE;
224 InsertTailList(&Ccb->IrpList, &Irp->Tail.Overlay.ListEntry);
225 return STATUS_PENDING;
226
229 break;
230
233 break;
234
235 default:
236 NpBugCheck(Ccb->NamedPipeState, 0, 0);
237 break;
238 }
239
240 return Status;
241}
#define FILE_PIPE_COMPLETE_OPERATION
Definition: iotypes.h:80
#define STATUS_PIPE_CONNECTED
Definition: ntstatus.h:414
#define STATUS_PIPE_LISTENING
Definition: ntstatus.h:415
#define STATUS_PIPE_CLOSING
Definition: ntstatus.h:413
VOID NTAPI NpCancelListeningQueueIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: statesup.c:20

Referenced by NpListen().

◆ NpUninitializeDataQueue()

NTSTATUS NTAPI NpUninitializeDataQueue ( IN PNP_DATA_QUEUE  DataQueue)

Definition at line 20 of file datasup.c.

21{
22 PAGED_CODE();
23
24 ASSERT(DataQueue->QueueState == Empty);
25
26 RtlZeroMemory(DataQueue, sizeof(*DataQueue));
27 return STATUS_SUCCESS;
28}

Referenced by NpCreateCcb(), and NpDeleteCcb().

◆ NpUninitializeSecurity()

VOID NTAPI NpUninitializeSecurity ( IN PNP_CCB  Ccb)

Definition at line 72 of file secursup.c.

73{
74 PAGED_CODE();
75
76 NpFreeClientSecurityContext(Ccb->ClientContext);
77 Ccb->ClientContext = NULL;
78}

Referenced by NpCreateClientEnd(), NpDeleteCcb(), NpDisconnect(), NpInitializeSecurity(), NpListen(), NpSetClosingPipeState(), and NpSetDisconnectedPipeState().

◆ NpWriteDataQueue()

NTSTATUS NTAPI NpWriteDataQueue ( IN PNP_DATA_QUEUE  WriteQueue,
IN ULONG  Mode,
IN PVOID  OutBuffer,
IN ULONG  OutBufferSize,
IN ULONG  PipeType,
OUT PULONG  BytesWritten,
IN PNP_CCB  Ccb,
IN ULONG  NamedPipeEnd,
IN PETHREAD  Thread,
IN PLIST_ENTRY  List 
)

Definition at line 20 of file writesup.c.

30{
31 BOOLEAN HaveContext = FALSE, MoreProcessing, AllocatedBuffer;
32 PNP_DATA_QUEUE_ENTRY DataEntry;
34 PIRP WriteIrp;
35 PIO_STACK_LOCATION IoStack;
39 PAGED_CODE();
40
41 *BytesNotWritten = OutBufferSize;
42
43 MoreProcessing = TRUE;
44 if ((PipeType != FILE_PIPE_MESSAGE_MODE) || (OutBufferSize))
45 {
46 MoreProcessing = FALSE;
47 }
48
49 for (DataEntry = CONTAINING_RECORD(NpGetNextRealDataQueueEntry(WriteQueue, List),
51 QueueEntry);
52 ((WriteQueue->QueueState == ReadEntries) &&
53 ((*BytesNotWritten > 0) || (MoreProcessing)));
54 DataEntry = CONTAINING_RECORD(NpGetNextRealDataQueueEntry(WriteQueue, List),
56 QueueEntry))
57 {
58 DataSize = DataEntry->DataSize;
59
60 IoStack = IoGetCurrentIrpStackLocation(DataEntry->Irp);
61
64 (DataSize < OutBufferSize || MoreProcessing))
65 {
66 WriteIrp = NpRemoveDataQueueEntry(WriteQueue, TRUE, List);
67 if (WriteIrp)
68 {
70 InsertTailList(List, &WriteIrp->Tail.Overlay.ListEntry);
71 }
72 continue;
73 }
74
75 if (DataEntry->DataEntryType == Unbuffered)
76 {
77 DataEntry->Irp->Overlay.AllocationSize.QuadPart = 0;
78 }
79
80 BufferSize = *BytesNotWritten;
82
83 if (DataEntry->DataEntryType != Unbuffered && BufferSize)
84 {
87 AllocatedBuffer = TRUE;
88 }
89 else
90 {
92 AllocatedBuffer = FALSE;
93 }
94
96 {
98 (PVOID)((ULONG_PTR)OutBuffer + OutBufferSize - *BytesNotWritten),
100 }
102 {
103 if (AllocatedBuffer) ExFreePool(Buffer);
105 }
106 _SEH2_END;
107
108 if (!HaveContext)
109 {
110 HaveContext = TRUE;
112 if (!NT_SUCCESS(Status))
113 {
114 if (AllocatedBuffer) ExFreePool(Buffer);
115 return Status;
116 }
117
118 if (ClientContext)
119 {
120 NpFreeClientSecurityContext(Ccb->ClientContext);
121 Ccb->ClientContext = ClientContext;
122 }
123 }
124
125 WriteIrp = NpRemoveDataQueueEntry(WriteQueue, TRUE, List);
126 if (WriteIrp)
127 {
128 *BytesNotWritten -= BufferSize;
129 WriteIrp->IoStatus.Information = BufferSize;
130
131 if (AllocatedBuffer)
132 {
135 }
136
137 if (!*BytesNotWritten)
138 {
139 MoreProcessing = FALSE;
140 WriteIrp->IoStatus.Status = STATUS_SUCCESS;
141 InsertTailList(List, &WriteIrp->Tail.Overlay.ListEntry);
142 continue;
143 }
144
146 {
148 }
149 else
150 {
151 WriteIrp->IoStatus.Status = STATUS_SUCCESS;
152 }
153
154 InsertTailList(List, &WriteIrp->Tail.Overlay.ListEntry);
155 }
156 else if (AllocatedBuffer)
157 {
159 }
160 }
161
162 if (*BytesNotWritten > 0 || MoreProcessing)
163 {
164 ASSERT(WriteQueue->QueueState != ReadEntries);
166 }
167 else
168 {
170 }
171
172 return Status;
173}
#define FSCTL_PIPE_INTERNAL_READ_OVFLOW
Definition: winioctl.h:206
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
struct _IO_STACK_LOCATION::@3978::@3993 FileSystemControl
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
#define IRP_DEALLOCATE_BUFFER
#define IRP_INPUT_OPERATION
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_BUFFERED_IO

Referenced by NpCommonWrite(), and NpTransceive().

Variable Documentation

◆ Buffer

◆ DeviceObject

◆ FileOffset

_In_ PLARGE_INTEGER FileOffset

Definition at line 636 of file npfs.h.

◆ IoStatus

◆ Length

Definition at line 637 of file npfs.h.

◆ LockKey

Definition at line 639 of file npfs.h.

◆ NpAliasList

PNPFS_ALIAS NpAliasList
extern

Definition at line 20 of file main.c.

Referenced by NpInitializeAliases(), and NpTranslateAlias().

◆ NpAliasListByLength

PNPFS_ALIAS NpAliasListByLength[MAX_INDEXED_LENGTH+1 - MIN_INDEXED_LENGTH]
extern

Definition at line 21 of file main.c.

Referenced by NpInitializeAliases(), and NpTranslateAlias().

◆ NpVcb

◆ Wait

Definition at line 638 of file npfs.h.