ReactOS 0.4.16-dev-338-g34e76ad
tdi.c File Reference
#include <kmt_test.h>
#include <tdikrnl.h>
Include dependency graph for tdi.c:

Go to the source code of this file.

Functions

static NTSTATUS NTAPI IrpCompletionRoutine (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PVOID Context)
 
static VOID TestProviderInfo (void)
 
static VOID NTAPI RunTest (_In_ PVOID Context)
 
NTSTATUS TestTdi (_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG ControlCode, _In_opt_ PVOID Buffer, _In_ SIZE_T InLength, _Inout_ PSIZE_T OutLength)
 

Variables

static KSTART_ROUTINE RunTest
 
KMT_MESSAGE_HANDLER TestTdi
 

Function Documentation

◆ IrpCompletionRoutine()

static NTSTATUS NTAPI IrpCompletionRoutine ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp,
_In_ PVOID  Context 
)
static

Definition at line 14 of file tdi.c.

18{
21
23
25}
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by TestProviderInfo().

◆ RunTest()

static VOID NTAPI RunTest ( _In_ PVOID  Context)
static

Definition at line 275 of file tdi.c.

277{
279
281}
static VOID TestProviderInfo(void)
Definition: tdi.c:29

◆ TestProviderInfo()

static VOID TestProviderInfo ( void  )
static

Definition at line 29 of file tdi.c.

