31#define MIN(x,y) (((x)<(y))?(x):(y))
35#define IP_MIB_STATS_ID 1
36#define IP_MIB_ADDRTABLE_ENTRY_ID 0x102
38#define TAG_AFD_DATA_BUFFER 'BdfA'
39#define TAG_AFD_TRANSPORT_ADDRESS 'tdfA'
40#define TAG_AFD_SOCKET_CONTEXT 'XdfA'
41#define TAG_AFD_CONNECT_DATA 'cdfA'
42#define TAG_AFD_DISCONNECT_DATA 'ddfA'
44#define TAG_AFD_CONNECT_OPTIONS 'ocfA'
45#define TAG_AFD_DISCONNECT_OPTIONS 'odfA'
46#define TAG_AFD_ACCEPT_QUEUE 'qafA'
47#define TAG_AFD_POLL_HANDLE 'hpfA'
48#define TAG_AFD_FCB 'cffA'
49#define TAG_AFD_ACTIVE_POLL 'pafA'
50#define TAG_AFD_EA_INFO 'aefA'
51#define TAG_AFD_STORED_DATAGRAM 'gsfA'
52#define TAG_AFD_SNMP_ADDRESS_INFO 'asfA'
53#define TAG_AFD_TDI_CONNECTION_INFORMATION 'cTfA'
54#define TAG_AFD_WSA_BUFFER 'bWfA'
67 ((((dw) & 0xFF000000L) >> 24) | \
68 (((dw) & 0x00FF0000L) >> 8) | \
69 (((dw) & 0x0000FF00L) << 8) | \
70 (((dw) & 0x000000FFL) << 24))
72#define SOCKET_STATE_INVALID_TRANSITION ((DWORD)-1)
73#define SOCKET_STATE_CREATED 0
74#define SOCKET_STATE_BOUND 1
75#define SOCKET_STATE_CONNECTING 2
76#define SOCKET_STATE_CONNECTED 3
77#define SOCKET_STATE_LISTENING 4
78#define SOCKET_STATE_MASK 0x0000ffff
79#define SOCKET_STATE_EOF_READ 0x20000000
80#define SOCKET_STATE_LOCKED 0x40000000
81#define SOCKET_STATE_NEW 0x80000000
82#define SOCKET_STATE_CLOSED 0x00000100
84#define FUNCTION_CONNECT 0
85#define FUNCTION_RECV 1
86#define FUNCTION_SEND 2
87#define FUNCTION_PREACCEPT 3
88#define FUNCTION_ACCEPT 4
89#define FUNCTION_DISCONNECT 5
90#define FUNCTION_CLOSE 6
91#define MAX_FUNCTIONS 7
93#define IN_FLIGHT_REQUESTS 5
95#define EXTRA_LOCK_BUFFERS 2
102#define AFD_HANDLES(x) ((PAFD_HANDLE)(x)->Exclusive)
103#define SET_AFD_HANDLES(x,y) (((x)->Exclusive) = (ULONG_PTR)(y))
403 PUINT MaxDatagramLength);
PVOID LockRequest(PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Output, KPROCESSOR_MODE *LockMode)
VOID RetryDisconnectCompletion(PAFD_FCB FCB)
struct IPADDR_ENTRY * PIPADDR_ENTRY
NTSTATUS MakeSocketIntoConnection(PAFD_FCB FCB)
struct _IRP_LIST IRP_LIST
NTSTATUS NTAPI AfdConnectedSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Short)
struct _AFD_TDI_OBJECT AFD_TDI_OBJECT
VOID OskitDumpBuffer(PCHAR Buffer, UINT Len)
NTSTATUS NTAPI AfdEnumEvents(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
struct _AFD_MAPBUF * PAFD_MAPBUF
NTSTATUS TdiListen(PIRP *Irp, PFILE_OBJECT ConnectionObject, PTDI_CONNECTION_INFORMATION *RequestConnectionInfo, PTDI_CONNECTION_INFORMATION *ReturnConnectionInfo, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
NTSTATUS NTAPI AfdSetConnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
IO_COMPLETION_ROUTINE ReceiveComplete
VOID UnlockBuffers(PAFD_WSABUF Buf, UINT Count, BOOL Address)
NTSTATUS TdiAssociateAddressFile(HANDLE AddressHandle, PFILE_OBJECT ConnectionObject)
VOID UnlockHandles(PAFD_HANDLE HandleArray, UINT HandleCount)
struct _AFD_IN_FLIGHT_REQUEST * PAFD_IN_FLIGHT_REQUEST
NTSTATUS NTAPI AfdSetContext(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS NTAPI AfdSelect(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
struct _AFD_ACTIVE_POLL * PAFD_ACTIVE_POLL
NTSTATUS NTAPI AfdConnectedSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN Short)
NTSTATUS NTAPI AfdSetInfo(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
BOOLEAN CheckUnlockExtraBuffers(PAFD_FCB FCB, PIO_STACK_LOCATION IrpSp)
struct _AFD_FCB * PAFD_FCB
NTSTATUS AfdAccept(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
VOID UnlockRequest(PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS TdiQueryMaxDatagramLength(PFILE_OBJECT FileObject, PUINT MaxDatagramLength)
NTSTATUS QueueUserModeIrp(PAFD_FCB FCB, PIRP Irp, UINT Function)
VOID DestroySocket(PAFD_FCB FCB)
NTSTATUS TdiDisassociateAddressFile(PFILE_OBJECT ConnectionObject)
NTSTATUS TdiReceiveDatagram(PIRP *Irp, PFILE_OBJECT TransportObject, USHORT Flags, PCHAR Buffer, UINT BufferLength, PTDI_CONNECTION_INFORMATION From, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
NTSTATUS WarmSocketForBind(PAFD_FCB FCB, ULONG ShareType)
NTSTATUS NTAPI AfdSetConnectDataSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
struct _IRP_LIST * PIRP_LIST
NTSTATUS NTAPI AfdStreamSocketConnect(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS NTAPI AfdPacketSocketReadData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS AfdListenSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
struct _AFD_TDI_OBJECT * PAFD_TDI_OBJECT
NTSTATUS NTAPI AfdGetSockName(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS TdiReceive(PIRP *Irp, PFILE_OBJECT ConnectionObject, USHORT Flags, PCHAR Buffer, UINT BufferLength, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
DRIVER_CANCEL AfdCancelHandler
NTSTATUS LostSocket(PIRP Irp)
NTSTATUS NTAPI AfdBindSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS NTAPI AfdEventSelect(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
VOID ZeroEvents(PAFD_HANDLE HandleArray, UINT HandleCount)
NTSTATUS NTAPI UnlockAndMaybeComplete(PAFD_FCB FCB, NTSTATUS Status, PIRP Irp, UINT Information)
NTSTATUS NTAPI AfdGetConnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS NTAPI AfdGetConnectData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
struct IPADDR_ENTRY IPADDR_ENTRY
IO_COMPLETION_ROUTINE PacketSocketRecvComplete
struct _AFD_TDI_OBJECT_QELT AFD_TDI_OBJECT_QELT
struct _AFD_DATA_WINDOW * PAFD_DATA_WINDOW
struct _AFD_IN_FLIGHT_REQUEST AFD_IN_FLIGHT_REQUEST
VOID KillSelectsForFCB(PAFD_DEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, BOOLEAN ExclusiveOnly)
PAFD_WSABUF LockBuffers(PAFD_WSABUF Buf, UINT Count, PVOID AddressBuf, PINT AddressLen, BOOLEAN Write, BOOLEAN LockAddress, KPROCESSOR_MODE LockMode)
struct _AFD_DEVICE_EXTENSION AFD_DEVICE_EXTENSION
VOID SocketStateUnlock(PAFD_FCB FCB)
NTSTATUS NTAPI AfdPacketSocketWriteData(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
VOID SignalSocket(PAFD_ACTIVE_POLL Poll OPTIONAL, PIRP _Irp OPTIONAL, PAFD_POLL_INFO PollReq, NTSTATUS Status)
NTSTATUS LeaveIrpUntilLater(PAFD_FCB FCB, PIRP Irp, UINT Function)
BOOLEAN SocketAcquireStateLock(PAFD_FCB FCB)
NTSTATUS TdiSendDatagram(PIRP *Irp, PFILE_OBJECT TransportObject, PCHAR Buffer, UINT BufferLength, PTDI_CONNECTION_INFORMATION To, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
PVOID GetLockedData(PIRP Irp, PIO_STACK_LOCATION IrpSp)
VOID PollReeval(PAFD_DEVICE_EXTENSION DeviceObject, PFILE_OBJECT FileObject)
NTSTATUS NTAPI AfdSetConnectOptions(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS NTAPI AfdGetInfo(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
struct _AFD_STORED_DATAGRAM * PAFD_STORED_DATAGRAM
struct _AFD_DEVICE_EXTENSION * PAFD_DEVICE_EXTENSION
NTSTATUS TdiOpenAddressFile(PUNICODE_STRING DeviceName, PTRANSPORT_ADDRESS Name, ULONG ShareType, PHANDLE AddressHandle, PFILE_OBJECT *AddressObject)
NTSTATUS NTAPI AfdGetContextSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS NTAPI AfdGetContext(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
struct _AFD_STORED_DATAGRAM AFD_STORED_DATAGRAM
struct _AFD_ACTIVE_POLL AFD_ACTIVE_POLL
struct _AFD_TDI_OBJECT_QELT * PAFD_TDI_OBJECT_QELT
NTSTATUS TdiSend(PIRP *Irp, PFILE_OBJECT ConnectionObject, USHORT Flags, PCHAR Buffer, UINT BufferLength, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
struct _AFD_DATA_WINDOW AFD_DATA_WINDOW
struct _AFD_MAPBUF AFD_MAPBUF
NTSTATUS WarmSocketForConnection(PAFD_FCB FCB)
PAFD_HANDLE LockHandles(PAFD_HANDLE HandleArray, UINT HandleCount)
NTSTATUS AfdWaitForListen(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS NTAPI AfdGetPeerName(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
NTSTATUS NTAPI AfdSetConnectOptionsSize(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
_In_ PIO_STACK_LOCATION IrpSp
PULONG MinorVersion OPTIONAL
PAFD_DEVICE_EXTENSION DeviceExt
PDEVICE_OBJECT DeviceObject
DWORD EventSelectDisabled
AFD_IN_FLIGHT_REQUEST ReceiveIrp
AFD_IN_FLIGHT_REQUEST ConnectIrp
UINT FilledDisconnectData
LARGE_INTEGER DisconnectTimeout
AFD_IN_FLIGHT_REQUEST ListenIrp
AFD_IN_FLIGHT_REQUEST DisconnectIrp
AFD_IN_FLIGHT_REQUEST SendIrp
UINT DisconnectOptionsSize
UINT FilledConnectOptions
PTRANSPORT_ADDRESS RemoteAddress
BOOLEAN DisconnectPending
LIST_ENTRY PendingIrpList[MAX_FUNCTIONS]
NTSTATUS PollStatus[FD_MAX_EVENTS]
PAFD_DEVICE_EXTENSION DeviceExt
UNICODE_STRING TdiDeviceName
AFD_TDI_OBJECT AddressFile
NTSTATUS LastReceiveStatus
AFD_TDI_OBJECT Connection
DWORD EventSelectTriggers
PTDI_CONNECTION_INFORMATION ConnectCallInfo
UINT FilledDisconnectOptions
PTDI_CONNECTION_INFORMATION AddressFrom
PTRANSPORT_ADDRESS LocalAddress
LIST_ENTRY PendingConnections
PTDI_CONNECTION_INFORMATION ConnectReturnInfo
PTDI_CONNECTION_INFORMATION ConnectionReturnInfo
PTDI_CONNECTION_INFORMATION ConnectionCallInfo
PTRANSPORT_ADDRESS Address
PTDI_CONNECTION_INFORMATION ConnInfo
static BOOL Write(PBYTE Address, PBYTE Data, SIZE_T Size)
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE _In_opt_ __drv_aliasesMem WDFCONTEXT CompletionContext
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
_Must_inspect_result_ _In_ ULONG Flags
IO_COMPLETION_ROUTINE * PIO_COMPLETION_ROUTINE