Don't directly call NtPlugPlayControl from setupapi, and replace it by RPC

As a bonus, setupapi is now (theorically) able to restart devices on remote machines
See issue #4400 for more details.

svn path=/trunk/; revision=40594
This commit is contained in:
Hervé Poussineau 2009-04-19 21:36:59 +00:00
parent 1d51cd9866
commit ae4881eaf5
2 changed files with 14 additions and 12 deletions

View file

@ -1097,10 +1097,10 @@ DWORD PNP_DeviceInstanceAction(
LPWSTR pszDeviceInstance2)
{
CONFIGRET ret = CR_SUCCESS;
NTSTATUS Status;
UNREFERENCED_PARAMETER(hBinding);
UNREFERENCED_PARAMETER(ulMinorAction);
UNREFERENCED_PARAMETER(pszDeviceInstance1);
UNREFERENCED_PARAMETER(pszDeviceInstance2);
DPRINT("PNP_DeviceInstanceAction() called\n");
@ -1114,10 +1114,15 @@ DWORD PNP_DeviceInstanceAction(
break;
case PNP_DEVINST_ENABLE:
{
PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData;
DPRINT("Enable device instance\n");
/* FIXME */
ret = CR_CALL_NOT_IMPLEMENTED;
RtlInitUnicodeString(&ResetDeviceData.DeviceInstance, pszDeviceInstance1);
Status = NtPlugPlayControl(PlugPlayControlResetDevice, &ResetDeviceData, sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA));
if (!NT_SUCCESS(Status))
ret = NtStatusToCrError(Status);
break;
}
case PNP_DEVINST_REENUMERATE:
DPRINT("Reenumerate device instance\n");

View file

@ -4642,21 +4642,18 @@ ResetDevice(
IN PSP_DEVINFO_DATA DeviceInfoData)
{
#ifndef __WINESRC__
PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData;
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
NTSTATUS Status;
CONFIGRET cr;
if (((struct DeviceInfoSet *)DeviceInfoSet)->HKLM != HKEY_LOCAL_MACHINE)
cr = CM_Enable_DevNode_Ex(deviceInfo->dnDevInst, 0, set->hMachine);
if (cr != CR_SUCCESS)
{
/* At the moment, I only know how to start local devices */
SetLastError(ERROR_INVALID_COMPUTERNAME);
SetLastError(GetErrorCodeFromCrCode(cr));
return FALSE;
}
RtlInitUnicodeString(&ResetDeviceData.DeviceInstance, deviceInfo->instanceId);
Status = NtPlugPlayControl(PlugPlayControlResetDevice, &ResetDeviceData, sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA));
SetLastError(RtlNtStatusToDosError(Status));
return NT_SUCCESS(Status);
return TRUE;
#else
FIXME("Stub: ResetDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
return TRUE;