ReactOS 0.4.16-dev-1946-g52006dd
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 517 of file tdi.c.

533{
535
536 DPRINT("Called\n");
537
538 if (!AcceptConnectionObject) {
539 DPRINT("Bad connection object.\n");
541 }
542
543 DeviceObject = IoGetRelatedDeviceObject(AcceptConnectionObject);
544 if (!DeviceObject) {
545 DPRINT("Bad device object.\n");
547 }
548
551 AcceptConnectionObject,
552 NULL,
553 NULL);
554 if (*Irp == NULL)
556
559 AcceptConnectionObject,
562 RequestConnectionInfo,
563 ReturnConnectionInfo);
564
565 TdiCall(*Irp, DeviceObject, NULL /* Don't wait for completion */, NULL);
566
567 return STATUS_PENDING;
568}
_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 366 of file tdi.c.

377{
381 PIRP Irp;
382
383 DPRINT("Called. AddressHandle (%p) ConnectionObject (%p)\n", AddressHandle, ConnectionObject);
384
385 if (!ConnectionObject) {
386 DPRINT("Bad connection object.\n");
388 }
389
390 DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
391 if (!DeviceObject) {
392 DPRINT("Bad device object.\n");
394 }
395
397
400 ConnectionObject,
401 &Event,
402 &Iosb);
403 if (!Irp)
405
408 ConnectionObject,
409 NULL,
410 NULL,
411 AddressHandle);
412
413 return TdiCall(Irp, DeviceObject, &Event, &Iosb);
414}
#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
361
362 return STATUS_PENDING;
363}
#define TDI_CONNECT
Definition: tdikrnl.h:49
#define TdiBuildConnect( Irp, DevObj, FileObj, CompRoutine, Contxt, Time, RequestConnectionInfo, ReturnConnectionInfo)
Definition: tdikrnl.h:494

Referenced by AfdStreamSocketConnect(), 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 416 of file tdi.c.

425{
429 PIRP Irp;
430
431 DPRINT("Called. ConnectionObject (%p)\n", ConnectionObject);
432
433 if (!ConnectionObject) {
434 DPRINT("Bad connection object.\n");
436 }
437
438 DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
439 if (!DeviceObject) {
440 DPRINT("Bad device object.\n");
442 }
443
445
448 ConnectionObject,
449 &Event,
450 &Iosb);
451 if (!Irp)
453
456 ConnectionObject,
457 NULL,
458 NULL);
459
460 return TdiCall(Irp, DeviceObject, &Event, &Iosb);
461}
#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 1266 of file tdi.c.

1274 {
1276
1277 if (!TransportObject) {
1278 DPRINT("Bad transport object.\n");
1280 }
1281
1282 DPRINT("Called(TransportObject %p)\n", TransportObject);
1283
1284 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1285 if (!DeviceObject) {
1286 DPRINT("Bad device object.\n");
1288 }
1289
1292 TransportObject,
1293 NULL,
1294 NULL);
1295
1296 if (!*Irp) {
1297 DPRINT("Insufficient resources.\n");
1299 }
1300
1303 TransportObject,
1306 Time,
1307 Flags,
1308 RequestConnectionInfo,
1309 ReturnConnectionInfo);
1310
1312
1313 return STATUS_PENDING;
1314}
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 463 of file tdi.c.

479{
481
482 DPRINT("Called\n");
483
484 if (!ConnectionObject) {
485 DPRINT("Bad connection object.\n");
487 }
488
489 DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
490 if (!DeviceObject) {
491 DPRINT("Bad device object.\n");
493 }
494
497 ConnectionObject,
498 NULL,
499 NULL);
500 if (*Irp == NULL)
502
505 ConnectionObject,
508 0,
509 *RequestConnectionInfo,
510 *ReturnConnectionInfo);
511
512 TdiCall(*Irp, DeviceObject, NULL /* Don't wait for completion */, NULL);
513
514 return STATUS_PENDING;
515}
#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:50
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 787 of file tdi.c.

798{
799 UINT i;
800 TDIEntityID *Entities;
802 ULONG EntityType;
803 IPSNMPInfo SnmpInfo;
804 PIPADDR_ENTRY IpAddress;
807
808 DPRINT("Called\n");
809
810 BufferSize = sizeof(TDIEntityID) * 20;
814 if (!Entities) {
815 DPRINT("Insufficient resources.\n");
817 }
818
819 /* Query device for supported entities */
820
821 Status = TdiQueryInformationEx(FileObject, /* File object */
822 GENERIC_ENTITY, /* Entity */
823 TL_INSTANCE, /* Instance */
824 INFO_CLASS_GENERIC, /* Entity class */
825 INFO_TYPE_PROVIDER, /* Entity type */
826 ENTITY_LIST_ID, /* Entity id */
827 Entities, /* Output buffer */
828 &BufferSize); /* Output buffer size */
829 if (!NT_SUCCESS(Status)) {
830 DPRINT("Unable to get list of supported entities (Status = 0x%X).\n", Status);
832 return Status;
833 }
834
835 /* Locate an IP entity */
837
838 DPRINT("EntityCount = %u\n", EntityCount);
839
840 for (i = 0; i < EntityCount; i++) {
841 if (Entities[i].tei_entity == CL_NL_ENTITY) {
842 /* Query device for entity type */
843
844 BufferSize = sizeof(EntityType);
845 Status = TdiQueryInformationEx(FileObject, /* File object */
846 CL_NL_ENTITY, /* Entity */
847 Entities[i].tei_instance, /* Instance */
848 INFO_CLASS_GENERIC, /* Entity class */
849 INFO_TYPE_PROVIDER, /* Entity type */
850 ENTITY_TYPE_ID, /* Entity id */
851 &EntityType, /* Output buffer */
852 &BufferSize); /* Output buffer size */
853 if (!NT_SUCCESS(Status) || (EntityType != CL_NL_IP)) {
854 DPRINT("Unable to get entity of type IP (Status = 0x%X).\n", Status);
855 break;
856 }
857
858 /* Query device for SNMP information */
859
860 BufferSize = sizeof(SnmpInfo);
861 Status = TdiQueryInformationEx(FileObject, /* File object */
862 CL_NL_ENTITY, /* Entity */
863 Entities[i].tei_instance, /* Instance */
864 INFO_CLASS_PROTOCOL, /* Entity class */
865 INFO_TYPE_PROVIDER, /* Entity type */
866 IP_MIB_STATS_ID, /* Entity id */
867 &SnmpInfo, /* Output buffer */
868 &BufferSize); /* Output buffer size */
869 if (!NT_SUCCESS(Status) || (SnmpInfo.ipsi_numaddr == 0)) {
870 DPRINT("Unable to get SNMP information or no IP addresses available (Status = 0x%X).\n", Status);
871 break;
872 }
873
874 /* Query device for all IP addresses */
875
876 if (SnmpInfo.ipsi_numaddr != 0) {
877 BufferSize = SnmpInfo.ipsi_numaddr * sizeof(IPADDR_ENTRY);
881 if (!IpAddress) {
882 DPRINT("Insufficient resources.\n");
883 break;
884 }
885
886 Status = TdiQueryInformationEx(FileObject, /* File object */
887 CL_NL_ENTITY, /* Entity */
888 Entities[i].tei_instance, /* Instance */
889 INFO_CLASS_PROTOCOL, /* Entity class */
890 INFO_TYPE_PROVIDER, /* Entity type */
891 IP_MIB_ADDRTABLE_ENTRY_ID, /* Entity id */
892 IpAddress, /* Output buffer */
893 &BufferSize); /* Output buffer size */
894 if (!NT_SUCCESS(Status)) {
895 DPRINT("Unable to get IP address (Status = 0x%X).\n", Status);
897 break;
898 }
899
900 if (SnmpInfo.ipsi_numaddr != 1) {
901 /* Skip loopback address */
902 *Address = DN2H(IpAddress[1].Addr);
903 } else {
904 /* Select the first address returned */
905 *Address = DN2H(IpAddress->Addr);
906 }
907
909 } else {
911 break;
912 }
913 }
914 }
915
917
918 DPRINT("Leaving\n");
919
920 return Status;
921}
#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:52
#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:745
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:56
ULONG Addr
Definition: afd.h:57
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 632 of file tdi.c.

652{
657 PIRP Irp;
658
659 if (!FileObject) {
660 DPRINT("Bad file object.\n");
662 }
663
665 if (!DeviceObject) {
666 DPRINT("Bad device object.\n");
668 }
669
671
678 FALSE,
679 &Event,
680 &Iosb);
681 if (!Irp)
683
685
686 if (Return)
687 *Return = Iosb.Information;
688
689 return Status;
690}
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 693 of file tdi.c.

706{
710 PIRP Irp;
711
712 if (!FileObject) {
713 DPRINT("Bad file object.\n");
715 }
716
718 if (!DeviceObject) {
719 DPRINT("Bad device object.\n");
721 }
722
724
727 ConnectionObject,
728 &Event,
729 &Iosb);
730 if (!Irp) {
732 }
733
737 NULL,
738 NULL,
739 QueryType,
740 MdlBuffer);
741
742 return TdiCall(Irp, DeviceObject, &Event, &Iosb);
743}
_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 745 of file tdi.c.

768{
770
772 QueryInfo.ID.toi_entity.tei_entity = Entity;
774 QueryInfo.ID.toi_class = Class;
775 QueryInfo.ID.toi_type = Type;
776 QueryInfo.ID.toi_id = Id;
777
778 return TdiQueryDeviceControl(FileObject, /* Transport/connection object */
779 IOCTL_TCP_QUERY_INFORMATION_EX, /* Control code */
780 &QueryInfo, /* Input buffer */
781 sizeof(TCP_REQUEST_QUERY_INFORMATION_EX), /* Input buffer length */
782 OutputBuffer, /* Output buffer */
783 *OutputLength, /* Output buffer length */
784 OutputLength); /* Return information */
785}
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:632
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:693
#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 999 of file tdi.c.

1007{
1009 PMDL Mdl;
1010
1011 if (!TransportObject) {
1012 DPRINT("Bad transport object.\n");
1014 }
1015
1016 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1017 if (!DeviceObject) {
1018 DPRINT("Bad device object.\n");
1020 }
1021
1024 TransportObject,
1025 NULL,
1026 NULL);
1027
1028 if (!*Irp) {
1029 DPRINT("Insufficient resources.\n");
1031 }
1032
1033 DPRINT("Allocating irp for %p:%u\n", Buffer,BufferLength);
1034
1035 Mdl = IoAllocateMdl(Buffer, /* Virtual address */
1036 BufferLength, /* Length of buffer */
1037 FALSE, /* Not secondary */
1038 FALSE, /* Don't charge quota */
1039 NULL); /* Don't use IRP */
1040 if (!Mdl) {
1041 DPRINT("Insufficient resources.\n");
1043 *Irp = NULL;
1045 }
1046
1047 _SEH2_TRY {
1048 DPRINT("probe and lock\n");
1049 MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
1050 DPRINT("probe and lock done\n");
1052 DPRINT("MmProbeAndLockPages() failed.\n");
1053 IoFreeMdl(Mdl);
1055 *Irp = NULL;
1057 } _SEH2_END;
1058
1059 DPRINT("AFD>>> Got an MDL: %p\n", Mdl);
1060
1063 TransportObject,
1066 Mdl,
1067 Flags,
1068 BufferLength);
1069
1070
1072 /* Does not block... The MDL is deleted in the receive completion
1073 routine. */
1074
1075 return STATUS_PENDING;
1076}
#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 1079 of file tdi.c.

1099{
1101 PMDL Mdl;
1102
1103 if (!TransportObject) {
1104 DPRINT("Bad tranport object.\n");
1106 }
1107
1108 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1109 if (!DeviceObject) {
1110 DPRINT("Bad device object.\n");
1112 }
1113
1116 TransportObject,
1117 NULL,
1118 NULL);
1119
1120 if (!*Irp) {
1121 DPRINT("Insufficient resources.\n");
1123 }
1124
1125 DPRINT("Allocating irp for %p:%u\n", Buffer,BufferLength);
1126
1127 Mdl = IoAllocateMdl(Buffer, /* Virtual address */
1128 BufferLength, /* Length of buffer */
1129 FALSE, /* Not secondary */
1130 FALSE, /* Don't charge quota */
1131 NULL); /* Don't use IRP */
1132 if (!Mdl) {
1133 DPRINT("Insufficient resources.\n");
1135 *Irp = NULL;
1137 }
1138
1139 _SEH2_TRY {
1140 MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
1142 DPRINT("MmProbeAndLockPages() failed.\n");
1143 IoFreeMdl(Mdl);
1145 *Irp = NULL;
1147 } _SEH2_END;
1148
1149 DPRINT("AFD>>> Got an MDL: %p\n", Mdl);
1150
1153 TransportObject,
1156 Mdl,
1158 Addr,
1159 Addr,
1160 Flags);
1161
1163 /* Does not block... The MDL is deleted in the receive completion
1164 routine. */
1165
1166 return STATUS_PENDING;
1167}
#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 923 of file tdi.c.

