- Define and use PLUGPLAY_CONTROL_CLASS

- PNP_GetVersion should return an error code
- Rename structs used by NtPlugPlayControl

svn path=/trunk/; revision=16390
This commit is contained in:
Eric Kohl 2005-07-03 12:18:23 +00:00
parent 3eb22d7480
commit 89d4545331
7 changed files with 83 additions and 66 deletions

View file

@ -60,17 +60,18 @@ DEFINE_GUID(GUID_DEVICE_EVENT_RBC, 0xD0744792, 0xA98E, 0x11D2, 0x91, 0x7A, 0x00,
#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 @@ NtGetPlugPlayEvent(
PPLUGPLAY_EVENT_BLOCK Buffer,
ULONG BufferSize);
*/
/*
* NtPlugPlayControl
*
@ -231,19 +232,13 @@ NtGetPlugPlayEvent(
* ...
*/
#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 @@ typedef struct _PLUGPLAY_PROPERTY_DATA
#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__ */

View file

@ -3,6 +3,7 @@
*/
#define WORD unsigned short
#define CONFIGRET unsigned long
[
uuid (809F4e40-A03D-11CE-8F69-08003E30051B),
@ -15,5 +16,6 @@ interface pnp
// 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);
}

View file

@ -1868,9 +1868,9 @@ ZwOpenTimer(
NTSTATUS
STDCALL
NtPlugPlayControl(
ULONG ControlCode,
PVOID Buffer,
ULONG BufferSize
IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
IN OUT PVOID Buffer,
IN ULONG BufferSize
);
NTSTATUS

View file

@ -246,6 +246,17 @@ typedef enum _IO_COMPLETION_INFORMATION_CLASS
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;

View file

@ -376,6 +376,7 @@ WORD WINAPI CM_Get_Version_Ex(HMACHINE hMachine)
{
RPC_BINDING_HANDLE BindingHandle = NULL;
RPC_STATUS Status;
WORD Version = 0;
FIXME("%lx\n", hMachine);
@ -392,7 +393,10 @@ WORD WINAPI CM_Get_Version_Ex(HMACHINE hMachine)
return 0;
}
return PNP_GetVersion(BindingHandle);
if (PNP_GetVersion(BindingHandle, &Version) != CR_SUCCESS)
return 0;
return Version;
}

View file

@ -285,7 +285,7 @@ IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
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 @@ IopGetRelatedDevice(PPLUGPLAY_RELATED_DEVICE_DATA RelatedDeviceData)
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 @@ IopGetRelatedDevice(PPLUGPLAY_RELATED_DEVICE_DATA RelatedDeviceData)
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 @@ IopGetRelatedDevice(PPLUGPLAY_RELATED_DEVICE_DATA RelatedDeviceData)
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 @@ IopDeviceStatus(PPLUGPLAY_DEVICE_STATUS_DATA DeviceStatusData)
* @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 @@ NtPlugPlayControl(IN ULONG ControlCode,
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;

View file

@ -109,9 +109,11 @@ void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
//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 @@ PnpEventThread(LPVOID lpParameter)
/* 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);