- Define and use PLUGPLAY_CONTROL_CLASS
- PNP_GetVersion should return an error code
- Rename structs used by NtPlugPlayControl
Modified: trunk/reactos/include/ddk/ntpnp.h
Modified: trunk/reactos/include/idl/pnp.idl
Modified: trunk/reactos/include/ndk/zwfuncs.h
Modified: trunk/reactos/include/ndk/zwtypes.h
Modified: trunk/reactos/lib/setupapi/cfgmgr.c
Modified: trunk/reactos/ntoskrnl/io/plugplay.c
Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c

Modified: trunk/reactos/include/ddk/ntpnp.h
--- trunk/reactos/include/ddk/ntpnp.h	2005-07-03 10:35:56 UTC (rev 16389)
+++ trunk/reactos/include/ddk/ntpnp.h	2005-07-03 12:18:23 UTC (rev 16390)
@@ -60,17 +60,18 @@
 
 #ifndef __GUIDS_ONLY__ /* This is defined to build libwdmguid.a */
 
-typedef enum _PLUGPLAY_EVENT_CATEGORY {
-   HardwareProfileChangeEvent,
-   TargetDeviceChangeEvent,
-   DeviceClassChangeEvent,
-   CustomDeviceEvent,
-   DeviceInstallEvent,
-   DeviceArrivalEvent,
-   PowerEvent,
-   VetoEvent,
-   BlockedDriverEvent,
-   MaxPlugEventCategory
+typedef enum _PLUGPLAY_EVENT_CATEGORY
+{
+    HardwareProfileChangeEvent,
+    TargetDeviceChangeEvent,
+    DeviceClassChangeEvent,
+    CustomDeviceEvent,
+    DeviceInstallEvent,
+    DeviceArrivalEvent,
+    PowerEvent,
+    VetoEvent,
+    BlockedDriverEvent,
+    MaxPlugEventCategory
 } PLUGPLAY_EVENT_CATEGORY;
 
 /*
@@ -175,7 +176,7 @@
    PPLUGPLAY_EVENT_BLOCK Buffer,
    ULONG BufferSize);
  */
- 
+
 /*
  * NtPlugPlayControl
  *
@@ -231,19 +232,13 @@
  *    ...
  */
 
-#define PLUGPLAY_USER_RESPONSE      0x07
-#define PLUGPLAY_GET_PROPERTY       0x0A
-#define PLUGPLAY_GET_RELATED_DEVICE 0x0C
-#define PLUGPLAY_DEVICE_STATUS      0x0E
-
-
-typedef struct _PLUGPLAY_PROPERTY_DATA
+typedef struct _PLUGPLAY_CONTROL_PROPERTY_DATA
 {
-  UNICODE_STRING DeviceInstance;
-  ULONG Property;
-  PVOID Buffer;
-  ULONG BufferSize;
-} PLUGPLAY_PROPERTY_DATA, *PPLUGPLAY_PROPERTY_DATA;
+    UNICODE_STRING DeviceInstance;
+    ULONG Property;
+    PVOID Buffer;
+    ULONG BufferSize;
+} PLUGPLAY_CONTROL_PROPERTY_DATA, *PPLUGPLAY_CONTROL_PROPERTY_DATA;
 
 
 /* PLUGPLAY_GET_RELATED_DEVICE (Code 0x0C) */
@@ -253,29 +248,29 @@
 #define PNP_GET_CHILD_DEVICE   2
 #define PNP_GET_SIBLING_DEVICE 3
 
-typedef struct _PLUGPLAY_RELATED_DEVICE_DATA
+typedef struct _PLUGPLAY_CONTROL_RELATED_DEVICE_DATA
 {
-  UNICODE_STRING DeviceInstance;
-  UNICODE_STRING RelatedDeviceInstance;
-  ULONG Relation; /* 1: Parent  2: Child  3: Sibling */
-} PLUGPLAY_RELATED_DEVICE_DATA, *PPLUGPLAY_RELATED_DEVICE_DATA;
+    UNICODE_STRING TargetDeviceInstance;
+    ULONG Relation; /* 1: Parent  2: Child  3: Sibling */
+    UNICODE_STRING RelatedDeviceInstance;
+} PLUGPLAY_CONTROL_RELATED_DEVICE_DATA, *PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA;
 
 
 /* PLUGPLAY_DEVICE_STATUS (Code 0x0E) */
 
-/* Action values */
+/* Operation values */
 #define PNP_GET_DEVICE_STATUS    0
 #define PNP_SET_DEVICE_STATUS    1
 #define PNP_CLEAR_DEVICE_STATUS  2
 
 
-typedef struct _PLUGPLAY_DEVICE_STATUS_DATA
+typedef struct _PLUGPLAY_CONTOL_STATUS_DATA
 {
-  UNICODE_STRING DeviceInstance;
-  ULONG Action;   /* 0: Get  1: Set  2: Clear */
-  ULONG Problem;  /* CM_PROB_  see cfg.h */
-  ULONG Flags;    /* DN_       see cfg.h */
-} PLUGPLAY_DEVICE_STATUS_DATA, *PPLUGPLAY_DEVICE_STATUS_DATA;
+    UNICODE_STRING DeviceInstance;
+    ULONG Operation;       /* 0: Get  1: Set  2: Clear */
+    ULONG DeviceStatus;    /* DN_       see cfg.h */
+    ULONG DeviceProblem;   /* CM_PROB_  see cfg.h */
+} PLUGPLAY_CONTROL_STATUS_DATA, *PPLUGPLAY_CONTROL_STATUS_DATA;
 
 #endif /* __GUIDS_ONLY__ */
 

Modified: trunk/reactos/include/idl/pnp.idl
--- trunk/reactos/include/idl/pnp.idl	2005-07-03 10:35:56 UTC (rev 16389)
+++ trunk/reactos/include/idl/pnp.idl	2005-07-03 12:18:23 UTC (rev 16390)
@@ -3,6 +3,7 @@
  */
 
 #define WORD unsigned short
+#define CONFIGRET unsigned long
 
 [
   uuid (809F4e40-A03D-11CE-8F69-08003E30051B),
@@ -15,5 +16,6 @@
 //  unsigned long PNP_GetRootDeviceInstance(handle_t BindingHandle,
 //					  [out, string, size_is(Length)] wchar_t *DeviceInstance,
 //					  [in] unsigned long Length);
-  WORD PNP_GetVersion(handle_t BindingHandle);
+  CONFIGRET PNP_GetVersion(handle_t BindingHandle,
+                           [out] WORD *Version);
 }

Modified: trunk/reactos/include/ndk/zwfuncs.h
--- trunk/reactos/include/ndk/zwfuncs.h	2005-07-03 10:35:56 UTC (rev 16389)
+++ trunk/reactos/include/ndk/zwfuncs.h	2005-07-03 12:18:23 UTC (rev 16390)
@@ -1868,9 +1868,9 @@
 NTSTATUS
 STDCALL
 NtPlugPlayControl(
-    ULONG ControlCode,
-    PVOID Buffer,
-    ULONG BufferSize
+    IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
+    IN OUT PVOID Buffer,
+    IN ULONG BufferSize
 );
 
 NTSTATUS

Modified: trunk/reactos/include/ndk/zwtypes.h
--- trunk/reactos/include/ndk/zwtypes.h	2005-07-03 10:35:56 UTC (rev 16389)
+++ trunk/reactos/include/ndk/zwtypes.h	2005-07-03 12:18:23 UTC (rev 16390)
@@ -246,6 +246,17 @@
     IoCompletionBasicInformation
 } IO_COMPLETION_INFORMATION_CLASS;
 
+/*
+ *  PlugPlay
+ */
+typedef enum _PLUGPLAY_CONTROL_CLASS
+{
+    PlugPlayControlUserResponse = 0x07,
+    PlugPlayControlProperty = 0x0A,
+    PlugPlayControlGetRelatedDevice = 0x0C,
+    PlugPlayControlDeviceStatus = 0x0E
+} PLUGPLAY_CONTROL_CLASS;
+
 /* TYPES *********************************************************************/
 
 typedef unsigned short LANGID;

