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

View file

@ -4642,21 +4642,18 @@ ResetDevice(
IN PSP_DEVINFO_DATA DeviceInfoData) IN PSP_DEVINFO_DATA DeviceInfoData)
{ {
#ifndef __WINESRC__ #ifndef __WINESRC__
PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData; struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved; 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(GetErrorCodeFromCrCode(cr));
SetLastError(ERROR_INVALID_COMPUTERNAME);
return FALSE; return FALSE;
} }
RtlInitUnicodeString(&ResetDeviceData.DeviceInstance, deviceInfo->instanceId); return TRUE;
Status = NtPlugPlayControl(PlugPlayControlResetDevice, &ResetDeviceData, sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA));
SetLastError(RtlNtStatusToDosError(Status));
return NT_SUCCESS(Status);
#else #else
FIXME("Stub: ResetDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData); FIXME("Stub: ResetDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
return TRUE; return TRUE;