ReactOS 0.4.16-dev-2293-g4d8327b
tdi.c File Reference
#include <afd.h>
#include <tdikrnl.h>
#include <tdiinfo.h>
#include <reactos/debug.h>
Include dependency graph for tdi.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS TdiCall (PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
 Calls a transport driver device.
 
static NTSTATUS TdiOpenDevice (PUNICODE_STRING DeviceName, ULONG EaLength, PFILE_FULL_EA_INFORMATION EaInfo, ULONG ShareType, PHANDLE Handle, PFILE_OBJECT *Object)
 Opens a device.
 
NTSTATUS TdiOpenAddressFile (PUNICODE_STRING DeviceName, PTRANSPORT_ADDRESS Name, ULONG ShareType, PHANDLE AddressHandle, PFILE_OBJECT *AddressObject)
 Opens an IPv4 address file object.
 
NTSTATUS TdiQueryMaxDatagramLength (PFILE_OBJECT FileObject, PUINT MaxDatagramLength)
 
NTSTATUS TdiOpenConnectionEndpointFile (PUNICODE_STRING DeviceName, PHANDLE ConnectionHandle, PFILE_OBJECT *ConnectionObject)
 Opens a connection endpoint file object.
 
NTSTATUS TdiConnect (PIRP *Irp, PFILE_OBJECT ConnectionObject, PTDI_CONNECTION_INFORMATION ConnectionCallInfo, PTDI_CONNECTION_INFORMATION ConnectionReturnInfo, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 Connect a connection endpoint to a remote peer.
 
NTSTATUS TdiAssociateAddressFile (HANDLE AddressHandle, PFILE_OBJECT ConnectionObject)
 Associates a connection endpoint to an address file object.
 
NTSTATUS TdiDisassociateAddressFile (PFILE_OBJECT ConnectionObject)
 Disassociates a connection endpoint from an address file object.
 
NTSTATUS TdiListen (PIRP *Irp, PFILE_OBJECT ConnectionObject, PTDI_CONNECTION_INFORMATION *RequestConnectionInfo, PTDI_CONNECTION_INFORMATION *ReturnConnectionInfo, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 Listen on a connection endpoint for a connection request from a remote peer.
 
NTSTATUS TdiAccept (PIRP *Irp, PFILE_OBJECT AcceptConnectionObject, PTDI_CONNECTION_INFORMATION RequestConnectionInfo, PTDI_CONNECTION_INFORMATION ReturnConnectionInfo, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 Listen on a connection endpoint for a connection request from a remote peer.
 
NTSTATUS TdiSetEventHandler (PFILE_OBJECT FileObject, LONG EventType, PVOID Handler, PVOID Context)
 Sets or resets an event handler.
 
NTSTATUS TdiQueryDeviceControl (PFILE_OBJECT FileObject, ULONG IoControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG Return)
 Queries a device for information.
 
NTSTATUS TdiQueryInformation (PFILE_OBJECT FileObject, LONG QueryType, PMDL MdlBuffer)
 Query for information.
 
NTSTATUS TdiQueryInformationEx (PFILE_OBJECT FileObject, ULONG Entity, ULONG Instance, ULONG Class, ULONG Type, ULONG Id, PVOID OutputBuffer, PULONG OutputLength)
 Extended query for information.
 
NTSTATUS TdiQueryAddress (PFILE_OBJECT FileObject, PULONG Address)
 Queries for a local IP address.
 
NTSTATUS TdiSend (PIRP *Irp, PFILE_OBJECT TransportObject, USHORT Flags, PCHAR Buffer, UINT BufferLength, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 
NTSTATUS TdiReceive (PIRP *Irp, PFILE_OBJECT TransportObject, USHORT Flags, PCHAR Buffer, UINT BufferLength, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 
NTSTATUS TdiReceiveDatagram (PIRP *Irp, PFILE_OBJECT TransportObject, USHORT Flags, PCHAR Buffer, UINT BufferLength, PTDI_CONNECTION_INFORMATION Addr, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 Receives a datagram.
 
NTSTATUS TdiSendDatagram (PIRP *Irp, PFILE_OBJECT TransportObject, PCHAR Buffer, UINT BufferLength, PTDI_CONNECTION_INFORMATION Addr, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 Sends a datagram.
 
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)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 23 of file tdi.c.

Function Documentation

◆ TdiAccept()

NTSTATUS TdiAccept ( PIRP Irp,
PFILE_OBJECT  AcceptConnectionObject,
PTDI_CONNECTION_INFORMATION  RequestConnectionInfo,
PTDI_CONNECTION_INFORMATION  ReturnConnectionInfo,
PIO_COMPLETION_ROUTINE  CompletionRoutine,
PVOID  CompletionContext 
)

Listen on a connection endpoint for a connection request from a remote peer.

Parameters
CompletionRoutine= Routine to be called when IRP is completed
CompletionContext= Context for CompletionRoutine
Returns
Status of operation May return STATUS_PENDING

Definition at line 515 of file tdi.c.

531{
533
534 DPRINT("Called\n");
535
536 if (!AcceptConnectionObject) {
537 DPRINT("Bad connection object.\n");
539 }
540
541 DeviceObject = IoGetRelatedDeviceObject(AcceptConnectionObject);
542 if (!DeviceObject) {
543 DPRINT("Bad device object.\n");
545 }
546
549 AcceptConnectionObject,
550 NULL,
551 NULL);
552 if (*Irp == NULL)
554
557 AcceptConnectionObject,
560 RequestConnectionInfo,
561 ReturnConnectionInfo);
562
563 TdiCall(*Irp, DeviceObject, NULL /* Don't wait for completion */, NULL);
564
565 return STATUS_PENDING;
566}
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Calls a transport driver device.
Definition: tdi.c:26
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
#define DPRINT
Definition: sndvol32.h:73
#define TDI_LISTEN
Definition: tdikrnl.h:50
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
#define TdiBuildAccept( Irp, DevObj, FileObj, CompRoutine, Contxt, RequestConnectionInfo, ReturnConnectionInfo)
Definition: tdikrnl.h:417
#define STATUS_PENDING
Definition: telnetd.h:14
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE _In_opt_ __drv_aliasesMem WDFCONTEXT CompletionContext
Definition: wdfrequest.h:898
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:895

◆ TdiAssociateAddressFile()

NTSTATUS TdiAssociateAddressFile ( HANDLE  AddressHandle,
PFILE_OBJECT  ConnectionObject 
)

Associates a connection endpoint to an address file object.

Parameters
AddressHandle= Handle to address file object
ConnectionObject= Connection endpoint file object
Returns
Status of operation

Definition at line 364 of file tdi.c.

375{
379 PIRP Irp;
380
381 DPRINT("Called. AddressHandle (%p) ConnectionObject (%p)\n", AddressHandle, ConnectionObject);
382
383 if (!ConnectionObject) {
384 DPRINT("Bad connection object.\n");
386 }
387
388 DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
389 if (!DeviceObject) {
390 DPRINT("Bad device object.\n");
392 }
393
395
398 ConnectionObject,
399 &Event,
400 &Iosb);
401 if (!Irp)
403
406 ConnectionObject,
407 NULL,
408 NULL,
409 AddressHandle);
410
411 return TdiCall(Irp, DeviceObject, &Event, &Iosb);
412}
#define FALSE
Definition: types.h:117
return Iosb
Definition: create.c:4403
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
@ NotificationEvent
#define TdiBuildAssociateAddress( Irp, DevObj, FileObj, CompRoutine, Contxt, AddrHandle)
Definition: tdikrnl.h:467
#define TDI_ASSOCIATE_ADDRESS
Definition: tdikrnl.h:47

Referenced by StartListening(), WarmSocketForConnection(), and WskConnect().

◆ TdiCall()

static NTSTATUS TdiCall ( PIRP  Irp,
PDEVICE_OBJECT  DeviceObject,
PKEVENT  Event,
PIO_STATUS_BLOCK  Iosb 
)
static

Calls a transport driver device.

Parameters
Irp= Pointer to I/O Request Packet
DeviceObject= Pointer to device object to call
Event= An optional pointer to an event handle that will be waited upon
Iosb= Pointer to an IO status block
Returns
Status of operation

Definition at line 26 of file tdi.c.

42{
44
45 DPRINT("Called\n");
46
47 DPRINT("Irp->UserEvent = %p\n", Irp->UserEvent);
48
50 DPRINT("IoCallDriver: %08x\n", Status);
51
52 if ((Status == STATUS_PENDING) && (Event != NULL)) {
53 DPRINT("Waiting on transport.\n");
57 FALSE,
58 NULL);
59 Status = Iosb->Status;
60 }
61
62 DPRINT("Status (0x%X).\n", Status);
63
64 return Status;
65}
LONG NTSTATUS
Definition: precomp.h:26
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
Status
Definition: gdiplustypes.h:25
#define KernelMode
Definition: asm.h:38
#define IoCallDriver
Definition: irp.c:1225
@ Executive
Definition: ketypes.h:467

Referenced by TdiAccept(), TdiAssociateAddressFile(), TdiConnect(), TdiDisassociateAddressFile(), TdiDisconnect(), TdiListen(), TdiQueryDeviceControl(), TdiQueryInformation(), TdiReceive(), TdiReceiveDatagram(), TdiSend(), TdiSendDatagram(), and TdiSetEventHandler().

◆ TdiConnect()

NTSTATUS TdiConnect ( PIRP Irp,
PFILE_OBJECT  ConnectionObject,
PTDI_CONNECTION_INFORMATION  ConnectionCallInfo,
PTDI_CONNECTION_INFORMATION  ConnectionReturnInfo,
PIO_COMPLETION_ROUTINE  CompletionRoutine,
PVOID  CompletionContext 
)

Connect a connection endpoint to a remote peer.

Parameters
ConnectionObject= Pointer to connection endpoint file object
RemoteAddress= Pointer to remote address
Returns
Status of operation

Definition at line 311 of file tdi.c.

326{
328
329 DPRINT("Called\n");
330
331 if (!ConnectionObject) {
332 DPRINT("Bad connection object.\n");
334 }
335
336 DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
337 if (!DeviceObject) {
338 DPRINT("Bad device object.\n");
340 }
341
344 ConnectionObject,
345 NULL,
346 NULL);
347 if (!*Irp) {
349 }
350
353 ConnectionObject,
356 NULL,
357 ConnectionCallInfo,
358 ConnectionReturnInfo);
359
360 return TdiCall(*Irp, DeviceObject, NULL, NULL);
361}
#define TDI_CONNECT
Definition: tdikrnl.h:49
#define TdiBuildConnect( Irp, DevObj, FileObj, CompRoutine, Contxt, Time, RequestConnectionInfo, ReturnConnectionInfo)
Definition: tdikrnl.h:494

Referenced by AfdStreamSocketConnect(), AfdStreamSocketSuperConnect(), and WskConnect().

◆ TdiDisassociateAddressFile()

NTSTATUS TdiDisassociateAddressFile ( PFILE_OBJECT  ConnectionObject)

Disassociates a connection endpoint from an address file object.

Parameters
ConnectionObject= Connection endpoint file object
Returns
Status of operation

Definition at line 414 of file tdi.c.

423{
427 PIRP Irp;
428
429 DPRINT("Called. ConnectionObject (%p)\n", ConnectionObject);
430
431 if (!ConnectionObject) {
432 DPRINT("Bad connection object.\n");
434 }
435
436 DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
437 if (!DeviceObject) {
438 DPRINT("Bad device object.\n");
440 }
441
443
446 ConnectionObject,
447 &Event,
448 &Iosb);
449 if (!Irp)
451
454 ConnectionObject,
455 NULL,
456 NULL);
457
458 return TdiCall(Irp, DeviceObject, &Event, &Iosb);
459}
#define TdiBuildDisassociateAddress( Irp, DevObj, FileObj, CompRoutine, Contxt)
Definition: tdikrnl.h:521
#define TDI_DISASSOCIATE_ADDRESS
Definition: tdikrnl.h:48

Referenced by AfdCloseSocket(), SocketShutdown(), StartListening(), and WskConnect().

◆ TdiDisconnect()

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 at line 1260 of file tdi.c.

1268 {
1270
1271 if (!TransportObject) {
1272 DPRINT("Bad transport object.\n");
1274 }
1275
1276 DPRINT("Called(TransportObject %p)\n", TransportObject);
1277
1278 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1279 if (!DeviceObject) {
1280 DPRINT("Bad device object.\n");
1282 }
1283
1286 TransportObject,
1287 NULL,
1288 NULL);
1289
1290 if (!*Irp) {
1291 DPRINT("Insufficient resources.\n");
1293 }
1294
1297 TransportObject,
1300 Time,
1301 Flags,
1302 RequestConnectionInfo,
1303 ReturnConnectionInfo);
1304
1306
1307 return STATUS_PENDING;
1308}
static PLARGE_INTEGER Time
Definition: time.c:105
#define TdiBuildDisconnect( Irp, DevObj, FileObj, CompRoutine, Contxt, Time, Flags, RequestConnectionInfo, ReturnConnectionInfo)
Definition: tdikrnl.h:545
#define TDI_DISCONNECT
Definition: tdikrnl.h:52
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by DoDisconnect().

◆ TdiListen()

NTSTATUS TdiListen ( PIRP Irp,
PFILE_OBJECT  ConnectionObject,
PTDI_CONNECTION_INFORMATION RequestConnectionInfo,
PTDI_CONNECTION_INFORMATION ReturnConnectionInfo,
PIO_COMPLETION_ROUTINE  CompletionRoutine,
PVOID  CompletionContext 
)

Listen on a connection endpoint for a connection request from a remote peer.

Parameters
CompletionRoutine= Routine to be called when IRP is completed
CompletionContext= Context for CompletionRoutine
Returns
Status of operation May return STATUS_PENDING

Definition at line 461 of file tdi.c.

477{
479
480 DPRINT("Called\n");
481
482 if (!ConnectionObject) {
483 DPRINT("Bad connection object.\n");
485 }
486
487 DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
488 if (!DeviceObject) {
489 DPRINT("Bad device object.\n");
491 }
492
495 ConnectionObject,
496 NULL,
497 NULL);
498 if (*Irp == NULL)
500
503 ConnectionObject,
506 0,
507 *RequestConnectionInfo,
508 *ReturnConnectionInfo);
509
510 TdiCall(*Irp, DeviceObject, NULL /* Don't wait for completion */, NULL);
511
512 return STATUS_PENDING;
513}
#define TdiBuildListen( Irp, DevObj, FileObj, CompRoutine, Contxt, Flags, RequestConnectionInfo, ReturnConnectionInfo)
Definition: tdikrnl.h:593

Referenced by AfdListenSocket(), ListenComplete(), and StartListening().

◆ TdiOpenAddressFile()

NTSTATUS TdiOpenAddressFile ( PUNICODE_STRING  DeviceName,
PTRANSPORT_ADDRESS  Name,
ULONG  ShareType,
PHANDLE  AddressHandle,
PFILE_OBJECT AddressObject 
)

Opens an IPv4 address file object.

Parameters
DeviceName= Pointer to counted string with name of device
Name= Pointer to socket name (IPv4 address family)
AddressHandle= Address of buffer to place address file handle
AddressObject= Address of buffer to place address file object
Returns
Status of operation

Definition at line 148 of file tdi.c.

164{
169
170 DPRINT("Called. DeviceName (%wZ) Name (%p)\n", DeviceName, Name);
171
172 /* EaName must be 0-terminated, even though TDI_TRANSPORT_ADDRESS_LENGTH does *not* include the 0 */
177 EaLength,
179 if (!EaInfo)
181
182 RtlZeroMemory(EaInfo, EaLength);
184 /* Don't copy the terminating 0; we have already zeroed it */
185 RtlCopyMemory(EaInfo->EaName,
188 EaInfo->EaValueLength = sizeof(TA_IP_ADDRESS);
189 Address =
190 (PTRANSPORT_ADDRESS)(EaInfo->EaName + TDI_TRANSPORT_ADDRESS_LENGTH + 1); /* 0-terminated */
192
194 EaLength,
195 EaInfo,
196 ShareType,
197 AddressHandle,
198 AddressObject);
200 return Status;
201}
#define TAG_AFD_EA_INFO
Definition: afd.h:51
LPWSTR Name
Definition: desk.c:124
static NTSTATUS TdiOpenDevice(PUNICODE_STRING DeviceName, ULONG EaLength, PFILE_FULL_EA_INFORMATION EaInfo, ULONG ShareType, PHANDLE Handle, PFILE_OBJECT *Object)
Opens a device.
Definition: tdi.c:68
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
IN PVCB IN PDIRENT OUT PULONG EaLength
Definition: fatprocs.h:879
struct _FILE_FULL_EA_INFORMATION * PFILE_FULL_EA_INFORMATION
struct _FILE_FULL_EA_INFORMATION FILE_FULL_EA_INFORMATION
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static WCHAR Address[46]
Definition: ping.c:68
struct _TA_ADDRESS_IP TA_IP_ADDRESS
struct _TRANSPORT_ADDRESS * PTRANSPORT_ADDRESS
#define TDI_TRANSPORT_ADDRESS_LENGTH
Definition: tdi.h:372
#define TdiTransportAddress
Definition: tdi.h:370
UINT TaLengthOfTransportAddress(PTRANSPORT_ADDRESS Addr)
Definition: tdiconn.c:56
VOID TaCopyTransportAddressInPlace(PTRANSPORT_ADDRESS Target, PTRANSPORT_ADDRESS Source)
Definition: tdiconn.c:84
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281

