ReactOS  0.4.14-dev-317-g96040ec
tdi.c File Reference
#include <afd.h>
#include <tdikrnl.h>
#include <tdiinfo.h>
Include dependency graph for tdi.c:

Go to the source code of this file.

Functions

static NTSTATUS TdiCall (PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
 
static NTSTATUS TdiOpenDevice (PUNICODE_STRING DeviceName, ULONG EaLength, PFILE_FULL_EA_INFORMATION EaInfo, ULONG ShareType, PHANDLE Handle, PFILE_OBJECT *Object)
 
NTSTATUS TdiOpenAddressFile (PUNICODE_STRING DeviceName, PTRANSPORT_ADDRESS Name, ULONG ShareType, PHANDLE AddressHandle, PFILE_OBJECT *AddressObject)
 
NTSTATUS TdiQueryMaxDatagramLength (PFILE_OBJECT FileObject, PUINT MaxDatagramLength)
 
NTSTATUS TdiOpenConnectionEndpointFile (PUNICODE_STRING DeviceName, PHANDLE ConnectionHandle, PFILE_OBJECT *ConnectionObject)
 
NTSTATUS TdiConnect (PIRP *Irp, PFILE_OBJECT ConnectionObject, PTDI_CONNECTION_INFORMATION ConnectionCallInfo, PTDI_CONNECTION_INFORMATION ConnectionReturnInfo, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 
NTSTATUS TdiAssociateAddressFile (HANDLE AddressHandle, PFILE_OBJECT ConnectionObject)
 
NTSTATUS TdiDisassociateAddressFile (PFILE_OBJECT ConnectionObject)
 
NTSTATUS TdiListen (PIRP *Irp, PFILE_OBJECT ConnectionObject, PTDI_CONNECTION_INFORMATION *RequestConnectionInfo, PTDI_CONNECTION_INFORMATION *ReturnConnectionInfo, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 
NTSTATUS TdiSetEventHandler (PFILE_OBJECT FileObject, LONG EventType, PVOID Handler, PVOID Context)
 
NTSTATUS TdiQueryDeviceControl (PFILE_OBJECT FileObject, ULONG IoControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG Return)
 
NTSTATUS TdiQueryInformation (PFILE_OBJECT FileObject, LONG QueryType, PMDL MdlBuffer)
 
NTSTATUS TdiQueryInformationEx (PFILE_OBJECT FileObject, ULONG Entity, ULONG Instance, ULONG Class, ULONG Type, ULONG Id, PVOID OutputBuffer, PULONG OutputLength)
 
NTSTATUS TdiQueryAddress (PFILE_OBJECT FileObject, PULONG 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)
 
NTSTATUS TdiSendDatagram (PIRP *Irp, PFILE_OBJECT TransportObject, PCHAR Buffer, UINT BufferLength, PTDI_CONNECTION_INFORMATION Addr, PIO_COMPLETION_ROUTINE CompletionRoutine, PVOID CompletionContext)
 
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)
 

Function Documentation

◆ TdiAssociateAddressFile()

NTSTATUS TdiAssociateAddressFile ( HANDLE  AddressHandle,
PFILE_OBJECT  ConnectionObject 
)

Definition at line 391 of file tdi.c.

402 {
405  KEVENT Event;
406  PIRP Irp;
407 
408  AFD_DbgPrint(MAX_TRACE, ("Called. AddressHandle (%p) ConnectionObject (%p)\n",
409  AddressHandle, ConnectionObject));
410 
411  if (!ConnectionObject) {
412  AFD_DbgPrint(MIN_TRACE, ("Bad connection object.\n"));
414  }
415 
416  DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
417  if (!DeviceObject) {
418  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
420  }
421 
423 
425  DeviceObject, /* Device object */
426  ConnectionObject, /* File object */
427  &Event, /* Event */
428  &Iosb); /* Status */
429  if (!Irp)
431 
433  DeviceObject,
434  ConnectionObject,
435  NULL,
436  NULL,
437  AddressHandle);
438 
439  return TdiCall(Irp, DeviceObject, &Event, &Iosb);
440 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TDI_ASSOCIATE_ADDRESS
Definition: tdikrnl.h:47
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
return Iosb
Definition: create.c:4426
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define MAX_TRACE
Definition: debug.h:16
#define MIN_TRACE
Definition: debug.h:14
#define TdiBuildAssociateAddress( Irp, DevObj, FileObj, CompRoutine, Contxt, AddrHandle)
Definition: tdikrnl.h:467

Referenced by WarmSocketForConnection().

◆ TdiCall()

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

Definition at line 46 of file tdi.c.

62 {
64 
65  AFD_DbgPrint(MID_TRACE, ("Called\n"));
66 
67  AFD_DbgPrint(MID_TRACE, ("Irp->UserEvent = %p\n", Irp->UserEvent));
68 
70  AFD_DbgPrint(MID_TRACE, ("IoCallDriver: %08x\n", Status));
71 
72  if ((Status == STATUS_PENDING) && (Event != NULL)) {
73  AFD_DbgPrint(MAX_TRACE, ("Waiting on transport.\n"));
75  Executive,
76  KernelMode,
77  FALSE,
78  NULL);
79  Status = Iosb->Status;
80  }
81 
82  AFD_DbgPrint(MAX_TRACE, ("Status (0x%X).\n", Status));
83 
84  return Status;
85 }
#define MID_TRACE
Definition: debug.h:15
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
smooth NULL
Definition: ftsmooth.c:416
return Iosb
Definition: create.c:4426
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define MAX_TRACE
Definition: debug.h:16
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

Referenced by 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 
)

Definition at line 334 of file tdi.c.

349 {
351 
352  AFD_DbgPrint(MAX_TRACE, ("Called\n"));
353 
354  ASSERT(*Irp == NULL);
355 
356  if (!ConnectionObject) {
357  AFD_DbgPrint(MIN_TRACE, ("Bad connection object.\n"));
359  }
360 
361  DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
362  if (!DeviceObject) {
363  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
365  }
366 
367  *Irp = TdiBuildInternalDeviceControlIrp(TDI_CONNECT, /* Sub function */
368  DeviceObject, /* Device object */
369  ConnectionObject, /* File object */
370  NULL, /* Event */
371  NULL); /* Status */
372  if (!*Irp) {
374  }
375 
376  TdiBuildConnect(*Irp, /* IRP */
377  DeviceObject, /* Device object */
378  ConnectionObject, /* File object */
379  CompletionRoutine, /* Completion routine */
380  CompletionContext, /* Completion routine context */
381  NULL, /* Time */
382  ConnectionCallInfo, /* Request connection information */
383  ConnectionReturnInfo); /* Return connection information */
384 
386 
387  return STATUS_PENDING;
388 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define TDI_CONNECT
Definition: tdikrnl.h:49
smooth NULL
Definition: ftsmooth.c:416
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define TdiBuildConnect( Irp, DevObj, FileObj, CompRoutine, Contxt, Time, RequestConnectionInfo, ReturnConnectionInfo)
Definition: tdikrnl.h:494
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define MAX_TRACE
Definition: debug.h:16
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
#define MIN_TRACE
Definition: debug.h:14

Referenced by AfdStreamSocketConnect().

◆ TdiDisassociateAddressFile()

NTSTATUS TdiDisassociateAddressFile ( PFILE_OBJECT  ConnectionObject)

Definition at line 442 of file tdi.c.

451 {
454  KEVENT Event;
455  PIRP Irp;
456 
457  AFD_DbgPrint(MAX_TRACE, ("Called. ConnectionObject (%p)\n", ConnectionObject));
458 
459  if (!ConnectionObject) {
460  AFD_DbgPrint(MIN_TRACE, ("Bad connection object.\n"));
462  }
463 
464  DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
465  if (!DeviceObject) {
466  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
468  }
469 
471 
473  DeviceObject, /* Device object */
474  ConnectionObject, /* File object */
475  &Event, /* Event */
476  &Iosb); /* Status */
477  if (!Irp)
479 
481  DeviceObject,
482  ConnectionObject,
483  NULL,
484  NULL);
485 
486  return TdiCall(Irp, DeviceObject, &Event, &Iosb);
487 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
#define TdiBuildDisassociateAddress( Irp, DevObj, FileObj, CompRoutine, Contxt)
Definition: tdikrnl.h:521
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
return Iosb
Definition: create.c:4426
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define MAX_TRACE
Definition: debug.h:16
#define MIN_TRACE
Definition: debug.h:14
#define TDI_DISASSOCIATE_ADDRESS
Definition: tdikrnl.h:48

Referenced by AfdCloseSocket().

◆ 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 1249 of file tdi.c.

1257  {
1259 
1260  if (!TransportObject) {
1261  AFD_DbgPrint(MIN_TRACE, ("Bad transport object.\n"));
1262  return STATUS_INVALID_PARAMETER;
1263  }
1264 
1265  AFD_DbgPrint(MID_TRACE,("Called(TransportObject %p)\n", TransportObject));
1266 
1267  DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1268  if (!DeviceObject) {
1269  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
1270  return STATUS_INVALID_PARAMETER;
1271  }
1272 
1273  *Irp = TdiBuildInternalDeviceControlIrp(TDI_DISCONNECT, /* Sub function */
1274  DeviceObject, /* Device object */
1275  TransportObject, /* File object */
1276  NULL, /* Event */
1277  NULL); /* Status */
1278 
1279  if (!*Irp) {
1280  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1282  }
1283 
1284  TdiBuildDisconnect(*Irp, /* I/O Request Packet */
1285  DeviceObject, /* Device object */
1286  TransportObject, /* File object */
1287  CompletionRoutine, /* Completion routine */
1288  CompletionContext, /* Completion context */
1289  Time, /* Time */
1290  Flags, /* Disconnect flags */
1291  RequestConnectionInfo, /* Indication of who to disconnect */
1292  ReturnConnectionInfo); /* Indication of who disconnected */
1293 
1295 
1296  return STATUS_PENDING;
1297 }
#define TdiBuildDisconnect( Irp, DevObj, FileObj, CompRoutine, Contxt, Time, Flags, RequestConnectionInfo, ReturnConnectionInfo)
Definition: tdikrnl.h:545
#define MID_TRACE
Definition: debug.h:15
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define TDI_DISCONNECT
Definition: tdikrnl.h:52
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
smooth NULL
Definition: ftsmooth.c:416
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
#define STATUS_PENDING
Definition: ntstatus.h:82
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
#define MIN_TRACE
Definition: debug.h:14
static PLARGE_INTEGER Time
Definition: time.c:105

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 
)

Definition at line 489 of file tdi.c.

