Author: hpoussin
Date: Mon Apr 20 01:36:59 2009
New Revision: 40594
URL:
http://svn.reactos.org/svn/reactos?rev=40594&view=rev
Log:
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.
Modified:
trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
trunk/reactos/dll/win32/setupapi/devinst.c
Modified: trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/umpnpmgr/ump…
==============================================================================
--- trunk/reactos/base/services/umpnpmgr/umpnpmgr.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/umpnpmgr/umpnpmgr.c [iso-8859-1] Mon Apr 20 01:36:59 2009
@@ -1097,10 +1097,10 @@
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 @@
break;
case PNP_DEVINST_ENABLE:
+ {
+ PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData;
DPRINT("Enable device instance\n");
- /* FIXME */
- ret = CR_CALL_NOT_IMPLEMENTED;
- break;
+ 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");
Modified: trunk/reactos/dll/win32/setupapi/devinst.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/devinst…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/devinst.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/devinst.c [iso-8859-1] Mon Apr 20 01:36:59 2009
@@ -4642,21 +4642,18 @@
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;
-
- if (((struct DeviceInfoSet *)DeviceInfoSet)->HKLM != HKEY_LOCAL_MACHINE)
- {
- /* At the moment, I only know how to start local devices */
- SetLastError(ERROR_INVALID_COMPUTERNAME);
- return FALSE;
- }
-
- RtlInitUnicodeString(&ResetDeviceData.DeviceInstance,
deviceInfo->instanceId);
- Status = NtPlugPlayControl(PlugPlayControlResetDevice, &ResetDeviceData,
sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA));
- SetLastError(RtlNtStatusToDosError(Status));
- return NT_SUCCESS(Status);
+ CONFIGRET cr;
+
+ cr = CM_Enable_DevNode_Ex(deviceInfo->dnDevInst, 0, set->hMachine);
+ if (cr != CR_SUCCESS)
+ {
+ SetLastError(GetErrorCodeFromCrCode(cr));
+ return FALSE;
+ }
+
+ return TRUE;
#else
FIXME("Stub: ResetDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
return TRUE;