Modified: trunk/reactos/lib/setupapi/cfgmgr.c
--- trunk/reactos/lib/setupapi/cfgmgr.c	2005-07-03 10:35:56 UTC (rev 16389)
+++ trunk/reactos/lib/setupapi/cfgmgr.c	2005-07-03 12:18:23 UTC (rev 16390)
@@ -376,6 +376,7 @@
 {
     RPC_BINDING_HANDLE BindingHandle = NULL;
     RPC_STATUS Status;
+    WORD Version = 0;
 
     FIXME("%lx\n", hMachine);
 
@@ -392,7 +393,10 @@
             return 0;
     }
 
-    return PNP_GetVersion(BindingHandle);
+    if (PNP_GetVersion(BindingHandle, &Version) != CR_SUCCESS)
+        return 0;
+
+    return Version;
 }
 
 

Modified: trunk/reactos/ntoskrnl/io/plugplay.c
--- trunk/reactos/ntoskrnl/io/plugplay.c	2005-07-03 10:35:56 UTC (rev 16389)
+++ trunk/reactos/ntoskrnl/io/plugplay.c	2005-07-03 12:18:23 UTC (rev 16390)
@@ -285,7 +285,7 @@
 
 
 static NTSTATUS
-IopGetRelatedDevice(PPLUGPLAY_RELATED_DEVICE_DATA RelatedDeviceData)
+IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
 {
     UNICODE_STRING RootDeviceName;
     PDEVICE_OBJECT DeviceObject = NULL;
@@ -294,11 +294,11 @@
 
     DPRINT("IopGetRelatedDevice() called\n");
 
-    DPRINT("Device name: %wZ\n", &RelatedDeviceData->DeviceInstance);
+    DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
 
     RtlInitUnicodeString(&RootDeviceName,
                          L"HTREE\\ROOT\\0");
-    if (RtlEqualUnicodeString(&RelatedDeviceData->DeviceInstance,
+    if (RtlEqualUnicodeString(&RelatedDeviceData->TargetDeviceInstance,
                               &RootDeviceName,
                               TRUE))
     {
@@ -307,7 +307,7 @@
     else
     {
         /* Get the device object */
-        DeviceObject = IopGetDeviceObjectFromDeviceInstance(&RelatedDeviceData->DeviceInstance);
+        DeviceObject = IopGetDeviceObjectFromDeviceInstance(&RelatedDeviceData->TargetDeviceInstance);
         if (DeviceObject == NULL)
             return STATUS_NO_SUCH_DEVICE;
 
@@ -377,34 +377,34 @@
 
 
 static NTSTATUS
-IopDeviceStatus(PPLUGPLAY_DEVICE_STATUS_DATA DeviceStatusData)
+IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
 {
     PDEVICE_OBJECT DeviceObject;
     PDEVICE_NODE DeviceNode;
 
     DPRINT("IopDeviceStatus() called\n");
 
-    DPRINT("Device name: %wZ\n", &DeviceStatusData->DeviceInstance);
+    DPRINT("Device name: %wZ\n", &StatusData->DeviceInstance);
 
     /* Get the device object */
-    DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceStatusData->DeviceInstance);
+    DeviceObject = IopGetDeviceObjectFromDeviceInstance(&StatusData->DeviceInstance);
     if (DeviceObject == NULL)
         return STATUS_NO_SUCH_DEVICE;
 
     DeviceNode = DeviceObject->DeviceObjectExtension->DeviceNode;
 
-    switch (DeviceStatusData->Action)
+    switch (StatusData->Operation)
     {
         case PNP_GET_DEVICE_STATUS:
             DPRINT("Get status data\n");
-            DeviceStatusData->Problem = DeviceNode->Problem;
-            DeviceStatusData->Flags = DeviceNode->Flags;
+            StatusData->DeviceStatus = DeviceNode->Flags;
+            StatusData->DeviceProblem = DeviceNode->Problem;
             break;
 
         case PNP_SET_DEVICE_STATUS:
             DPRINT("Set status data\n");
-            DeviceNode->Problem = DeviceStatusData->Problem;
-            DeviceNode->Flags = DeviceStatusData->Flags;
+            DeviceNode->Flags = StatusData->DeviceStatus;
+            DeviceNode->Problem = StatusData->DeviceProblem;
             break;
 
         case PNP_CLEAR_DEVICE_STATUS:
@@ -422,14 +422,14 @@
  * @unimplemented
  */
 NTSTATUS STDCALL
-NtPlugPlayControl(IN ULONG ControlCode,
+NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
                   IN OUT PVOID Buffer,
                   IN ULONG BufferLength)
 {
     NTSTATUS Status = STATUS_SUCCESS;
 
     DPRINT("NtPlugPlayControl(%lu %p %lu) called\n",
-           ControlCode, Buffer, BufferLength);
+           PlugPlayControlClass, Buffer, BufferLength);
 
     /* Function can only be called from user-mode */
     if (KeGetPreviousMode() != UserMode)
@@ -464,22 +464,25 @@
         return Status;
     }
 
-    switch (ControlCode)
+    switch (PlugPlayControlClass)
     {
-        case PLUGPLAY_USER_RESPONSE:
+        case PlugPlayControlUserResponse:
             if (Buffer || BufferLength != 0)
                 return STATUS_INVALID_PARAMETER;
             return IopRemovePlugPlayEvent();
 
-        case PLUGPLAY_GET_RELATED_DEVICE:
-            if (!Buffer || BufferLength < sizeof(PLUGPLAY_RELATED_DEVICE_DATA))
+        case PlugPlayControlGetRelatedDevice:
+            if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA))
                 return STATUS_INVALID_PARAMETER;
-            return IopGetRelatedDevice((PPLUGPLAY_RELATED_DEVICE_DATA)Buffer);
+            return IopGetRelatedDevice((PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA)Buffer);
 
-        case PLUGPLAY_DEVICE_STATUS:
-            if (!Buffer || BufferLength < sizeof(PLUGPLAY_DEVICE_STATUS_DATA))
+        case PlugPlayControlDeviceStatus:
+            if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_STATUS_DATA))
                 return STATUS_INVALID_PARAMETER;
-            return IopDeviceStatus((PPLUGPLAY_DEVICE_STATUS_DATA)Buffer);
+            return IopDeviceStatus((PPLUGPLAY_CONTROL_STATUS_DATA)Buffer);
+
+        default:
+            return STATUS_NOT_IMPLEMENTED;
     }
 
     return STATUS_NOT_IMPLEMENTED;

Modified: trunk/reactos/services/umpnpmgr/umpnpmgr.c
--- trunk/reactos/services/umpnpmgr/umpnpmgr.c	2005-07-03 10:35:56 UTC (rev 16389)
+++ trunk/reactos/services/umpnpmgr/umpnpmgr.c	2005-07-03 12:18:23 UTC (rev 16390)
@@ -109,9 +109,11 @@
 
 
 //WORD PNP_GetVersion(RPC_BINDING_HANDLE BindingHandle)
-WORD PNP_GetVersion(handle_t BindingHandle)
+unsigned long PNP_GetVersion(handle_t BindingHandle,
+                             unsigned short *Version)
 {
-  return 0x0400;
+  *Version = 0x0400;
+  return 0;
 }
 
 
@@ -162,7 +164,7 @@
     /* FIXME: Process the pnp event */
 
     /* Dequeue the current pnp event and signal the next one */
-    NtPlugPlayControl(PLUGPLAY_USER_RESPONSE, NULL, 0);
+    NtPlugPlayControl(PlugPlayControlUserResponse, NULL, 0);
   }
 
   HeapFree(GetProcessHeap(), 0, PnpEvent);