mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[UMPNPMGR][USETUP] Use PlugPlayControlStartDevice in usetup and umpnpmgr
Instead of PlugPlayControlResetDevice, PlugPlayControlStartDevice should be used for a newly installed device. For usetup, add a device status check before starting attempt, so we're not touching devices which are already started. CORE-17463 CORE-17490
This commit is contained in:
parent
59a5dba443
commit
abbc5ba45a
2 changed files with 31 additions and 16 deletions
|
@ -3081,17 +3081,14 @@ static CONFIGRET
|
||||||
EnableDeviceInstance(
|
EnableDeviceInstance(
|
||||||
_In_ LPWSTR pszDeviceInstance)
|
_In_ LPWSTR pszDeviceInstance)
|
||||||
{
|
{
|
||||||
PLUGPLAY_CONTROL_DEVICE_CONTROL_DATA ResetDeviceData;
|
PLUGPLAY_CONTROL_DEVICE_CONTROL_DATA ControlData;
|
||||||
CONFIGRET ret = CR_SUCCESS;
|
CONFIGRET ret = CR_SUCCESS;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("Enable device instance %S\n", pszDeviceInstance);
|
DPRINT("Enable device instance %S\n", pszDeviceInstance);
|
||||||
|
|
||||||
RtlInitUnicodeString(&ResetDeviceData.DeviceInstance,
|
RtlInitUnicodeString(&ControlData.DeviceInstance, pszDeviceInstance);
|
||||||
pszDeviceInstance);
|
Status = NtPlugPlayControl(PlugPlayControlStartDevice, &ControlData, sizeof(ControlData));
|
||||||
Status = NtPlugPlayControl(PlugPlayControlResetDevice,
|
|
||||||
&ResetDeviceData,
|
|
||||||
sizeof(PLUGPLAY_CONTROL_DEVICE_CONTROL_DATA));
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
ret = NtStatusToCrError(Status);
|
ret = NtStatusToCrError(Status);
|
||||||
|
|
||||||
|
|
|
@ -39,20 +39,25 @@ typedef struct
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
ResetDevice(
|
AreDriversLoaded(
|
||||||
IN LPCWSTR DeviceId)
|
IN PCWSTR DeviceId)
|
||||||
{
|
{
|
||||||
PLUGPLAY_CONTROL_DEVICE_CONTROL_DATA ResetDeviceData;
|
PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
RtlInitUnicodeString(&ResetDeviceData.DeviceInstance, DeviceId);
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance, DeviceId);
|
||||||
Status = NtPlugPlayControl(PlugPlayControlResetDevice, &ResetDeviceData, sizeof(PLUGPLAY_CONTROL_DEVICE_CONTROL_DATA));
|
PlugPlayData.Operation = PNP_GET_DEVICE_STATUS;
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
|
Status = NtPlugPlayControl(PlugPlayControlDeviceStatus, &PlugPlayData, sizeof(PlugPlayData));
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return (_Bool)((PlugPlayData.DeviceStatus & DN_DRIVER_LOADED) &&
|
||||||
|
!(PlugPlayData.DeviceStatus & DN_HAS_PROBLEM));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
DPRINT1("NtPlugPlayControl() failed with status 0x%08x\n", Status);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
|
@ -81,6 +86,10 @@ InstallDriver(
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
BOOLEAN deviceInstalled = FALSE;
|
BOOLEAN deviceInstalled = FALSE;
|
||||||
|
|
||||||
|
/* First check if the driver needs any action at all */
|
||||||
|
if (AreDriversLoaded(DeviceId))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
/* Check if we know the hardware */
|
/* Check if we know the hardware */
|
||||||
if (!SpInfFindFirstLine(hInf, L"HardwareIdsDatabase", HardwareId, &Context))
|
if (!SpInfFindFirstLine(hInf, L"HardwareIdsDatabase", HardwareId, &Context))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -190,8 +199,17 @@ InstallDriver(
|
||||||
(wcslen(Driver) + 1) * sizeof(WCHAR));
|
(wcslen(Driver) + 1) * sizeof(WCHAR));
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Restart the device, so it will use the driver we registered */
|
/* We've registered the driver, time to start a device */
|
||||||
deviceInstalled = ResetDevice(DeviceId);
|
PLUGPLAY_CONTROL_DEVICE_CONTROL_DATA ControlData;
|
||||||
|
RtlInitUnicodeString(&ControlData.DeviceInstance, DeviceId);
|
||||||
|
|
||||||
|
Status = NtPlugPlayControl(PlugPlayControlStartDevice, &ControlData, sizeof(ControlData));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("NtPlugPlayControl() failed with status 0x%08x\n", Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
deviceInstalled = NT_SUCCESS(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
INF_FreeData(Driver);
|
INF_FreeData(Driver);
|
||||||
|
|
Loading…
Reference in a new issue