Code below. However, just found a bug in my code. I was calling WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_SERIAL_PORT); again from one of the help functions. Can this mismatch cause this issue?
////////////////// Defining Network class GUID
13
14 DEFINE_GUID(GUID_DEVCLASS_NET,
15 0x4d36e972, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18);
16
/////////////////// Defining child pdo device id
27 #define MY_NET_DEVICE_ID L"{31FCF443-3CE3-41a2-A754-86F223461EC9}\ABCD\XYZ\0"
28 #define ASMD_NET_DEVICE_ID_LEN sizeof(ASMD_NET_DEVICE_ID)
29
/////////////////// Defining child pdo hardware id
40 #define MY_NET_DEVICE_HW_ID L"{31FCF443-3CE3-41a2-A754-86F223461EC9}\ABCD\XYZ"
41 #define MY_NET_DEVICE_HW_ID_LEN sizeof (MY_NET_DEVICE_HW_ID)
42
////////////////// Function that enumerates the network child pdo
58 DECLARE_UNICODE_STRING_SIZE(netDeviceId, MY_NET_DEVICE_ID_LEN);
59
119 RtlInitUnicodeString(&netDeviceId, MY_NET_DEVICE_ID);
120
121 status = WdfPdoInitAssignDeviceID(ChildInit, &netDeviceId);
122 if (!NT_SUCCESS(status)) {
123 goto Cleanup;
124 }
203 DECLARE_UNICODE_STRING_SIZE(nethwid, MY_NET_DEVICE_HW_ID_LEN);
204
205 status = WdfPdoInitAssignRawDevice(ChildInit, &GUID_DEVCLASS_NET);
206 if (!NT_SUCCESS(status)) {
207 goto Cleanup;
208 }
209
210 WdfDeviceInitSetDeviceType(ChildInit, FILE_DEVICE_NETWORK);
211
212 RtlInitUnicodeString(&nethwid, MY_NET_DEVICE_HW_ID);
213 status = WdfPdoInitAddHardwareID(ChildInit, &nethwid);
214 if (!NT_SUCCESS(status)) {
215 goto Cleanup;
216 }
217
218 status = RtlUnicodeStringPrintf(&buffer,
219 L"My Company NET Device");
220 if (!NT_SUCCESS(status)) {
221 goto Cleanup;
222 }
240 status = WdfPdoInitAddDeviceText(ChildInit,
241 &buffer,
242 &deviceLocation,
243 0x409);
244 if (!NT_SUCCESS(status)) {
245 goto Cleanup;
246 }
247
248 WdfPdoInitSetDefaultLocale(ChildInit, 0x409);
249
250 WdfPdoInitAllowForwardingRequestToParent(ChildInit);
251
252 //
253 // Set child device properties
254 //
10 NTSTATUS status;
11 WDFDEVICE device;
12 WDF_OBJECT_ATTRIBUTES attributes;
13
14 TraceEvents(TRACE_LEVEL_INFORMATION, DBG_PNP,“MY_DEVICE_NET–> NetChildEvtDeviceAdd routine\n”);
15
16 WdfDeviceInitSetDeviceType(DeviceInit, FILE_DEVICE_SERIAL_PORT); <— Just found this bug. Do you think this can cause this problem
17
18 WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
19 attributes.SynchronizationScope = WdfSynchronizationScopeNone;
20
21 status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
22 if (!NT_SUCCESS(status)) {
23 TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT,
24 “MY_DEVICE_NET WdfDeviceCreate failed with Status code %!STATUS!\n”, status);
25 return status;
26 }
27
28 return status;
259
260 return status;
261
262 Cleanup:
263
264 TraceEvents(TRACE_LEVEL_ERROR, DBG_INIT,“CreatePdo failed %x\n”, status);
265
266 //
267 // On error, framework will cleanup all the resources when it deletes
268 // the device. So there is nothing to do.
269 //
270
271 return status;