505 {
507 
508  AFD_DbgPrint(MAX_TRACE, ("Called\n"));
509 
510  ASSERT(*Irp == NULL);
511 
512  if (!ConnectionObject) {
513  AFD_DbgPrint(MIN_TRACE, ("Bad connection object.\n"));
515  }
516 
517  DeviceObject = IoGetRelatedDeviceObject(ConnectionObject);
518  if (!DeviceObject) {
519  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
521  }
522 
523  *Irp = TdiBuildInternalDeviceControlIrp(TDI_LISTEN, /* Sub function */
524  DeviceObject, /* Device object */
525  ConnectionObject, /* File object */
526  NULL, /* Event */
527  NULL); /* Status */
528  if (*Irp == NULL)
530 
531  TdiBuildListen(*Irp, /* IRP */
532  DeviceObject, /* Device object */
533  ConnectionObject, /* File object */
534  CompletionRoutine, /* Completion routine */
535  CompletionContext, /* Completion routine context */
536  0, /* Flags */
537  *RequestConnectionInfo, /* Request connection information */
538  *ReturnConnectionInfo); /* Return connection information */
539 
540  TdiCall(*Irp, DeviceObject, NULL /* Don't wait for completion */, NULL);
541 
542  return STATUS_PENDING;
543 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TDI_LISTEN
Definition: tdikrnl.h:50
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
smooth NULL
Definition: ftsmooth.c:416
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define MAX_TRACE
Definition: debug.h:16
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
#define MIN_TRACE
Definition: debug.h:14
#define TdiBuildListen( Irp, DevObj, FileObj, CompRoutine, Contxt, Flags, RequestConnectionInfo, ReturnConnectionInfo)
Definition: tdikrnl.h:593

Referenced by AfdListenSocket(), and ListenComplete().

◆ TdiOpenAddressFile()

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

Definition at line 170 of file tdi.c.

186 {
189  ULONG EaLength;
191 
192  AFD_DbgPrint(MAX_TRACE, ("Called. DeviceName (%wZ) Name (%p)\n",
193  DeviceName, Name));
194 
195  /* EaName must be 0-terminated, even though TDI_TRANSPORT_ADDRESS_LENGTH does *not* include the 0 */
200  EaLength,
202  if (!EaInfo)
204 
205  RtlZeroMemory(EaInfo, EaLength);
207  /* Don't copy the terminating 0; we have already zeroed it */
208  RtlCopyMemory(EaInfo->EaName,
211  EaInfo->EaValueLength = sizeof(TA_IP_ADDRESS);
212  Address =
213  (PTRANSPORT_ADDRESS)(EaInfo->EaName + TDI_TRANSPORT_ADDRESS_LENGTH + 1); /* 0-terminated */
215 
217  EaLength,
218  EaInfo,
219  ShareType,
220  AddressHandle,
221  AddressObject);
223  return Status;
224 }
UINT TaLengthOfTransportAddress(PTRANSPORT_ADDRESS Addr)
Definition: tdiconn.c:46
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _FILE_FULL_EA_INFORMATION * PFILE_FULL_EA_INFORMATION
LONG NTSTATUS
Definition: precomp.h:26
#define TAG_AFD_EA_INFO
Definition: afd.h:50
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
static WCHAR Address[46]
Definition: ping.c:68
struct _TRANSPORT_ADDRESS * PTRANSPORT_ADDRESS
IN PVCB IN PDIRENT OUT PULONG EaLength
Definition: fatprocs.h:866
struct _TA_ADDRESS_IP TA_IP_ADDRESS
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _FILE_FULL_EA_INFORMATION FILE_FULL_EA_INFORMATION
Status
Definition: gdiplustypes.h:24
VOID TaCopyTransportAddressInPlace(PTRANSPORT_ADDRESS Target, PTRANSPORT_ADDRESS Source)
Definition: tdiconn.c:74
#define MAX_TRACE
Definition: debug.h:16
#define TdiTransportAddress
Definition: tdi.h:370
static NTSTATUS TdiOpenDevice(PUNICODE_STRING DeviceName, ULONG EaLength, PFILE_FULL_EA_INFORMATION EaInfo, ULONG ShareType, PHANDLE Handle, PFILE_OBJECT *Object)
Definition: tdi.c:88
#define TDI_TRANSPORT_ADDRESS_LENGTH
Definition: tdi.h:372
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by WarmSocketForBind().

◆ TdiOpenConnectionEndpointFile()

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

Definition at line 281 of file tdi.c.

294 {
296  PVOID *ContextArea;
298  ULONG EaLength;
299 
300  AFD_DbgPrint(MAX_TRACE, ("Called. DeviceName (%wZ)\n", DeviceName));
301 
302  /* EaName must be 0-terminated, even though TDI_TRANSPORT_ADDRESS_LENGTH does *not* include the 0 */
305  sizeof(PVOID) + 1;
306 
308  EaLength,
310  if (!EaInfo)
312 
313  RtlZeroMemory(EaInfo, EaLength);
315  /* Don't copy the terminating 0; we have already zeroed it */
316  RtlCopyMemory(EaInfo->EaName,
319  EaInfo->EaValueLength = sizeof(PVOID);
320  ContextArea = (PVOID*)(EaInfo->EaName + TDI_CONNECTION_CONTEXT_LENGTH + 1); /* 0-terminated */
321  /* FIXME: Allocate context area */
322  *ContextArea = NULL;
324  EaLength,
325  EaInfo,
328  ConnectionObject);
330  return Status;
331 }
#define AFD_SHARE_UNIQUE
Definition: shared.h:191
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _FILE_FULL_EA_INFORMATION * PFILE_FULL_EA_INFORMATION
LONG NTSTATUS
Definition: precomp.h:26
#define TAG_AFD_EA_INFO
Definition: afd.h:50
#define TDI_CONNECTION_CONTEXT_LENGTH
Definition: tdi.h:373
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
IN PVCB IN PDIRENT OUT PULONG EaLength
Definition: fatprocs.h:866
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _FILE_FULL_EA_INFORMATION FILE_FULL_EA_INFORMATION
Status
Definition: gdiplustypes.h:24
#define MAX_TRACE
Definition: debug.h:16
static NTSTATUS TdiOpenDevice(PUNICODE_STRING DeviceName, ULONG EaLength, PFILE_FULL_EA_INFORMATION EaInfo, ULONG ShareType, PHANDLE Handle, PFILE_OBJECT *Object)
Definition: tdi.c:88
#define TdiConnectionContext
Definition: tdi.h:371
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
_In_ PKSPIN_CONNECT _In_ ACCESS_MASK _Out_ PHANDLE ConnectionHandle
Definition: ks.h:4536

Referenced by WarmSocketForConnection().

◆ TdiOpenDevice()

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

Definition at line 88 of file tdi.c.

106 {
107  OBJECT_ATTRIBUTES Attr;
111 
112  AFD_DbgPrint(MAX_TRACE, ("Called. DeviceName (%wZ, %u)\n", DeviceName, ShareType));
113 
114  /* Determine the share access */
115  if (ShareType != AFD_SHARE_REUSE)
116  {
117  /* Exclusive access */
118  ShareAccess = 0;
119  }
120  else
121  {
122  /* Shared access */
124  }
125 
126  InitializeObjectAttributes(&Attr, /* Attribute buffer */
127  DeviceName, /* Device name */
128  OBJ_CASE_INSENSITIVE | /* Attributes */
130  NULL, /* Root directory */
131  NULL); /* Security descriptor */
132 
133  Status = ZwCreateFile(Handle, /* Return file handle */
134  GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, /* Desired access */
135  &Attr, /* Object attributes */
136  &Iosb, /* IO status */
137  0, /* Initial allocation size */
138  FILE_ATTRIBUTE_NORMAL, /* File attributes */
139  ShareAccess, /* Share access */
140  FILE_OPEN_IF, /* Create disposition */
141  0, /* Create options */
142  EaInfo, /* EA buffer */
143  EaLength); /* EA length */
144  if (NT_SUCCESS(Status)) {
145  Status = ObReferenceObjectByHandle(*Handle, /* Handle to open file */
146  GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, /* Access mode */
147  *IoFileObjectType, /* Object type */
148  KernelMode, /* Access mode */
149  (PVOID*)Object, /* Pointer to object */
150  NULL); /* Handle information */
151  if (!NT_SUCCESS(Status)) {
152  AFD_DbgPrint(MIN_TRACE, ("ObReferenceObjectByHandle() failed with status (0x%X).\n", Status));
153  ZwClose(*Handle);
154  } else {
155  AFD_DbgPrint(MAX_TRACE, ("Got handle (%p) Object (%p)\n",
156  *Handle, *Object));
157  }
158  } else {
159  AFD_DbgPrint(MIN_TRACE, ("ZwCreateFile() failed with status (0x%X)\n", Status));
160  }
161 
162  if (!NT_SUCCESS(Status)) {
164  *Object = NULL;
165  }
166 
167  return Status;
168 }
#define FILE_OPEN_IF
Definition: from_kernel.h:56
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
WCHAR DeviceName[]
Definition: adapter.cpp:21
_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:4157
#define FILE_SHARE_READ
Definition: compat.h:125
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:496
#define GENERIC_WRITE
Definition: nt_native.h:90
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
IN PVCB IN PDIRENT OUT PULONG EaLength
Definition: fatprocs.h:866
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static IUnknown Object
Definition: main.c:512
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
#define SYNCHRONIZE
Definition: nt_native.h:61
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
Status
Definition: gdiplustypes.h:24
#define MAX_TRACE
Definition: debug.h:16
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define AFD_SHARE_REUSE
Definition: shared.h:192

Referenced by TdiOpenAddressFile(), and TdiOpenConnectionEndpointFile().

◆ TdiQueryAddress()

NTSTATUS TdiQueryAddress ( PFILE_OBJECT  FileObject,
PULONG  Address 
)

Definition at line 762 of file tdi.c.

773 {
774  UINT i;
775  TDIEntityID *Entities;
777  ULONG EntityType;
778  IPSNMPInfo SnmpInfo;
779  PIPADDR_ENTRY IpAddress;
782 
783  AFD_DbgPrint(MAX_TRACE, ("Called\n"));
784 
785  BufferSize = sizeof(TDIEntityID) * 20;
787  BufferSize,
789  if (!Entities) {
790  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
792  }
793 
794  /* Query device for supported entities */
795 
796  Status = TdiQueryInformationEx(FileObject, /* File object */
797  GENERIC_ENTITY, /* Entity */
798  TL_INSTANCE, /* Instance */
799  INFO_CLASS_GENERIC, /* Entity class */
800  INFO_TYPE_PROVIDER, /* Entity type */
801  ENTITY_LIST_ID, /* Entity id */
802  Entities, /* Output buffer */
803  &BufferSize); /* Output buffer size */
804  if (!NT_SUCCESS(Status)) {
805  AFD_DbgPrint(MIN_TRACE, ("Unable to get list of supported entities (Status = 0x%X).\n", Status));
807  return Status;
808  }
809 
810  /* Locate an IP entity */
811  EntityCount = BufferSize / sizeof(TDIEntityID);
812 
813  AFD_DbgPrint(MAX_TRACE, ("EntityCount = %u\n", EntityCount));
814 
815  for (i = 0; i < EntityCount; i++) {
816  if (Entities[i].tei_entity == CL_NL_ENTITY) {
817  /* Query device for entity type */
818 
819  BufferSize = sizeof(EntityType);
820  Status = TdiQueryInformationEx(FileObject, /* File object */
821  CL_NL_ENTITY, /* Entity */
822  Entities[i].tei_instance, /* Instance */
823  INFO_CLASS_GENERIC, /* Entity class */
824  INFO_TYPE_PROVIDER, /* Entity type */
825  ENTITY_TYPE_ID, /* Entity id */
826  &EntityType, /* Output buffer */
827  &BufferSize); /* Output buffer size */
828  if (!NT_SUCCESS(Status) || (EntityType != CL_NL_IP)) {
829  AFD_DbgPrint(MIN_TRACE, ("Unable to get entity of type IP (Status = 0x%X).\n", Status));
830  break;
831  }
832 
833  /* Query device for SNMP information */
834 
835  BufferSize = sizeof(SnmpInfo);
836  Status = TdiQueryInformationEx(FileObject, /* File object */
837  CL_NL_ENTITY, /* Entity */
838  Entities[i].tei_instance, /* Instance */
839  INFO_CLASS_PROTOCOL, /* Entity class */
840  INFO_TYPE_PROVIDER, /* Entity type */
841  IP_MIB_STATS_ID, /* Entity id */
842  &SnmpInfo, /* Output buffer */
843  &BufferSize); /* Output buffer size */
844  if (!NT_SUCCESS(Status) || (SnmpInfo.ipsi_numaddr == 0)) {
845  AFD_DbgPrint(MIN_TRACE, ("Unable to get SNMP information or no IP addresses available (Status = 0x%X).\n", Status));
846  break;
847  }
848 
849  /* Query device for all IP addresses */
850 
851  if (SnmpInfo.ipsi_numaddr != 0) {
852  BufferSize = SnmpInfo.ipsi_numaddr * sizeof(IPADDR_ENTRY);
854  BufferSize,
856  if (!IpAddress) {
857  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
858  break;
859  }
860 
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_ADDRTABLE_ENTRY_ID, /* Entity id */
867  IpAddress, /* Output buffer */
868  &BufferSize); /* Output buffer size */
869  if (!NT_SUCCESS(Status)) {
870  AFD_DbgPrint(MIN_TRACE, ("Unable to get IP address (Status = 0x%X).\n", Status));
872  break;
873  }
874 
875  if (SnmpInfo.ipsi_numaddr != 1) {
876  /* Skip loopback address */
877  *Address = DN2H(IpAddress[1].Addr);
878  } else {
879  /* Select the first address returned */
880  *Address = DN2H(IpAddress->Addr);
881  }
882 
884  } else {
886  break;
887  }
888  }
889  }
890 
892 
893  AFD_DbgPrint(MAX_TRACE, ("Leaving\n"));
894 
895  return Status;
896 }
ULONG ipsi_numaddr
Definition: tcpioctl.h:153
ULONG EntityCount
Definition: main.c:24
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _TDIEntityID TDIEntityID
Definition: afd.h:56
LONG NTSTATUS
Definition: precomp.h:26
#define TAG_AFD_TRANSPORT_ADDRESS
Definition: afd.h:39
#define ENTITY_TYPE_ID
Definition: tdiinfo.h:39
NTSTATUS TdiQueryInformationEx(PFILE_OBJECT FileObject, ULONG Entity, ULONG Instance, ULONG Class, ULONG Type, ULONG Id, PVOID OutputBuffer, PULONG OutputLength)
Definition: tdi.c:720
#define CL_NL_IP
Definition: tdiinfo.h:54
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TL_INSTANCE
Definition: afd.h:34
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
static WCHAR Address[46]
Definition: ping.c:68
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
struct IPADDR_ENTRY * PIPADDR_ENTRY
#define IP_MIB_STATS_ID
Definition: afd.h:35
#define INFO_CLASS_GENERIC
Definition: tdiinfo.h:64
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define BufferSize
Definition: classpnp.h:419
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define CL_NL_ENTITY
Definition: tdiinfo.h:42
Status
Definition: gdiplustypes.h:24
#define MAX_TRACE
Definition: debug.h:16
#define ENTITY_LIST_ID
Definition: tdiinfo.h:38
#define DN2H(dw)
Definition: addrconv.c:21
unsigned int UINT
Definition: ndis.h:50
#define INFO_TYPE_PROVIDER
Definition: tdiinfo.h:69
ULONG Addr
Definition: afd.h:57
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define IP_MIB_ADDRTABLE_ENTRY_ID
Definition: afd.h:36
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define GENERIC_ENTITY
Definition: tdiinfo.h:37
#define TAG_AFD_SNMP_ADDRESS_INFO
Definition: afd.h:52
struct IPADDR_ENTRY IPADDR_ENTRY
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65

◆ TdiQueryDeviceControl()

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

Definition at line 607 of file tdi.c.

627 {
631  KEVENT Event;
632  PIRP Irp;
633 
634  if (!FileObject) {
635  AFD_DbgPrint(MIN_TRACE, ("Bad file object.\n"));
637  }
638 
640  if (!DeviceObject) {
641  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
643  }
644 
646 
648  DeviceObject,
649  InputBuffer,
651  OutputBuffer,
653  FALSE,
654  &Event,
655  &Iosb);
656  if (!Irp)
658 
660 
661  if (Return)
662  *Return = Iosb.Information;
663 
664  return Status;
665 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG _In_ ULONG OutputBufferLength
Definition: fltkernel.h:1374
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
CHAR InputBuffer[80]
Definition: conmgr.c:33
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
return Iosb
Definition: create.c:4426
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ ULONG InputBufferLength
Definition: fltkernel.h:1372
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
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
#define MIN_TRACE
Definition: debug.h:14

Referenced by TdiQueryInformationEx().

◆ TdiQueryInformation()

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

Definition at line 668 of file tdi.c.

681 {
684  KEVENT Event;
685  PIRP Irp;
686 
687  if (!FileObject) {
688  AFD_DbgPrint(MIN_TRACE, ("Bad file object.\n"));
690  }
691 
693  if (!DeviceObject) {
694  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
696  }
697 
699 
701  DeviceObject, /* Device object */
702  ConnectionObject, /* File object */
703  &Event, /* Event */
704  &Iosb); /* Status */
705  if (!Irp) {
707  }
708 
710  DeviceObject,
711  FileObject,
712  NULL,
713  NULL,
714  QueryType,
715  MdlBuffer);
716 
717  return TdiCall(Irp, DeviceObject, &Event, &Iosb);
718 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
return Iosb
Definition: create.c:4426
_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
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define MIN_TRACE
Definition: debug.h:14

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 
)