931{
933 PMDL Mdl;
934
935 if (!TransportObject) {
936 DPRINT("Bad transport object.\n");
938 }
939
940 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
941 if (!DeviceObject) {
942 DPRINT("Bad device object.\n");
944 }
945
948 TransportObject,
949 NULL,
950 NULL);
951
952 if (!*Irp) {
953 DPRINT("Insufficient resources.\n");
955 }
956
957 DPRINT("Allocating irp for %p:%u\n", Buffer,BufferLength);
958
959 Mdl = IoAllocateMdl(Buffer, /* Virtual address */
960 BufferLength, /* Length of buffer */
961 FALSE, /* Not secondary */
962 FALSE, /* Don't charge quota */
963 NULL); /* Don't use IRP */
964 if (!Mdl) {
965 DPRINT("Insufficient resources.\n");
967 *Irp = NULL;
969 }
970
971 _SEH2_TRY {
972 MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoReadAccess);
974 DPRINT("MmProbeAndLockPages() failed.\n");
975 IoFreeMdl(Mdl);
977 *Irp = NULL;
979 } _SEH2_END;
980
981 DPRINT("AFD>>> Got an MDL: %p\n", Mdl);
982
985 TransportObject,
988 Mdl,
989 Flags,
991
993 /* Does not block... The MDL is deleted in the receive completion
994 routine. */
995
996 return STATUS_PENDING;
997}
#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(), 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 1170 of file tdi.c.

1189{
1191 PMDL Mdl;
1192
1193 if (!TransportObject) {
1194 DPRINT("Bad transport object.\n");
1196 }
1197
1198 DPRINT("Called(TransportObject %p)\n", TransportObject);
1199
1200 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1201 if (!DeviceObject) {
1202 DPRINT("Bad device object.\n");
1204 }
1205
1206 if (BufferLength == 0)
1207 {
1208 DPRINT("Succeeding send with length 0.\n");
1209 return STATUS_SUCCESS;
1210 }
1211
1214 TransportObject,
1215 NULL,
1216 NULL);
1217
1218 if (!*Irp) {
1219 DPRINT("Insufficient resources.\n");
1221 }
1222
1223 DPRINT("Allocating irp for %p:%u\n", Buffer,BufferLength);
1224
1225 Mdl = IoAllocateMdl(Buffer, /* Virtual address */
1226 BufferLength, /* Length of buffer */
1227 FALSE, /* Not secondary */
1228 FALSE, /* Don't charge quota */
1229 NULL); /* Don't use IRP */
1230
1231 if (!Mdl) {
1232 DPRINT("Insufficient resources.\n");
1234 *Irp = NULL;
1236 }
1237
1238 _SEH2_TRY {
1239 MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoReadAccess);
1241 DPRINT("MmProbeAndLockPages() failed.\n");
1242 IoFreeMdl(Mdl);
1244 *Irp = NULL;
1246 } _SEH2_END;
1247
1248 DPRINT("AFD>>> Got an MDL: %p\n", Mdl);
1249
1252 TransportObject,
1255 Mdl,
1257 Addr);
1258
1260 /* Does not block... The MDL is deleted in the send completion
1261 routine. */
1262
1263 return STATUS_PENDING;
1264}
#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 571 of file tdi.c.

588{
592 PIRP Irp;
593
594 DPRINT("Called\n");
595
596 if (!FileObject) {
597 DPRINT("Bad file object.\n");
599 }
600
602 if (!DeviceObject) {
603 DPRINT("Bad device object.\n");
605 }
606
608
612 &Event,
613 &Iosb);
614 if (!Irp)
616
617
618
622 NULL,
623 NULL,
624 EventType,
625 Handler,
626 Context);
627
628 return TdiCall(Irp, DeviceObject, &Event, &Iosb);
629}
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().