NTSTATUS TdiQueryMaxDatagramLength( PFILE_OBJECT FileObject, PUINT MaxDatagramLength) { PMDL Mdl; PTDI_MAX_DATAGRAM_INFO Buffer; NTSTATUS Status = STATUS_SUCCESS; Buffer = ExAllocatePool(NonPagedPool, sizeof(TDI_MAX_DATAGRAM_INFO)); if (!Buffer) return STATUS_NO_MEMORY; Mdl = IoAllocateMdl(Buffer, sizeof(TDI_MAX_DATAGRAM_INFO), FALSE, FALSE, NULL); if (!Mdl) { ExFreePool(Buffer); return STATUS_NO_MEMORY; } _SEH2_TRY { MmProbeAndLockPages(Mdl, KernelMode, IoModifyAccess); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END; if (!NT_SUCCESS(Status)) { AFD_DbgPrint(MIN_TRACE,("Failed to lock pages\n")); IoFreeMdl(Mdl); ExFreePool(Buffer); return Status; } Status = TdiQueryInformation(FileObject, TDI_QUERY_MAX_DATAGRAM_INFO, Mdl); if (!NT_SUCCESS(Status)) { ExFreePool(Buffer); return Status; } *MaxDatagramLength = Buffer->MaxDatagramSize; ExFreePool(Buffer); return STATUS_SUCCESS; }
NTSTATUS NTAPI AfdGetSockName( PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp ) { NTSTATUS Status = STATUS_SUCCESS; PFILE_OBJECT FileObject = IrpSp->FileObject; PAFD_FCB FCB = FileObject->FsContext; PMDL Mdl = NULL; UNREFERENCED_PARAMETER(DeviceObject); if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp ); if( FCB->AddressFile.Object == NULL && FCB->Connection.Object == NULL ) { return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0 ); } Mdl = IoAllocateMdl( Irp->UserBuffer, IrpSp->Parameters.DeviceIoControl.OutputBufferLength, FALSE, FALSE, NULL ); if( Mdl != NULL ) { _SEH2_TRY { MmProbeAndLockPages( Mdl, Irp->RequestorMode, IoModifyAccess ); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n")); Status = _SEH2_GetExceptionCode(); } _SEH2_END; if( NT_SUCCESS(Status) ) { Status = TdiQueryInformation( FCB->Connection.Object ? FCB->Connection.Object : FCB->AddressFile.Object, TDI_QUERY_ADDRESS_INFO, Mdl ); } } else