[MSPORTS] Hackfix the code to determine the serial and parallel port numbers.

Now that SetupDiCreateDevRegKeyW is working as expected, we can no
longer (ab)use it to retrieve a ports resources. Use SetupDiGetDeviceInstanceIdW instead and open the registry keys manually.
This commit is contained in:
Eric Kohl 2018-09-25 17:48:27 +02:00
parent 69e834fa54
commit af37e0e565

View file

@ -29,6 +29,8 @@ GetBootResourceList(HDEVINFO DeviceInfoSet,
PSP_DEVINFO_DATA DeviceInfoData,
PCM_RESOURCE_LIST *ppResourceList)
{
WCHAR DeviceInstanceIdBuffer[128];
HKEY hEnumKey = NULL;
HKEY hDeviceKey = NULL;
HKEY hConfigKey = NULL;
LPBYTE lpBuffer = NULL;
@ -36,17 +38,41 @@ GetBootResourceList(HDEVINFO DeviceInfoSet,
LONG lError;
BOOL ret = FALSE;
FIXME("GetBootResourceList()\n");
*ppResourceList = NULL;
hDeviceKey = SetupDiCreateDevRegKeyW(DeviceInfoSet,
if (!SetupDiGetDeviceInstanceIdW(DeviceInfoSet,
DeviceInfoData,
DICS_FLAG_GLOBAL,
0,
DIREG_DEV,
NULL,
NULL);
if (!hDeviceKey)
DeviceInstanceIdBuffer,
ARRAYSIZE(DeviceInstanceIdBuffer),
&dwDataSize))
{
ERR("SetupDiGetDeviceInstanceIdW() failed\n");
return FALSE;
}
lError = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Enum",
0,
KEY_QUERY_VALUE,
&hEnumKey);
if (lError != ERROR_SUCCESS)
{
ERR("RegOpenKeyExW() failed (Error %lu)\n", lError);
goto done;
}
lError = RegOpenKeyExW(hEnumKey,
DeviceInstanceIdBuffer,
0,
KEY_QUERY_VALUE,
&hDeviceKey);
if (lError != ERROR_SUCCESS)
{
ERR("RegOpenKeyExW() failed (Error %lu)\n", lError);
goto done;
}
lError = RegOpenKeyExW(hDeviceKey,
L"LogConf",
@ -54,7 +80,10 @@ GetBootResourceList(HDEVINFO DeviceInfoSet,
KEY_QUERY_VALUE,
&hConfigKey);
if (lError != ERROR_SUCCESS)
{
ERR("RegOpenKeyExW() failed (Error %lu)\n", lError);
goto done;
}
/* Get the configuration data size */
lError = RegQueryValueExW(hConfigKey,
@ -64,12 +93,18 @@ GetBootResourceList(HDEVINFO DeviceInfoSet,
NULL,
&dwDataSize);
if (lError != ERROR_SUCCESS)
{
ERR("RegQueryValueExW() failed (Error %lu)\n", lError);
goto done;
}
/* Allocate the buffer */
lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwDataSize);
if (lpBuffer == NULL)
{
ERR("Failed to allocate the resource list buffer\n");
goto done;
}
/* Retrieve the configuration data */
lError = RegQueryValueExW(hConfigKey,
@ -79,7 +114,10 @@ GetBootResourceList(HDEVINFO DeviceInfoSet,
(LPBYTE)lpBuffer,
&dwDataSize);
if (lError == ERROR_SUCCESS)
{
ERR("RegQueryValueExW() failed (Error %lu)\n", lError);
ret = TRUE;
}
done:
if (ret == FALSE && lpBuffer != NULL)
@ -91,6 +129,9 @@ done:
if (hDeviceKey)
RegCloseKey(hDeviceKey);
if (hEnumKey)
RegCloseKey(hEnumKey);
if (ret != FALSE)
*ppResourceList = (PCM_RESOURCE_LIST)lpBuffer;