Definition at line 720 of file tdi.c.

743 {
745 
746  RtlZeroMemory(&QueryInfo, sizeof(TCP_REQUEST_QUERY_INFORMATION_EX));
747  QueryInfo.ID.toi_entity.tei_entity = Entity;
748  QueryInfo.ID.toi_entity.tei_instance = Instance;
749  QueryInfo.ID.toi_class = Class;
750  QueryInfo.ID.toi_type = Type;
751  QueryInfo.ID.toi_id = Id;
752 
753  return TdiQueryDeviceControl(FileObject, /* Transport/connection object */
754  IOCTL_TCP_QUERY_INFORMATION_EX, /* Control code */
755  &QueryInfo, /* Input buffer */
756  sizeof(TCP_REQUEST_QUERY_INFORMATION_EX), /* Input buffer length */
757  OutputBuffer, /* Output buffer */
758  *OutputLength, /* Output buffer length */
759  OutputLength); /* Return information */
760 }
TDIEntityID toi_entity
Definition: tdiinfo.h:74
static const WCHAR Class[]
Definition: cfgmgr.c:39
Type
Definition: Type.h:6
ULONG toi_class
Definition: tdiinfo.h:75
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: ticonsts.h:42
DWORD Id
ULONG toi_id
Definition: tdiinfo.h:77
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
ULONG tei_entity
Definition: tdiinfo.h:31
ULONG tei_instance
Definition: tdiinfo.h:32
NTSTATUS TdiQueryDeviceControl(PFILE_OBJECT FileObject, ULONG IoControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG Return)
Definition: tdi.c:607
IN PVOID Instance
Definition: pci.h:359
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG toi_type
Definition: tdiinfo.h:76

Referenced by TdiQueryAddress().

◆ TdiQueryMaxDatagramLength()

NTSTATUS TdiQueryMaxDatagramLength ( PFILE_OBJECT  FileObject,
PUINT  MaxDatagramLength 
)

Definition at line 226 of file tdi.c.

229 {
230  PMDL Mdl;
233 
235  sizeof(TDI_MAX_DATAGRAM_INFO),
237 
238  if (!Buffer) return STATUS_NO_MEMORY;
239 
241  if (!Mdl)
242  {
244  return STATUS_NO_MEMORY;
245  }
246 
247  _SEH2_TRY
248  {
250  }
252  {
254  }
255  _SEH2_END;
256 
257  if (!NT_SUCCESS(Status))
258  {
259  AFD_DbgPrint(MIN_TRACE,("Failed to lock pages\n"));
260  IoFreeMdl(Mdl);
262  return Status;
263  }
264 
267  Mdl);
268  if (!NT_SUCCESS(Status))
269  {
271  return Status;
272  }
273 
274  *MaxDatagramLength = Buffer->MaxDatagramSize;
275 
277 
278  return STATUS_SUCCESS;
279 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS TdiQueryInformation(PFILE_OBJECT FileObject, LONG QueryType, PMDL MdlBuffer)
Definition: tdi.c:668
_SEH2_TRY
Definition: create.c:4250
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define TAG_AFD_DATA_BUFFER
Definition: afd.h:38
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
_SEH2_END
Definition: create.c:4424
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MIN_TRACE
Definition: debug.h:14
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define TDI_QUERY_MAX_DATAGRAM_INFO
Definition: tdi.h:187

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 976 of file tdi.c.

984 {
986  PMDL Mdl;
987 
988  ASSERT(*Irp == NULL);
989 
990  if (!TransportObject) {
991  AFD_DbgPrint(MIN_TRACE, ("Bad transport object.\n"));
993  }
994 
995  DeviceObject = IoGetRelatedDeviceObject(TransportObject);
996  if (!DeviceObject) {
997  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
999  }
1000 
1001  *Irp = TdiBuildInternalDeviceControlIrp(TDI_RECEIVE, /* Sub function */
1002  DeviceObject, /* Device object */
1003  TransportObject, /* File object */
1004  NULL, /* Event */
1005  NULL); /* Status */
1006 
1007  if (!*Irp) {
1008  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1010  }
1011 
1012  AFD_DbgPrint(MID_TRACE, ("Allocating irp for %p:%u\n", Buffer,BufferLength));
1013 
1014  Mdl = IoAllocateMdl(Buffer, /* Virtual address */
1015  BufferLength, /* Length of buffer */
1016  FALSE, /* Not secondary */
1017  FALSE, /* Don't charge quota */
1018  NULL); /* Don't use IRP */
1019  if (!Mdl) {
1020  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1022  *Irp = NULL;
1024  }
1025 
1026  _SEH2_TRY {
1027  AFD_DbgPrint(MID_TRACE, ("probe and lock\n"));
1028  MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
1029  AFD_DbgPrint(MID_TRACE, ("probe and lock done\n"));
1031  AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
1032  IoFreeMdl(Mdl);
1034  *Irp = NULL;
1036  } _SEH2_END;
1037 
1038  AFD_DbgPrint(MID_TRACE,("AFD>>> Got an MDL: %p\n", Mdl));
1039 
1040  TdiBuildReceive(*Irp, /* I/O Request Packet */
1041  DeviceObject, /* Device object */
1042  TransportObject, /* File object */
1043  CompletionRoutine, /* Completion routine */
1044  CompletionContext, /* Completion context */
1045  Mdl, /* Data buffer */
1046  Flags, /* Flags */
1047  BufferLength); /* Length of data */
1048 
1049 
1051  /* Does not block... The MDL is deleted in the receive completion
1052  routine. */
1053 
1054  return STATUS_PENDING;
1055 }
#define MID_TRACE
Definition: debug.h:15
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TdiBuildReceive( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, InFlags, ReceiveLen)
Definition: tdikrnl.h:667
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
_SEH2_TRY
Definition: create.c:4250
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG BufferLength
Definition: usbdlib.h:225
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
Definition: bufpool.h:45
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
#define TDI_RECEIVE
Definition: tdikrnl.h:54
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define MIN_TRACE
Definition: debug.h:14
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by MakeSocketIntoConnection(), and RefillSocketBuffer().

◆ TdiReceiveDatagram()

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

Definition at line 1058 of file tdi.c.

1078 {
1080  PMDL Mdl;
1081 
1082  ASSERT(*Irp == NULL);
1083 
1084  if (!TransportObject) {
1085  AFD_DbgPrint(MIN_TRACE, ("Bad tranport object.\n"));
1086  return STATUS_INVALID_PARAMETER;
1087  }
1088 
1089  DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1090  if (!DeviceObject) {
1091  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
1092  return STATUS_INVALID_PARAMETER;
1093  }
1094 
1096  DeviceObject, /* Device object */
1097  TransportObject, /* File object */
1098  NULL, /* Event */
1099  NULL); /* Status */
1100 
1101  if (!*Irp) {
1102  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1104  }
1105 
1106  AFD_DbgPrint(MID_TRACE, ("Allocating irp for %p:%u\n", Buffer,BufferLength));
1107 
1108  Mdl = IoAllocateMdl(Buffer, /* Virtual address */
1109  BufferLength, /* Length of buffer */
1110  FALSE, /* Not secondary */
1111  FALSE, /* Don't charge quota */
1112  NULL); /* Don't use IRP */
1113  if (!Mdl) {
1114  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1116  *Irp = NULL;
1118  }
1119 
1120  _SEH2_TRY {
1121  MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
1123  AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
1124  IoFreeMdl(Mdl);
1126  *Irp = NULL;
1128  } _SEH2_END;
1129 
1130  AFD_DbgPrint(MID_TRACE,("AFD>>> Got an MDL: %p\n", Mdl));
1131 
1132  TdiBuildReceiveDatagram(*Irp, /* I/O Request Packet */
1133  DeviceObject, /* Device object */
1134  TransportObject, /* File object */
1135  CompletionRoutine, /* Completion routine */
1136  CompletionContext, /* Completion context */
1137  Mdl, /* Data buffer */
1138  BufferLength,
1139  Addr,
1140  Addr,
1141  Flags); /* Length of data */
1142 
1144  /* Does not block... The MDL is deleted in the receive completion
1145  routine. */
1146 
1147  return STATUS_PENDING;
1148 }
#define MID_TRACE
Definition: debug.h:15
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
_SEH2_TRY
Definition: create.c:4250
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG BufferLength
Definition: usbdlib.h:225
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
Definition: bufpool.h:45
#define TDI_RECEIVE_DATAGRAM
Definition: tdikrnl.h:56
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define TdiBuildReceiveDatagram( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, ReceiveLen, ReceiveDatagramInfo, ReturnInfo, InFlags)
Definition: tdikrnl.h:699
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define MIN_TRACE
Definition: debug.h:14
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

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 898 of file tdi.c.

906 {
908  PMDL Mdl;
909 
910  ASSERT(*Irp == NULL);
911 
912  if (!TransportObject) {
913  AFD_DbgPrint(MIN_TRACE, ("Bad transport object.\n"));
915  }
916 
917  DeviceObject = IoGetRelatedDeviceObject(TransportObject);
918  if (!DeviceObject) {
919  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
921  }
922 
923  *Irp = TdiBuildInternalDeviceControlIrp(TDI_SEND, /* Sub function */
924  DeviceObject, /* Device object */
925  TransportObject, /* File object */
926  NULL, /* Event */
927  NULL); /* Status */
928 
929  if (!*Irp) {
930  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
932  }
933 
934  AFD_DbgPrint(MID_TRACE, ("Allocating irp for %p:%u\n", Buffer,BufferLength));
935 
936  Mdl = IoAllocateMdl(Buffer, /* Virtual address */
937  BufferLength, /* Length of buffer */
938  FALSE, /* Not secondary */
939  FALSE, /* Don't charge quota */
940  NULL); /* Don't use IRP */
941  if (!Mdl) {
942  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
944  *Irp = NULL;
946  }
947 
948  _SEH2_TRY {
949  MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoReadAccess);
951  AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
952  IoFreeMdl(Mdl);
954  *Irp = NULL;
956  } _SEH2_END;
957 
958  AFD_DbgPrint(MID_TRACE,("AFD>>> Got an MDL: %p\n", Mdl));
959 
960  TdiBuildSend(*Irp, /* I/O Request Packet */
961  DeviceObject, /* Device object */
962  TransportObject, /* File object */
963  CompletionRoutine, /* Completion routine */
964  CompletionContext, /* Completion context */
965  Mdl, /* Data buffer */
966  Flags, /* Flags */
967  BufferLength); /* Length of data */
968 
970  /* Does not block... The MDL is deleted in the receive completion
971  routine. */
972 
973  return STATUS_PENDING;
974 }
#define MID_TRACE
Definition: debug.h:15
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
#define TdiBuildSend( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, InFlags, SendLen)
Definition: tdikrnl.h:731
_SEH2_TRY
Definition: create.c:4250
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG BufferLength
Definition: usbdlib.h:225
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
Definition: bufpool.h:45
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
#define TDI_SEND
Definition: tdikrnl.h:53
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define MIN_TRACE
Definition: debug.h:14
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by AfdConnectedSocketWriteData(), and SendComplete().

◆ TdiSendDatagram()

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

Definition at line 1151 of file tdi.c.

1170 {
1172  PMDL Mdl;
1173 
1174  ASSERT(*Irp == NULL);
1175 
1176  if (!TransportObject) {
1177  AFD_DbgPrint(MIN_TRACE, ("Bad transport object.\n"));
1178  return STATUS_INVALID_PARAMETER;
1179  }
1180 
1181  AFD_DbgPrint(MID_TRACE,("Called(TransportObject %p)\n", TransportObject));
1182 
1183  DeviceObject = IoGetRelatedDeviceObject(TransportObject);
1184  if (!DeviceObject) {
1185  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
1186  return STATUS_INVALID_PARAMETER;
1187  }
1188 
1189  if (BufferLength == 0)
1190  {
1191  AFD_DbgPrint(MID_TRACE, ("Succeeding send with length 0.\n"));
1192  return STATUS_SUCCESS;
1193  }
1194 
1196  DeviceObject, /* Device object */
1197  TransportObject, /* File object */
1198  NULL, /* Event */
1199  NULL); /* Status */
1200 
1201  if (!*Irp) {
1202  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1204  }
1205 
1206  AFD_DbgPrint(MID_TRACE, ("Allocating irp for %p:%u\n", Buffer,BufferLength));
1207 
1208  Mdl = IoAllocateMdl(Buffer, /* Virtual address */
1209  BufferLength, /* Length of buffer */
1210  FALSE, /* Not secondary */
1211  FALSE, /* Don't charge quota */
1212  NULL); /* Don't use IRP */
1213 
1214  if (!Mdl) {
1215  AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
1217  *Irp = NULL;
1219  }
1220 
1221  _SEH2_TRY {
1222  MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoReadAccess);
1224  AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
1225  IoFreeMdl(Mdl);
1227  *Irp = NULL;
1229  } _SEH2_END;
1230 
1231  AFD_DbgPrint(MID_TRACE,("AFD>>> Got an MDL: %p\n", Mdl));
1232 
1233  TdiBuildSendDatagram(*Irp, /* I/O Request Packet */
1234  DeviceObject, /* Device object */
1235  TransportObject, /* File object */
1236  CompletionRoutine, /* Completion routine */
1237  CompletionContext, /* Completion context */
1238  Mdl, /* Data buffer */
1239  BufferLength, /* Bytes to send */
1240  Addr); /* Address */
1241 
1243  /* Does not block... The MDL is deleted in the send completion
1244  routine. */
1245 
1246  return STATUS_PENDING;
1247 }
#define MID_TRACE
Definition: debug.h:15
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TdiBuildSendDatagram( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, SendLen, SendDatagramInfo)
Definition: tdikrnl.h:761
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
_SEH2_TRY
Definition: create.c:4250
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
_In_ ULONG BufferLength
Definition: usbdlib.h:225
_Unreferenced_parameter_ PVOID * CompletionContext
Definition: cdprocs.h:1130
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
Definition: bufpool.h:45
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
#define TDI_SEND_DATAGRAM
Definition: tdikrnl.h:55
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
Definition: fsrtlfuncs.h:673
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define MIN_TRACE
Definition: debug.h:14
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by AfdConnectedSocketWriteData(), and AfdPacketSocketWriteData().

◆ TdiSetEventHandler()

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

Definition at line 546 of file tdi.c.

563 {
566  KEVENT Event;
567  PIRP Irp;
568 
569  AFD_DbgPrint(MAX_TRACE, ("Called\n"));
570 
571  if (!FileObject) {
572  AFD_DbgPrint(MIN_TRACE, ("Bad file object.\n"));
574  }
575 
577  if (!DeviceObject) {
578  AFD_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
580  }
581 
583 
585  DeviceObject, /* Device object */
586  FileObject, /* File object */
587  &Event, /* Event */
588  &Iosb); /* Status */
589  if (!Irp)
591 
592 
593 
595  DeviceObject,
596  FileObject,
597  NULL,
598  NULL,
599  EventType,
600  Handler,
601  Context);
602 
603  return TdiCall(Irp, DeviceObject, &Event, &Iosb);
604 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
#define TdiBuildSetEventHandler( Irp, DevObj, FileObj, CompRoutine, Contxt, InEventType, InEventHandler, InEventContext)
Definition: tdikrnl.h:791
static NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PKEVENT Event, PIO_STATUS_BLOCK Iosb)
Definition: tdi.c:46
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
#define TDI_SET_EVENT_HANDLER
Definition: tdikrnl.h:57
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
return Iosb
Definition: create.c:4426
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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:662
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define MAX_TRACE
Definition: debug.h:16
#define MIN_TRACE
Definition: debug.h:14
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ EVENT_TYPE EventType
Definition: exfuncs.h:165

Referenced by AfdDeregisterEventHandlers(), and AfdRegisterEventHandlers().