{
UNICODE_STRING DeviceInstance;
PDEVICE_OBJECT DeviceObject;
+ PDEVICE_NODE DeviceNode;
NTSTATUS Status = STATUS_SUCCESS;
DPRINT("IopInitializeDevice(%p)\n", ControlData);
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
if (DeviceInstance.Buffer != NULL)
{
- DPRINT("Device %wZ already exists!\n", &DeviceInstance);
+ DPRINT1("Device %wZ already exists!\n", &DeviceInstance);
Status = STATUS_SUCCESS;
goto done;
}
DPRINT("Device %wZ does not exist!\n", &DeviceInstance);
- /* FIXME: Create a device node for the device instan*/
+ /* Create a device node for the device instance */
+ Status = IoCreateDevice(IopRootDriverObject,
+ 0,
+ NULL,
+ FILE_DEVICE_CONTROLLER,
+ FILE_AUTOGENERATED_DEVICE_NAME,
+ FALSE,
+ &DeviceObject);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("IoCreateDevice() failed (Status 0x%08lx)\n", Status);
+ goto done;
+ }
+
+ /* Allocate a new device node */
+ DeviceNode = PipAllocateDeviceNode(DeviceObject);
+ if (DeviceNode == NULL)
+ {
+ DPRINT1("Failed to allocate a device node!\n");
+ IoDeleteDevice(DeviceObject);
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ /* Set the device instance of the device node */
+ RtlDuplicateUnicodeString(0, &DeviceInstance, &DeviceNode->InstancePath);
+
+
+ /* Insert as a root enumerated device node */
+ PiInsertDevNode(DeviceNode, IopRootDeviceNode);
done:
ExFreePool(DeviceInstance.Buffer);