ReactOS  0.4.13-dev-1148-g9b75b67
context.c File Reference
#include "afd.h"
Include dependency graph for context.c:

Go to the source code of this file.

Functions

NTSTATUS NTAPI AfdGetContext (PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS NTAPI AfdGetContextSize (PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
 
NTSTATUS NTAPI AfdSetContext (PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
 

Function Documentation

◆ AfdGetContext()

NTSTATUS NTAPI AfdGetContext ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 14 of file context.c.

15  {
18  PAFD_FCB FCB = FileObject->FsContext;
19  UINT ContextSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
20 
22 
23  if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
24 
25  if( FCB->ContextSize < ContextSize ) ContextSize = FCB->ContextSize;
26 
27  if( FCB->Context ) {
28  RtlCopyMemory( Irp->UserBuffer,
29  FCB->Context,
30  ContextSize );
32  }
33 
34  AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
35 
37 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define MID_TRACE
Definition: debug.h:15
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
Definition: cdstruc.h:908
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN SocketAcquireStateLock(PAFD_FCB FCB)
Definition: lock.c:360
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T ContextSize
Definition: fltkernel.h:1444
NTSTATUS NTAPI UnlockAndMaybeComplete(PAFD_FCB FCB, NTSTATUS Status, PIRP Irp, UINT Information)
Definition: lock.c:375
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
Definition: afd.h:161
* PFILE_OBJECT
Definition: iotypes.h:1955
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
NTSTATUS LostSocket(PIRP Irp)
Definition: lock.c:387
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
unsigned int UINT
Definition: ndis.h:50
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by AfdDispatch().

◆ AfdGetContextSize()

NTSTATUS NTAPI AfdGetContextSize ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 40 of file context.c.

42 {
44  PAFD_FCB FCB = FileObject->FsContext;
45 
47 
48  if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
49 
50  if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG))
51  {
52  AFD_DbgPrint(MIN_TRACE,("Buffer too small\n"));
54  }
55 
56  RtlCopyMemory(Irp->UserBuffer,
57  &FCB->ContextSize,
58  sizeof(ULONG));
59 
61 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
Definition: cdstruc.h:908
BOOLEAN SocketAcquireStateLock(PAFD_FCB FCB)
Definition: lock.c:360
NTSTATUS NTAPI UnlockAndMaybeComplete(PAFD_FCB FCB, NTSTATUS Status, PIRP Irp, UINT Information)
Definition: lock.c:375
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
Definition: afd.h:161
* PFILE_OBJECT
Definition: iotypes.h:1955
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
NTSTATUS LostSocket(PIRP Irp)
Definition: lock.c:387
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by AfdDispatch().

◆ AfdSetContext()

NTSTATUS NTAPI AfdSetContext ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PIO_STACK_LOCATION  IrpSp 
)

Definition at line 64 of file context.c.

65  {
67  PAFD_FCB FCB = FileObject->FsContext;
69 
71 
72  if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
73 
74  if (!Context)
76 
77  if( FCB->Context ) {
79  FCB->ContextSize = 0;
80  }
81 
83  IrpSp->Parameters.DeviceIoControl.InputBufferLength,
85 
86  if( !FCB->Context ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 );
87 
88  FCB->ContextSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
89 
90  RtlCopyMemory( FCB->Context,
91  Context,
92  FCB->ContextSize );
93 
95 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
Definition: cdstruc.h:908
PVOID LockRequest(PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Output, KPROCESSOR_MODE *LockMode)
Definition: lock.c:24
BOOLEAN SocketAcquireStateLock(PAFD_FCB FCB)
Definition: lock.c:360
NTSTATUS NTAPI UnlockAndMaybeComplete(PAFD_FCB FCB, NTSTATUS Status, PIRP Irp, UINT Information)
Definition: lock.c:375
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
Definition: afd.h:161
* PFILE_OBJECT
Definition: iotypes.h:1955
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
NTSTATUS LostSocket(PIRP Irp)
Definition: lock.c:387
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define TAG_AFD_SOCKET_CONTEXT
Definition: afd.h:40

Referenced by AfdDispatch().