Referenced by WarmSocketForBind(), and WskBind().

◆ TdiOpenConnectionEndpointFile()

NTSTATUS TdiOpenConnectionEndpointFile ( PUNICODE_STRING  DeviceName,
PHANDLE  ConnectionHandle,
PFILE_OBJECT ConnectionObject 
)

Opens a connection endpoint file object.

Parameters
DeviceName= Pointer to counted string with name of device
ConnectionHandle= Address of buffer to place connection endpoint file handle
ConnectionObject= Address of buffer to place connection endpoint file object
Returns
Status of operation

Definition at line 258 of file tdi.c.

271{
273 PVOID *ContextArea;
276
277 DPRINT("Called. DeviceName (%wZ)\n", DeviceName);
278
279 /* EaName must be 0-terminated, even though TDI_TRANSPORT_ADDRESS_LENGTH does *not* include the 0 */
282 sizeof(PVOID) + 1;
283
285 EaLength,
287 if (!EaInfo)
289
290 RtlZeroMemory(EaInfo, EaLength);
292 /* Don't copy the terminating 0; we have already zeroed it */
293 RtlCopyMemory(EaInfo->EaName,
296 EaInfo->EaValueLength = sizeof(PVOID);
297 ContextArea = (PVOID*)(EaInfo->EaName + TDI_CONNECTION_CONTEXT_LENGTH + 1); /* 0-terminated */
298 /* FIXME: Allocate context area */
299 *ContextArea = NULL;
301 EaLength,
302 EaInfo,
305 ConnectionObject);
307 return Status;
308}
_In_ PKSPIN_CONNECT _In_ ACCESS_MASK _Out_ PHANDLE ConnectionHandle
Definition: ks.h:4538
#define AFD_SHARE_UNIQUE
Definition: netio.c:67
#define TDI_CONNECTION_CONTEXT_LENGTH
Definition: tdi.h:373
#define TdiConnectionContext
Definition: tdi.h:371
void * PVOID
Definition: typedefs.h:50

Referenced by WarmSocketForConnection(), and WskSocket().

◆ TdiOpenDevice()

static NTSTATUS TdiOpenDevice ( PUNICODE_STRING  DeviceName,
ULONG  EaLength,
PFILE_FULL_EA_INFORMATION  EaInfo,
ULONG  ShareType,
PHANDLE  Handle,
PFILE_OBJECT Object 
)
static

Opens a device.

Parameters
DeviceName= Pointer to counted string with name of device
EaLength= Length of EA information
EaInfo= Pointer to buffer with EA information
Handle= Address of buffer to place device handle
Object= Address of buffer to place device object
Returns
Status of operation

Definition at line 68 of file tdi.c.

86{
91
92 DPRINT("Called. DeviceName (%wZ, %u)\n", DeviceName, ShareType);
93
94 /* Determine the share access */
95 if (ShareType != AFD_SHARE_REUSE)
96 {
97 /* Exclusive access */
98 ShareAccess = 0;
99 }
100 else
101 {
102 /* Shared access */
104 }
105
106 InitializeObjectAttributes(&Attr, /* Attribute buffer */
107 DeviceName, /* Device name */
108 OBJ_CASE_INSENSITIVE | /* Attributes */
110 NULL, /* Root directory */
111 NULL); /* Security descriptor */
112 Status = ZwCreateFile(Handle, /* Return file handle */
113 GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, /* Desired access */
114 &Attr, /* Object attributes */
115 &Iosb, /* IO status */
116 0, /* Initial allocation size */
117 FILE_ATTRIBUTE_NORMAL, /* File attributes */
118 ShareAccess, /* Share access */
119 FILE_OPEN_IF, /* Create disposition */
120 0, /* Create options */
121 EaInfo, /* EA buffer */
122 EaLength); /* EA length */
123 if (NT_SUCCESS(Status)) {
124 Status = ObReferenceObjectByHandle(*Handle, /* Handle to open file */
125 GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, /* Access mode */
126 *IoFileObjectType, /* Object type */
127 KernelMode, /* Access mode */
128 (PVOID*)Object, /* Pointer to object */
129 NULL); /* Handle information */
130 if (!NT_SUCCESS(Status)) {
131 DPRINT("ObReferenceObjectByHandle() failed with status (0x%X).\n", Status);
132 ZwClose(*Handle);
133 } else {
134 DPRINT("Got handle (%p) Object (%p)\n", *Handle, *Object);
135 }
136 } else {
137 DPRINT("ZwCreateFile() failed with status (0x%X)\n", Status);
138 }
139
140 if (!NT_SUCCESS(Status)) {
142 *Object = NULL;
143 }
144
145 return Status;
146}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
Definition: create.c:4148
#define FILE_OPEN_IF
Definition: from_kernel.h:56
ULONG Handle
Definition: gdb_input.c:15
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define AFD_SHARE_REUSE
Definition: netio.c:68
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

Referenced by TdiOpenAddressFile(), and TdiOpenConnectionEndpointFile().

◆ TdiQueryAddress()

NTSTATUS TdiQueryAddress ( PFILE_OBJECT  FileObject,
PULONG  Address 
)

Queries for a local IP address.

Parameters
FileObject= Pointer to file object
Address= Address of buffer to place local address
Returns
Status of operation

Definition at line 785 of file tdi.c.

