ReactOS 0.4.15-dev-5669-g09dde2c
main.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/main.c
5 * PURPOSE: Ancillary functions driver
6 * PROGRAMMER: Art Yerkes (ayerkes@speakeasy.net)
7 * UPDATE HISTORY:
8 * 20040630 Created
9 *
10 * Suggestions: Uniform naming (AfdXxx)
11 */
12
13/* INCLUDES */
14
15#include "afd.h"
16
17#if DBG
18
19/* See debug.h for debug/trace constants */
20//DWORD DebugTraceLevel = DEBUG_ULTRA;
22
23#endif /* DBG */
24
25/* FIXME: should depend on SystemSize */
28
30 unsigned int i;
31
32 for( i = 0; i < Len; i++ ) {
33 if( i && !(i & 0xf) ) DbgPrint( "\n" );
34 if( !(i & 0xf) ) DbgPrint( "%p: ", (Data + i) );
35 DbgPrint( " %02x", Data[i] & 0xff );
36 }
37 DbgPrint("\n");
38}
39
40/* FUNCTIONS */
41
44
48{
50 PAFD_FCB FCB = FileObject->FsContext;
51 UINT BufferSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
52
54
56
57 if (FCB->DisconnectOptionsSize == 0)
58 {
59 AFD_DbgPrint(MIN_TRACE,("Invalid parameter\n"));
61 }
62
63 ASSERT(FCB->DisconnectOptions);
64
65 if (FCB->FilledDisconnectOptions < BufferSize) BufferSize = FCB->FilledDisconnectOptions;
66
67 RtlCopyMemory(Irp->UserBuffer,
68 FCB->DisconnectOptions,
70
72}
73
78{
80 PAFD_FCB FCB = FileObject->FsContext;
81 PVOID DisconnectOptions = LockRequest(Irp, IrpSp, FALSE, NULL);
82 UINT DisconnectOptionsSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
83
85
87
88 if (!DisconnectOptions)
90
91 if (FCB->DisconnectOptions)
92 {
94 FCB->DisconnectOptions = NULL;
95 FCB->DisconnectOptionsSize = 0;
96 FCB->FilledDisconnectOptions = 0;
97 }
98
99 FCB->DisconnectOptions = ExAllocatePoolWithTag(PagedPool,
100 DisconnectOptionsSize,
102
103 if (!FCB->DisconnectOptions)
105
106 RtlCopyMemory(FCB->DisconnectOptions,
107 DisconnectOptions,
108 DisconnectOptionsSize);
109
110 FCB->DisconnectOptionsSize = DisconnectOptionsSize;
111
113}
114
116NTAPI
119{
121 PAFD_FCB FCB = FileObject->FsContext;
122 PUINT DisconnectOptionsSize = LockRequest(Irp, IrpSp, FALSE, NULL);
123 UINT BufferSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
124
126
128
129 if (!DisconnectOptionsSize)
131
132 if (BufferSize < sizeof(UINT))
133 {
134 AFD_DbgPrint(MIN_TRACE,("Buffer too small\n"));
136 }
137
138 if (FCB->DisconnectOptions)
139 {
141 FCB->DisconnectOptionsSize = 0;
142 FCB->FilledDisconnectOptions = 0;
143 }
144
145 FCB->DisconnectOptions = ExAllocatePoolWithTag(PagedPool,
146 *DisconnectOptionsSize,
148
149 if (!FCB->DisconnectOptions) return UnlockAndMaybeComplete(FCB, STATUS_NO_MEMORY, Irp, 0);
150
151 FCB->DisconnectOptionsSize = *DisconnectOptionsSize;
152
154}
155
159{
161 PAFD_FCB FCB = FileObject->FsContext;
162 UINT BufferSize = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
163
165
167
168 if (FCB->DisconnectDataSize == 0)
169 {
170 AFD_DbgPrint(MIN_TRACE,("Invalid parameter\n"));
172 }
173
174 ASSERT(FCB->DisconnectData);
175
176 if (FCB->FilledDisconnectData < BufferSize)
177 BufferSize = FCB->FilledDisconnectData;
178
179 RtlCopyMemory(Irp->UserBuffer,
180 FCB->DisconnectData,
181 BufferSize);
182
184}
185
187NTAPI
190{
192 PAFD_FCB FCB = FileObject->FsContext;
193 PVOID DisconnectData = LockRequest(Irp, IrpSp, FALSE, NULL);
194 UINT DisconnectDataSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
195
197
199
200 if (!DisconnectData)
202
203 if (FCB->DisconnectData)
204 {
206 FCB->DisconnectData = NULL;
207 FCB->DisconnectDataSize = 0;
208 FCB->FilledDisconnectData = 0;
209 }
210
211 FCB->DisconnectData = ExAllocatePoolWithTag(PagedPool,
212 DisconnectDataSize,
214
215 if (!FCB->DisconnectData)
217
218 RtlCopyMemory(FCB->DisconnectData,
219 DisconnectData,
220 DisconnectDataSize);
221
222 FCB->DisconnectDataSize = DisconnectDataSize;
223
225}
226
228NTAPI
231{
233 PAFD_FCB FCB = FileObject->FsContext;
234 PUINT DisconnectDataSize = LockRequest(Irp, IrpSp, FALSE, NULL);
235 UINT BufferSize = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
236
238
240
241 if (!DisconnectDataSize)
243
244 if (BufferSize < sizeof(UINT))
245 {
246 AFD_DbgPrint(MIN_TRACE,("Buffer too small\n"));
248 }
249
250 if (FCB->DisconnectData)
251 {
253 FCB->DisconnectDataSize = 0;
254 FCB->FilledDisconnectData = 0;
255 }
256
257 FCB->DisconnectData = ExAllocatePoolWithTag(PagedPool,
258 *DisconnectDataSize,
260
261 if (!FCB->DisconnectData)
263
264 FCB->DisconnectDataSize = *DisconnectDataSize;
265
267}
268
269static NTSTATUS NTAPI
272{
274 PAFD_FCB FCB = FileObject->FsContext;
275 PULONG HandleFlags = LockRequest(Irp, IrpSp, TRUE, NULL);
276 PAFD_TDI_HANDLE_DATA HandleData = Irp->UserBuffer;
277
279
281
282 if (!HandleFlags)
284
285 if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(ULONG) ||
286 IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(*HandleData))
287 {
288 AFD_DbgPrint(MIN_TRACE,("Buffer too small\n"));
290 }
291
292 if ((*HandleFlags) & AFD_ADDRESS_HANDLE)
293 HandleData->TdiAddressHandle = FCB->AddressFile.Handle;
294
295 if ((*HandleFlags) & AFD_CONNECTION_HANDLE)
296 HandleData->TdiConnectionHandle = FCB->Connection.Handle;
297
299}
300
301static NTSTATUS NTAPI
306 PAFD_DEVICE_EXTENSION DeviceExt;
308 PAFD_CREATE_PACKET ConnectInfo = NULL;
309 //ULONG EaLength;
310 PWCHAR EaInfoValue = NULL;
311 //UINT Disposition;
312 UINT i;
314
315 AFD_DbgPrint(MID_TRACE,("AfdCreate(DeviceObject %p Irp %p)\n",
316 DeviceObject, Irp));
317
318 DeviceExt = DeviceObject->DeviceExtension;
320 FileObject->Flags |= FO_NAMED_PIPE;
321 //Disposition = (IrpSp->Parameters.Create.Options >> 24) & 0xff;
322
323 Irp->IoStatus.Information = 0;
324
325 EaInfo = Irp->AssociatedIrp.SystemBuffer;
326
327 if( EaInfo ) {
328 ConnectInfo = (PAFD_CREATE_PACKET)(EaInfo->EaName + EaInfo->EaNameLength + 1);
329 EaInfoValue = (PWCHAR)(((PCHAR)ConnectInfo) + sizeof(AFD_CREATE_PACKET));
330
331 //EaLength = sizeof(FILE_FULL_EA_INFORMATION) + EaInfo->EaNameLength + EaInfo->EaValueLength;
332
333 AFD_DbgPrint(MID_TRACE,("EaInfo: %p, EaInfoValue: %p\n",
334 EaInfo, EaInfoValue));
335 }
336
337 AFD_DbgPrint(MID_TRACE,("About to allocate the new FCB\n"));
338
340 if( FCB == NULL ) {
341 Irp->IoStatus.Status = STATUS_NO_MEMORY;
343 return STATUS_NO_MEMORY;
344 }
345
346 AFD_DbgPrint(MID_TRACE,("Initializing the new FCB @ %p (FileObject %p Flags %x)\n",
347 FCB, FileObject, ConnectInfo ? ConnectInfo->EndpointFlags : 0));
348
349 RtlZeroMemory( FCB, sizeof( *FCB ) );
350
351 FCB->Flags = ConnectInfo ? ConnectInfo->EndpointFlags : 0;
352 FCB->GroupID = ConnectInfo ? ConnectInfo->GroupID : 0;
353 FCB->GroupType = 0; /* FIXME */
354 FCB->State = SOCKET_STATE_CREATED;
356 FCB->DeviceExt = DeviceExt;
357 FCB->AddressFile.Handle = INVALID_HANDLE_VALUE;
358 FCB->Connection.Handle = INVALID_HANDLE_VALUE;
359 FCB->Recv.Size = AfdReceiveWindowSize;
360 FCB->Send.Size = AfdSendWindowSize;
361
362 KeInitializeMutex( &FCB->Mutex, 0 );
363
364 for( i = 0; i < MAX_FUNCTIONS; i++ ) {
365 InitializeListHead( &FCB->PendingIrpList[i] );
366 }
367
368 InitializeListHead( &FCB->DatagramList );
369 InitializeListHead( &FCB->PendingConnections );
370
371 AFD_DbgPrint(MID_TRACE,("%p: Checking command channel\n", FCB));
372
373 if( ConnectInfo ) {
374 FCB->TdiDeviceName.Length = ConnectInfo->SizeOfTransportName;
375 FCB->TdiDeviceName.MaximumLength = FCB->TdiDeviceName.Length;
376 FCB->TdiDeviceName.Buffer = ExAllocatePoolWithTag(NonPagedPool,
377 FCB->TdiDeviceName.Length,
379
380 if( !FCB->TdiDeviceName.Buffer ) {
382 AFD_DbgPrint(MID_TRACE,("Could not copy target string\n"));
383 Irp->IoStatus.Status = STATUS_NO_MEMORY;
385 return STATUS_NO_MEMORY;
386 }
387
388 RtlCopyMemory( FCB->TdiDeviceName.Buffer,
389 ConnectInfo->TransportName,
390 FCB->TdiDeviceName.Length );
391
392 AFD_DbgPrint(MID_TRACE,("Success: %s %wZ\n",
393 EaInfo->EaName, &FCB->TdiDeviceName));
394 } else {
395 AFD_DbgPrint(MID_TRACE,("Success: Control connection\n"));
396 }
397
398 FileObject->FsContext = FCB;
399
400 /* It seems that UDP sockets are writable from inception */
402 AFD_DbgPrint(MID_TRACE,("Packet oriented socket\n"));
403
404 /* A datagram socket is always sendable */
405 FCB->PollState |= AFD_EVENT_SEND;
406 FCB->PollStatus[FD_WRITE_BIT] = STATUS_SUCCESS;
407 PollReeval( FCB->DeviceExt, FCB->FileObject );
408 }
409
410 if( !NT_SUCCESS(Status) ) {
411 if (FCB->TdiDeviceName.Buffer)
412 {
413 ExFreePoolWithTag(FCB->TdiDeviceName.Buffer, TAG_AFD_TRANSPORT_ADDRESS);
414 }
416 FileObject->FsContext = NULL;
417 }
418
419 Irp->IoStatus.Status = Status;
421
422 return Status;
423}
424
425static NTSTATUS NTAPI
428{
430 PAFD_FCB FCB = FileObject->FsContext;
431 PLIST_ENTRY CurrentEntry, NextEntry;
433 PIRP CurrentIrp;
434
436
437 if( !SocketAcquireStateLock( FCB ) ) return LostSocket(Irp);
438
440 {
441 CurrentEntry = FCB->PendingIrpList[Function].Flink;
442 while (CurrentEntry != &FCB->PendingIrpList[Function])
443 {
444 NextEntry = CurrentEntry->Flink;
445 CurrentIrp = CONTAINING_RECORD(CurrentEntry, IRP, Tail.Overlay.ListEntry);
446
447 /* The cancel routine will remove the IRP from the list */
448 IoCancelIrp(CurrentIrp);
449
450 CurrentEntry = NextEntry;
451 }
452 }
453
454 KillSelectsForFCB( FCB->DeviceExt, FileObject, FALSE );
455
457}
458
459static NTSTATUS NTAPI
462{
464 PAFD_FCB FCB = FileObject->FsContext;
465 UINT i;
468 PLIST_ENTRY QeltEntry;
469
470
471 AFD_DbgPrint(MID_TRACE,("AfdClose(DeviceObject %p Irp %p)\n",
472 DeviceObject, Irp));
473
475
476 FCB->State = SOCKET_STATE_CLOSED;
477
478 InFlightRequest[0] = &FCB->ListenIrp;
479 InFlightRequest[1] = &FCB->ReceiveIrp;
480 InFlightRequest[2] = &FCB->SendIrp;
481 InFlightRequest[3] = &FCB->ConnectIrp;
482 InFlightRequest[4] = &FCB->DisconnectIrp;
483
484 /* Cancel our pending requests */
485 for( i = 0; i < IN_FLIGHT_REQUESTS; i++ ) {
486 if( InFlightRequest[i]->InFlightRequest ) {
487 AFD_DbgPrint(MID_TRACE,("Cancelling in flight irp %u (%p)\n",
488 i, InFlightRequest[i]->InFlightRequest));
489 IoCancelIrp(InFlightRequest[i]->InFlightRequest);
490 }
491 }
492
493 KillSelectsForFCB( FCB->DeviceExt, FileObject, FALSE );
494
495 ASSERT(IsListEmpty(&FCB->PendingIrpList[FUNCTION_CONNECT]));
496 ASSERT(IsListEmpty(&FCB->PendingIrpList[FUNCTION_SEND]));
497 ASSERT(IsListEmpty(&FCB->PendingIrpList[FUNCTION_RECV]));
498 ASSERT(IsListEmpty(&FCB->PendingIrpList[FUNCTION_PREACCEPT]));
499 ASSERT(IsListEmpty(&FCB->PendingIrpList[FUNCTION_DISCONNECT]));
500
501 while (!IsListEmpty(&FCB->PendingConnections))
502 {
503 QeltEntry = RemoveHeadList(&FCB->PendingConnections);
504 Qelt = CONTAINING_RECORD(QeltEntry, AFD_TDI_OBJECT_QELT, ListEntry);
505
506 /* We have to close all pending connections or the listen won't get closed */
509 ZwClose(Qelt->Object.Handle);
510
512 }
513
515
516 if( FCB->EventSelect )
517 ObDereferenceObject( FCB->EventSelect );
518
519 if (FCB->Context)
521
522 if (FCB->Recv.Window)
524
525 if (FCB->Send.Window)
527
528 if (FCB->AddressFrom)
530
531 if (FCB->ConnectCallInfo)
533
534 if (FCB->ConnectReturnInfo)
536
537 if (FCB->ConnectData)
539
540 if (FCB->DisconnectData)
542
543 if (FCB->ConnectOptions)
545
546 if (FCB->DisconnectOptions)
548
549 if (FCB->LocalAddress)
551
552 if (FCB->RemoteAddress)
554
555 if( FCB->Connection.Object )
556 {
557 TdiDisassociateAddressFile(FCB->Connection.Object);
558 ObDereferenceObject(FCB->Connection.Object);
559 }
560
561 if( FCB->AddressFile.Object )
562 ObDereferenceObject(FCB->AddressFile.Object);
563
564 if( FCB->AddressFile.Handle != INVALID_HANDLE_VALUE )
565 {
566 if (ZwClose(FCB->AddressFile.Handle) == STATUS_INVALID_HANDLE)
567 {
568 DbgPrint("INVALID ADDRESS FILE HANDLE VALUE: %p %p\n", FCB->AddressFile.Handle, FCB->AddressFile.Object);
569 }
570 }
571
572 if( FCB->Connection.Handle != INVALID_HANDLE_VALUE )
573 {
574 if (ZwClose(FCB->Connection.Handle) == STATUS_INVALID_HANDLE)
575 {
576 DbgPrint("INVALID CONNECTION HANDLE VALUE: %p %p\n", FCB->Connection.Handle, FCB->Connection.Object);
577 }
578 }
579
580 if (FCB->TdiDeviceName.Buffer)
581 {
582 ExFreePoolWithTag(FCB->TdiDeviceName.Buffer, TAG_AFD_TRANSPORT_ADDRESS);
583 }
584
586
587 Irp->IoStatus.Status = STATUS_SUCCESS;
588 Irp->IoStatus.Information = 0;
590
591 AFD_DbgPrint(MID_TRACE, ("Returning success.\n"));
592
593 return STATUS_SUCCESS;
594}
595
596static IO_COMPLETION_ROUTINE DisconnectComplete;
597static
599NTAPI
601 PIRP Irp,
603{
605 PIRP CurrentIrp;
606 PLIST_ENTRY CurrentEntry;
607
609
611 return STATUS_FILE_CLOSED;
612
613 ASSERT(FCB->DisconnectIrp.InFlightRequest == Irp);
614 FCB->DisconnectIrp.InFlightRequest = NULL;
615
616 ASSERT(FCB->DisconnectPending);
617 ASSERT((IsListEmpty(&FCB->PendingIrpList[FUNCTION_SEND]) && !FCB->SendIrp.InFlightRequest) ||
618 (FCB->DisconnectFlags & TDI_DISCONNECT_ABORT));
619
620 if (NT_SUCCESS(Irp->IoStatus.Status) && (FCB->DisconnectFlags & TDI_DISCONNECT_RELEASE))
621 {
622 FCB->FilledDisconnectData = MIN(FCB->DisconnectDataSize, FCB->ConnectReturnInfo->UserDataLength);
623 if (FCB->FilledDisconnectData)
624 {
625 RtlCopyMemory(FCB->DisconnectData,
626 FCB->ConnectReturnInfo->UserData,
627 FCB->FilledDisconnectData);
628 }
629
630 FCB->FilledDisconnectOptions = MIN(FCB->DisconnectOptionsSize, FCB->ConnectReturnInfo->OptionsLength);
631 if (FCB->FilledDisconnectOptions)
632 {
633 RtlCopyMemory(FCB->DisconnectOptions,
634 FCB->ConnectReturnInfo->Options,
635 FCB->FilledDisconnectOptions);
636 }
637 }
638
639 FCB->DisconnectPending = FALSE;
640
641 while (!IsListEmpty(&FCB->PendingIrpList[FUNCTION_DISCONNECT]))
642 {
643 CurrentEntry = RemoveHeadList(&FCB->PendingIrpList[FUNCTION_DISCONNECT]);
644 CurrentIrp = CONTAINING_RECORD(CurrentEntry, IRP, Tail.Overlay.ListEntry);
645 CurrentIrp->IoStatus.Status = Irp->IoStatus.Status;
646 CurrentIrp->IoStatus.Information = 0;
647 UnlockRequest(CurrentIrp, IoGetCurrentIrpStackLocation(CurrentIrp));
648 (void)IoSetCancelRoutine(CurrentIrp, NULL);
650 }
651
652 if (!(FCB->DisconnectFlags & TDI_DISCONNECT_RELEASE))
653 {
654 /* Signal complete connection closure immediately */
655 FCB->PollState |= AFD_EVENT_ABORT;
656 FCB->PollStatus[FD_CLOSE_BIT] = Irp->IoStatus.Status;
657 FCB->LastReceiveStatus = STATUS_FILE_CLOSED;
658 PollReeval(FCB->DeviceExt, FCB->FileObject);
659 }
660
662
663 return Irp->IoStatus.Status;
664}
665
666static
669{
671
672 ASSERT(FCB->DisconnectPending);
673 ASSERT((IsListEmpty(&FCB->PendingIrpList[FUNCTION_SEND]) && !FCB->SendIrp.InFlightRequest) ||
674 (FCB->DisconnectFlags & TDI_DISCONNECT_ABORT));
675
676 if (FCB->DisconnectIrp.InFlightRequest)
677 {
678 return STATUS_PENDING;
679 }
680
681 FCB->ConnectCallInfo->UserData = FCB->DisconnectData;
682 FCB->ConnectCallInfo->UserDataLength = FCB->DisconnectDataSize;
683 FCB->ConnectCallInfo->Options = FCB->DisconnectOptions;
684 FCB->ConnectCallInfo->OptionsLength = FCB->DisconnectOptionsSize;
685
686 Status = TdiDisconnect(&FCB->DisconnectIrp.InFlightRequest,
687 FCB->Connection.Object,
688 &FCB->DisconnectTimeout,
689 FCB->DisconnectFlags,
691 FCB,
692 FCB->ConnectCallInfo,
693 FCB->ConnectReturnInfo);
694 if (Status != STATUS_PENDING)
695 {
696 FCB->DisconnectPending = FALSE;
697 }
698
699 return Status;
700}
701
702VOID
704{
705 ASSERT(FCB->RemoteAddress);
706
707 if (IsListEmpty(&FCB->PendingIrpList[FUNCTION_SEND]) && !FCB->SendIrp.InFlightRequest && FCB->DisconnectPending)
708 {
709 /* Sends are done; fire off a TDI_DISCONNECT request */
711 }
712}
713
714static NTSTATUS NTAPI
718 PAFD_FCB FCB = FileObject->FsContext;
722 PLIST_ENTRY CurrentEntry;
723 PIRP CurrentIrp;
724
726
728
729 if (!(DisReq = LockRequest(Irp, IrpSp, FALSE, NULL)))
731 Irp, 0 );
732
733 /* Send direction only */
734 if ((DisReq->DisconnectType & AFD_DISCONNECT_SEND) &&
736 {
737 /* Perform a controlled disconnect */
739 }
740 /* Receive direction or both */
741 else
742 {
743 /* Mark that we can't issue another receive request */
744 FCB->TdiReceiveClosed = TRUE;
745
746 /* Try to cancel a pending TDI receive IRP if there was one in progress */
747 if (FCB->ReceiveIrp.InFlightRequest)
748 IoCancelIrp(FCB->ReceiveIrp.InFlightRequest);
749
750 /* Discard any pending data */
751 FCB->Recv.Content = 0;
752 FCB->Recv.BytesUsed = 0;
753
754 /* Mark us as overread to complete future reads with an error */
755 FCB->Overread = TRUE;
756
757 /* Set a successful receive status to indicate a shutdown on overread */
758 FCB->LastReceiveStatus = STATUS_SUCCESS;
759
760 /* Clear the receive event */
761 FCB->PollState &= ~AFD_EVENT_RECEIVE;
762
763 /* Receive direction only */
764 if ((DisReq->DisconnectType & AFD_DISCONNECT_RECV) &&
766 {
767 /* No need to tell the transport driver for receive direction only */
769 }
770 else
771 {
772 /* Perform an abortive disconnect */
774 }
775 }
776
778 {
779 if (!FCB->ConnectCallInfo)
780 {
781 AFD_DbgPrint(MIN_TRACE,("Invalid parameter\n"));
783 Irp, 0 );
784 }
785
786 if (FCB->DisconnectPending)
787 {
788 if (FCB->DisconnectIrp.InFlightRequest)
789 {
790 IoCancelIrp(FCB->DisconnectIrp.InFlightRequest);
791 ASSERT(!FCB->DisconnectIrp.InFlightRequest);
792 }
793 else
794 {
795 while (!IsListEmpty(&FCB->PendingIrpList[FUNCTION_DISCONNECT]))
796 {
797 CurrentEntry = RemoveHeadList(&FCB->PendingIrpList[FUNCTION_DISCONNECT]);
798 CurrentIrp = CONTAINING_RECORD(CurrentEntry, IRP, Tail.Overlay.ListEntry);
799 CurrentIrp->IoStatus.Status = STATUS_CANCELLED;
800 CurrentIrp->IoStatus.Information = 0;
801 UnlockRequest(CurrentIrp, IoGetCurrentIrpStackLocation(CurrentIrp));
802 (void)IoSetCancelRoutine(CurrentIrp, NULL);
804 }
805 }
806 }
807
808 FCB->DisconnectFlags = Flags;
809 FCB->DisconnectTimeout = DisReq->Timeout;
810 FCB->DisconnectPending = TRUE;
811 FCB->SendClosed = TRUE;
812 FCB->PollState &= ~AFD_EVENT_SEND;
813
815 if (Status == STATUS_PENDING)
816 {
817 if ((IsListEmpty(&FCB->PendingIrpList[FUNCTION_SEND]) && !FCB->SendIrp.InFlightRequest) ||
818 (FCB->DisconnectFlags & TDI_DISCONNECT_ABORT))
819 {
820 /* Go ahead and execute the disconnect because we're ready for it */
822 }
823
824 if (Status != STATUS_PENDING)
825 RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
826 }
827
828 if (Status == STATUS_PENDING)
829 {
831
832 return Status;
833 }
834 }
835 else
836 {
838 {
839 if (!FCB->RemoteAddress)
840 {
841 AFD_DbgPrint(MIN_TRACE,("Invalid parameter\n"));
843 }
844
846
847 FCB->RemoteAddress = NULL;
848 }
849
850 FCB->PollState &= ~AFD_EVENT_SEND;
851 FCB->SendClosed = TRUE;
852 }
853
854 return UnlockAndMaybeComplete( FCB, Status, Irp, 0 );
855}
856
859{
860 if (*Length >= sizeof(FILE_FS_DEVICE_INFORMATION))
861 {
862 Buffer->Characteristics = 0;
863 Buffer->DeviceType = FILE_DEVICE_NAMED_PIPE;
864
866
867 return STATUS_SUCCESS;
868 }
869 else
870 {
873 }
874}
875
876static NTSTATUS NTAPI
878{
879 FS_INFORMATION_CLASS InfoClass;
883
884 Buffer = Irp->AssociatedIrp.SystemBuffer;
885 Length = IrpSp->Parameters.QueryVolume.Length;
886 InfoClass = IrpSp->Parameters.QueryVolume.FsInformationClass;
887
888 switch (InfoClass)
889 {
892 break;
893 default:
894 break;
895 }
896
897 Irp->IoStatus.Status = Status;
898 Irp->IoStatus.Information = IrpSp->Parameters.QueryVolume.Length - Length;
900
901 return Status;
902}
903
905static NTSTATUS NTAPI
907{
910#if DBG
912#endif
913
914 AFD_DbgPrint(MID_TRACE,("AfdDispatch: %u\n", IrpSp->MajorFunction));
916 AFD_DbgPrint(MID_TRACE,("FO %p, IrpSp->FO %p\n",
919 }
920
921 Irp->IoStatus.Information = 0;
922
923 switch(IrpSp->MajorFunction)
924 {
925 /* opening and closing handles to the device */
926 case IRP_MJ_CREATE:
927 /* Mostly borrowed from the named pipe file system */
929
930 case IRP_MJ_CLOSE:
931 /* Ditto the borrowing */
933
934 case IRP_MJ_CLEANUP:
936
937 /* write data */
938 case IRP_MJ_WRITE:
940
941 /* read data */
942 case IRP_MJ_READ:
944
945 /* query volume info */
948
950 {
951 switch( IrpSp->Parameters.DeviceIoControl.IoControlCode ) {
952 case IOCTL_AFD_BIND:
954
957
960
961 case IOCTL_AFD_RECV:
963 FALSE );
964
965 case IOCTL_AFD_SELECT:
966 return AfdSelect( DeviceObject, Irp, IrpSp );
967
970
973
976
977 case IOCTL_AFD_SEND:
979 FALSE );
980
983
985 return AfdGetInfo( DeviceObject, Irp, IrpSp );
986
988 return AfdSetInfo( DeviceObject, Irp, IrpSp );
989
992
995
998
1001
1002 case IOCTL_AFD_ACCEPT:
1003 return AfdAccept( DeviceObject, Irp, IrpSp );
1004
1006 return AfdDisconnect( DeviceObject, Irp, IrpSp );
1007
1010
1013
1016
1019
1022
1025
1028
1031
1034
1037
1040
1043
1046
1049
1052
1054 DbgPrint("IOCTL_AFD_DEFER_ACCEPT is UNIMPLEMENTED!\n");
1055 break;
1056
1058 DbgPrint("IOCTL_AFD_GET_PENDING_CONNECT_DATA is UNIMPLEMENTED!\n");
1059 break;
1060
1062 DbgPrint("IOCTL_AFD_VALIDATE_GROUP is UNIMPLEMENTED!\n");
1063 break;
1064
1065 default:
1067 DbgPrint("Unknown IOCTL (0x%x)\n",
1068 IrpSp->Parameters.DeviceIoControl.IoControlCode);
1069 break;
1070 }
1071 break;
1072 }
1073
1074/* unsupported operations */
1075 default:
1076 {
1079 ("Irp: Unknown Major code was %x\n",
1081 break;
1082 }
1083 }
1084
1085 AFD_DbgPrint(MID_TRACE, ("Returning %x\n", Status));
1086 Irp->IoStatus.Status = Status;
1088
1089 return Status;
1090}
1091
1093{
1095 {
1097 {
1098 /* read()/write() call - no extra buffers */
1099 return FALSE;
1100 }
1102 {
1103 if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_RECV_DATAGRAM)
1104 {
1105 /* recvfrom() call - extra buffers */
1106 return TRUE;
1107 }
1108 else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_RECV)
1109 {
1110 /* recv() call - no extra buffers */
1111 return FALSE;
1112 }
1113 else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_SEND ||
1114 IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_SEND_DATAGRAM)
1115 {
1116 /* send()/sendto() call - no extra buffers */
1117 return FALSE;
1118 }
1119 else
1120 {
1121 /* Unknown IOCTL */
1122 ASSERT(FALSE);
1123 return FALSE;
1124 }
1125 }
1126 else
1127 {
1128 /* Unknown IRP_MJ code */
1129 ASSERT(FALSE);
1130 return FALSE;
1131 }
1132 }
1133 else
1134 {
1135 /* Connection-oriented never has extra buffers */
1136 return FALSE;
1137 }
1138}
1139
1140VOID
1142{
1143 PAFD_RECV_INFO RecvReq;
1144 PAFD_SEND_INFO SendReq;
1145 PAFD_POLL_INFO PollReq;
1146
1148 {
1149 RecvReq = GetLockedData(Irp, IrpSp);
1151 }
1152 else if (IrpSp->MajorFunction == IRP_MJ_WRITE)
1153 {
1154 SendReq = GetLockedData(Irp, IrpSp);
1156 }
1157 else
1158 {
1160
1161 if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_RECV)
1162 {
1163 RecvReq = GetLockedData(Irp, IrpSp);
1165 }
1166 else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_SEND)
1167 {
1168 SendReq = GetLockedData(Irp, IrpSp);
1170 }
1171 else if (IrpSp->Parameters.DeviceIoControl.IoControlCode == IOCTL_AFD_SELECT)
1172 {
1173 ASSERT(Poll);
1174
1175 PollReq = Irp->AssociatedIrp.SystemBuffer;
1176 ZeroEvents(PollReq->Handles, PollReq->HandleCount);
1177 SignalSocket(Poll, NULL, PollReq, STATUS_CANCELLED);
1178 }
1179 }
1180}
1181
1182VOID
1183NTAPI
1185 PIRP Irp)
1186{
1189 PAFD_FCB FCB = FileObject->FsContext;
1191 PIRP CurrentIrp;
1192 PLIST_ENTRY CurrentEntry;
1193 PAFD_DEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
1194 KIRQL OldIrql;
1195 PAFD_ACTIVE_POLL Poll;
1196
1197 IoReleaseCancelSpinLock(Irp->CancelIrql);
1198
1200 return;
1201
1202 switch (IrpSp->MajorFunction)
1203 {
1205 IoctlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode;
1206 break;
1207
1208 case IRP_MJ_READ:
1210 break;
1211
1212 case IRP_MJ_WRITE:
1214 break;
1215
1216 default:
1217 ASSERT(FALSE);
1219 return;
1220 }
1221
1222 switch (IoctlCode)
1223 {
1224 case IOCTL_AFD_RECV:
1227 break;
1228
1229 case IOCTL_AFD_SEND:
1232 break;
1233
1234 case IOCTL_AFD_CONNECT:
1236 break;
1237
1240 break;
1241
1242 case IOCTL_AFD_SELECT:
1243 KeAcquireSpinLock(&DeviceExt->Lock, &OldIrql);
1244
1245 CurrentEntry = DeviceExt->Polls.Flink;
1246 while (CurrentEntry != &DeviceExt->Polls)
1247 {
1248 Poll = CONTAINING_RECORD(CurrentEntry, AFD_ACTIVE_POLL, ListEntry);
1249
1250 if (Irp == Poll->Irp)
1251 {
1252 CleanupPendingIrp(FCB, Irp, IrpSp, Poll);
1253 KeReleaseSpinLock(&DeviceExt->Lock, OldIrql);
1255 return;
1256 }
1257 else
1258 {
1259 CurrentEntry = CurrentEntry->Flink;
1260 }
1261 }
1262
1263 KeReleaseSpinLock(&DeviceExt->Lock, OldIrql);
1264
1266
1267 DbgPrint("WARNING!!! IRP cancellation race could lead to a process hang! (IOCTL_AFD_SELECT)\n");
1268 return;
1269
1272 break;
1273
1274 default:
1275 ASSERT(FALSE);
1277 return;
1278 }
1279
1280 CurrentEntry = FCB->PendingIrpList[Function].Flink;
1281 while (CurrentEntry != &FCB->PendingIrpList[Function])
1282 {
1283 CurrentIrp = CONTAINING_RECORD(CurrentEntry, IRP, Tail.Overlay.ListEntry);
1284
1285 if (CurrentIrp == Irp)
1286 {
1287 RemoveEntryList(CurrentEntry);
1290 return;
1291 }
1292 else
1293 {
1294 CurrentEntry = CurrentEntry->Flink;
1295 }
1296 }
1297
1299
1300 DbgPrint("WARNING!!! IRP cancellation race could lead to a process hang! (Function: %u)\n", Function);
1301}
1302
1303static DRIVER_UNLOAD AfdUnload;
1304static VOID NTAPI
1306{
1308}
1309
1312{
1314 UNICODE_STRING wstrDeviceName = RTL_CONSTANT_STRING(L"\\Device\\Afd");
1315 PAFD_DEVICE_EXTENSION DeviceExt;
1317
1319 /* register driver routines */
1320 DriverObject->MajorFunction[IRP_MJ_CLOSE] = AfdDispatch;
1321 DriverObject->MajorFunction[IRP_MJ_CREATE] = AfdDispatch;
1322 DriverObject->MajorFunction[IRP_MJ_CLEANUP] = AfdDispatch;
1323 DriverObject->MajorFunction[IRP_MJ_WRITE] = AfdDispatch;
1324 DriverObject->MajorFunction[IRP_MJ_READ] = AfdDispatch;
1327 DriverObject->DriverUnload = AfdUnload;
1328
1330 sizeof(AFD_DEVICE_EXTENSION),
1331 &wstrDeviceName,
1333 0,
1334 FALSE,
1335 &DeviceObject);
1336
1337 /* failure */
1338 if (!NT_SUCCESS(Status))
1339 {
1340 return Status;
1341 }
1342
1343 DeviceExt = DeviceObject->DeviceExtension;
1344 KeInitializeSpinLock( &DeviceExt->Lock );
1345 InitializeListHead( &DeviceExt->Polls );
1346
1347 AFD_DbgPrint(MID_TRACE,("Device created: object %p ext %p\n",
1348 DeviceObject, DeviceExt));
1349
1350 return Status;
1351}
1352
1353/* EOF */
unsigned char BOOLEAN
#define FUNCTION_CONNECT
Definition: afd.h:84
#define SOCKET_STATE_CLOSED
Definition: afd.h:82
#define IN_FLIGHT_REQUESTS
Definition: afd.h:93
#define SOCKET_STATE_CREATED
Definition: afd.h:73
#define TAG_AFD_DISCONNECT_DATA
Definition: afd.h:42
#define TAG_AFD_TDI_CONNECTION_INFORMATION
Definition: afd.h:53
#define FUNCTION_RECV
Definition: afd.h:85
#define TAG_AFD_DISCONNECT_OPTIONS
Definition: afd.h:45
#define FUNCTION_PREACCEPT
Definition: afd.h:87
#define TAG_AFD_ACCEPT_QUEUE
Definition: afd.h:46
#define TAG_AFD_CONNECT_OPTIONS
Definition: afd.h:44
#define TAG_AFD_SOCKET_CONTEXT
Definition: afd.h:40
DRIVER_CANCEL AfdCancelHandler
Definition: afd.h:302
#define TAG_AFD_FCB
Definition: afd.h:48
#define TAG_AFD_CONNECT_DATA
Definition: afd.h:41
#define MAX_FUNCTIONS
Definition: afd.h:91
#define TAG_AFD_DATA_BUFFER
Definition: afd.h:38
#define TAG_AFD_TRANSPORT_ADDRESS
Definition: afd.h:39
#define FUNCTION_DISCONNECT
Definition: afd.h:89
#define FUNCTION_SEND
Definition: afd.h:86
LONG NTSTATUS
Definition: precomp.h:26
#define MIN(x, y)
Definition: rdesktop.h:171
#define MIN_TRACE
Definition: debug.h:14
#define MID_TRACE
Definition: debug.h:15
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
struct _FCB FCB
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define Len
Definition: deflate.h:82
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS NTAPI AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: bind.c:76
NTSTATUS NTAPI AfdSetConnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: connect.c:157
NTSTATUS NTAPI AfdSetConnectDataSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: connect.c:197
NTSTATUS NTAPI AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: connect.c:431
NTSTATUS NTAPI AfdGetConnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: connect.c:15
NTSTATUS NTAPI AfdGetConnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: connect.c:127
NTSTATUS NTAPI AfdSetConnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: connect.c:45
NTSTATUS NTAPI AfdSetConnectOptionsSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: connect.c:86
NTSTATUS NTAPI AfdSetContext(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: context.c:64
NTSTATUS NTAPI AfdGetContextSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: context.c:40
NTSTATUS NTAPI AfdGetContext(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: context.c:14
NTSTATUS NTAPI AfdSetInfo(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: info.c:102
NTSTATUS NTAPI AfdGetSockName(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: info.c:232
NTSTATUS NTAPI AfdGetInfo(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: info.c:14
NTSTATUS NTAPI AfdGetPeerName(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: info.c:281
NTSTATUS AfdAccept(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: listen.c:337
NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: listen.c:225
NTSTATUS AfdWaitForListen(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: listen.c:293
PVOID LockRequest(PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Output, KPROCESSOR_MODE *LockMode)
Definition: lock.c:24
VOID UnlockBuffers(PAFD_WSABUF Buf, UINT Count, BOOL Address)
Definition: lock.c:289
VOID UnlockRequest(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: lock.c:180
NTSTATUS QueueUserModeIrp(PAFD_FCB FCB, PIRP Irp, UINT Function)
Definition: lock.c:397
NTSTATUS LostSocket(PIRP Irp)
Definition: lock.c:387
NTSTATUS NTAPI UnlockAndMaybeComplete(PAFD_FCB FCB, NTSTATUS Status, PIRP Irp, UINT Information)
Definition: lock.c:375
VOID SocketStateUnlock(PAFD_FCB FCB)
Definition: lock.c:370
BOOLEAN SocketAcquireStateLock(PAFD_FCB FCB)
Definition: lock.c:360
PVOID GetLockedData(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: lock.c:13
VOID RetryDisconnectCompletion(PAFD_FCB FCB)
Definition: main.c:703
NTSTATUS NTAPI AfdSetDisconnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:188
static DRIVER_UNLOAD AfdUnload
Definition: main.c:1303
static NTSTATUS NTAPI AfdQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:877
BOOLEAN CheckUnlockExtraBuffers(PAFD_FCB FCB, PIO_STACK_LOCATION IrpSp)
Definition: main.c:1092
NTSTATUS NTAPI AfdSetDisconnectDataSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:229
static NTSTATUS NTAPI AfdGetTdiHandles(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:270
ULONG AfdSendWindowSize
Definition: main.c:27
static NTSTATUS NTAPI AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:302
static NTSTATUS NTAPI AfdCleanupSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:426
NTSTATUS AfdQueryFsDeviceInfo(PDEVICE_OBJECT DeviceObject, PFILE_FS_DEVICE_INFORMATION Buffer, PULONG Length)
Definition: main.c:858
void OskitDumpBuffer(PCHAR Data, UINT Len)
Definition: main.c:29
NTSTATUS NTAPI AfdSetDisconnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:76
static NTSTATUS NTAPI AfdDisconnect(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:715
VOID CleanupPendingIrp(PAFD_FCB FCB, PIRP Irp, PIO_STACK_LOCATION IrpSp, PAFD_ACTIVE_POLL Poll)
Definition: main.c:1141
static DRIVER_DISPATCH AfdDispatch
Definition: main.c:904
static IO_COMPLETION_ROUTINE DisconnectComplete
Definition: main.c:596
NTSTATUS NTAPI AfdSetDisconnectOptionsSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:117
static NTSTATUS NTAPI AfdCloseSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:460
ULONG AfdReceiveWindowSize
Definition: main.c:26
NTSTATUS NTAPI AfdGetDisconnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:46
NTSTATUS NTAPI AfdGetDisconnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:157
static NTSTATUS DoDisconnect(PAFD_FCB FCB)
Definition: main.c:668
NTSTATUS NTAPI AfdEnumEvents(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: select.c:328
VOID KillSelectsForFCB(PAFD_DEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, BOOLEAN OnlyExclusive)
Definition: select.c:125
NTSTATUS NTAPI AfdSelect(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: select.c:165
NTSTATUS NTAPI AfdEventSelect(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: select.c:265
VOID ZeroEvents(PAFD_HANDLE HandleArray, UINT HandleCount)
Definition: select.c:44
VOID PollReeval(PAFD_DEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
Definition: select.c:407
VOID SignalSocket(PAFD_ACTIVE_POLL Poll OPTIONAL, PIRP _Irp OPTIONAL, PAFD_POLL_INFO PollReq, NTSTATUS Status)
Definition: select.c:56
NTSTATUS TdiDisassociateAddressFile(PFILE_OBJECT ConnectionObject)
Definition: tdi.c:442
NTSTATUS TdiDisconnect(PIRP *Irp, PFILE_OBJECT TransportObject, PLARGE_INTEGER Time, USHORT Flags, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext, PTDI_CONNECTION_INFORMATION RequestConnectionInfo, PTDI_CONNECTION_INFORMATION ReturnConnectionInfo)
Definition: tdi.c:1249
NTSTATUS NTAPI AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Short)
Definition: write.c:329
NTSTATUS NTAPI AfdPacketSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: write.c:564
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
ULONG DebugTraceLevel
Definition: ndis.c:13
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
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 RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
#define PagedPool
Definition: env_spec_w32.h:308
unsigned long DWORD
Definition: ntddk_ex.h:95
@ FileFsDeviceInformation
Definition: from_kernel.h:222
enum _FSINFOCLASS FS_INFORMATION_CLASS
Status
Definition: gdiplustypes.h:25
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
#define DbgPrint
Definition: hal.h:12
IoSetCancelRoutine(Irp, CancelRoutine)
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
unsigned int * PUINT
Definition: ndis.h:50
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSTATUS NTAPI AfdConnectedSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Short)
Definition: read.c:422
NTSTATUS NTAPI AfdPacketSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: read.c:703
DRIVER_DISPATCH(nfs41_FsdDispatch)
struct _FILE_FS_DEVICE_INFORMATION FILE_FS_DEVICE_INFORMATION
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define IoCompleteRequest
Definition: irp.c:1240
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
#define STATUS_FILE_CLOSED
Definition: ntstatus.h:532
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
#define FILE_DEVICE_NAMED_PIPE
Definition: winioctl.h:123
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IOCTL_AFD_EVENT_SELECT
Definition: shared.h:329
#define IOCTL_AFD_GET_TDI_HANDLES
Definition: shared.h:293
#define AFD_DISCONNECT_RECV
Definition: shared.h:198
struct _AFD_CREATE_PACKET * PAFD_CREATE_PACKET
#define IOCTL_AFD_SET_INFO
Definition: shared.h:295
#define IOCTL_AFD_SET_DISCONNECT_OPTIONS
Definition: shared.h:309
#define AFD_EVENT_SEND
Definition: shared.h:205
#define IOCTL_AFD_WAIT_FOR_LISTEN
Definition: shared.h:273
#define IOCTL_AFD_SET_CONNECT_OPTIONS_SIZE
Definition: shared.h:321
#define IOCTL_AFD_GET_SOCK_NAME
Definition: shared.h:289
#define IOCTL_AFD_DEFER_ACCEPT
Definition: shared.h:331
#define IOCTL_AFD_START_LISTEN
Definition: shared.h:271
#define IOCTL_AFD_SET_CONNECT_OPTIONS
Definition: shared.h:305
#define IOCTL_AFD_GET_DISCONNECT_DATA
Definition: shared.h:315
#define IOCTL_AFD_GET_CONTEXT
Definition: shared.h:299
#define IOCTL_AFD_SET_DISCONNECT_DATA_SIZE
Definition: shared.h:323
#define IOCTL_AFD_SELECT
Definition: shared.h:285
#define IOCTL_AFD_GET_DISCONNECT_OPTIONS
Definition: shared.h:317
#define IOCTL_AFD_RECV
Definition: shared.h:277
#define IOCTL_AFD_GET_INFO
Definition: shared.h:327
#define IOCTL_AFD_GET_CONTEXT_SIZE
Definition: shared.h:297
#define IOCTL_AFD_GET_CONNECT_OPTIONS
Definition: shared.h:313
#define IOCTL_AFD_SET_CONNECT_DATA
Definition: shared.h:303
#define AFD_CONNECTION_HANDLE
Definition: shared.h:162
#define IOCTL_AFD_CONNECT
Definition: shared.h:269
#define IOCTL_AFD_ACCEPT
Definition: shared.h:275
#define IOCTL_AFD_BIND
Definition: shared.h:267
#define IOCTL_AFD_DISCONNECT
Definition: shared.h:287
#define IOCTL_AFD_SEND_DATAGRAM
Definition: shared.h:283
#define AFD_EVENT_ABORT
Definition: shared.h:207
#define AFD_ADDRESS_HANDLE
Definition: shared.h:161
#define IOCTL_AFD_VALIDATE_GROUP
Definition: shared.h:337
#define IOCTL_AFD_SET_DISCONNECT_OPTIONS_SIZE
Definition: shared.h:325
#define IOCTL_AFD_RECV_DATAGRAM
Definition: shared.h:279
#define IOCTL_AFD_ENUM_NETWORK_EVENTS
Definition: shared.h:335
#define IOCTL_AFD_SET_DISCONNECT_DATA
Definition: shared.h:307
#define IOCTL_AFD_SEND
Definition: shared.h:281
#define AFD_ENDPOINT_CONNECTIONLESS
Definition: shared.h:153
#define IOCTL_AFD_GET_PENDING_CONNECT_DATA
Definition: shared.h:333
#define IOCTL_AFD_SET_CONNECT_DATA_SIZE
Definition: shared.h:319
#define IOCTL_AFD_GET_PEER_NAME
Definition: shared.h:291
#define IOCTL_AFD_SET_CONTEXT
Definition: shared.h:301
#define IOCTL_AFD_GET_CONNECT_DATA
Definition: shared.h:311
#define AFD_DISCONNECT_SEND
Definition: shared.h:197
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
PIRP Irp
Definition: afd.h:116
DWORD EndpointFlags
Definition: shared.h:22
WCHAR TransportName[1]
Definition: shared.h:25
DWORD SizeOfTransportName
Definition: shared.h:24
LIST_ENTRY Polls
Definition: afd.h:110
KSPIN_LOCK Lock
Definition: afd.h:111
LARGE_INTEGER Timeout
Definition: shared.h:137
ULONG DisconnectType
Definition: shared.h:136
Definition: afd.h:159
ULONG HandleCount
Definition: shared.h:57
AFD_HANDLE Handles[1]
Definition: shared.h:59
ULONG BufferCount
Definition: shared.h:86
PAFD_WSABUF BufferArray
Definition: shared.h:85
ULONG BufferCount
Definition: shared.h:102
PAFD_WSABUF BufferArray
Definition: shared.h:101
HANDLE TdiConnectionHandle
Definition: shared.h:149
HANDLE TdiAddressHandle
Definition: shared.h:148
AFD_TDI_OBJECT Object
Definition: afd.h:138
HANDLE Handle
Definition: afd.h:131
PFILE_OBJECT Object
Definition: afd.h:130
Definition: cdstruc.h:902
ULONG Flags
Definition: ntfs.h:536
PFILE_OBJECT FileObject
Definition: ntfs.h:520
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
IO_STATUS_BLOCK IoStatus
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TDI_DISCONNECT_RELEASE
Definition: tdi.h:144
#define TDI_DISCONNECT_ABORT
Definition: tdi.h:143
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint16_t * PWCHAR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG IoctlCode
Definition: wdfiotarget.h:1043
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
#define FD_CLOSE_BIT
Definition: winsock2.h:303
#define FD_WRITE_BIT
Definition: winsock2.h:295
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define FO_NAMED_PIPE
Definition: iotypes.h:1782
#define IO_NO_INCREMENT
Definition: iotypes.h:598
* PFILE_OBJECT
Definition: iotypes.h:1998
#define IRP_MJ_CLEANUP
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792
#define ObDereferenceObject
Definition: obfuncs.h:203