Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencontext.c
Go to the documentation of this file.
00001 /* $Id: context.c 56389 2012-04-22 13:11:54Z tfaber $ 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS kernel 00004 * FILE: drivers/net/afd/afd/context.c 00005 * PURPOSE: Ancillary functions driver 00006 * PROGRAMMER: Art Yerkes (ayerkes@speakeasy.net) 00007 * UPDATE HISTORY: 00008 * 20040708 Created 00009 */ 00010 #include "afd.h" 00011 00012 NTSTATUS NTAPI 00013 AfdGetContext( PDEVICE_OBJECT DeviceObject, PIRP Irp, 00014 PIO_STACK_LOCATION IrpSp ) { 00015 NTSTATUS Status = STATUS_INVALID_PARAMETER; 00016 PFILE_OBJECT FileObject = IrpSp->FileObject; 00017 PAFD_FCB FCB = FileObject->FsContext; 00018 UINT ContextSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength; 00019 00020 if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); 00021 00022 if( FCB->ContextSize < ContextSize ) ContextSize = FCB->ContextSize; 00023 00024 if( FCB->Context ) { 00025 RtlCopyMemory( Irp->UserBuffer, 00026 FCB->Context, 00027 ContextSize ); 00028 Status = STATUS_SUCCESS; 00029 } 00030 00031 AFD_DbgPrint(MID_TRACE,("Returning %x\n", Status)); 00032 00033 return UnlockAndMaybeComplete( FCB, Status, Irp, ContextSize ); 00034 } 00035 00036 NTSTATUS NTAPI 00037 AfdGetContextSize( PDEVICE_OBJECT DeviceObject, PIRP Irp, 00038 PIO_STACK_LOCATION IrpSp ) 00039 { 00040 PFILE_OBJECT FileObject = IrpSp->FileObject; 00041 PAFD_FCB FCB = FileObject->FsContext; 00042 00043 if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); 00044 00045 if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG)) 00046 { 00047 AFD_DbgPrint(MIN_TRACE,("Buffer too small\n")); 00048 return UnlockAndMaybeComplete(FCB, STATUS_BUFFER_TOO_SMALL, Irp, sizeof(ULONG)); 00049 } 00050 00051 RtlCopyMemory(Irp->UserBuffer, 00052 &FCB->ContextSize, 00053 sizeof(ULONG)); 00054 00055 return UnlockAndMaybeComplete(FCB, STATUS_SUCCESS, Irp, sizeof(ULONG)); 00056 } 00057 00058 NTSTATUS NTAPI 00059 AfdSetContext( PDEVICE_OBJECT DeviceObject, PIRP Irp, 00060 PIO_STACK_LOCATION IrpSp ) { 00061 PFILE_OBJECT FileObject = IrpSp->FileObject; 00062 PAFD_FCB FCB = FileObject->FsContext; 00063 PVOID Context = LockRequest(Irp, IrpSp); 00064 00065 if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); 00066 00067 if (!Context) 00068 return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0); 00069 00070 if( FCB->Context ) { 00071 ExFreePool( FCB->Context ); 00072 FCB->ContextSize = 0; 00073 } 00074 00075 FCB->Context = ExAllocatePool( PagedPool, 00076 IrpSp->Parameters.DeviceIoControl.InputBufferLength ); 00077 00078 if( !FCB->Context ) return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 ); 00079 00080 FCB->ContextSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength; 00081 00082 RtlCopyMemory( FCB->Context, 00083 Context, 00084 FCB->ContextSize ); 00085 00086 return UnlockAndMaybeComplete( FCB, STATUS_SUCCESS, Irp, 0 ); 00087 } Generated on Sat May 26 2012 04:18:59 for ReactOS by
1.7.6.1
|