796{
797 UINT i;
798 TDIEntityID *Entities;
800 ULONG EntityType;
801 IPSNMPInfo SnmpInfo;
802 PIPADDR_ENTRY IpAddress;
805
806 DPRINT("Called\n");
807
808 BufferSize = sizeof(TDIEntityID) * 20;
812 if (!Entities) {
813 DPRINT("Insufficient resources.\n");
815 }
816
817 /* Query device for supported entities */
818
819 Status = TdiQueryInformationEx(FileObject, /* File object */
820 GENERIC_ENTITY, /* Entity */
821 TL_INSTANCE, /* Instance */
822 INFO_CLASS_GENERIC, /* Entity class */
823 INFO_TYPE_PROVIDER, /* Entity type */
824 ENTITY_LIST_ID, /* Entity id */
825 Entities, /* Output buffer */
826 &BufferSize); /* Output buffer size */
827 if (!NT_SUCCESS(Status)) {
828 DPRINT("Unable to get list of supported entities (Status = 0x%X).\n", Status);
830 return Status;
831 }
832
833 /* Locate an IP entity */
835
836 DPRINT("EntityCount = %u\n", EntityCount);
837
838 for (i = 0; i < EntityCount; i++) {
839 if (Entities[i].tei_entity == CL_NL_ENTITY) {
840 /* Query device for entity type */
841
842 BufferSize = sizeof(EntityType);
843 Status = TdiQueryInformationEx(FileObject, /* File object */
844 CL_NL_ENTITY, /* Entity */
845 Entities[i].tei_instance, /* Instance */
846 INFO_CLASS_GENERIC, /* Entity class */
847 INFO_TYPE_PROVIDER, /* Entity type */
848 ENTITY_TYPE_ID, /* Entity id */
849 &EntityType, /* Output buffer */
850 &BufferSize); /* Output buffer size */
851 if (!NT_SUCCESS(Status) || (EntityType != CL_NL_IP)) {
852 DPRINT("Unable to get entity of type IP (Status = 0x%X).\n", Status);
853 break;
854 }
855
856 /* Query device for SNMP information */
857
858 BufferSize = sizeof(SnmpInfo);
859 Status = TdiQueryInformationEx(FileObject, /* File object */
860 CL_NL_ENTITY, /* Entity */
861 Entities[i].tei_instance, /* Instance */
862 INFO_CLASS_PROTOCOL, /* Entity class */
863 INFO_TYPE_PROVIDER, /* Entity type */
864 IP_MIB_STATS_ID, /* Entity id */
865 &SnmpInfo, /* Output buffer */
866 &BufferSize); /* Output buffer size */
867 if (!NT_SUCCESS(Status) || (SnmpInfo.ipsi_numaddr == 0)) {
868 DPRINT("Unable to get SNMP information or no IP addresses available (Status = 0x%X).\n", Status);
869 break;
870 }
871
872 /* Query device for all IP addresses */
873
874 if (SnmpInfo.ipsi_numaddr != 0) {
875 BufferSize = SnmpInfo.ipsi_numaddr * sizeof(IPADDR_ENTRY);
879 if (!IpAddress) {
880 DPRINT("Insufficient resources.\n");
881 break;
882 }
883
884 Status = TdiQueryInformationEx(FileObject, /* File object */
885 CL_NL_ENTITY, /* Entity */
886 Entities[i].tei_instance, /* Instance */
887 INFO_CLASS_PROTOCOL, /* Entity class */
888 INFO_TYPE_PROVIDER, /* Entity type */
889 IP_MIB_ADDRTABLE_ENTRY_ID, /* Entity id */
890 IpAddress, /* Output buffer */
891 &BufferSize); /* Output buffer size */
892 if (!NT_SUCCESS(Status)) {
893 DPRINT("Unable to get IP address (Status = 0x%X).\n", Status);
895 break;
896 }
897
898 if (SnmpInfo.ipsi_numaddr != 1) {
899 /* Skip loopback address */
900 *Address = DN2H(IpAddress[1].Addr);
901 } else {
902 /* Select the first address returned */
903 *Address = DN2H(IpAddress->Addr);
904 }
905
907 } else {
909 break;
910 }
911 }
912 }
913
915
916 DPRINT("Leaving\n");
917
918 return Status;
919}
#define DN2H(dw)
Definition: addrconv.c:21
struct IPADDR_ENTRY * PIPADDR_ENTRY
#define IP_MIB_STATS_ID
Definition: afd.h:35
#define IP_MIB_ADDRTABLE_ENTRY_ID
Definition: afd.h:36
#define TAG_AFD_SNMP_ADDRESS_INFO
Definition: afd.h:53
#define TL_INSTANCE
Definition: afd.h:34
#define TAG_AFD_TRANSPORT_ADDRESS
Definition: afd.h:39
#define BufferSize
Definition: mmc.h:75
ULONG EntityCount
Definition: main.c:28
NTSTATUS TdiQueryInformationEx(PFILE_OBJECT FileObject, ULONG Entity, ULONG Instance, ULONG Class, ULONG Type, ULONG Id, PVOID OutputBuffer, PULONG OutputLength)
Extended query for information.
Definition: tdi.c:743
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
unsigned int UINT
Definition: ndis.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: afd.h:57
ULONG Addr
Definition: afd.h:58
ULONG ipsi_numaddr
Definition: tcpioctl.h:159
#define CL_NL_IP
Definition: tdiinfo.h:54
#define ENTITY_LIST_ID
Definition: tdiinfo.h:38
struct _TDIEntityID TDIEntityID
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65
#define ENTITY_TYPE_ID
Definition: tdiinfo.h:39
#define INFO_CLASS_GENERIC
Definition: tdiinfo.h:64
#define INFO_TYPE_PROVIDER
Definition: tdiinfo.h:69
#define GENERIC_ENTITY
Definition: tdiinfo.h:37
#define CL_NL_ENTITY
Definition: tdiinfo.h:42
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

