mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 12:45:55 +00:00
[UMPNPMGR] PNP_GetDeviceList/PNP_GetDeviceListSize: Move device relations code into separate functions.
This commit is contained in:
parent
c4d25d27f6
commit
ccb8c906b0
1 changed files with 108 additions and 70 deletions
|
@ -529,6 +529,57 @@ PNP_EnumerateSubKeys(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
CONFIGRET
|
||||||
|
GetRelationsInstanceList(
|
||||||
|
_In_ PWSTR pszDevice,
|
||||||
|
_In_ DWORD ulFlags,
|
||||||
|
_Inout_ PWSTR pszBuffer,
|
||||||
|
_Inout_ PDWORD pulLength)
|
||||||
|
{
|
||||||
|
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
|
||||||
|
NTSTATUS Status;
|
||||||
|
CONFIGRET ret = CR_SUCCESS;
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
||||||
|
pszDevice);
|
||||||
|
|
||||||
|
if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
|
||||||
|
{
|
||||||
|
PlugPlayData.Relations = 3;
|
||||||
|
}
|
||||||
|
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
|
||||||
|
{
|
||||||
|
PlugPlayData.Relations = 2;
|
||||||
|
}
|
||||||
|
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
|
||||||
|
{
|
||||||
|
PlugPlayData.Relations = 1;
|
||||||
|
}
|
||||||
|
else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
|
||||||
|
{
|
||||||
|
PlugPlayData.Relations = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
|
||||||
|
PlugPlayData.Buffer = pszBuffer;
|
||||||
|
|
||||||
|
Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations,
|
||||||
|
(PVOID)&PlugPlayData,
|
||||||
|
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
*pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = NtStatusToCrError(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
CONFIGRET
|
CONFIGRET
|
||||||
GetDeviceInstanceList(
|
GetDeviceInstanceList(
|
||||||
|
@ -729,12 +780,10 @@ PNP_GetDeviceList(
|
||||||
PNP_RPC_STRING_LEN *pulLength,
|
PNP_RPC_STRING_LEN *pulLength,
|
||||||
DWORD ulFlags)
|
DWORD ulFlags)
|
||||||
{
|
{
|
||||||
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
|
|
||||||
WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
|
WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
|
||||||
WCHAR szDevice[MAX_DEVICE_ID_LEN];
|
WCHAR szDevice[MAX_DEVICE_ID_LEN];
|
||||||
WCHAR szInstance[MAX_DEVICE_ID_LEN];
|
WCHAR szInstance[MAX_DEVICE_ID_LEN];
|
||||||
CONFIGRET ret = CR_SUCCESS;
|
CONFIGRET ret = CR_SUCCESS;
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT("PNP_GetDeviceList() called\n");
|
DPRINT("PNP_GetDeviceList() called\n");
|
||||||
|
|
||||||
|
@ -754,39 +803,10 @@ PNP_GetDeviceList(
|
||||||
CM_GETIDLIST_FILTER_REMOVALRELATIONS |
|
CM_GETIDLIST_FILTER_REMOVALRELATIONS |
|
||||||
CM_GETIDLIST_FILTER_EJECTRELATIONS))
|
CM_GETIDLIST_FILTER_EJECTRELATIONS))
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
ret = GetRelationsInstanceList(pszFilter,
|
||||||
pszFilter);
|
ulFlags,
|
||||||
if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
|
Buffer,
|
||||||
{
|
pulLength);
|
||||||
PlugPlayData.Relations = 3;
|
|
||||||
}
|
|
||||||
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
|
|
||||||
{
|
|
||||||
PlugPlayData.Relations = 2;
|
|
||||||
}
|
|
||||||
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
|
|
||||||
{
|
|
||||||
PlugPlayData.Relations = 1;
|
|
||||||
}
|
|
||||||
else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
|
|
||||||
{
|
|
||||||
PlugPlayData.Relations = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
|
|
||||||
PlugPlayData.Buffer = Buffer;
|
|
||||||
|
|
||||||
Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations,
|
|
||||||
(PVOID)&PlugPlayData,
|
|
||||||
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
*pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = NtStatusToCrError(Status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
|
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
|
||||||
{
|
{
|
||||||
|
@ -822,6 +842,56 @@ PNP_GetDeviceList(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
CONFIGRET
|
||||||
|
GetRelationsInstanceListSize(
|
||||||
|
_In_ PWSTR pszDevice,
|
||||||
|
_In_ DWORD ulFlags,
|
||||||
|
_Inout_ PDWORD pulLength)
|
||||||
|
{
|
||||||
|
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
|
||||||
|
NTSTATUS Status;
|
||||||
|
CONFIGRET ret = CR_SUCCESS;
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
||||||
|
pszDevice);
|
||||||
|
|
||||||
|
if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
|
||||||
|
{
|
||||||
|
PlugPlayData.Relations = 3;
|
||||||
|
}
|
||||||
|
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
|
||||||
|
{
|
||||||
|
PlugPlayData.Relations = 2;
|
||||||
|
}
|
||||||
|
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
|
||||||
|
{
|
||||||
|
PlugPlayData.Relations = 1;
|
||||||
|
}
|
||||||
|
else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
|
||||||
|
{
|
||||||
|
PlugPlayData.Relations = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlugPlayData.BufferSize = 0;
|
||||||
|
PlugPlayData.Buffer = NULL;
|
||||||
|
|
||||||
|
Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations,
|
||||||
|
(PVOID)&PlugPlayData,
|
||||||
|
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
*pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = NtStatusToCrError(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
CONFIGRET
|
CONFIGRET
|
||||||
GetDeviceInstanceListSize(
|
GetDeviceInstanceListSize(
|
||||||
|
@ -978,12 +1048,10 @@ PNP_GetDeviceListSize(
|
||||||
PNP_RPC_BUFFER_SIZE *pulLength,
|
PNP_RPC_BUFFER_SIZE *pulLength,
|
||||||
DWORD ulFlags)
|
DWORD ulFlags)
|
||||||
{
|
{
|
||||||
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
|
|
||||||
WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
|
WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
|
||||||
WCHAR szDevice[MAX_DEVICE_ID_LEN];
|
WCHAR szDevice[MAX_DEVICE_ID_LEN];
|
||||||
WCHAR szInstance[MAX_DEVICE_ID_LEN];
|
WCHAR szInstance[MAX_DEVICE_ID_LEN];
|
||||||
CONFIGRET ret = CR_SUCCESS;
|
CONFIGRET ret = CR_SUCCESS;
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%lx)\n",
|
DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%lx)\n",
|
||||||
hBinding, pszFilter, pulLength, ulFlags);
|
hBinding, pszFilter, pulLength, ulFlags);
|
||||||
|
@ -1006,39 +1074,9 @@ PNP_GetDeviceListSize(
|
||||||
CM_GETIDLIST_FILTER_REMOVALRELATIONS |
|
CM_GETIDLIST_FILTER_REMOVALRELATIONS |
|
||||||
CM_GETIDLIST_FILTER_EJECTRELATIONS))
|
CM_GETIDLIST_FILTER_EJECTRELATIONS))
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
|
ret = GetRelationsInstanceListSize(pszFilter,
|
||||||
pszFilter);
|
ulFlags,
|
||||||
if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
|
pulLength);
|
||||||
{
|
|
||||||
PlugPlayData.Relations = 3;
|
|
||||||
}
|
|
||||||
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
|
|
||||||
{
|
|
||||||
PlugPlayData.Relations = 2;
|
|
||||||
}
|
|
||||||
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
|
|
||||||
{
|
|
||||||
PlugPlayData.Relations = 1;
|
|
||||||
}
|
|
||||||
else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
|
|
||||||
{
|
|
||||||
PlugPlayData.Relations = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlugPlayData.BufferSize = 0;
|
|
||||||
PlugPlayData.Buffer = NULL;
|
|
||||||
|
|
||||||
Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations,
|
|
||||||
(PVOID)&PlugPlayData,
|
|
||||||
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
*pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = NtStatusToCrError(Status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
|
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue