ReactOS 0.4.16-dev-306-g647d351
tditest.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TDI test driver
4 * FILE: tditest.c
5 * PURPOSE: Testing TDI drivers
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * Vizzini (vizzini@plasmic.com)
8 * REVISIONS:
9 * CSH 01/08-2000 Created
10 * 26-Nov-2003 Vizzini Updated to run properly on Win2ksp4
11 */
12#include <tditest.h>
13#include <pseh/pseh2.h>
14
15
16#if DBG
17
18/* See debug.h for debug/trace constants */
20
21#endif /* DBG */
22
23
31
33 PIRP Irp,
36 BOOLEAN CanCancel)
37/*
38 * FUNCTION: Calls a transport driver device
39 * ARGUMENTS:
40 * Irp = Pointer to I/O Request Packet
41 * DeviceObject = Pointer to device object to call
42 * IoStatusBlock = Address of buffer with I/O status block
43 * CanCancel = TRUE if the IRP can be cancelled, FALSE if not
44 * RETURNS:
45 * Status of operation
46 * NOTES
47 * All requests are completed synchronously. A request may be cancelled
48 */
49{
51 PKEVENT Events[2];
53 Events[0] = &StopEvent;
54 Events[1] = &Event;
55
57 Irp->UserEvent = &Event;
58 Irp->UserIosb = IoStatusBlock;
59
61
63 {
64 if (CanCancel)
65 {
67
68 if (KeReadStateEvent(&StopEvent) != 0)
69 {
70 if (IoCancelIrp(Irp))
71 {
72 TDI_DbgPrint(MAX_TRACE, ("Cancelled IRP.\n"));
73 }
74 else
75 {
76 TDI_DbgPrint(MIN_TRACE, ("Could not cancel IRP.\n"));
77 }
78 return STATUS_CANCELLED;
79 }
80 }
81 else
83 }
84
86}
87
88
95/*
96 * FUNCTION: Opens a device
97 * ARGUMENTS:
98 * Protocol = Pointer to buffer with name of device
99 * EaLength = Length of EA information
100 * EaInfo = Pointer to buffer with EA information
101 * Handle = Address of buffer to place device handle
102 * Object = Address of buffer to place device object
103 * RETURNS:
104 * Status of operation
105 */
106{
111
114 &Attr, /* Attribute buffer */
115 &Name, /* Device name */
116 OBJ_CASE_INSENSITIVE, /* Attributes */
117 NULL, /* Root directory */
118 NULL); /* Security descriptor */
119
120 Status = ZwCreateFile(
121 Handle, /* Return file handle */
122 GENERIC_READ | GENERIC_WRITE, /* Desired access */
123 &Attr, /* Object attributes */
124 &Iosb, /* IO status */
125 0, /* Initial allocation size */
126 FILE_ATTRIBUTE_NORMAL, /* File attributes */
127 FILE_SHARE_READ | FILE_SHARE_WRITE, /* Share access */
128 FILE_OPEN_IF, /* Create disposition */
129 0, /* Create options */
130 EaInfo, /* EA buffer */
131 EaLength); /* EA length */
132
133 if (NT_SUCCESS(Status))
134 {
136 *Handle, /* Handle to open file */
137 GENERIC_READ | GENERIC_WRITE, /* Access mode */
138 NULL, /* Object type */
139 KernelMode, /* Access mode */
140 (PVOID*)Object, /* Pointer to object */
141 NULL); /* Handle information */
142
143 if (!NT_SUCCESS(Status))
144 {
145 TDI_DbgPrint(MIN_TRACE, ("ObReferenceObjectByHandle() failed with status (0x%X).\n", Status));
146 ZwClose(*Handle);
147 }
148 }
149 else
150 {
151 TDI_DbgPrint(MIN_TRACE, ("ZwCreateFile() failed with status (0x%X)\n", Status));
152 }
153
154 return Status;
155}
156
157
161{
162 if (FileObject)
164
165 if (Handle)
167
168 return STATUS_SUCCESS;
169}
170
171
174 USHORT Port,
175 PHANDLE Transport,
176 PFILE_OBJECT *TransportObject)
177/*
178 * FUNCTION: Opens a transport driver
179 * ARGUMENTS:
180 * Protocol = Pointer to buffer with name of device
181 * Port = Port number to use
182 * Transport = Address of buffer to place transport device handle
183 * TransportObject = Address of buffer to place transport object
184 * RETURNS:
185 * Status of operation
186 */
187{
192
193 /* EaName must be 0-termed, even though TDI_TRANSPORT_ADDRESS_LENGTH does *not* include the 0 */
196
197 if (!EaInfo)
198 {
199 TDI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
201 }
202
203 RtlZeroMemory(EaInfo, EaLength);
204
206
207 /* don't copy the 0; we have already zeroed it */
209
210 EaInfo->EaValueLength = sizeof(TA_IP_ADDRESS);
211 Address = (PTA_IP_ADDRESS)(EaInfo->EaName + TDI_TRANSPORT_ADDRESS_LENGTH + 1); // 0-term
212 Address->TAAddressCount = 1;
213 Address->Address[0].AddressLength = TDI_ADDRESS_LENGTH_IP;
214 Address->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
215 Address->Address[0].Address[0].sin_port = WH2N(Port);
216 Address->Address[0].Address[0].in_addr = 0;
217
218 Status = TdiOpenDevice(Protocol, EaLength, EaInfo, Transport, TransportObject);
219
220 ExFreePool(EaInfo);
221
222 return Status;
223}
224
225
233 PULONG Return)
234/*
235 * FUNCTION: Queries a device for information
236 * ARGUMENTS:
237 * FileObject = Pointer to device object
238 * IoControlCode = I/O control code
239 * InputBuffer = Pointer to buffer with input data
240 * InputBufferLength = Length of InputBuffer
241 * OutputBuffer = Address of buffer to place output data
242 * OutputBufferLength = Length of OutputBuffer
243 * RETURNS:
244 * Status of operation
245 */
246{
248 PIO_STACK_LOCATION IoStack;
251 PIRP Irp;
252
256
257 if (!Irp)
258 {
259 TDI_DbgPrint(MIN_TRACE, ("IoBuildDeviceIoControlRequest() failed.\n"));
261 }
262
264 IoStack->DeviceObject = DeviceObject;
265 IoStack->FileObject = FileObject;
267
268 if (Return)
269 *Return = Iosb.Information;
270
271 return Status;
272}
273
274
277 ULONG Entity,
279 ULONG Class,
280 ULONG Type,
281 ULONG Id,
283 PULONG OutputLength)
284/*
285 * FUNCTION: Extended query for information
286 * ARGUMENTS:
287 * FileObject = Pointer to transport object
288 * Entity = Entity
289 * Instance = Instance
290 * Class = Entity class
291 * Type = Entity type
292 * Id = Entity id
293 * OutputBuffer = Address of buffer to place data
294 * OutputLength = Address of buffer with length of OutputBuffer (updated)
295 * RETURNS:
296 * Status of operation
297 */
298{
300
302 QueryInfo.ID.toi_entity.tei_entity = Entity;
304 QueryInfo.ID.toi_class = Class;
305 QueryInfo.ID.toi_type = Type;
306 QueryInfo.ID.toi_id = Id;
307
309 FileObject, /* Transport/connection object */
310 IOCTL_TCP_QUERY_INFORMATION_EX, /* Control code */
311 &QueryInfo, /* Input buffer */
312 sizeof(TCP_REQUEST_QUERY_INFORMATION_EX), /* Input buffer length */
313 OutputBuffer, /* Output buffer */
314 *OutputLength, /* Output buffer length */
315 OutputLength); /* Return information */
316}
317
318
322/*
323 * FUNCTION: Queries for a local IP address
324 * ARGUMENTS:
325 * FileObject = Pointer to file object
326 * Address = Address of buffer to place local address
327 * RETURNS:
328 * Status of operation
329 */
330{
331 ULONG i;
332 TDIEntityID *Entities;
334 ULONG EntityType;
335 IPSNMP_INFO SnmpInfo;
336 PIPADDR_ENTRY IpAddress;
339
340 TDI_DbgPrint(MAX_TRACE, ("Called\n"));
341
342 BufferSize = sizeof(TDIEntityID) * 20;
344
345 if (!Entities)
346 {
347 TDI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
349 }
350
351 /* Query device for supported entities */
353 FileObject, /* File object */
354 GENERIC_ENTITY, /* Entity */
355 TL_INSTANCE, /* Instance */
356 INFO_CLASS_GENERIC, /* Entity class */
357 INFO_TYPE_PROVIDER, /* Entity type */
358 ENTITY_LIST_ID, /* Entity id */
359 Entities, /* Output buffer */
360 &BufferSize); /* Output buffer size */
361
362 if (!NT_SUCCESS(Status))
363 {
364 TDI_DbgPrint(MIN_TRACE, ("Unable to get list of supported entities (Status = 0x%X).\n", Status));
365 ExFreePool(Entities);
366 return Status;
367 }
368
369 /* Locate an IP entity */
371
372 TDI_DbgPrint(MAX_TRACE, ("EntityCount = %d\n", EntityCount));
373
374 for (i = 0; i < EntityCount; i++)
375 {
376 if (Entities[i].tei_entity == CL_NL_ENTITY)
377 {
378 /* Query device for entity type */
379 BufferSize = sizeof(EntityType);
381 FileObject, /* File object */
382 CL_NL_ENTITY, /* Entity */
383 Entities[i].tei_instance, /* Instance */
384 INFO_CLASS_GENERIC, /* Entity class */
385 INFO_TYPE_PROVIDER, /* Entity type */
386 ENTITY_TYPE_ID, /* Entity id */
387 &EntityType, /* Output buffer */
388 &BufferSize); /* Output buffer size */
389
390 if (!NT_SUCCESS(Status) || (EntityType != CL_NL_IP))
391 {
392 TDI_DbgPrint(MIN_TRACE, ("Unable to get entity of type IP (Status = 0x%X).\n", Status));
393 break;
394 }
395
396 /* Query device for SNMP information */
397 BufferSize = sizeof(SnmpInfo);
399 FileObject, /* File object */
400 CL_NL_ENTITY, /* Entity */
401 Entities[i].tei_instance, /* Instance */
402 INFO_CLASS_PROTOCOL, /* Entity class */
403 INFO_TYPE_PROVIDER, /* Entity type */
404 IP_MIB_STATS_ID, /* Entity id */
405 &SnmpInfo, /* Output buffer */
406 &BufferSize); /* Output buffer size */
407
408 if (!NT_SUCCESS(Status) || (SnmpInfo.NumAddr == 0))
409 {
410 TDI_DbgPrint(MIN_TRACE, ("Unable to get SNMP information or no IP addresses available (Status = 0x%X).\n", Status));
411 break;
412 }
413
414 /* Query device for all IP addresses */
415 if (SnmpInfo.NumAddr != 0)
416 {
417 BufferSize = SnmpInfo.NumAddr * sizeof(IPADDR_ENTRY);
419 if (!IpAddress)
420 {
421 TDI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
422 break;
423 }
424
426 FileObject, /* File object */
427 CL_NL_ENTITY, /* Entity */
428 Entities[i].tei_instance, /* Instance */
429 INFO_CLASS_PROTOCOL, /* Entity class */
430 INFO_TYPE_PROVIDER, /* Entity type */
431 IP_MIB_ADDRTABLE_ENTRY_ID, /* Entity id */
432 IpAddress, /* Output buffer */
433 &BufferSize); /* Output buffer size */
434
435 if (!NT_SUCCESS(Status))
436 {
437 TDI_DbgPrint(MIN_TRACE, ("Unable to get IP address (Status = 0x%X).\n", Status));
438 ExFreePool(IpAddress);
439 break;
440 }
441
442 if (SnmpInfo.NumAddr != 1)
443 {
444 /* Skip loopback address */
445 *Address = DN2H(((PIPADDR_ENTRY)((PUCHAR)IpAddress + sizeof(IPADDR_ENTRY)))->Addr);
446 }
447 else
448 {
449 /* Select the first address returned */
450 *Address = DN2H(IpAddress->Addr);
451 }
452 ExFreePool(IpAddress);
453
454 }
455 else
456 {
458 break;
459 }
460 }
461 }
462
463 ExFreePool(Entities);
464
465 TDI_DbgPrint(MAX_TRACE, ("Leaving\n"));
466
467 return Status;
468}
469
470
472 PFILE_OBJECT TransportObject,
473 USHORT Port,
477/*
478 * FUNCTION: Sends a datagram
479 * ARGUMENTS:
480 * TransportObject = Pointer to transport object
481 * Port = Remote port
482 * Address = Remote address
483 * Buffer = Pointer to buffer with data to send
484 * BufferSize = Length of Buffer
485 * RETURNS:
486 * Status of operation
487 */
488{
489 PIRP Irp;
490 PMDL Mdl;
492 PTDI_CONNECTION_INFORMATION ConnectInfo;
494 PTDI_ADDRESS_IP IpAddress;
497
498 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
499 ConnectInfo = (PTDI_CONNECTION_INFORMATION)
502 sizeof(TA_IP_ADDRESS));
503
504 if (!ConnectInfo)
506
507 RtlZeroMemory(ConnectInfo, sizeof(TDI_CONNECTION_INFORMATION) + sizeof(TA_IP_ADDRESS));
508
509 ConnectInfo->RemoteAddressLength = sizeof(TA_IP_ADDRESS);
510 ConnectInfo->RemoteAddress = ((PUCHAR)ConnectInfo + sizeof(TDI_CONNECTION_INFORMATION));
511
512 TA = (PTA_IP_ADDRESS)(ConnectInfo->RemoteAddress);
513 TA->TAAddressCount = 1;
514 TA->Address[0].AddressLength = sizeof(TDI_ADDRESS_IP);
515 TA->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
516 IpAddress = (PTDI_ADDRESS_IP)(TA->Address[0].Address);
517 IpAddress->sin_port = WH2N(Port);
518 IpAddress->in_addr = DH2N(Address);
520 TDI_SEND_DATAGRAM, /* Sub function */
521 DeviceObject, /* Device object */
522 TransportObject, /* File object */
523 NULL, /* Event */
524 NULL); /* Return buffer */
525
526 if (!Irp)
527 {
528 TDI_DbgPrint(MIN_TRACE, ("TdiBuildInternalDeviceControlIrp() failed.\n"));
529 ExFreePool(ConnectInfo);
531 }
532
534 Buffer, /* Virtual address of buffer */
535 BufferSize, /* Length of buffer */
536 FALSE, /* Not secondary */
537 FALSE, /* Don't charge quota */
538 NULL); /* Don't use IRP */
539
540 if (!Mdl)
541 {
542 TDI_DbgPrint(MIN_TRACE, ("IoAllocateMdl() failed.\n"));
543 IoFreeIrp(Irp);
544 ExFreePool(ConnectInfo);
546 }
547
549 {
551 }
553 {
554 TDI_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
555 IoFreeMdl(Mdl);
556 IoFreeIrp(Irp);
557 ExFreePool(ConnectInfo);
559 } _SEH2_END;
560
562 Irp, /* I/O Request Packet */
563 DeviceObject, /* Device object */
564 TransportObject, /* File object */
565 NULL, /* Completion routine */
566 NULL, /* Completion context */
567 Mdl, /* Descriptor for data buffer */
568 BufferSize, /* Size of data to send */
569 ConnectInfo); /* Connection information */
570
572
573 ExFreePool(ConnectInfo);
574
575 return Status;
576}
577
578
580 PFILE_OBJECT TransportObject,
581 USHORT Port,
585/*
586 * FUNCTION: Receives a datagram
587 * ARGUMENTS:
588 * TransportObject = Pointer to transport object
589 * Port = Port to receive on
590 * Address = Address of buffer to place remote address
591 * Buffer = Address of buffer to place received data
592 * BufferSize = Address of buffer with length of Buffer (updated)
593 * RETURNS:
594 * Status of operation
595 */
596{
597 PTDI_CONNECTION_INFORMATION ReceiveInfo;
599 PTA_IP_ADDRESS ReturnAddress;
601 PTDI_ADDRESS_IP IpAddress;
603 PVOID MdlBuffer;
605 PIRP Irp;
606 PMDL Mdl;
607
608 DeviceObject = IoGetRelatedDeviceObject(TransportObject);
609 if (!DeviceObject)
611
615 sizeof(TA_IP_ADDRESS));
616
617 if (!ReceiveInfo)
619
620 MdlBuffer = ExAllocatePool(PagedPool, *BufferSize);
621 if (!MdlBuffer)
623
625 sizeof(TA_IP_ADDRESS));
626
627 RtlCopyMemory(MdlBuffer, Buffer, *BufferSize);
628
629 /* Receive from any address */
630 ReceiveInfo->RemoteAddressLength = 0;
631 ReceiveInfo->RemoteAddress = NULL;
632
633 ReturnInfo = (PTDI_CONNECTION_INFORMATION) ((PUCHAR)ReceiveInfo + sizeof(TDI_CONNECTION_INFORMATION));
634 ReturnInfo->RemoteAddressLength = sizeof(TA_IP_ADDRESS);
635 ReturnInfo->RemoteAddress = ((PUCHAR)ReturnInfo + sizeof(TDI_CONNECTION_INFORMATION));
636
637 ReturnAddress = (PTA_IP_ADDRESS)(ReturnInfo->RemoteAddress);
638 ReturnAddress->TAAddressCount = 1;
639 ReturnAddress->Address[0].AddressLength = sizeof(TDI_ADDRESS_IP);
640 ReturnAddress->Address[0].AddressType = TDI_ADDRESS_TYPE_IP;
641
642 IpAddress = (PTDI_ADDRESS_IP)(ReturnAddress->Address[0].Address);
643 IpAddress->sin_port = WH2N(Port);
644 IpAddress->in_addr = DH2N(LocalAddress);
645
647 TDI_RECEIVE_DATAGRAM, /* Sub function */
648 DeviceObject, /* Device object */
649 TransportObject, /* File object */
650 NULL, /* Event */
651 NULL); /* Return buffer */
652
653 if (!Irp)
654 {
655 ExFreePool(MdlBuffer);
656 ExFreePool(ReceiveInfo);
658 }
659
661 MdlBuffer, /* Virtual address */
662 *BufferSize, /* Length of buffer */
663 FALSE, /* Not secondary */
664 FALSE, /* Don't charge quota */
665 NULL); /* Don't use IRP */
666
667 if (!Mdl)
668 {
669 IoFreeIrp(Irp);
670 ExFreePool(MdlBuffer);
671 ExFreePool(ReceiveInfo);
673 }
674
676 {
678 }
680 {
681 TDI_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
682 IoFreeMdl(Mdl);
683 IoFreeIrp(Irp);
684 ExFreePool(MdlBuffer);
685 ExFreePool(ReceiveInfo);
687 } _SEH2_END;
688
690 Irp, /* I/O Request Packet */
691 DeviceObject, /* Device object */
692 TransportObject, /* File object */
693 NULL, /* Completion routine */
694 NULL, /* Completion context */
695 Mdl, /* Data buffer */
696 *BufferSize, /* Size of data buffer */
697 ReceiveInfo, /* Connection information */
698 ReturnInfo, /* Connection information */
699 TDI_RECEIVE_NORMAL); /* Flags */
700
702
703 if (NT_SUCCESS(Status))
704 {
705 RtlCopyMemory(Buffer, MdlBuffer, Iosb.Information);
706 *BufferSize = Iosb.Information;
707 *Address = DN2H(IpAddress->in_addr);
708 }
709
710 ExFreePool(MdlBuffer);
711 ExFreePool(ReceiveInfo);
712
713 return Status;
714}
715
716
719/*
720 * FUNCTION: Send thread
721 * ARGUMENTS:
722 * Context = Pointer to context information
723 * NOTES:
724 * Transmits an UDP packet every two seconds to ourselves on the chosen port
725 */
726{
728 PKEVENT Events[2];
731 UCHAR Data[40] = "Testing one, two, three, ...";
732
733 if (!OpenError)
734 {
735 Timeout.QuadPart = 10000000L; /* Second factor */
736 Timeout.QuadPart *= 2; /* Number of seconds */
737 Timeout.QuadPart = -(Timeout.QuadPart); /* Relative time */
738
740
741 Events[0] = &StopEvent;
742 Events[1] = &Event;
743
744 while (NT_SUCCESS(Status))
745 {
746 /* Wait until timeout or stop flag is set */
748
749 if (KeReadStateEvent(&StopEvent) != 0)
750 {
751 TDI_DbgPrint(MAX_TRACE, ("Received terminate signal...\n"));
752 break;
753 }
754
755 DbgPrint("Sending data - '%s'\n", Data);
756
758
759 if (!NT_SUCCESS(Status))
760 DbgPrint("Failed sending data (Status = 0x%X)\n", Status);
761 }
762 }
763
764 TDI_DbgPrint(MAX_TRACE, ("Terminating send thread...\n"));
765
767}
768
769
772/*
773 * FUNCTION: Receive thread
774 * ARGUMENTS:
775 * Context = Pointer to context information
776 * NOTES:
777 * Waits until an UDP packet is received on the chosen endpoint and displays the data
778 */
779{
781 UCHAR Data[40];
782 ULONG Size;
784
785 if (!OpenError)
786 {
787 while (NT_SUCCESS(Status))
788 {
789 Size = sizeof(Data);
791
793
794 if (NT_SUCCESS(Status))
795 {
796 DbgPrint("Received data - '%s'\n", Data);
797 }
798 else
800 {
801 TDI_DbgPrint(MIN_TRACE, ("Receive error (Status = 0x%X).\n", Status));
802 }
803 else
804 {
805 TDI_DbgPrint(MAX_TRACE, ("IRP was cancelled.\n"));
806 }
807 }
808 }
809
810 TDI_DbgPrint(MAX_TRACE, ("Terminating receive thread...\n"));
811
813}
814
815
818/*
819 * FUNCTION: Open thread
820 * ARGUMENTS:
821 * Context = Pointer to context information (event)
822 */
823{
825
826 TDI_DbgPrint(MAX_TRACE, ("Called.\n"));
827
828 OpenError = TRUE;
829
831
832 if (NT_SUCCESS(Status))
833 {
835
836 if (NT_SUCCESS(Status))
837 {
839 DbgPrint("Using local IP address 0x%X\n", LocalAddress);
840 }
841 else
842 {
843 TDI_DbgPrint(MIN_TRACE, ("Unable to determine local IP address.\n"));
844 }
845 }
846 else
847 TDI_DbgPrint(MIN_TRACE, ("Cannot open transport (Status = 0x%X).\n", Status));
848
849 TDI_DbgPrint(MAX_TRACE, ("Setting close event.\n"));
850
852
853 TDI_DbgPrint(MIN_TRACE, ("Leaving.\n"));
854}
855
856
859/*
860 * FUNCTION: Unload routine
861 * ARGUMENTS:
862 * DriverObject = Pointer to a driver object for this driver
863 */
864{
865 PVOID ReceiveThreadObject = 0;
866 PVOID SendThreadObject = 0;
867
868 TDI_DbgPrint(MAX_TRACE, ("Setting stop flag\n"));
869
870 /* Get pointers to the thread objects */
873
875
876 /* Wait for send thread to stop */
878
879 /* Wait for receive thread to stop */
880 KeWaitForSingleObject(ReceiveThreadObject, Executive, KernelMode, FALSE, NULL);
881
882 /* Close device */
884}
885
886
888NTAPI
892/*
893 * FUNCTION: Main driver entry point
894 * ARGUMENTS:
895 * DriverObject = Pointer to a driver object for this driver
896 * RegistryPath = Registry node for configuration parameters
897 * RETURNS:
898 * Status of driver initialization
899 */
900{
904
906
907 /* Call TdiOpenThread() */
912
913 /* Create a UDP send thread that sends a dgram every 2 seconds */
915 &SendThread, /* Thread handle */
916 0, /* Desired access */
917 NULL, /* Object attributes */
918 NULL, /* Process handle */
919 NULL, /* Client id */
920 (PKSTART_ROUTINE)TdiSendThread, /* Start routine */
921 NULL); /* Start context */
922
923 if (!NT_SUCCESS(Status))
924 {
925 TDI_DbgPrint(MIN_TRACE, ("PsCreateSystemThread() failed for send thread (Status = 0x%X).\n", Status));
927 }
928
929 /* Create a UDP receive thread */
931 &ReceiveThread, /* Thread handle */
932 0, /* Desired access */
933 NULL, /* Object attributes */
934 NULL, /* Process handle */
935 NULL, /* Client id */
936 (PKSTART_ROUTINE)TdiReceiveThread, /* Start routine */
937 NULL); /* Start context */
938
939 if (!NT_SUCCESS(Status))
940 {
941 TDI_DbgPrint(MIN_TRACE, ("PsCreateSystemThread() failed for receive thread (Status = 0x%X).\n", Status));
944 }
945
946 DriverObject->DriverUnload = (PDRIVER_UNLOAD)TdiUnload;
947
948 return STATUS_SUCCESS;
949}
950
951/* EOF */
952
DWORD Id
unsigned char BOOLEAN
Type
Definition: Type.h:7
#define DH2N(dw)
Definition: addrconv.c:28
#define WH2N(w)
Definition: addrconv.c:40
#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 TL_INSTANCE
Definition: afd.h:34
struct NameRec_ * Name
Definition: cdprocs.h:460
LONG NTSTATUS
Definition: precomp.h:26
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
HANDLE Events[3]
Definition: schedsvc.c:40
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define BufferSize
Definition: mmc.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
return Iosb
Definition: create.c:4402
ULONG EntityCount
Definition: main.c:28
ULONG DebugTraceLevel
Definition: ndis.c:13
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define PagedPool
Definition: env_spec_w32.h:308
LONG NTAPI KeReadStateEvent(IN PKEVENT Event)
Definition: eventobj.c:120
IN PVCB IN PDIRENT OUT PULONG EaLength
Definition: fatprocs.h:879
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
struct _FILE_FULL_EA_INFORMATION * PFILE_FULL_EA_INFORMATION
#define FILE_OPEN_IF
Definition: from_kernel.h:56
struct _FILE_FULL_EA_INFORMATION FILE_FULL_EA_INFORMATION
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DbgPrint
Definition: hal.h:12
CPPORT Port[4]
Definition: headless.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#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 TDI_DbgPrint(_t_, _x_)
Definition: debug.h:59
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define GENERIC_WRITE
Definition: nt_native.h:90
@ NotificationEvent
@ SynchronizationEvent
@ WaitAny
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
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 IoCallDriver
Definition: irp.c:1225
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
Definition: wait.c:586
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1145
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
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
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
static ULONG Timeout
Definition: ping.c:61
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: afd.h:56
ULONG Addr
Definition: afd.h:57
ULONG NumAddr
Definition: tditest.h:88
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:3223
struct _TA_ADDRESS_IP::_AddrIp Address[1]
LONG TAAddressCount
Definition: tdi.h:523
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
ULONG in_addr
Definition: tdi.h:409
USHORT sin_port
Definition: tdi.h:408
struct _TDI_CONNECTION_INFORMATION * PTDI_CONNECTION_INFORMATION
struct _TA_ADDRESS_IP TA_IP_ADDRESS
struct _TA_ADDRESS_IP * PTA_IP_ADDRESS
struct _TDI_ADDRESS_IP * PTDI_ADDRESS_IP
#define TDI_TRANSPORT_ADDRESS_LENGTH
Definition: tdi.h:372
#define TDI_RECEIVE_NORMAL
Definition: tdi.h:122
#define TDI_ADDRESS_LENGTH_IP
Definition: tdi.h:413
struct _TDI_ADDRESS_IP TDI_ADDRESS_IP
#define TDI_ADDRESS_TYPE_IP
Definition: tdi.h:345
struct _TDI_CONNECTION_INFORMATION TDI_CONNECTION_INFORMATION
#define TdiTransportAddress
Definition: tdi.h:370
#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 TDI_SEND_DATAGRAM
Definition: tdikrnl.h:55
#define TDI_RECEIVE_DATAGRAM
Definition: tdikrnl.h:56
#define TdiBuildInternalDeviceControlIrp(IrpSubFunction, DeviceObject, FileObject, Event, IoStatusBlock)
Definition: tdikrnl.h:573
#define TdiBuildReceiveDatagram( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, ReceiveLen, ReceiveDatagramInfo, ReturnInfo, InFlags)
Definition: tdikrnl.h:699
#define TdiBuildSendDatagram( Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, SendLen, SendDatagramInfo)
Definition: tdikrnl.h:761
NTSTATUS TdiOpenTransport(PWSTR Protocol, USHORT Port, PHANDLE Transport, PFILE_OBJECT *TransportObject)
Definition: tditest.c:172
VOID TdiUnload(PDRIVER_OBJECT DriverObject)
Definition: tditest.c:857
NTSTATUS TdiQueryInformationEx(PFILE_OBJECT FileObject, ULONG Entity, ULONG Instance, ULONG Class, ULONG Type, ULONG Id, PVOID OutputBuffer, PULONG OutputLength)
Definition: tditest.c:275
VOID TdiOpenThread(PVOID Context)
Definition: tditest.c:816
VOID TdiSendThread(PVOID Context)
Definition: tditest.c:717
HANDLE SendThread
Definition: tditest.c:29
NTSTATUS TdiCall(PIRP Irp, PDEVICE_OBJECT DeviceObject, PIO_STATUS_BLOCK IoStatusBlock, BOOLEAN CanCancel)
Definition: tditest.c:32
ULONG LocalAddress
Definition: tditest.c:26
NTSTATUS TdiCloseDevice(HANDLE Handle, PFILE_OBJECT FileObject)
Definition: tditest.c:158
HANDLE ReceiveThread
Definition: tditest.c:30
BOOLEAN OpenError
Definition: tditest.c:27
NTSTATUS TdiReceiveDatagram(PFILE_OBJECT TransportObject, USHORT Port, PULONG Address, PUCHAR Buffer, PULONG BufferSize)
Definition: tditest.c:579
NTSTATUS TdiOpenDevice(PWSTR Protocol, ULONG EaLength, PFILE_FULL_EA_INFORMATION EaInfo, PHANDLE Handle, PFILE_OBJECT *Object)
Definition: tditest.c:89
NTSTATUS TdiQueryDeviceControl(PFILE_OBJECT FileObject, ULONG IoControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG Return)
Definition: tditest.c:226
PFILE_OBJECT TdiTransportObject
Definition: tditest.c:25
HANDLE TdiTransport
Definition: tditest.c:24
VOID TdiReceiveThread(PVOID Context)
Definition: tditest.c:770
NTSTATUS TdiSendDatagram(PFILE_OBJECT TransportObject, USHORT Port, ULONG Address, PVOID Buffer, ULONG BufferSize)
Definition: tditest.c:471
KEVENT StopEvent
Definition: tditest.c:28
NTSTATUS TdiQueryAddress(PFILE_OBJECT FileObject, PULONG Address)
Definition: tditest.c:319
#define UDP_DEVICE_NAME
Definition: tditest.h:17
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: tditest.h:110
#define TEST_PORT
Definition: tditest.h:116
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_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
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:723
_Must_inspect_result_ _In_ ULONG _In_ PSOCKADDR LocalAddress
Definition: wsk.h:171
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
@ DelayedWorkQueue
Definition: extypes.h:190
WORKER_THREAD_ROUTINE * PWORKER_THREAD_ROUTINE
Definition: extypes.h:200
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
DRIVER_UNLOAD * PDRIVER_UNLOAD
Definition: iotypes.h:2253
* PFILE_OBJECT
Definition: iotypes.h:1998
KSTART_ROUTINE * PKSTART_ROUTINE
Definition: ketypes.h:499
@ Executive
Definition: ketypes.h:415
@ IoModifyAccess
Definition: ketypes.h:865
#define ObDereferenceObject
Definition: obfuncs.h:203
unsigned char UCHAR
Definition: xmlstorage.h:181