◆ TdiQueryDeviceControl()

NTSTATUS TdiQueryDeviceControl ( PFILE_OBJECT  FileObject,
ULONG  IoControlCode,
PVOID  InputBuffer,
ULONG  InputBufferLength,
PVOID  OutputBuffer,
ULONG  OutputBufferLength,
PULONG  Return 
)

Queries a device for information.

Parameters
FileObject= Pointer to file object
IoControlCode= I/O control code
InputBuffer= Pointer to buffer with input data
InputBufferLength= Length of InputBuffer
OutputBuffer= Address of buffer to place output data
OutputBufferLength= Length of OutputBuffer
Returns
Status of operation

Definition at line 630 of file tdi.c.

650{
655 PIRP Irp;
656
657 if (!FileObject) {
658 DPRINT("Bad file object.\n");
660 }
661
663 if (!DeviceObject) {
664 DPRINT("Bad device object.\n");
666 }
667
669
676 FALSE,
677 &Event,
678 &Iosb);
679 if (!Irp)
681
683
684 if (Return)
685 *Return = Iosb.Information;
686
687 return Status;
688}
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953

Referenced by TdiQueryInformationEx().

◆ TdiQueryInformation()

NTSTATUS TdiQueryInformation ( PFILE_OBJECT  FileObject,
LONG  QueryType,
PMDL  MdlBuffer 
)

Query for information.

Parameters
FileObject= Pointer to file object
QueryType= Query type
MdlBuffer= Pointer to MDL buffer specific for query type
Returns
Status of operation

Definition at line 691 of file tdi.c.

704{
708 PIRP Irp;
709
710 if (!FileObject) {
711 DPRINT("Bad file object.\n");
713 }
714
716 if (!DeviceObject) {
717 DPRINT("Bad device object.\n");
719 }
720
722
725 ConnectionObject,
726 &Event,
727 &Iosb);
728 if (!Irp) {
730 }
731
735 NULL,
736 NULL,
737 QueryType,
738 MdlBuffer);
739
740 return TdiCall(Irp, DeviceObject, &Event, &Iosb);
741}
_Must_inspect_result_ _In_ KTMOBJECT_TYPE QueryType
Definition: nttmapi.h:404
#define TDI_QUERY_INFORMATION
Definition: tdikrnl.h:58
#define TdiBuildQueryInformation( Irp, DevObj, FileObj, CompRoutine, Contxt, QType, MdlAddr)
Definition: tdikrnl.h:638

Referenced by AfdGetSockName(), and TdiQueryMaxDatagramLength().

◆ TdiQueryInformationEx()

NTSTATUS TdiQueryInformationEx ( PFILE_OBJECT  FileObject,
ULONG  Entity,
ULONG  Instance,
ULONG  Class,
ULONG  Type,
ULONG  Id,
PVOID  OutputBuffer,
PULONG  OutputLength 
)

Extended query for information.

Parameters
FileObject= Pointer to file object
Entity= Entity
Instance= Instance
Class= Entity class
Type= Entity type
Id= Entity id
OutputBuffer= Address of buffer to place data
OutputLength= Address of buffer with length of OutputBuffer (updated)
Returns
Status of operation

Definition at line 743 of file tdi.c.

766{
768
770 QueryInfo.ID.toi_entity.tei_entity = Entity;
772 QueryInfo.ID.toi_class = Class;
773 QueryInfo.ID.toi_type = Type;
774 QueryInfo.ID.toi_id = Id;
775
776 return TdiQueryDeviceControl(FileObject, /* Transport/connection object */
777 IOCTL_TCP_QUERY_INFORMATION_EX, /* Control code */
778 &QueryInfo, /* Input buffer */
779 sizeof(TCP_REQUEST_QUERY_INFORMATION_EX), /* Input buffer length */
780 OutputBuffer, /* Output buffer */
781 *OutputLength, /* Output buffer length */
782 OutputLength); /* Return information */
783}
DWORD Id
Type
Definition: Type.h:7
NTSTATUS TdiQueryDeviceControl(PFILE_OBJECT FileObject, ULONG IoControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG Return)
Queries a device for information.
Definition: tdi.c:630
ULONG tei_entity
Definition: tdiinfo.h:31
ULONG tei_instance
Definition: tdiinfo.h:32
ULONG toi_id
Definition: tdiinfo.h:77
ULONG toi_type
Definition: tdiinfo.h:76
ULONG toi_class
Definition: tdiinfo.h:75
TDIEntityID toi_entity
Definition: tdiinfo.h:74
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: tditest.h:110
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481

Referenced by TdiQueryAddress().

◆ TdiQueryMaxDatagramLength()

NTSTATUS TdiQueryMaxDatagramLength ( PFILE_OBJECT  FileObject,
PUINT  MaxDatagramLength 
)

Definition at line 203 of file tdi.c.

206{
207 PMDL Mdl;
210
212 sizeof(TDI_MAX_DATAGRAM_INFO),
214
215 if (!Buffer) return STATUS_NO_MEMORY;
216
218 if (!Mdl)
219 {
221 return STATUS_NO_MEMORY;
222 }
223
225 {
227 }
229 {
231 }
232 _SEH2_END;
233
234 if (!NT_SUCCESS(Status))
235 {
236 DPRINT("Failed to lock pages\n");
237 IoFreeMdl(Mdl);
239 return Status;
240 }
241
244 Mdl);
245 if (!NT_SUCCESS(Status))
246 {
248 return Status;
249 }
250
251 *MaxDatagramLength = Buffer->MaxDatagramSize;
252
254
255 return STATUS_SUCCESS;
256}
#define TAG_AFD_DATA_BUFFER
Definition: afd.h:38
Definition: bufpool.h:45
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
NTSTATUS TdiQueryInformation(PFILE_OBJECT FileObject, LONG QueryType, PMDL MdlBuffer)
Query for information.
Definition: tdi.c:691
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define TDI_QUERY_MAX_DATAGRAM_INFO
Definition: tdi.h:187
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
@ IoModifyAccess
Definition: ketypes.h:917

