mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 22:12:05 +00:00
- 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:
parent
3eb22d7480
commit
89d4545331
7 changed files with 83 additions and 66 deletions
|
@ -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 */
|
#ifndef __GUIDS_ONLY__ /* This is defined to build libwdmguid.a */
|
||||||
|
|
||||||
typedef enum _PLUGPLAY_EVENT_CATEGORY {
|
typedef enum _PLUGPLAY_EVENT_CATEGORY
|
||||||
HardwareProfileChangeEvent,
|
{
|
||||||
TargetDeviceChangeEvent,
|
HardwareProfileChangeEvent,
|
||||||
DeviceClassChangeEvent,
|
TargetDeviceChangeEvent,
|
||||||
CustomDeviceEvent,
|
DeviceClassChangeEvent,
|
||||||
DeviceInstallEvent,
|
CustomDeviceEvent,
|
||||||
DeviceArrivalEvent,
|
DeviceInstallEvent,
|
||||||
PowerEvent,
|
DeviceArrivalEvent,
|
||||||
VetoEvent,
|
PowerEvent,
|
||||||
BlockedDriverEvent,
|
VetoEvent,
|
||||||
MaxPlugEventCategory
|
BlockedDriverEvent,
|
||||||
|
MaxPlugEventCategory
|
||||||
} PLUGPLAY_EVENT_CATEGORY;
|
} PLUGPLAY_EVENT_CATEGORY;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -175,7 +176,7 @@ NtGetPlugPlayEvent(
|
||||||
PPLUGPLAY_EVENT_BLOCK Buffer,
|
PPLUGPLAY_EVENT_BLOCK Buffer,
|
||||||
ULONG BufferSize);
|
ULONG BufferSize);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NtPlugPlayControl
|
* NtPlugPlayControl
|
||||||
*
|
*
|
||||||
|
@ -231,19 +232,13 @@ NtGetPlugPlayEvent(
|
||||||
* ...
|
* ...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PLUGPLAY_USER_RESPONSE 0x07
|
typedef struct _PLUGPLAY_CONTROL_PROPERTY_DATA
|
||||||
#define PLUGPLAY_GET_PROPERTY 0x0A
|
|
||||||
#define PLUGPLAY_GET_RELATED_DEVICE 0x0C
|
|
||||||
#define PLUGPLAY_DEVICE_STATUS 0x0E
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _PLUGPLAY_PROPERTY_DATA
|
|
||||||
{
|
{
|
||||||
UNICODE_STRING DeviceInstance;
|
UNICODE_STRING DeviceInstance;
|
||||||
ULONG Property;
|
ULONG Property;
|
||||||
PVOID Buffer;
|
PVOID Buffer;
|
||||||
ULONG BufferSize;
|
ULONG BufferSize;
|
||||||
} PLUGPLAY_PROPERTY_DATA, *PPLUGPLAY_PROPERTY_DATA;
|
} PLUGPLAY_CONTROL_PROPERTY_DATA, *PPLUGPLAY_CONTROL_PROPERTY_DATA;
|
||||||
|
|
||||||
|
|
||||||
/* PLUGPLAY_GET_RELATED_DEVICE (Code 0x0C) */
|
/* PLUGPLAY_GET_RELATED_DEVICE (Code 0x0C) */
|
||||||
|
@ -253,29 +248,29 @@ typedef struct _PLUGPLAY_PROPERTY_DATA
|
||||||
#define PNP_GET_CHILD_DEVICE 2
|
#define PNP_GET_CHILD_DEVICE 2
|
||||||
#define PNP_GET_SIBLING_DEVICE 3
|
#define PNP_GET_SIBLING_DEVICE 3
|
||||||
|
|
||||||
typedef struct _PLUGPLAY_RELATED_DEVICE_DATA
|
typedef struct _PLUGPLAY_CONTROL_RELATED_DEVICE_DATA
|
||||||
{
|
{
|
||||||
UNICODE_STRING DeviceInstance;
|
UNICODE_STRING TargetDeviceInstance;
|
||||||
UNICODE_STRING RelatedDeviceInstance;
|
ULONG Relation; /* 1: Parent 2: Child 3: Sibling */
|
||||||
ULONG Relation; /* 1: Parent 2: Child 3: Sibling */
|
UNICODE_STRING RelatedDeviceInstance;
|
||||||
} PLUGPLAY_RELATED_DEVICE_DATA, *PPLUGPLAY_RELATED_DEVICE_DATA;
|
} PLUGPLAY_CONTROL_RELATED_DEVICE_DATA, *PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA;
|
||||||
|
|
||||||
|
|
||||||
/* PLUGPLAY_DEVICE_STATUS (Code 0x0E) */
|
/* PLUGPLAY_DEVICE_STATUS (Code 0x0E) */
|
||||||
|
|
||||||
/* Action values */
|
/* Operation values */
|
||||||
#define PNP_GET_DEVICE_STATUS 0
|
#define PNP_GET_DEVICE_STATUS 0
|
||||||
#define PNP_SET_DEVICE_STATUS 1
|
#define PNP_SET_DEVICE_STATUS 1
|
||||||
#define PNP_CLEAR_DEVICE_STATUS 2
|
#define PNP_CLEAR_DEVICE_STATUS 2
|
||||||
|
|
||||||
|
|
||||||
typedef struct _PLUGPLAY_DEVICE_STATUS_DATA
|
typedef struct _PLUGPLAY_CONTOL_STATUS_DATA
|
||||||
{
|
{
|
||||||
UNICODE_STRING DeviceInstance;
|
UNICODE_STRING DeviceInstance;
|
||||||
ULONG Action; /* 0: Get 1: Set 2: Clear */
|
ULONG Operation; /* 0: Get 1: Set 2: Clear */
|
||||||
ULONG Problem; /* CM_PROB_ see cfg.h */
|
ULONG DeviceStatus; /* DN_ see cfg.h */
|
||||||
ULONG Flags; /* DN_ see cfg.h */
|
ULONG DeviceProblem; /* CM_PROB_ see cfg.h */
|
||||||
} PLUGPLAY_DEVICE_STATUS_DATA, *PPLUGPLAY_DEVICE_STATUS_DATA;
|
} PLUGPLAY_CONTROL_STATUS_DATA, *PPLUGPLAY_CONTROL_STATUS_DATA;
|
||||||
|
|
||||||
#endif /* __GUIDS_ONLY__ */
|
#endif /* __GUIDS_ONLY__ */
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define WORD unsigned short
|
#define WORD unsigned short
|
||||||
|
#define CONFIGRET unsigned long
|
||||||
|
|
||||||
[
|
[
|
||||||
uuid (809F4e40-A03D-11CE-8F69-08003E30051B),
|
uuid (809F4e40-A03D-11CE-8F69-08003E30051B),
|
||||||
|
@ -15,5 +16,6 @@ interface pnp
|
||||||
// unsigned long PNP_GetRootDeviceInstance(handle_t BindingHandle,
|
// unsigned long PNP_GetRootDeviceInstance(handle_t BindingHandle,
|
||||||
// [out, string, size_is(Length)] wchar_t *DeviceInstance,
|
// [out, string, size_is(Length)] wchar_t *DeviceInstance,
|
||||||
// [in] unsigned long Length);
|
// [in] unsigned long Length);
|
||||||
WORD PNP_GetVersion(handle_t BindingHandle);
|
CONFIGRET PNP_GetVersion(handle_t BindingHandle,
|
||||||
|
[out] WORD *Version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1868,9 +1868,9 @@ ZwOpenTimer(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
NtPlugPlayControl(
|
NtPlugPlayControl(
|
||||||
ULONG ControlCode,
|
IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
|
||||||
PVOID Buffer,
|
IN OUT PVOID Buffer,
|
||||||
ULONG BufferSize
|
IN ULONG BufferSize
|
||||||
);
|
);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -246,6 +246,17 @@ typedef enum _IO_COMPLETION_INFORMATION_CLASS
|
||||||
IoCompletionBasicInformation
|
IoCompletionBasicInformation
|
||||||
} IO_COMPLETION_INFORMATION_CLASS;
|
} IO_COMPLETION_INFORMATION_CLASS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PlugPlay
|
||||||
|
*/
|
||||||
|
typedef enum _PLUGPLAY_CONTROL_CLASS
|
||||||
|
{
|
||||||
|
PlugPlayControlUserResponse = 0x07,
|
||||||
|
PlugPlayControlProperty = 0x0A,
|
||||||
|
PlugPlayControlGetRelatedDevice = 0x0C,
|
||||||
|
PlugPlayControlDeviceStatus = 0x0E
|
||||||
|
} PLUGPLAY_CONTROL_CLASS;
|
||||||
|
|
||||||
/* TYPES *********************************************************************/
|
/* TYPES *********************************************************************/
|
||||||
|
|
||||||
typedef unsigned short LANGID;
|
typedef unsigned short LANGID;
|
||||||
|
|
|
@ -376,6 +376,7 @@ WORD WINAPI CM_Get_Version_Ex(HMACHINE hMachine)
|
||||||
{
|
{
|
||||||
RPC_BINDING_HANDLE BindingHandle = NULL;
|
RPC_BINDING_HANDLE BindingHandle = NULL;
|
||||||
RPC_STATUS Status;
|
RPC_STATUS Status;
|
||||||
|
WORD Version = 0;
|
||||||
|
|
||||||
FIXME("%lx\n", hMachine);
|
FIXME("%lx\n", hMachine);
|
||||||
|
|
||||||
|
@ -392,7 +393,10 @@ WORD WINAPI CM_Get_Version_Ex(HMACHINE hMachine)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PNP_GetVersion(BindingHandle);
|
if (PNP_GetVersion(BindingHandle, &Version) != CR_SUCCESS)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
IopGetRelatedDevice(PPLUGPLAY_RELATED_DEVICE_DATA RelatedDeviceData)
|
IopGetRelatedDevice(PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedDeviceData)
|
||||||
{
|
{
|
||||||
UNICODE_STRING RootDeviceName;
|
UNICODE_STRING RootDeviceName;
|
||||||
PDEVICE_OBJECT DeviceObject = NULL;
|
PDEVICE_OBJECT DeviceObject = NULL;
|
||||||
|
@ -294,11 +294,11 @@ IopGetRelatedDevice(PPLUGPLAY_RELATED_DEVICE_DATA RelatedDeviceData)
|
||||||
|
|
||||||
DPRINT("IopGetRelatedDevice() called\n");
|
DPRINT("IopGetRelatedDevice() called\n");
|
||||||
|
|
||||||
DPRINT("Device name: %wZ\n", &RelatedDeviceData->DeviceInstance);
|
DPRINT("Device name: %wZ\n", &RelatedDeviceData->TargetDeviceInstance);
|
||||||
|
|
||||||
RtlInitUnicodeString(&RootDeviceName,
|
RtlInitUnicodeString(&RootDeviceName,
|
||||||
L"HTREE\\ROOT\\0");
|
L"HTREE\\ROOT\\0");
|
||||||
if (RtlEqualUnicodeString(&RelatedDeviceData->DeviceInstance,
|
if (RtlEqualUnicodeString(&RelatedDeviceData->TargetDeviceInstance,
|
||||||
&RootDeviceName,
|
&RootDeviceName,
|
||||||
TRUE))
|
TRUE))
|
||||||
{
|
{
|
||||||
|
@ -307,7 +307,7 @@ IopGetRelatedDevice(PPLUGPLAY_RELATED_DEVICE_DATA RelatedDeviceData)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Get the device object */
|
/* Get the device object */
|
||||||
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&RelatedDeviceData->DeviceInstance);
|
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&RelatedDeviceData->TargetDeviceInstance);
|
||||||
if (DeviceObject == NULL)
|
if (DeviceObject == NULL)
|
||||||
return STATUS_NO_SUCH_DEVICE;
|
return STATUS_NO_SUCH_DEVICE;
|
||||||
|
|
||||||
|
@ -377,34 +377,34 @@ IopGetRelatedDevice(PPLUGPLAY_RELATED_DEVICE_DATA RelatedDeviceData)
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
IopDeviceStatus(PPLUGPLAY_DEVICE_STATUS_DATA DeviceStatusData)
|
IopDeviceStatus(PPLUGPLAY_CONTROL_STATUS_DATA StatusData)
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
PDEVICE_NODE DeviceNode;
|
PDEVICE_NODE DeviceNode;
|
||||||
|
|
||||||
DPRINT("IopDeviceStatus() called\n");
|
DPRINT("IopDeviceStatus() called\n");
|
||||||
|
|
||||||
DPRINT("Device name: %wZ\n", &DeviceStatusData->DeviceInstance);
|
DPRINT("Device name: %wZ\n", &StatusData->DeviceInstance);
|
||||||
|
|
||||||
/* Get the device object */
|
/* Get the device object */
|
||||||
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&DeviceStatusData->DeviceInstance);
|
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&StatusData->DeviceInstance);
|
||||||
if (DeviceObject == NULL)
|
if (DeviceObject == NULL)
|
||||||
return STATUS_NO_SUCH_DEVICE;
|
return STATUS_NO_SUCH_DEVICE;
|
||||||
|
|
||||||
DeviceNode = DeviceObject->DeviceObjectExtension->DeviceNode;
|
DeviceNode = DeviceObject->DeviceObjectExtension->DeviceNode;
|
||||||
|
|
||||||
switch (DeviceStatusData->Action)
|
switch (StatusData->Operation)
|
||||||
{
|
{
|
||||||
case PNP_GET_DEVICE_STATUS:
|
case PNP_GET_DEVICE_STATUS:
|
||||||
DPRINT("Get status data\n");
|
DPRINT("Get status data\n");
|
||||||
DeviceStatusData->Problem = DeviceNode->Problem;
|
StatusData->DeviceStatus = DeviceNode->Flags;
|
||||||
DeviceStatusData->Flags = DeviceNode->Flags;
|
StatusData->DeviceProblem = DeviceNode->Problem;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PNP_SET_DEVICE_STATUS:
|
case PNP_SET_DEVICE_STATUS:
|
||||||
DPRINT("Set status data\n");
|
DPRINT("Set status data\n");
|
||||||
DeviceNode->Problem = DeviceStatusData->Problem;
|
DeviceNode->Flags = StatusData->DeviceStatus;
|
||||||
DeviceNode->Flags = DeviceStatusData->Flags;
|
DeviceNode->Problem = StatusData->DeviceProblem;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PNP_CLEAR_DEVICE_STATUS:
|
case PNP_CLEAR_DEVICE_STATUS:
|
||||||
|
@ -422,14 +422,14 @@ IopDeviceStatus(PPLUGPLAY_DEVICE_STATUS_DATA DeviceStatusData)
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
NtPlugPlayControl(IN ULONG ControlCode,
|
NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
|
||||||
IN OUT PVOID Buffer,
|
IN OUT PVOID Buffer,
|
||||||
IN ULONG BufferLength)
|
IN ULONG BufferLength)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
DPRINT("NtPlugPlayControl(%lu %p %lu) called\n",
|
DPRINT("NtPlugPlayControl(%lu %p %lu) called\n",
|
||||||
ControlCode, Buffer, BufferLength);
|
PlugPlayControlClass, Buffer, BufferLength);
|
||||||
|
|
||||||
/* Function can only be called from user-mode */
|
/* Function can only be called from user-mode */
|
||||||
if (KeGetPreviousMode() != UserMode)
|
if (KeGetPreviousMode() != UserMode)
|
||||||
|
@ -464,22 +464,25 @@ NtPlugPlayControl(IN ULONG ControlCode,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ControlCode)
|
switch (PlugPlayControlClass)
|
||||||
{
|
{
|
||||||
case PLUGPLAY_USER_RESPONSE:
|
case PlugPlayControlUserResponse:
|
||||||
if (Buffer || BufferLength != 0)
|
if (Buffer || BufferLength != 0)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
return IopRemovePlugPlayEvent();
|
return IopRemovePlugPlayEvent();
|
||||||
|
|
||||||
case PLUGPLAY_GET_RELATED_DEVICE:
|
case PlugPlayControlGetRelatedDevice:
|
||||||
if (!Buffer || BufferLength < sizeof(PLUGPLAY_RELATED_DEVICE_DATA))
|
if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA))
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
return IopGetRelatedDevice((PPLUGPLAY_RELATED_DEVICE_DATA)Buffer);
|
return IopGetRelatedDevice((PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA)Buffer);
|
||||||
|
|
||||||
case PLUGPLAY_DEVICE_STATUS:
|
case PlugPlayControlDeviceStatus:
|
||||||
if (!Buffer || BufferLength < sizeof(PLUGPLAY_DEVICE_STATUS_DATA))
|
if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_STATUS_DATA))
|
||||||
return STATUS_INVALID_PARAMETER;
|
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;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
|
|
@ -109,9 +109,11 @@ void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
|
||||||
|
|
||||||
|
|
||||||
//WORD PNP_GetVersion(RPC_BINDING_HANDLE BindingHandle)
|
//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 */
|
/* FIXME: Process the pnp event */
|
||||||
|
|
||||||
/* Dequeue the current pnp event and signal the next one */
|
/* Dequeue the current pnp event and signal the next one */
|
||||||
NtPlugPlayControl(PLUGPLAY_USER_RESPONSE, NULL, 0);
|
NtPlugPlayControl(PlugPlayControlUserResponse, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, PnpEvent);
|
HeapFree(GetProcessHeap(), 0, PnpEvent);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue