ReactOS 0.4.16-dev-2284-g3529151
context.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/net/afd/afd/context.c
5 * PURPOSE: Ancillary functions driver
6 * PROGRAMMER: Art Yerkes (ayerkes@speakeasy.net)
7 * UPDATE HISTORY:
8 * 20040708 Created
9 */
10
11#include "afd.h"
12
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 (ContextSize == sizeof(FCB->SharedData))
26 {
27 RtlCopyMemory(Irp->UserBuffer,
28 &FCB->SharedData,
31 }
32 else if (FCB->Context)
33 {
34 ContextSize = min(ContextSize, FCB->ContextSize);
35 RtlCopyMemory( Irp->UserBuffer,
36 FCB->Context,
39 }
40
41 AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status));
42
44}
45
49{
51 PAFD_FCB FCB = FileObject->FsContext;
52
54
55 if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
56
57 if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG))
58 {
59 AFD_DbgPrint(MIN_TRACE,("Buffer too small\n"));
61 }
62
63 RtlCopyMemory(Irp->UserBuffer,
64 &FCB->ContextSize,
65 sizeof(ULONG));
66
68}
69
74 PAFD_FCB FCB = FileObject->FsContext;
76
78
79 if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
80
81 if (!Context)
83
84 if( FCB->Context ) {
86 FCB->ContextSize = 0;
87 }
88
90 IrpSp->Parameters.DeviceIoControl.InputBufferLength,
92
93 if( !FCB->Context ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 );
94
95 FCB->ContextSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
96
97 RtlCopyMemory( FCB->Context,
98 Context,
99 FCB->ContextSize );
100
102}
#define TAG_AFD_SOCKET_CONTEXT
Definition: afd.h:40
LONG NTSTATUS
Definition: precomp.h:26
#define MIN_TRACE
Definition: debug.h:14
#define MID_TRACE
Definition: debug.h:15
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4138
NTSTATUS NTAPI AfdSetContext(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: context.c:71
NTSTATUS NTAPI AfdGetContextSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: context.c:47
NTSTATUS NTAPI AfdGetContext(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: context.c:14
PVOID LockRequest(PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Output, KPROCESSOR_MODE *LockMode)
Definition: lock.c:24
NTSTATUS LostSocket(PIRP Irp)
Definition: lock.c:387
NTSTATUS NTAPI UnlockAndMaybeComplete(PAFD_FCB FCB, NTSTATUS Status, PIRP Irp, UINT Information)
Definition: lock.c:375
BOOLEAN SocketAcquireStateLock(PAFD_FCB FCB)
Definition: lock.c:360
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T ContextSize
Definition: fltkernel.h:1444
Status
Definition: gdiplustypes.h:25
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
Definition: afd.h:161
Definition: cdstruc.h:902
PFILE_OBJECT FileObject
Definition: iotypes.h:3171
struct _IO_STACK_LOCATION::@1658::@1659 DeviceIoControl
union _IO_STACK_LOCATION::@1658 Parameters
#define NTAPI
Definition: typedefs.h:36
#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
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
* PFILE_OBJECT
Definition: iotypes.h:1998