Referenced by MakeSocketIntoConnection(), and WarmSocketForBind().

◆ TdiReceive()

NTSTATUS TdiReceive ( PIRP Irp,
PFILE_OBJECT  TransportObject,
USHORT  Flags,
PCHAR  Buffer,
UINT  BufferLength,
PIO_COMPLETION_ROUTINE  CompletionRoutine,
PVOID  CompletionContext 
)

Definition at line 995 of file tdi.c.

1003{
1005 PMDL Mdl;
1006
1007 if (!TransportObject) {
1008 DPRINT("Bad transport object.\n");
1010 }
1011
1012 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1013 if (!DeviceObject) {
1014 DPRINT("Bad device object.\n");
1016 }
1017
1020 TransportObject,
1021 NULL,
1022 NULL);
1023
1024 if (!*Irp) {
1025 DPRINT("Insufficient resources.\n");
1027 }
1028
1029 DPRINT("Allocating irp for %p:%u\n", Buffer,BufferLength);
1030
1031 Mdl = IoAllocateMdl(Buffer, /* Virtual address */
1032 BufferLength, /* Length of buffer */
1033 FALSE, /* Not secondary */
1034 FALSE, /* Don't charge quota */
1035 NULL); /* Don't use IRP */
1036 if (!Mdl) {
1037 DPRINT("Insufficient resources.\n");
1039 *Irp = NULL;
1041 }
1042
1043 _SEH2_TRY {
1044 DPRINT("probe and lock\n");
1045 MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
1046 DPRINT("probe and lock done\n");
1048 DPRINT("MmProbeAndLockPages() failed.\n");
1049 IoFreeMdl(Mdl);
1051 *Irp = NULL;
1053 } _SEH2_END;
1054
1055 DPRINT("AFD>>> Got an MDL: %p\n", Mdl);
1056
1059 TransportObject,
1062 Mdl,
1063 Flags,
1064 BufferLength);
1065
1066
1068 /* Does not block... The MDL is deleted in the receive completion
1069 routine. */
1070
1071 return STATUS_PENDING;
1072}
#define IoCompleteRequest
Definition: irp.c:1240
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
#define TdiBuildReceive( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, InFlags, ReceiveLen)
Definition: tdikrnl.h:667
#define TDI_RECEIVE
Definition: tdikrnl.h:54
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by MakeSocketIntoConnection(), RefillSocketBuffer(), and WskStreamIo().

◆ TdiReceiveDatagram()

NTSTATUS TdiReceiveDatagram ( PIRP Irp,
PFILE_OBJECT  TransportObject,
USHORT  Flags,
PCHAR  Buffer,
UINT  BufferLength,
PTDI_CONNECTION_INFORMATION  Addr,
PIO_COMPLETION_ROUTINE  CompletionRoutine,
PVOID  CompletionContext 
)

Receives a datagram.

Parameters
TransportObject= Pointer to transport object
From= Receive filter (NULL if none)
Address= Address of buffer to place remote address
Buffer= Address of buffer to place received data
BufferSize= Address of buffer with length of Buffer (updated)
Returns
Status of operation

Definition at line 1075 of file tdi.c.

1095{
1097 PMDL Mdl;
1098
1099 if (!TransportObject) {
1100 DPRINT("Bad tranport object.\n");
1102 }
1103
1104 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1105 if (!DeviceObject) {
1106 DPRINT("Bad device object.\n");
1108 }
1109
1112 TransportObject,
1113 NULL,
1114 NULL);
1115
1116 if (!*Irp) {
1117 DPRINT("Insufficient resources.\n");
1119 }
1120
1121 DPRINT("Allocating irp for %p:%u\n", Buffer,BufferLength);
1122
1123 Mdl = IoAllocateMdl(Buffer, /* Virtual address */
1124 BufferLength, /* Length of buffer */
1125 FALSE, /* Not secondary */
1126 FALSE, /* Don't charge quota */
1127 NULL); /* Don't use IRP */
1128 if (!Mdl) {
1129 DPRINT("Insufficient resources.\n");
1131 *Irp = NULL;
1133 }
1134
1135 _SEH2_TRY {
1136 MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
1138 DPRINT("MmProbeAndLockPages() failed.\n");
1139 IoFreeMdl(Mdl);
1141 *Irp = NULL;
1143 } _SEH2_END;
1144
1145 DPRINT("AFD>>> Got an MDL: %p\n", Mdl);
1146
1149 TransportObject,
1152 Mdl,
1154 Addr,
1155 Addr,
1156 Flags);
1157
1159 /* Does not block... The MDL is deleted in the receive completion
1160 routine. */
1161
1162 return STATUS_PENDING;
1163}
#define TDI_RECEIVE_DATAGRAM
Definition: tdikrnl.h:56
#define TdiBuildReceiveDatagram( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, ReceiveLen, ReceiveDatagramInfo, ReturnInfo, InFlags)
Definition: tdikrnl.h:699

Referenced by PacketSocketRecvComplete(), and WarmSocketForBind().

◆ TdiSend()

NTSTATUS TdiSend ( PIRP Irp,
PFILE_OBJECT  TransportObject,
USHORT  Flags,
PCHAR  Buffer,
UINT  BufferLength,
PIO_COMPLETION_ROUTINE  CompletionRoutine,
PVOID  CompletionContext 
)

Definition at line 921 of file tdi.c.

