[UMPNPMGR]

PNP_GetDeviceList and PNP_GetDeviceListSize:
- Do not return CR_CALL_NOT_IMPLEMENTED by default.
- pulLength is counted in characters, not in bytes!
- Use the correct Relations value for PowerRelations.

[NDK]
Add the PowerRelations value to a comment.

[DEVMGR]
CM_Get_Device_ID_List_Size_ExW and CM_Get_Device_ID_List_ExW count the buffer length in characters, not in bytes!

svn path=/trunk/; revision=73796
This commit is contained in:
Eric Kohl 2017-02-13 22:59:40 +00:00
parent afde7ef918
commit 8c77497afc
3 changed files with 17 additions and 22 deletions

View file

@ -489,7 +489,7 @@ PNP_GetDeviceList(
DWORD ulFlags) DWORD ulFlags)
{ {
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData; PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
CONFIGRET ret = CR_CALL_NOT_IMPLEMENTED; CONFIGRET ret = CR_SUCCESS;
NTSTATUS Status; NTSTATUS Status;
DPRINT("PNP_GetDeviceList() called\n"); DPRINT("PNP_GetDeviceList() called\n");
@ -501,9 +501,7 @@ PNP_GetDeviceList(
return CR_INVALID_POINTER; return CR_INVALID_POINTER;
// if (Buffer == NULL) // if (Buffer == NULL)
// return // return CR_INVALID_POINTER;
*pulLength = 0;
if (ulFlags & if (ulFlags &
(CM_GETIDLIST_FILTER_BUSRELATIONS | (CM_GETIDLIST_FILTER_BUSRELATIONS |
@ -519,8 +517,7 @@ PNP_GetDeviceList(
} }
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS) else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
{ {
/* FIXME */ PlugPlayData.Relations = 2;
PlugPlayData.Relations = 0;
} }
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS) else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
{ {
@ -531,7 +528,7 @@ PNP_GetDeviceList(
PlugPlayData.Relations = 0; PlugPlayData.Relations = 0;
} }
PlugPlayData.BufferSize = *pulLength; PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
PlugPlayData.Buffer = Buffer; PlugPlayData.Buffer = Buffer;
Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations, Status = NtPlugPlayControl(PlugPlayControlQueryDeviceRelations,
@ -539,7 +536,7 @@ PNP_GetDeviceList(
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA)); sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
*pulLength = PlugPlayData.BufferSize; *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
} }
else else
{ {
@ -548,15 +545,15 @@ PNP_GetDeviceList(
} }
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE) else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
{ {
ret = CR_CALL_NOT_IMPLEMENTED;
} }
else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR) else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
{ {
ret = CR_CALL_NOT_IMPLEMENTED;
} }
else /* CM_GETIDLIST_FILTER_NONE */ else /* CM_GETIDLIST_FILTER_NONE */
{ {
ret = CR_CALL_NOT_IMPLEMENTED;
} }
return ret; return ret;
@ -573,7 +570,7 @@ PNP_GetDeviceListSize(
DWORD ulFlags) DWORD ulFlags)
{ {
PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData; PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData;
CONFIGRET ret = CR_CALL_NOT_IMPLEMENTED; CONFIGRET ret = CR_SUCCESS;
NTSTATUS Status; NTSTATUS Status;
DPRINT("PNP_GetDeviceListSize() called\n"); DPRINT("PNP_GetDeviceListSize() called\n");
@ -600,8 +597,7 @@ PNP_GetDeviceListSize(
} }
else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS) else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
{ {
/* FIXME */ PlugPlayData.Relations = 2;
PlugPlayData.Relations = 0;
} }
else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS) else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
{ {
@ -620,7 +616,7 @@ PNP_GetDeviceListSize(
sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA)); sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA));
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
*pulLength = PlugPlayData.BufferSize; *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
} }
else else
{ {
@ -629,15 +625,15 @@ PNP_GetDeviceListSize(
} }
else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE) else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
{ {
ret = CR_CALL_NOT_IMPLEMENTED;
} }
else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR) else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
{ {
ret = CR_CALL_NOT_IMPLEMENTED;
} }
else /* CM_GETIDLIST_FILTER_NONE */ else /* CM_GETIDLIST_FILTER_NONE */
{ {
ret = CR_CALL_NOT_IMPLEMENTED;
} }
return ret; return ret;
@ -994,7 +990,7 @@ PNP_GetDeviceRegProp(
done: done:
if(pulTransferLen) if (pulTransferLen)
*pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0; *pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
if (hKey != NULL) if (hKey != NULL)

View file

@ -1339,7 +1339,6 @@ DisplayDeviceRelations(
ULONG ulLength = 0; ULONG ulLength = 0;
LPWSTR pszBuffer = NULL, pszStr; LPWSTR pszBuffer = NULL, pszStr;
INT index = 0, len; INT index = 0, len;
CONFIGRET ret; CONFIGRET ret;
ret = CM_Get_Device_ID_List_Size_ExW(&ulLength, ret = CM_Get_Device_ID_List_Size_ExW(&ulLength,
@ -1351,7 +1350,7 @@ DisplayDeviceRelations(
pszBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(), pszBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
ulLength); ulLength * sizeof(WCHAR));
if (pszBuffer == NULL) if (pszBuffer == NULL)
return; return;

View file

@ -466,7 +466,7 @@ typedef struct _PLUGPLAY_CONTROL_DEPTH_DATA
typedef struct _PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA typedef struct _PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA
{ {
UNICODE_STRING DeviceInstance; UNICODE_STRING DeviceInstance;
ULONG Relations; // 0:EjectRelations, 1:RemovalRelations, 3:BusRelations ULONG Relations; // 0:EjectRelations, 1:RemovalRelations, 2:PowerRelations, 3:BusRelations
ULONG BufferSize; ULONG BufferSize;
PWCHAR Buffer; PWCHAR Buffer;
} PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA, *PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA; } PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA, *PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA;