mirror of
https://github.com/reactos/reactos.git
synced 2026-06-03 17:59:48 +08:00
[NTOS:PNP] IopInitializeDevice: Create a device, allocate a device node and attach it to the root node
This commit is contained in:
@@ -194,6 +194,7 @@ IopInitializeDevice(
|
|||||||
{
|
{
|
||||||
UNICODE_STRING DeviceInstance;
|
UNICODE_STRING DeviceInstance;
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
PDEVICE_NODE DeviceNode;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
DPRINT("IopInitializeDevice(%p)\n", ControlData);
|
DPRINT("IopInitializeDevice(%p)\n", ControlData);
|
||||||
@@ -210,7 +211,7 @@ IopInitializeDevice(
|
|||||||
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
|
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance);
|
||||||
if (DeviceInstance.Buffer != NULL)
|
if (DeviceInstance.Buffer != NULL)
|
||||||
{
|
{
|
||||||
DPRINT("Device %wZ already exists!\n", &DeviceInstance);
|
DPRINT1("Device %wZ already exists!\n", &DeviceInstance);
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@@ -219,7 +220,36 @@ IopInitializeDevice(
|
|||||||
|
|
||||||
DPRINT("Device %wZ does not exist!\n", &DeviceInstance);
|
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:
|
done:
|
||||||
ExFreePool(DeviceInstance.Buffer);
|
ExFreePool(DeviceInstance.Buffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user