929{
931 PMDL Mdl;
932
933 if (!TransportObject) {
934 DPRINT("Bad transport object.\n");
936 }
937
938 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
939 if (!DeviceObject) {
940 DPRINT("Bad device object.\n");
942 }
943
946 TransportObject,
947 NULL,
948 NULL);
949
950 if (!*Irp) {
951 DPRINT("Insufficient resources.\n");
953 }
954
955 DPRINT("Allocating irp for %p:%u\n", Buffer,BufferLength);
956
957 Mdl = IoAllocateMdl(Buffer, /* Virtual address */
958 BufferLength, /* Length of buffer */
959 FALSE, /* Not secondary */
960 FALSE, /* Don't charge quota */
961 NULL); /* Don't use IRP */
962 if (!Mdl) {
963 DPRINT("Insufficient resources.\n");
965 *Irp = NULL;
967 }
968
969 _SEH2_TRY {
970 MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoReadAccess);
972 DPRINT("MmProbeAndLockPages() failed.\n");
973 IoFreeMdl(Mdl);
975 *Irp = NULL;
977 } _SEH2_END;
978
979 DPRINT("AFD>>> Got an MDL: %p\n", Mdl);
980
983 TransportObject,
986 Mdl,
987 Flags,
989
990 /* Does not block... The MDL is deleted in the receive completion
991 routine. */
992 return TdiCall(*Irp, DeviceObject, NULL, NULL);
993}
#define TDI_SEND
Definition: tdikrnl.h:53
#define TdiBuildSend( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, InFlags, SendLen)
Definition: tdikrnl.h:731
@ IoReadAccess
Definition: ketypes.h:915

Referenced by AfdConnectedSocketWriteData(), SendComplete(), StreamSocketConnectComplete(), and WskStreamIo().

◆ TdiSendDatagram()

NTSTATUS TdiSendDatagram ( PIRP Irp,
PFILE_OBJECT  TransportObject,
PCHAR  Buffer,
UINT  BufferLength,
PTDI_CONNECTION_INFORMATION  Addr,
PIO_COMPLETION_ROUTINE  CompletionRoutine,
PVOID  CompletionContext 
)

Sends a datagram.

Parameters
TransportObject= Pointer to transport object
From= Send filter (NULL if none)
Address= Address of buffer to place remote address
Buffer= Address of buffer to place send data
BufferSize= Address of buffer with length of Buffer (updated)
Returns
Status of operation

Definition at line 1166 of file tdi.c.

1185{
1187 PMDL Mdl;
1188
1189 if (!TransportObject) {
1190 DPRINT("Bad transport object.\n");
1192 }
1193
1194 DPRINT("Called(TransportObject %p)\n", TransportObject);
1195
1196 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1197 if (!DeviceObject) {
1198 DPRINT("Bad device object.\n");
1200 }
1201
1202 if (BufferLength == 0)
1203 {
1204 DPRINT("Succeeding send with length 0.\n");
1205 return STATUS_SUCCESS;
1206 }
1207
1210 TransportObject,
1211 NULL,
1212 NULL);
1213
1214 if (!*Irp) {
1215 DPRINT("Insufficient resources.\n");
1217 }
1218
1219 DPRINT("Allocating irp for %p:%u\n", Buffer,BufferLength);
1220
1221 Mdl = IoAllocateMdl(Buffer, /* Virtual address */
1222 BufferLength, /* Length of buffer */
1223 FALSE, /* Not secondary */
1224 FALSE, /* Don't charge quota */
1225 NULL); /* Don't use IRP */
1226
1227 if (!Mdl) {
1228 DPRINT("Insufficient resources.\n");
1230 *Irp = NULL;
1232 }
1233
1234 _SEH2_TRY {
1235 MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoReadAccess);
1237 DPRINT("MmProbeAndLockPages() failed.\n");
1238 IoFreeMdl(Mdl);
1240 *Irp = NULL;
1242 } _SEH2_END;
1243
1244 DPRINT("AFD>>> Got an MDL: %p\n", Mdl);
1245
1248 TransportObject,
1251 Mdl,
1253 Addr);
1254
1255 /* Does not block... The MDL is deleted in the send completion
1256 routine. */
1257 return TdiCall(*Irp, DeviceObject, NULL, NULL);
1258}
#define TDI_SEND_DATAGRAM
Definition: tdikrnl.h:55
#define TdiBuildSendDatagram( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, SendLen, SendDatagramInfo)
Definition: tdikrnl.h:761

Referenced by AfdConnectedSocketWriteData(), AfdPacketSocketWriteData(), and WskSendTo().

◆ TdiSetEventHandler()

NTSTATUS TdiSetEventHandler ( PFILE_OBJECT  FileObject,
LONG  EventType,
PVOID  Handler,
PVOID  Context 
)

Sets or resets an event handler.

Parameters
FileObject= Pointer to file object
EventType= Event code
Handler= Event handler to be called when the event occurs
Context= Context input to handler when the event occurs
Returns
Status of operation

Specify NULL for Handler to stop calling event handler

Definition at line 569 of file tdi.c.

586{
590 PIRP Irp;
591
592 DPRINT("Called\n");
593
594 if (!FileObject) {
595 DPRINT("Bad file object.\n");
597 }
598
600 if (!DeviceObject) {
601 DPRINT("Bad device object.\n");
603 }
604
606
610 &Event,
611 &Iosb);
612 if (!Irp)
614
615
616
620 NULL,
621 NULL,
622 EventType,
623 Handler,
624 Context);
625
626 return TdiCall(Irp, DeviceObject, &Event, &Iosb);
627}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:672
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ EVENT_TYPE EventType
Definition: exfuncs.h:167
#define TdiBuildSetEventHandler( Irp, DevObj, FileObj, CompRoutine, Contxt, InEventType, InEventHandler, InEventContext)
Definition: tdikrnl.h:791
#define TDI_SET_EVENT_HANDLER
Definition: tdikrnl.h:57

Referenced by AfdDeregisterEventHandlers(), and AfdRegisterEventHandlers().