30{
31 struct
32 {
34 NTSTATUS CreateStatus, IrpStatus;
35 TDI_PROVIDER_INFO ExpectedInfo;
36 } TestData[] =
37 {
38 {
39 RTL_CONSTANT_STRING(L"\\Device\\Tcp"),
41 {
42 0x0100, // Version
43 0xFFFFFFFF, // MaxSendSize
44 0, // MaxConnectionUserData
45 65507, // MaxDatagramSize
60 TDI_SERVICE_NO_PUSH, // ServiceFlags
61 1, // MinimumLookaheadData
62 65535, // MaximumLookaheadData
63 0, // NumberOfResources
64 {{0}} // StartTime
65 }
66 },
67 {
68 RTL_CONSTANT_STRING(L"\\Device\\Udp"),
70 {
71 0x0100, // Version
72 0xFFFFFFFF, // MaxSendSize
73 0, // MaxConnectionUserData
74 65507, // MaxDatagramSize
89 TDI_SERVICE_NO_PUSH, // ServiceFlags
90 1, // MinimumLookaheadData
91 65535, // MaximumLookaheadData
92 0, // NumberOfResources
93 {{0}} // StartTime
94 }
95 },
96 {
97 RTL_CONSTANT_STRING(L"\\Device\\Ip"),
99 },
100 {
101 RTL_CONSTANT_STRING(L"\\Device\\RawIp"),
103 {
104 0x0100, // Version
105 0xFFFFFFFF, // MaxSendSize
106 0, // MaxConnectionUserData
107 65507, // MaxDatagramSize
122 TDI_SERVICE_NO_PUSH, // ServiceFlags
123 1, // MinimumLookaheadData
124 65535, // MaximumLookaheadData
125 0, // NumberOfResources
126 {{0}} // StartTime
127 }
128 },
129 {
130 RTL_CONSTANT_STRING(L"\\Device\\IPMULTICAST"),
132 },
133 };
134 ULONG i;
135
136 for (i = 0; i < (sizeof(TestData) / sizeof(TestData[0])); i++)
137 {
138 IO_STATUS_BLOCK StatusBlock;
142 PIRP Irp;
144 PMDL Mdl;
145 TDI_PROVIDER_INFO* ProviderInfo;
148
149 trace("Testing device %wZ\n", &TestData[i].DeviceName);
150
155 NULL,
156 NULL);
157
158 Status = ZwCreateFile(
159 &FileHandle,
162 &StatusBlock,
163 NULL,
166 FILE_OPEN,
167 0,
168 NULL,
169 0);
170 ok_eq_hex(Status, TestData[i].CreateStatus);
171 if (!NT_SUCCESS(Status))
172 continue;
173
179 (PVOID*)&FileObject,
180 NULL);
182 if (!NT_SUCCESS(Status))
183 return;
184
186 ok(DeviceObject != NULL, "Device object is NULL!\n");
187 if (!DeviceObject)
188 {
190 return;
191 }
192
193 ProviderInfo = ExAllocatePoolWithTag(NonPagedPool, sizeof(*ProviderInfo), 'tseT');
194 ok(ProviderInfo != NULL, "Ran out of memory.\n");
195 if (!ProviderInfo)
196 {
198 return;
199 }
200
201 Mdl = IoAllocateMdl(ProviderInfo, sizeof(*ProviderInfo), FALSE, FALSE, NULL);
202 ok(Mdl != NULL, "Could not allocate the MDL!\n");
203 if (!Mdl)
204 {
205 ExFreePoolWithTag(ProviderInfo, 'tseT');
207 return;
208 }
209
211
212 /* Build the IRP */
214 Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
215 ok(Irp != NULL, "TdiBuildInternalDeviceControlIrp returned NULL!\n");
216 if (!Irp)
217 {
218 IoFreeMdl(Mdl);
219 ExFreePoolWithTag(ProviderInfo, 'tseT');
221 return;
222 }
223
225 Irp,
228 NULL,
229 NULL,
231 Mdl);
232
234
236 if (Status == STATUS_PENDING)
237 {
239 &Event,
240 Executive,
242 FALSE,
243 NULL);
244 Status = StatusBlock.Status;
245 }
246 ok_eq_hex(Status, TestData[i].IrpStatus);
247
248 IoFreeIrp(Irp);
249 IoFreeMdl(Mdl);
251
252 if (!NT_SUCCESS(Status))
253 {
254 ExFreePoolWithTag(ProviderInfo, 'tseT');
255 continue;
256 }
257
258 ok_eq_hex(ProviderInfo->Version, TestData[i].ExpectedInfo.Version);
259 ok_eq_ulong(ProviderInfo->MaxSendSize, TestData[i].ExpectedInfo.MaxSendSize);
260 ok_eq_ulong(ProviderInfo->MaxConnectionUserData, TestData[i].ExpectedInfo.MaxConnectionUserData);
261 ok_eq_ulong(ProviderInfo->MaxDatagramSize, TestData[i].ExpectedInfo.MaxDatagramSize);
262 ok_eq_hex(ProviderInfo->ServiceFlags, TestData[i].ExpectedInfo.ServiceFlags);
263 ok_eq_ulong(ProviderInfo->MinimumLookaheadData, TestData[i].ExpectedInfo.MinimumLookaheadData);
264 ok_eq_ulong(ProviderInfo->MaximumLookaheadData, TestData[i].ExpectedInfo.MaximumLookaheadData);
265 ok_eq_ulong(ProviderInfo->NumberOfResources, TestData[i].ExpectedInfo.NumberOfResources);
266
267 ExFreePoolWithTag(ProviderInfo, 'tseT');
268 }
269}
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#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
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#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 NonPagedPool
Definition: env_spec_w32.h:307
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_OPEN
Definition: from_kernel.h:54
#define IoFreeMdl
Definition: fxmdl.h:89
#define IoAllocateMdl
Definition: fxmdl.h:88
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 OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:424
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static NTSTATUS NTAPI IrpCompletionRoutine(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PVOID Context)
Definition: tdi.c:14
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:34
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
@ NotificationEvent
@ FILE_OBJECT
Definition: ntobjenum.h:17
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
#define IoCallDriver
Definition: irp.c:1225
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define L(x)
Definition: ntvdm.h:50
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
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG MaxConnectionUserData
Definition: tdi.h:236
ULONG MaxSendSize
Definition: tdi.h:235
ULONG MaxDatagramSize
Definition: tdi.h:237
ULONG ServiceFlags
Definition: tdi.h:238
ULONG MaximumLookaheadData
Definition: tdi.h:240
ULONG Version
Definition: tdi.h:234
ULONG NumberOfResources
Definition: tdi.h:241
ULONG MinimumLookaheadData
Definition: tdi.h:239
#define TDI_SERVICE_DGRAM_CONNECTION
Definition: tdi.h:260
#define TDI_SERVICE_CONNECTIONLESS_MODE
Definition: tdi.h:247
#define TDI_SERVICE_SEND_AND_DISCONNECT
Definition: tdi.h:262
#define TDI_SERVICE_EXPEDITED_DATA
Definition: tdi.h:253
#define TDI_SERVICE_PREPOST_RECVS
Definition: tdi.h:266
#define TDI_SERVICE_ORDERLY_RELEASE
Definition: tdi.h:246
#define TDI_SERVICE_ERROR_FREE_DELIVERY
Definition: tdi.h:248
#define TDI_SERVICE_FORCE_ACCESS_CHECK
Definition: tdi.h:261
#define TDI_SERVICE_ADDRESS_SECURITY
Definition: tdi.h:265
#define TDI_SERVICE_DELAYED_ACCEPTANCE
Definition: tdi.h:252
#define TDI_SERVICE_NO_PUSH
Definition: tdi.h:267
#define TDI_QUERY_PROVIDER_INFO
Definition: tdi.h:180
#define TDI_SERVICE_CONNECTION_MODE
Definition: tdi.h:245
#define TDI_SERVICE_NO_ZERO_LENGTH
Definition: tdi.h:256
#define TDI_SERVICE_ACCEPT_LOCAL_ADDR
Definition: tdi.h:264
#define TDI_SERVICE_BROADCAST_SUPPORTED
Definition: tdi.h:250
#define TdiBuildQueryInformation( Irp, DevObj, FileObj, CompRoutine, Contxt, QType, MdlAddr)
Definition: tdikrnl.h:638
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
@ Executive
Definition: ketypes.h:415
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by RunTest().

◆ TestTdi()

NTSTATUS TestTdi ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ ULONG  ControlCode,
_In_opt_ PVOID  Buffer,
_In_ SIZE_T  InLength,
_Inout_ PSIZE_T  OutLength 
)

Definition at line 285 of file tdi.c.

292{
294
297
298 return STATUS_SUCCESS;
299}
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
static KSTART_ROUTINE RunTest
Definition: tdi.c:271

Variable Documentation

◆ RunTest

KSTART_ROUTINE RunTest
static

Definition at line 271 of file tdi.c.

Referenced by TestTdi().

◆ TestTdi

KMT_MESSAGE_HANDLER TestTdi

Definition at line 283 of file tdi.c.