https://git.reactos.org/?p=reactos.git;a=commitdiff;h=969f950bf34c4789738785...
commit 969f950bf34c4789738785581d8c06fe8870b862 Author: Eric Kohl eric.kohl@reactos.org AuthorDate: Sun Apr 24 10:02:17 2022 +0200 Commit: Eric Kohl eric.kohl@reactos.org CommitDate: Sun Apr 24 10:02:17 2022 +0200
[NTOS:PNP] Add a stub for NtPlugPlayControl:PlugPlayControlInitializeDevice --- ntoskrnl/io/pnpmgr/plugplay.c | 48 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/io/pnpmgr/plugplay.c b/ntoskrnl/io/pnpmgr/plugplay.c index 4d64c1e54da..c1f108da332 100644 --- a/ntoskrnl/io/pnpmgr/plugplay.c +++ b/ntoskrnl/io/pnpmgr/plugplay.c @@ -186,6 +186,48 @@ IopCaptureUnicodeString(PUNICODE_STRING DstName, PUNICODE_STRING SrcName) return Status; }
+ +static +NTSTATUS +IopInitializeDevice( + _In_ PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA ControlData) +{ + UNICODE_STRING DeviceInstance; + PDEVICE_OBJECT DeviceObject; + NTSTATUS Status = STATUS_SUCCESS; + + DPRINT("IopInitializeDevice(%p)\n", ControlData); + + Status = IopCaptureUnicodeString(&DeviceInstance, &ControlData->DeviceInstance); + if (!NT_SUCCESS(Status)) + { + return Status; + } + + DPRINT("Device: %wZ\n", &DeviceInstance); + + /* Leave, if the device already exists */ + DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceInstance); + if (DeviceInstance.Buffer != NULL) + { + DPRINT("Device %wZ already exists!\n", &DeviceInstance); + Status = STATUS_SUCCESS; + goto done; + } + + ObDereferenceObject(DeviceObject); + + DPRINT("Device %wZ does not exist!\n", &DeviceInstance); + + /* FIXME: Create a device node for the device instan*/ + +done: + ExFreePool(DeviceInstance.Buffer); + + return Status; +} + + /* * Remove the current PnP event from the tail of the event queue * and signal IopPnpNotifyEvent if there is yet another event in the queue. @@ -1308,7 +1350,11 @@ NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
// case PlugPlayControlRegisterNewDevice: // case PlugPlayControlDeregisterDevice: -// case PlugPlayControlInitializeDevice: + + case PlugPlayControlInitializeDevice: + if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_DEVICE_CONTROL_DATA)) + return STATUS_INVALID_PARAMETER; + return IopInitializeDevice((PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA)Buffer);
case PlugPlayControlStartDevice: case PlugPlayControlResetDevice: