2006-06-02 09:06:05 +00:00
|
|
|
|
/*
|
|
|
|
|
* SetupAPI device class-related functions
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2000 Andreas Mohr for CodeWeavers
|
|
|
|
|
* 2005-2006 Herv<EFBFBD> Poussineau (hpoussin@reactos.org)
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "setupapi_private.h"
|
|
|
|
|
|
2013-12-27 11:32:40 +00:00
|
|
|
|
#include <wingdi.h>
|
2014-10-20 13:08:42 +00:00
|
|
|
|
#include <shellapi.h>
|
2017-02-02 19:41:19 +00:00
|
|
|
|
#include <strsafe.h>
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
/* Unicode constants */
|
|
|
|
|
static const WCHAR BackSlash[] = {'\\',0};
|
|
|
|
|
static const WCHAR ClassGUID[] = {'C','l','a','s','s','G','U','I','D',0};
|
|
|
|
|
static const WCHAR ClassInstall32[] = {'C','l','a','s','s','I','n','s','t','a','l','l','3','2',0};
|
|
|
|
|
static const WCHAR DotServices[] = {'.','S','e','r','v','i','c','e','s',0};
|
|
|
|
|
static const WCHAR InterfaceInstall32[] = {'I','n','t','e','r','f','a','c','e','I','n','s','t','a','l','l','3','2',0};
|
2007-05-23 21:40:46 +00:00
|
|
|
|
static const WCHAR SetupapiDll[] = {'s','e','t','u','p','a','p','i','.','d','l','l',0};
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
typedef BOOL
|
|
|
|
|
(WINAPI* PROPERTY_PAGE_PROVIDER) (
|
|
|
|
|
IN PSP_PROPSHEETPAGE_REQUEST PropPageRequest,
|
|
|
|
|
IN LPFNADDPROPSHEETPAGE fAddFunc,
|
|
|
|
|
IN LPARAM lParam);
|
|
|
|
|
typedef BOOL
|
|
|
|
|
(*UPDATE_CLASS_PARAM_HANDLER) (
|
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
|
|
|
|
IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
|
|
|
|
|
IN DWORD ClassInstallParamsSize);
|
|
|
|
|
|
|
|
|
|
static BOOL
|
2006-06-10 20:48:17 +00:00
|
|
|
|
SETUP_PropertyChangeHandler(
|
2006-06-02 09:06:05 +00:00
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
|
|
|
|
IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
|
|
|
|
|
IN DWORD ClassInstallParamsSize);
|
|
|
|
|
|
2007-03-14 12:29:18 +00:00
|
|
|
|
static BOOL
|
|
|
|
|
SETUP_PropertyAddPropertyAdvancedHandler(
|
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
|
|
|
|
IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
|
|
|
|
|
IN DWORD ClassInstallParamsSize);
|
|
|
|
|
|
|
|
|
|
typedef struct _INSTALL_PARAMS_DATA
|
|
|
|
|
{
|
|
|
|
|
DI_FUNCTION Function;
|
|
|
|
|
UPDATE_CLASS_PARAM_HANDLER UpdateHandler;
|
|
|
|
|
ULONG ParamsSize;
|
|
|
|
|
LONG FieldOffset;
|
|
|
|
|
} INSTALL_PARAMS_DATA;
|
|
|
|
|
|
|
|
|
|
#define ADD_PARAM_HANDLER(Function, UpdateHandler, ParamsType, ParamsField) \
|
|
|
|
|
{ Function, UpdateHandler, sizeof(ParamsType), FIELD_OFFSET(struct ClassInstallParams, ParamsField) },
|
|
|
|
|
|
|
|
|
|
static const INSTALL_PARAMS_DATA InstallParamsData[] = {
|
|
|
|
|
ADD_PARAM_HANDLER(DIF_PROPERTYCHANGE, SETUP_PropertyChangeHandler, SP_PROPCHANGE_PARAMS, PropChangeParams)
|
|
|
|
|
ADD_PARAM_HANDLER(DIF_ADDPROPERTYPAGE_ADVANCED, SETUP_PropertyAddPropertyAdvancedHandler, SP_ADDPROPERTYPAGE_DATA, AddPropertyPageData)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
};
|
2007-03-14 12:29:18 +00:00
|
|
|
|
#undef ADD_PARAM_HANDLER
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2014-10-20 13:08:42 +00:00
|
|
|
|
#define UNKNOWN_ICON_INDEX 18
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2008-01-18 11:51:01 +00:00
|
|
|
|
* SetupDiDestroyClassImageList(SETUPAPI.@)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
*/
|
2008-01-18 11:51:01 +00:00
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiDestroyClassImageList(
|
|
|
|
|
IN PSP_CLASSIMAGELIST_DATA ClassImageListData)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2008-01-18 11:51:01 +00:00
|
|
|
|
struct ClassImageList *list;
|
|
|
|
|
BOOL ret = FALSE;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2008-01-18 11:51:01 +00:00
|
|
|
|
TRACE("%p\n", ClassImageListData);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2008-01-18 11:51:01 +00:00
|
|
|
|
if (!ClassImageListData)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (ClassImageListData->cbSize != sizeof(SP_CLASSIMAGELIST_DATA))
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else if ((list = (struct ClassImageList *)ClassImageListData->Reserved) == NULL)
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else if (list->magic != SETUP_CLASS_IMAGE_LIST_MAGIC)
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2016-09-22 21:39:25 +00:00
|
|
|
|
/* If Reserved wasn't NULL, then this is valid too */
|
|
|
|
|
if (ClassImageListData->ImageList)
|
|
|
|
|
{
|
|
|
|
|
ImageList_Destroy(ClassImageListData->ImageList);
|
|
|
|
|
ClassImageListData->ImageList = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyFree(list);
|
|
|
|
|
ClassImageListData->Reserved = 0;
|
|
|
|
|
|
|
|
|
|
ret = TRUE;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-01-18 11:51:01 +00:00
|
|
|
|
TRACE("Returning %d\n", ret);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2006-06-10 20:48:17 +00:00
|
|
|
|
* SETUP_CreateDevicesListFromEnumerator
|
|
|
|
|
*
|
|
|
|
|
* PARAMS
|
2006-09-09 17:10:51 +00:00
|
|
|
|
* list [IO] Device info set to fill with discovered devices.
|
2006-06-10 20:48:17 +00:00
|
|
|
|
* pClassGuid [I] If specified, only devices which belong to this class will be added.
|
|
|
|
|
* Enumerator [I] Location to search devices to add.
|
2006-09-09 17:10:51 +00:00
|
|
|
|
* hEnumeratorKey [I] Registry key corresponding to Enumerator key. Must have KEY_ENUMERATE_SUB_KEYS right.
|
2006-06-10 20:48:17 +00:00
|
|
|
|
*
|
|
|
|
|
* RETURNS
|
|
|
|
|
* Success: ERROR_SUCCESS.
|
|
|
|
|
* Failure: an error code.
|
2006-06-02 09:06:05 +00:00
|
|
|
|
*/
|
|
|
|
|
static LONG
|
2006-06-10 20:48:17 +00:00
|
|
|
|
SETUP_CreateDevicesListFromEnumerator(
|
|
|
|
|
IN OUT struct DeviceInfoSet *list,
|
|
|
|
|
IN CONST GUID *pClassGuid OPTIONAL,
|
|
|
|
|
IN LPCWSTR Enumerator,
|
|
|
|
|
IN HKEY hEnumeratorKey) /* handle to Enumerator registry key */
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
|
|
|
|
HKEY hDeviceIdKey = NULL, hInstanceIdKey;
|
|
|
|
|
WCHAR KeyBuffer[MAX_PATH];
|
|
|
|
|
WCHAR InstancePath[MAX_PATH];
|
|
|
|
|
LPWSTR pEndOfInstancePath; /* Pointer into InstancePath buffer */
|
2007-11-10 14:04:55 +00:00
|
|
|
|
struct DeviceInfo *deviceInfo;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
DWORD i = 0, j;
|
|
|
|
|
DWORD dwLength, dwRegType;
|
|
|
|
|
DWORD rc;
|
|
|
|
|
|
|
|
|
|
/* Enumerate device IDs (subkeys of hEnumeratorKey) */
|
|
|
|
|
while (TRUE)
|
|
|
|
|
{
|
|
|
|
|
dwLength = sizeof(KeyBuffer) / sizeof(KeyBuffer[0]);
|
|
|
|
|
rc = RegEnumKeyExW(hEnumeratorKey, i, KeyBuffer, &dwLength, NULL, NULL, NULL, NULL);
|
|
|
|
|
if (rc == ERROR_NO_MORE_ITEMS)
|
|
|
|
|
break;
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
/* Open device id sub key */
|
|
|
|
|
if (hDeviceIdKey != NULL)
|
|
|
|
|
RegCloseKey(hDeviceIdKey);
|
|
|
|
|
rc = RegOpenKeyExW(hEnumeratorKey, KeyBuffer, 0, KEY_ENUMERATE_SUB_KEYS, &hDeviceIdKey);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
2017-02-02 19:41:19 +00:00
|
|
|
|
|
2017-02-02 19:48:38 +00:00
|
|
|
|
if (FAILED(StringCchCopyW(InstancePath, _countof(InstancePath), Enumerator)) ||
|
|
|
|
|
FAILED(StringCchCatW(InstancePath, _countof(InstancePath), BackSlash)) ||
|
|
|
|
|
FAILED(StringCchCatW(InstancePath, _countof(InstancePath), KeyBuffer)) ||
|
|
|
|
|
FAILED(StringCchCatW(InstancePath, _countof(InstancePath), BackSlash)))
|
2017-02-02 19:41:19 +00:00
|
|
|
|
{
|
|
|
|
|
rc = ERROR_GEN_FAILURE;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-02 09:06:05 +00:00
|
|
|
|
pEndOfInstancePath = &InstancePath[strlenW(InstancePath)];
|
|
|
|
|
|
|
|
|
|
/* Enumerate instance IDs (subkeys of hDeviceIdKey) */
|
|
|
|
|
j = 0;
|
|
|
|
|
while (TRUE)
|
|
|
|
|
{
|
|
|
|
|
GUID KeyGuid;
|
|
|
|
|
|
|
|
|
|
dwLength = sizeof(KeyBuffer) / sizeof(KeyBuffer[0]);
|
|
|
|
|
rc = RegEnumKeyExW(hDeviceIdKey, j, KeyBuffer, &dwLength, NULL, NULL, NULL, NULL);
|
|
|
|
|
if (rc == ERROR_NO_MORE_ITEMS)
|
|
|
|
|
break;
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
j++;
|
|
|
|
|
|
|
|
|
|
/* Open instance id sub key */
|
|
|
|
|
rc = RegOpenKeyExW(hDeviceIdKey, KeyBuffer, 0, KEY_QUERY_VALUE, &hInstanceIdKey);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
*pEndOfInstancePath = '\0';
|
|
|
|
|
strcatW(InstancePath, KeyBuffer);
|
|
|
|
|
|
|
|
|
|
/* Read ClassGUID value */
|
|
|
|
|
dwLength = sizeof(KeyBuffer) - sizeof(WCHAR);
|
|
|
|
|
rc = RegQueryValueExW(hInstanceIdKey, ClassGUID, NULL, &dwRegType, (LPBYTE)KeyBuffer, &dwLength);
|
|
|
|
|
RegCloseKey(hInstanceIdKey);
|
|
|
|
|
if (rc == ERROR_FILE_NOT_FOUND)
|
|
|
|
|
{
|
|
|
|
|
if (pClassGuid)
|
|
|
|
|
/* Skip this bad entry as we can't verify it */
|
|
|
|
|
continue;
|
|
|
|
|
/* Set a default GUID for this device */
|
|
|
|
|
memcpy(&KeyGuid, &GUID_NULL, sizeof(GUID));
|
|
|
|
|
}
|
|
|
|
|
else if (rc != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
2006-06-21 06:40:02 +00:00
|
|
|
|
else if (dwRegType != REG_SZ || dwLength < MAX_GUID_STRING_LEN * sizeof(WCHAR))
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
|
|
|
|
rc = ERROR_GEN_FAILURE;
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-06-10 20:48:17 +00:00
|
|
|
|
KeyBuffer[MAX_GUID_STRING_LEN - 2] = '\0'; /* Replace the } by a NULL character */
|
2006-06-02 09:06:05 +00:00
|
|
|
|
if (UuidFromStringW(&KeyBuffer[1], &KeyGuid) != RPC_S_OK)
|
|
|
|
|
/* Bad GUID, skip the entry */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pClassGuid && !IsEqualIID(&KeyGuid, pClassGuid))
|
|
|
|
|
{
|
|
|
|
|
/* Skip this entry as it is not the right device class */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add the entry to the list */
|
2007-11-10 14:04:55 +00:00
|
|
|
|
if (!CreateDeviceInfo(list, InstancePath, &KeyGuid, &deviceInfo))
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
|
|
|
|
rc = GetLastError();
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
TRACE("Adding '%s' to device info set %p\n", debugstr_w(InstancePath), list);
|
|
|
|
|
InsertTailList(&list->ListHead, &deviceInfo->ListEntry);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
if (hDeviceIdKey != NULL)
|
|
|
|
|
RegCloseKey(hDeviceIdKey);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-18 11:51:01 +00:00
|
|
|
|
LONG
|
2006-06-10 20:48:17 +00:00
|
|
|
|
SETUP_CreateDevicesList(
|
|
|
|
|
IN OUT struct DeviceInfoSet *list,
|
|
|
|
|
IN PCWSTR MachineName OPTIONAL,
|
|
|
|
|
IN CONST GUID *Class OPTIONAL,
|
|
|
|
|
IN PCWSTR Enumerator OPTIONAL)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
|
|
|
|
HKEY HKLM = HKEY_LOCAL_MACHINE;
|
|
|
|
|
HKEY hEnumKey = NULL;
|
|
|
|
|
HKEY hEnumeratorKey = NULL;
|
|
|
|
|
WCHAR KeyBuffer[MAX_PATH];
|
|
|
|
|
DWORD i;
|
|
|
|
|
DWORD dwLength;
|
|
|
|
|
DWORD rc;
|
|
|
|
|
|
2006-06-10 20:48:17 +00:00
|
|
|
|
if (Class && IsEqualIID(Class, &GUID_NULL))
|
|
|
|
|
Class = NULL;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
/* Open Enum key (if applicable) */
|
|
|
|
|
if (MachineName != NULL)
|
|
|
|
|
{
|
|
|
|
|
rc = RegConnectRegistryW(MachineName, HKEY_LOCAL_MACHINE, &HKLM);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rc = RegOpenKeyExW(
|
|
|
|
|
HKLM,
|
|
|
|
|
REGSTR_PATH_SYSTEMENUM,
|
|
|
|
|
0,
|
|
|
|
|
KEY_ENUMERATE_SUB_KEYS,
|
|
|
|
|
&hEnumKey);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
2006-06-10 20:48:17 +00:00
|
|
|
|
/* If enumerator is provided, call directly SETUP_CreateDevicesListFromEnumerator.
|
|
|
|
|
* Else, enumerate all enumerators and call SETUP_CreateDevicesListFromEnumerator
|
2006-06-02 09:06:05 +00:00
|
|
|
|
* for each one.
|
|
|
|
|
*/
|
|
|
|
|
if (Enumerator)
|
|
|
|
|
{
|
|
|
|
|
rc = RegOpenKeyExW(
|
|
|
|
|
hEnumKey,
|
|
|
|
|
Enumerator,
|
|
|
|
|
0,
|
|
|
|
|
KEY_ENUMERATE_SUB_KEYS,
|
|
|
|
|
&hEnumeratorKey);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
2006-06-21 06:40:02 +00:00
|
|
|
|
{
|
|
|
|
|
if (rc == ERROR_FILE_NOT_FOUND)
|
|
|
|
|
rc = ERROR_INVALID_DATA;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
goto cleanup;
|
2006-06-21 06:40:02 +00:00
|
|
|
|
}
|
2006-06-10 20:48:17 +00:00
|
|
|
|
rc = SETUP_CreateDevicesListFromEnumerator(list, Class, Enumerator, hEnumeratorKey);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Enumerate enumerators */
|
|
|
|
|
i = 0;
|
|
|
|
|
while (TRUE)
|
|
|
|
|
{
|
|
|
|
|
dwLength = sizeof(KeyBuffer) / sizeof(KeyBuffer[0]);
|
|
|
|
|
rc = RegEnumKeyExW(hEnumKey, i, KeyBuffer, &dwLength, NULL, NULL, NULL, NULL);
|
|
|
|
|
if (rc == ERROR_NO_MORE_ITEMS)
|
|
|
|
|
break;
|
|
|
|
|
else if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
|
|
/* Open sub key */
|
|
|
|
|
if (hEnumeratorKey != NULL)
|
|
|
|
|
RegCloseKey(hEnumeratorKey);
|
|
|
|
|
rc = RegOpenKeyExW(hEnumKey, KeyBuffer, 0, KEY_ENUMERATE_SUB_KEYS, &hEnumeratorKey);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
2006-06-10 20:48:17 +00:00
|
|
|
|
/* Call SETUP_CreateDevicesListFromEnumerator */
|
|
|
|
|
rc = SETUP_CreateDevicesListFromEnumerator(list, Class, KeyBuffer, hEnumeratorKey);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
if (HKLM != HKEY_LOCAL_MACHINE)
|
|
|
|
|
RegCloseKey(HKLM);
|
|
|
|
|
if (hEnumKey != NULL)
|
|
|
|
|
RegCloseKey(hEnumKey);
|
|
|
|
|
if (hEnumeratorKey != NULL)
|
|
|
|
|
RegCloseKey(hEnumeratorKey);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static BOOL
|
2006-06-10 20:48:17 +00:00
|
|
|
|
SETUP_GetIconIndex(
|
2006-06-02 09:06:05 +00:00
|
|
|
|
IN HKEY hClassKey,
|
|
|
|
|
OUT PINT ImageIndex)
|
|
|
|
|
{
|
|
|
|
|
LPWSTR Buffer = NULL;
|
|
|
|
|
DWORD dwRegType, dwLength;
|
|
|
|
|
LONG rc;
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
/* Read icon registry key */
|
|
|
|
|
rc = RegQueryValueExW(hClassKey, REGSTR_VAL_INSICON, NULL, &dwRegType, NULL, &dwLength);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(rc);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
} else if (dwRegType != REG_SZ)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_INVALID_INDEX);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
Buffer = MyMalloc(dwLength + sizeof(WCHAR));
|
|
|
|
|
if (!Buffer)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
rc = RegQueryValueExW(hClassKey, REGSTR_VAL_INSICON, NULL, NULL, (LPBYTE)Buffer, &dwLength);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(rc);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
/* make sure the returned buffer is NULL-terminated */
|
|
|
|
|
Buffer[dwLength / sizeof(WCHAR)] = 0;
|
|
|
|
|
|
|
|
|
|
/* Transform icon value to a INT */
|
|
|
|
|
*ImageIndex = atoiW(Buffer);
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
MyFree(Buffer);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-20 13:08:42 +00:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiGetClassImageIndex (SETUPAPI.@)
|
|
|
|
|
*/
|
2006-06-02 09:06:05 +00:00
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiGetClassImageIndex(
|
|
|
|
|
IN PSP_CLASSIMAGELIST_DATA ClassImageListData,
|
|
|
|
|
IN CONST GUID *ClassGuid,
|
|
|
|
|
OUT PINT ImageIndex)
|
|
|
|
|
{
|
|
|
|
|
struct ClassImageList *list;
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", ClassImageListData, debugstr_guid(ClassGuid), ImageIndex);
|
|
|
|
|
|
|
|
|
|
if (!ClassImageListData || !ClassGuid || !ImageIndex)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (ClassImageListData->cbSize != sizeof(SP_CLASSIMAGELIST_DATA))
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else if ((list = (struct ClassImageList *)ClassImageListData->Reserved) == NULL)
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else if (list->magic != SETUP_CLASS_IMAGE_LIST_MAGIC)
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-10-01 09:05:19 +00:00
|
|
|
|
DWORD i;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2006-10-01 09:05:19 +00:00
|
|
|
|
for (i = 0; i < list->NumberOfGuids; i++)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2006-10-01 09:05:19 +00:00
|
|
|
|
if (IsEqualIID(ClassGuid, &list->Guids[i]))
|
|
|
|
|
break;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-10-01 09:05:19 +00:00
|
|
|
|
if (i == list->NumberOfGuids || list->IconIndexes[i] < 0)
|
|
|
|
|
SetLastError(ERROR_FILE_NOT_FOUND);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*ImageIndex = list->IconIndexes[i];
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
}
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE("Returning %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiGetClassImageList(SETUPAPI.@)
|
|
|
|
|
*/
|
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiGetClassImageList(
|
|
|
|
|
OUT PSP_CLASSIMAGELIST_DATA ClassImageListData)
|
|
|
|
|
{
|
|
|
|
|
return SetupDiGetClassImageListExW(ClassImageListData, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiGetClassImageListExA(SETUPAPI.@)
|
|
|
|
|
*/
|
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiGetClassImageListExA(
|
|
|
|
|
OUT PSP_CLASSIMAGELIST_DATA ClassImageListData,
|
|
|
|
|
IN PCSTR MachineName OPTIONAL,
|
|
|
|
|
IN PVOID Reserved)
|
|
|
|
|
{
|
|
|
|
|
PWSTR MachineNameW = NULL;
|
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
|
|
if (MachineName)
|
|
|
|
|
{
|
2011-02-26 21:40:17 +00:00
|
|
|
|
MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
if (MachineNameW == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = SetupDiGetClassImageListExW(ClassImageListData, MachineNameW, Reserved);
|
|
|
|
|
|
2006-06-10 20:48:17 +00:00
|
|
|
|
MyFree(MachineNameW);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-20 13:08:42 +00:00
|
|
|
|
static BOOL WINAPI
|
|
|
|
|
SETUP_GetClassIconInfo(IN CONST GUID *ClassGuid, OUT PINT OutIndex, OUT LPWSTR *OutDllName)
|
|
|
|
|
{
|
|
|
|
|
LPWSTR Buffer = NULL;
|
|
|
|
|
INT iconIndex = -UNKNOWN_ICON_INDEX;
|
|
|
|
|
HKEY hKey = INVALID_HANDLE_VALUE;
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
if (ClassGuid)
|
|
|
|
|
{
|
|
|
|
|
hKey = SetupDiOpenClassRegKey(ClassGuid, KEY_QUERY_VALUE);
|
|
|
|
|
if (hKey != INVALID_HANDLE_VALUE)
|
|
|
|
|
{
|
|
|
|
|
SETUP_GetIconIndex(hKey, &iconIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (iconIndex > 0)
|
|
|
|
|
{
|
|
|
|
|
/* Look up icon in dll specified by Installer32 or EnumPropPages32 key */
|
|
|
|
|
PWCHAR Comma;
|
|
|
|
|
LONG rc;
|
|
|
|
|
DWORD dwRegType, dwLength;
|
|
|
|
|
rc = RegQueryValueExW(hKey, REGSTR_VAL_INSTALLER_32, NULL, &dwRegType, NULL, &dwLength);
|
|
|
|
|
if (rc == ERROR_SUCCESS && dwRegType == REG_SZ)
|
|
|
|
|
{
|
|
|
|
|
Buffer = MyMalloc(dwLength + sizeof(WCHAR));
|
|
|
|
|
if (Buffer == NULL)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
rc = RegQueryValueExW(hKey, REGSTR_VAL_INSTALLER_32, NULL, NULL, (LPBYTE)Buffer, &dwLength);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(rc);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
/* make sure the returned buffer is NULL-terminated */
|
|
|
|
|
Buffer[dwLength / sizeof(WCHAR)] = 0;
|
|
|
|
|
}
|
|
|
|
|
else if
|
|
|
|
|
(ERROR_SUCCESS == (rc = RegQueryValueExW(hKey, REGSTR_VAL_ENUMPROPPAGES_32, NULL, &dwRegType, NULL, &dwLength))
|
|
|
|
|
&& dwRegType == REG_SZ)
|
|
|
|
|
{
|
|
|
|
|
Buffer = MyMalloc(dwLength + sizeof(WCHAR));
|
|
|
|
|
if (Buffer == NULL)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
rc = RegQueryValueExW(hKey, REGSTR_VAL_ENUMPROPPAGES_32, NULL, NULL, (LPBYTE)Buffer, &dwLength);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(rc);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
/* make sure the returned buffer is NULL-terminated */
|
|
|
|
|
Buffer[dwLength / sizeof(WCHAR)] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Unable to find where to load the icon */
|
|
|
|
|
SetLastError(ERROR_FILE_NOT_FOUND);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
Comma = strchrW(Buffer, ',');
|
|
|
|
|
if (!Comma)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_GEN_FAILURE);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
*Comma = '\0';
|
|
|
|
|
*OutDllName = Buffer;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Look up icon in setupapi.dll */
|
|
|
|
|
iconIndex = -iconIndex;
|
|
|
|
|
*OutDllName = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*OutIndex = iconIndex;
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
|
|
TRACE("Icon index %d, dll name %s\n", iconIndex, debugstr_w(*OutDllName ? *OutDllName : SetupapiDll));
|
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
|
|
|
|
|
if (hKey != INVALID_HANDLE_VALUE)
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
2015-10-24 09:54:54 +00:00
|
|
|
|
if (Buffer && !ret)
|
|
|
|
|
MyFree(Buffer);
|
|
|
|
|
|
2014-10-20 13:08:42 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-06-02 09:06:05 +00:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiGetClassImageListExW(SETUPAPI.@)
|
|
|
|
|
*/
|
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiGetClassImageListExW(
|
|
|
|
|
OUT PSP_CLASSIMAGELIST_DATA ClassImageListData,
|
|
|
|
|
IN PCWSTR MachineName OPTIONAL,
|
|
|
|
|
IN PVOID Reserved)
|
|
|
|
|
{
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
TRACE("%p %p %p\n", ClassImageListData, debugstr_w(MachineName), Reserved);
|
|
|
|
|
|
|
|
|
|
if (!ClassImageListData)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (ClassImageListData->cbSize != sizeof(SP_CLASSIMAGELIST_DATA))
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else if (Reserved)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
struct ClassImageList *list = NULL;
|
2009-03-30 19:08:16 +00:00
|
|
|
|
HDC hDC;
|
2006-10-01 09:05:19 +00:00
|
|
|
|
DWORD RequiredSize;
|
2009-03-30 19:08:16 +00:00
|
|
|
|
DWORD ilMask, bkColor;
|
2006-10-01 09:05:19 +00:00
|
|
|
|
HICON hIcon;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
DWORD size;
|
2009-03-30 19:08:16 +00:00
|
|
|
|
INT i, bpp;
|
2014-10-05 08:55:55 +00:00
|
|
|
|
UINT idx;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2006-10-01 09:05:19 +00:00
|
|
|
|
/* Get list of all class GUIDs in given computer */
|
|
|
|
|
ret = SetupDiBuildClassInfoListExW(
|
|
|
|
|
0,
|
|
|
|
|
NULL,
|
|
|
|
|
0,
|
|
|
|
|
&RequiredSize,
|
|
|
|
|
MachineName,
|
|
|
|
|
NULL);
|
|
|
|
|
if (!ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
size = sizeof(struct ClassImageList)
|
|
|
|
|
+ (sizeof(GUID) + sizeof(INT)) * RequiredSize;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
list = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
|
if (!list)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
list->magic = SETUP_CLASS_IMAGE_LIST_MAGIC;
|
2006-10-01 09:05:19 +00:00
|
|
|
|
list->NumberOfGuids = RequiredSize;
|
|
|
|
|
list->Guids = (GUID*)(list + 1);
|
|
|
|
|
list->IconIndexes = (INT*)((ULONG_PTR)(list + 1) + sizeof(GUID) * RequiredSize);
|
|
|
|
|
|
|
|
|
|
ret = SetupDiBuildClassInfoListExW(
|
|
|
|
|
0,
|
|
|
|
|
list->Guids,
|
|
|
|
|
list->NumberOfGuids,
|
|
|
|
|
&RequiredSize,
|
|
|
|
|
MachineName,
|
|
|
|
|
NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
else if (RequiredSize != list->NumberOfGuids)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2006-10-01 09:05:19 +00:00
|
|
|
|
/* Hm. Class list changed since last call. Ignore
|
|
|
|
|
* this case as it should be very rare */
|
|
|
|
|
SetLastError(ERROR_GEN_FAILURE);
|
|
|
|
|
ret = FALSE;
|
|
|
|
|
goto cleanup;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
2006-10-01 09:05:19 +00:00
|
|
|
|
|
|
|
|
|
/* Prepare a HIMAGELIST */
|
|
|
|
|
InitCommonControls();
|
2009-03-30 19:08:16 +00:00
|
|
|
|
|
|
|
|
|
hDC = GetDC(NULL);
|
|
|
|
|
if (!hDC)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
bpp = GetDeviceCaps(hDC, BITSPIXEL);
|
|
|
|
|
ReleaseDC(NULL, hDC);
|
|
|
|
|
|
|
|
|
|
if (bpp <= 4)
|
|
|
|
|
ilMask = ILC_COLOR4;
|
|
|
|
|
else if (bpp <= 8)
|
|
|
|
|
ilMask = ILC_COLOR8;
|
|
|
|
|
else if (bpp <= 16)
|
|
|
|
|
ilMask = ILC_COLOR16;
|
|
|
|
|
else if (bpp <= 24)
|
|
|
|
|
ilMask = ILC_COLOR24;
|
|
|
|
|
else if (bpp <= 32)
|
|
|
|
|
ilMask = ILC_COLOR32;
|
|
|
|
|
else
|
|
|
|
|
ilMask = ILC_COLOR;
|
|
|
|
|
|
|
|
|
|
ilMask |= ILC_MASK;
|
|
|
|
|
|
|
|
|
|
ClassImageListData->ImageList = ImageList_Create(16, 16, ilMask, 100, 10);
|
2006-10-01 09:05:19 +00:00
|
|
|
|
if (!ClassImageListData->ImageList)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
ClassImageListData->Reserved = (ULONG_PTR)list;
|
|
|
|
|
|
2009-03-30 19:08:16 +00:00
|
|
|
|
/* For some reason, Windows sets the list background to COLOR_WINDOW */
|
|
|
|
|
bkColor = GetSysColor(COLOR_WINDOW);
|
|
|
|
|
ImageList_SetBkColor(ClassImageListData->ImageList, bkColor);
|
|
|
|
|
|
2006-10-01 09:05:19 +00:00
|
|
|
|
/* Now, we "simply" need to load icons associated with all class guids,
|
|
|
|
|
* and put their index in the image list in the IconIndexes array */
|
|
|
|
|
for (i = 0; i < list->NumberOfGuids; i++)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2007-09-04 21:30:22 +00:00
|
|
|
|
INT miniIconIndex;
|
2014-10-20 13:08:42 +00:00
|
|
|
|
LPWSTR DllName = NULL;
|
2007-09-04 21:30:22 +00:00
|
|
|
|
|
2014-10-20 13:08:42 +00:00
|
|
|
|
if (SETUP_GetClassIconInfo(&list->Guids[i], &miniIconIndex, &DllName))
|
2007-09-03 14:51:06 +00:00
|
|
|
|
{
|
2014-10-20 13:08:42 +00:00
|
|
|
|
if (DllName && ExtractIconExW(DllName, -miniIconIndex, NULL, &hIcon, 1) == 1)
|
2007-09-04 21:30:22 +00:00
|
|
|
|
{
|
|
|
|
|
list->IconIndexes[i] = ImageList_AddIcon(ClassImageListData->ImageList, hIcon);
|
|
|
|
|
}
|
2014-10-20 13:08:42 +00:00
|
|
|
|
else if(!DllName)
|
|
|
|
|
{
|
|
|
|
|
hIcon = LoadImage(hInstance, MAKEINTRESOURCE(miniIconIndex), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
|
list->IconIndexes[i] = ImageList_AddIcon(ClassImageListData->ImageList, hIcon);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(hIcon)
|
|
|
|
|
DestroyIcon(hIcon);
|
2007-09-04 21:30:22 +00:00
|
|
|
|
else
|
|
|
|
|
list->IconIndexes[i] = -1;
|
2014-10-20 13:08:42 +00:00
|
|
|
|
|
|
|
|
|
if(DllName)
|
|
|
|
|
MyFree(DllName);
|
2007-09-03 14:51:06 +00:00
|
|
|
|
}
|
2006-10-01 09:05:19 +00:00
|
|
|
|
else
|
2014-10-20 13:08:42 +00:00
|
|
|
|
{
|
2007-09-04 21:30:22 +00:00
|
|
|
|
list->IconIndexes[i] = -1; /* Special value to indicate that the icon is unavailable */
|
2014-10-20 13:08:42 +00:00
|
|
|
|
}
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-05 08:55:55 +00:00
|
|
|
|
/* Finally, add the overlay icons to the image list */
|
2015-06-04 08:29:55 +00:00
|
|
|
|
for (i = 0; i <= 2; i++)
|
2014-10-05 08:55:55 +00:00
|
|
|
|
{
|
|
|
|
|
hIcon = LoadImage(hInstance, MAKEINTRESOURCE(500 + i), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
|
|
|
|
|
if (hIcon)
|
|
|
|
|
{
|
|
|
|
|
idx = ImageList_AddIcon(ClassImageListData->ImageList, hIcon);
|
|
|
|
|
if (idx != -1)
|
2015-06-04 08:29:55 +00:00
|
|
|
|
ImageList_SetOverlayImage(ClassImageListData->ImageList, idx, i + 1);
|
2014-10-05 08:55:55 +00:00
|
|
|
|
DestroyIcon(hIcon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-02 09:06:05 +00:00
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
if (!ret)
|
2006-10-01 09:05:19 +00:00
|
|
|
|
{
|
|
|
|
|
if (ClassImageListData->Reserved)
|
|
|
|
|
SetupDiDestroyClassImageList(ClassImageListData);
|
|
|
|
|
else if (list)
|
|
|
|
|
MyFree(list);
|
|
|
|
|
}
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE("Returning %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-14 12:29:18 +00:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiGetClassInstallParamsA(SETUPAPI.@)
|
|
|
|
|
*/
|
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiGetClassInstallParamsA(
|
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
|
|
|
|
OUT PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
|
|
|
|
|
IN DWORD ClassInstallParamsSize,
|
|
|
|
|
OUT PDWORD RequiredSize OPTIONAL)
|
|
|
|
|
{
|
|
|
|
|
FIXME("SetupDiGetClassInstallParamsA(%p %p %p %lu %p) Stub\n",
|
|
|
|
|
DeviceInfoSet, DeviceInfoData, ClassInstallParams, ClassInstallParamsSize, RequiredSize);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiGetClassInstallParamsW(SETUPAPI.@)
|
|
|
|
|
*/
|
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiGetClassInstallParamsW(
|
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
|
|
|
|
OUT PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
|
|
|
|
|
IN DWORD ClassInstallParamsSize,
|
|
|
|
|
OUT PDWORD RequiredSize OPTIONAL)
|
|
|
|
|
{
|
|
|
|
|
FIXME("SetupDiGetClassInstallParamsW(%p %p %p %lu %p) Stub\n",
|
|
|
|
|
DeviceInfoSet, DeviceInfoData, ClassInstallParams, ClassInstallParamsSize, RequiredSize);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-02 09:06:05 +00:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiLoadClassIcon(SETUPAPI.@)
|
|
|
|
|
*/
|
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiLoadClassIcon(
|
|
|
|
|
IN CONST GUID *ClassGuid,
|
|
|
|
|
OUT HICON *LargeIcon OPTIONAL,
|
|
|
|
|
OUT PINT MiniIconIndex OPTIONAL)
|
|
|
|
|
{
|
2014-10-20 13:08:42 +00:00
|
|
|
|
INT iconIndex = 0;
|
|
|
|
|
LPWSTR DllName = NULL;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
BOOL ret = FALSE;
|
2014-10-20 13:08:42 +00:00
|
|
|
|
HICON hIcon = NULL;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2014-10-20 13:08:42 +00:00
|
|
|
|
if (LargeIcon)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2014-10-20 13:08:42 +00:00
|
|
|
|
if(!SETUP_GetClassIconInfo(ClassGuid, &iconIndex, &DllName))
|
2017-02-02 19:41:19 +00:00
|
|
|
|
goto cleanup;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2017-02-02 19:41:19 +00:00
|
|
|
|
if (!DllName || ExtractIconExW(DllName, -iconIndex, &hIcon, NULL, 1) != 1 || hIcon == NULL)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2014-10-20 13:08:42 +00:00
|
|
|
|
/* load the default unknown device icon if ExtractIcon failed */
|
|
|
|
|
if(DllName)
|
|
|
|
|
iconIndex = UNKNOWN_ICON_INDEX;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2014-10-20 13:08:42 +00:00
|
|
|
|
hIcon = LoadImage(hInstance, MAKEINTRESOURCE(iconIndex), IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
|
|
|
|
|
|
2017-02-02 19:41:19 +00:00
|
|
|
|
if(!hIcon)
|
2014-10-20 13:08:42 +00:00
|
|
|
|
goto cleanup;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
2017-02-02 19:41:19 +00:00
|
|
|
|
|
|
|
|
|
*LargeIcon = hIcon;
|
2012-12-11 22:47:35 +00:00
|
|
|
|
}
|
2014-10-20 13:08:42 +00:00
|
|
|
|
|
2012-12-11 22:47:35 +00:00
|
|
|
|
if (MiniIconIndex)
|
|
|
|
|
*MiniIconIndex = iconIndex;
|
2014-10-20 13:08:42 +00:00
|
|
|
|
|
2012-12-11 22:47:35 +00:00
|
|
|
|
ret = TRUE;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
cleanup:
|
2012-12-11 22:47:35 +00:00
|
|
|
|
|
2014-10-20 13:08:42 +00:00
|
|
|
|
if(DllName)
|
|
|
|
|
MyFree(DllName);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
TRACE("Returning %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiInstallClassExW (SETUPAPI.@)
|
|
|
|
|
*/
|
2008-01-18 11:51:01 +00:00
|
|
|
|
HKEY
|
|
|
|
|
SETUP_CreateClassKey(HINF hInf);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiInstallClassExW(
|
|
|
|
|
IN HWND hwndParent OPTIONAL,
|
|
|
|
|
IN PCWSTR InfFileName OPTIONAL,
|
|
|
|
|
IN DWORD Flags,
|
|
|
|
|
IN HSPFILEQ FileQueue OPTIONAL,
|
|
|
|
|
IN CONST GUID *InterfaceClassGuid OPTIONAL,
|
|
|
|
|
IN PVOID Reserved1,
|
|
|
|
|
IN PVOID Reserved2)
|
|
|
|
|
{
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
TRACE("%p %s 0x%lx %p %s %p %p\n", hwndParent, debugstr_w(InfFileName), Flags,
|
|
|
|
|
FileQueue, debugstr_guid(InterfaceClassGuid), Reserved1, Reserved2);
|
|
|
|
|
|
|
|
|
|
if (!InfFileName)
|
|
|
|
|
{
|
|
|
|
|
FIXME("Case not implemented: InfFileName NULL\n");
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
}
|
|
|
|
|
else if (Flags & ~(DI_NOVCP | DI_NOBROWSE | DI_FORCECOPY | DI_QUIETINSTALL))
|
|
|
|
|
{
|
|
|
|
|
TRACE("Unknown flags: 0x%08lx\n", Flags & ~(DI_NOVCP | DI_NOBROWSE | DI_FORCECOPY | DI_QUIETINSTALL));
|
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
|
}
|
|
|
|
|
else if ((Flags & DI_NOVCP) && FileQueue == NULL)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (Reserved1 != NULL)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (Reserved2 != NULL)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE;
|
|
|
|
|
SP_DEVINSTALL_PARAMS_W InstallParams;
|
|
|
|
|
WCHAR SectionName[MAX_PATH];
|
|
|
|
|
HINF hInf = INVALID_HANDLE_VALUE;
|
|
|
|
|
HKEY hRootKey = INVALID_HANDLE_VALUE;
|
|
|
|
|
PVOID callback_context = NULL;
|
|
|
|
|
|
|
|
|
|
hDeviceInfo = SetupDiCreateDeviceInfoList(NULL, NULL);
|
2006-06-21 09:00:17 +00:00
|
|
|
|
if (hDeviceInfo == INVALID_HANDLE_VALUE)
|
|
|
|
|
goto cleanup;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
|
|
|
|
|
if (!SetupDiGetDeviceInstallParamsW(hDeviceInfo, NULL, &InstallParams))
|
|
|
|
|
goto cleanup;
|
2015-03-30 09:34:29 +00:00
|
|
|
|
|
2006-06-02 09:06:05 +00:00
|
|
|
|
InstallParams.Flags &= ~(DI_NOVCP | DI_NOBROWSE | DI_QUIETINSTALL);
|
|
|
|
|
InstallParams.Flags |= Flags & (DI_NOVCP | DI_NOBROWSE | DI_QUIETINSTALL);
|
|
|
|
|
if (Flags & DI_NOVCP)
|
|
|
|
|
InstallParams.FileQueue = FileQueue;
|
|
|
|
|
if (!SetupDiSetDeviceInstallParamsW(hDeviceInfo, NULL, &InstallParams))
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
/* Open the .inf file */
|
|
|
|
|
hInf = SetupOpenInfFileW(
|
|
|
|
|
InfFileName,
|
|
|
|
|
NULL,
|
|
|
|
|
INF_STYLE_WIN4,
|
|
|
|
|
NULL);
|
|
|
|
|
if (hInf == INVALID_HANDLE_VALUE)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
/* Try to append a layout file */
|
2009-05-23 10:17:24 +00:00
|
|
|
|
SetupOpenAppendInfFileW(NULL, hInf, NULL);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
if (InterfaceClassGuid)
|
|
|
|
|
{
|
|
|
|
|
/* Retrieve the actual section name */
|
|
|
|
|
ret = SetupDiGetActualSectionToInstallW(
|
|
|
|
|
hInf,
|
|
|
|
|
InterfaceInstall32,
|
|
|
|
|
SectionName,
|
|
|
|
|
MAX_PATH,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
/* Open registry key related to this interface */
|
|
|
|
|
/* FIXME: What happens if the key doesn't exist? */
|
|
|
|
|
hRootKey = SetupDiOpenClassRegKeyExW(InterfaceClassGuid, KEY_ENUMERATE_SUB_KEYS, DIOCR_INTERFACE, NULL, NULL);
|
|
|
|
|
if (hRootKey == INVALID_HANDLE_VALUE)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
/* SetupDiCreateDeviceInterface??? */
|
|
|
|
|
FIXME("Installing an interface is not implemented\n");
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Create or open the class registry key 'HKLM\CurrentControlSet\Class\{GUID}' */
|
2006-06-10 20:48:17 +00:00
|
|
|
|
hRootKey = SETUP_CreateClassKey(hInf);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
if (hRootKey == INVALID_HANDLE_VALUE)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
/* Retrieve the actual section name */
|
|
|
|
|
ret = SetupDiGetActualSectionToInstallW(
|
|
|
|
|
hInf,
|
|
|
|
|
ClassInstall32,
|
|
|
|
|
SectionName,
|
|
|
|
|
MAX_PATH - strlenW(DotServices),
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
callback_context = SetupInitDefaultQueueCallback(hwndParent);
|
|
|
|
|
if (!callback_context)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
ret = SetupInstallFromInfSectionW(
|
|
|
|
|
hwndParent,
|
|
|
|
|
hInf,
|
|
|
|
|
SectionName,
|
|
|
|
|
SPINST_REGISTRY | SPINST_FILES | SPINST_BITREG | SPINST_INIFILES | SPINST_INI2REG,
|
|
|
|
|
hRootKey,
|
|
|
|
|
NULL, /* FIXME: SourceRootPath */
|
|
|
|
|
!(Flags & DI_NOVCP) && (Flags & DI_FORCECOPY) ? SP_COPY_FORCE_IN_USE : 0, /* CopyFlags */
|
|
|
|
|
SetupDefaultQueueCallbackW,
|
|
|
|
|
callback_context,
|
|
|
|
|
hDeviceInfo,
|
|
|
|
|
NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
goto cleanup;
|
|
|
|
|
|
2015-03-30 09:34:29 +00:00
|
|
|
|
/* OPTIONAL: Install .Services section */
|
2006-06-02 09:06:05 +00:00
|
|
|
|
lstrcatW(SectionName, DotServices);
|
2015-03-30 09:34:29 +00:00
|
|
|
|
SetupInstallServicesFromInfSectionExW(
|
2006-06-02 09:06:05 +00:00
|
|
|
|
hInf,
|
|
|
|
|
SectionName,
|
|
|
|
|
0,
|
|
|
|
|
hDeviceInfo,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
if (hDeviceInfo != INVALID_HANDLE_VALUE)
|
|
|
|
|
SetupDiDestroyDeviceInfoList(hDeviceInfo);
|
|
|
|
|
if (hInf != INVALID_HANDLE_VALUE)
|
|
|
|
|
SetupCloseInfFile(hInf);
|
|
|
|
|
if (hRootKey != INVALID_HANDLE_VALUE)
|
|
|
|
|
RegCloseKey(hRootKey);
|
|
|
|
|
SetupTermDefaultQueueCallback(callback_context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE("Returning %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* Helper functions for SetupDiSetClassInstallParamsW
|
|
|
|
|
*/
|
|
|
|
|
static BOOL
|
2006-06-10 20:48:17 +00:00
|
|
|
|
SETUP_PropertyChangeHandler(
|
2006-06-02 09:06:05 +00:00
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData,
|
|
|
|
|
IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
|
|
|
|
|
IN DWORD ClassInstallParamsSize)
|
|
|
|
|
{
|
|
|
|
|
PSP_PROPCHANGE_PARAMS PropChangeParams = (PSP_PROPCHANGE_PARAMS)ClassInstallParams;
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
if (!DeviceInfoData)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (ClassInstallParamsSize != sizeof(SP_PROPCHANGE_PARAMS))
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (PropChangeParams && PropChangeParams->StateChange != DICS_ENABLE
|
|
|
|
|
&& PropChangeParams->StateChange != DICS_DISABLE && PropChangeParams->StateChange != DICS_PROPCHANGE
|
|
|
|
|
&& PropChangeParams->StateChange != DICS_START && PropChangeParams->StateChange != DICS_STOP)
|
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
|
else if (PropChangeParams && PropChangeParams->Scope != DICS_FLAG_GLOBAL
|
|
|
|
|
&& PropChangeParams->Scope != DICS_FLAG_CONFIGSPECIFIC)
|
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
|
else if (PropChangeParams
|
|
|
|
|
&& (PropChangeParams->StateChange == DICS_START || PropChangeParams->StateChange == DICS_STOP)
|
|
|
|
|
&& PropChangeParams->Scope != DICS_FLAG_CONFIGSPECIFIC)
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PSP_PROPCHANGE_PARAMS *CurrentPropChangeParams;
|
2007-11-10 14:04:55 +00:00
|
|
|
|
struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
2007-03-14 12:29:18 +00:00
|
|
|
|
CurrentPropChangeParams = &deviceInfo->ClassInstallParams.PropChangeParams;
|
|
|
|
|
|
|
|
|
|
if (*CurrentPropChangeParams)
|
|
|
|
|
{
|
|
|
|
|
MyFree(*CurrentPropChangeParams);
|
|
|
|
|
*CurrentPropChangeParams = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (PropChangeParams)
|
|
|
|
|
{
|
|
|
|
|
*CurrentPropChangeParams = MyMalloc(ClassInstallParamsSize);
|
|
|
|
|
if (!*CurrentPropChangeParams)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
memcpy(*CurrentPropChangeParams, PropChangeParams, ClassInstallParamsSize);
|
|
|
|
|
}
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
|
SETUP_PropertyAddPropertyAdvancedHandler(
|
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
|
|
|
|
IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
|
|
|
|
|
IN DWORD ClassInstallParamsSize)
|
|
|
|
|
{
|
|
|
|
|
PSP_ADDPROPERTYPAGE_DATA AddPropertyPageData = (PSP_ADDPROPERTYPAGE_DATA)ClassInstallParams;
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
if (ClassInstallParamsSize != sizeof(SP_PROPCHANGE_PARAMS))
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (AddPropertyPageData && AddPropertyPageData->Flags != 0)
|
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
|
else if (AddPropertyPageData && AddPropertyPageData->NumDynamicPages >= MAX_INSTALLWIZARD_DYNAPAGES)
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PSP_ADDPROPERTYPAGE_DATA *CurrentAddPropertyPageData;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
if (!DeviceInfoData)
|
|
|
|
|
{
|
|
|
|
|
struct DeviceInfoSet *list = (struct DeviceInfoSet *)DeviceInfoSet;
|
2007-03-14 12:29:18 +00:00
|
|
|
|
CurrentAddPropertyPageData = &list->ClassInstallParams.AddPropertyPageData;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-11-10 14:04:55 +00:00
|
|
|
|
struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
2007-03-14 12:29:18 +00:00
|
|
|
|
CurrentAddPropertyPageData = &deviceInfo->ClassInstallParams.AddPropertyPageData;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
2007-03-14 12:29:18 +00:00
|
|
|
|
if (*CurrentAddPropertyPageData)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2007-03-14 12:29:18 +00:00
|
|
|
|
MyFree(*CurrentAddPropertyPageData);
|
|
|
|
|
*CurrentAddPropertyPageData = NULL;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
2007-03-14 12:29:18 +00:00
|
|
|
|
if (AddPropertyPageData)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2007-03-14 12:29:18 +00:00
|
|
|
|
*CurrentAddPropertyPageData = MyMalloc(ClassInstallParamsSize);
|
|
|
|
|
if (!*CurrentAddPropertyPageData)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2007-03-14 12:29:18 +00:00
|
|
|
|
memcpy(*CurrentAddPropertyPageData, AddPropertyPageData, ClassInstallParamsSize);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiSetClassInstallParamsW (SETUPAPI.@)
|
|
|
|
|
*/
|
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiSetClassInstallParamsW(
|
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
|
|
|
|
IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
|
|
|
|
|
IN DWORD ClassInstallParamsSize)
|
|
|
|
|
{
|
|
|
|
|
struct DeviceInfoSet *list;
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
TRACE("%p %p %p %lu\n", DeviceInfoSet, DeviceInfoData,
|
|
|
|
|
ClassInstallParams, ClassInstallParamsSize);
|
|
|
|
|
|
|
|
|
|
if (!DeviceInfoSet)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
|
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
2007-11-10 14:04:55 +00:00
|
|
|
|
else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
|
else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else if (ClassInstallParams && ClassInstallParams->cbSize != sizeof(SP_CLASSINSTALL_HEADER))
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
|
|
|
|
else if (ClassInstallParams && ClassInstallParamsSize < sizeof(SP_CLASSINSTALL_HEADER))
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (!ClassInstallParams && ClassInstallParamsSize != 0)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SP_DEVINSTALL_PARAMS_W InstallParams;
|
|
|
|
|
BOOL Result;
|
|
|
|
|
|
|
|
|
|
InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
|
|
|
|
|
Result = SetupDiGetDeviceInstallParamsW(DeviceInfoSet, DeviceInfoData, &InstallParams);
|
|
|
|
|
if (!Result)
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
if (ClassInstallParams)
|
|
|
|
|
{
|
2007-03-14 12:29:18 +00:00
|
|
|
|
DWORD i;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
/* Check parameters in ClassInstallParams */
|
2007-03-14 12:29:18 +00:00
|
|
|
|
for (i = 0; i < sizeof(InstallParamsData) / sizeof(InstallParamsData[0]); i++)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2007-03-14 12:29:18 +00:00
|
|
|
|
if (InstallParamsData[i].Function == ClassInstallParams->InstallFunction)
|
|
|
|
|
{
|
|
|
|
|
ret = InstallParamsData[i].UpdateHandler(
|
|
|
|
|
DeviceInfoSet,
|
|
|
|
|
DeviceInfoData,
|
|
|
|
|
ClassInstallParams,
|
|
|
|
|
ClassInstallParamsSize);
|
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
InstallParams.Flags |= DI_CLASSINSTALLPARAMS;
|
|
|
|
|
ret = SetupDiSetDeviceInstallParamsW(DeviceInfoSet, DeviceInfoData, &InstallParams);
|
|
|
|
|
}
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
2007-03-14 12:29:18 +00:00
|
|
|
|
ERR("InstallFunction %u has no associated update handler\n", ClassInstallParams->InstallFunction);
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
goto done;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
InstallParams.Flags &= ~DI_CLASSINSTALLPARAMS;
|
2007-03-14 12:29:18 +00:00
|
|
|
|
ret = SetupDiSetDeviceInstallParamsW(DeviceInfoSet, DeviceInfoData, &InstallParams);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
TRACE("Returning %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiGetClassDevPropertySheetsA(SETUPAPI.@)
|
|
|
|
|
*/
|
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiGetClassDevPropertySheetsA(
|
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
|
|
|
|
IN LPPROPSHEETHEADERA PropertySheetHeader,
|
|
|
|
|
IN DWORD PropertySheetHeaderPageListSize,
|
|
|
|
|
OUT PDWORD RequiredSize OPTIONAL,
|
|
|
|
|
IN DWORD PropertySheetType)
|
|
|
|
|
{
|
|
|
|
|
PROPSHEETHEADERW psh;
|
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
TRACE("%p %p %p 0%lx %p 0x%lx\n", DeviceInfoSet, DeviceInfoData,
|
|
|
|
|
PropertySheetHeader, PropertySheetHeaderPageListSize,
|
|
|
|
|
RequiredSize, PropertySheetType);
|
|
|
|
|
|
2017-02-02 19:41:19 +00:00
|
|
|
|
if(PropertySheetHeader)
|
|
|
|
|
{
|
|
|
|
|
psh.dwFlags = PropertySheetHeader->dwFlags;
|
|
|
|
|
psh.phpage = PropertySheetHeader->phpage;
|
|
|
|
|
psh.nPages = PropertySheetHeader->nPages;
|
|
|
|
|
}
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
ret = SetupDiGetClassDevPropertySheetsW(DeviceInfoSet, DeviceInfoData, PropertySheetHeader ? &psh : NULL,
|
|
|
|
|
PropertySheetHeaderPageListSize, RequiredSize,
|
|
|
|
|
PropertySheetType);
|
|
|
|
|
if (ret)
|
|
|
|
|
{
|
|
|
|
|
PropertySheetHeader->nPages = psh.nPages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE("Returning %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ClassDevPropertySheetsData
|
|
|
|
|
{
|
2011-05-27 15:07:43 +00:00
|
|
|
|
LPPROPSHEETHEADERW PropertySheetHeader;
|
|
|
|
|
DWORD PropertySheetHeaderPageListSize;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
DWORD NumberOfPages;
|
2011-05-27 15:07:43 +00:00
|
|
|
|
BOOL DontCancel;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static BOOL WINAPI
|
2006-06-10 20:48:17 +00:00
|
|
|
|
SETUP_GetClassDevPropertySheetsCallback(
|
2006-06-02 09:06:05 +00:00
|
|
|
|
IN HPROPSHEETPAGE hPropSheetPage,
|
|
|
|
|
IN OUT LPARAM lParam)
|
|
|
|
|
{
|
|
|
|
|
struct ClassDevPropertySheetsData *PropPageData;
|
|
|
|
|
|
|
|
|
|
PropPageData = (struct ClassDevPropertySheetsData *)lParam;
|
|
|
|
|
|
2011-05-27 15:07:43 +00:00
|
|
|
|
PropPageData->NumberOfPages++;
|
|
|
|
|
|
|
|
|
|
if (PropPageData->PropertySheetHeader->nPages < PropPageData->PropertySheetHeaderPageListSize)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2011-05-27 15:07:43 +00:00
|
|
|
|
PropPageData->PropertySheetHeader->phpage[PropPageData->PropertySheetHeader->nPages] = hPropSheetPage;
|
|
|
|
|
PropPageData->PropertySheetHeader->nPages++;
|
|
|
|
|
return TRUE;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-27 15:07:43 +00:00
|
|
|
|
return PropPageData->DontCancel;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-26 21:42:00 +00:00
|
|
|
|
static DWORD
|
|
|
|
|
SETUP_GetValueString(
|
|
|
|
|
IN HKEY hKey,
|
|
|
|
|
IN LPWSTR lpValueName,
|
|
|
|
|
OUT LPWSTR *lpString)
|
|
|
|
|
{
|
|
|
|
|
LPWSTR lpBuffer;
|
|
|
|
|
DWORD dwLength = 0;
|
|
|
|
|
DWORD dwRegType;
|
|
|
|
|
DWORD rc;
|
|
|
|
|
|
|
|
|
|
*lpString = NULL;
|
|
|
|
|
|
|
|
|
|
RegQueryValueExW(hKey, lpValueName, NULL, &dwRegType, NULL, &dwLength);
|
|
|
|
|
|
|
|
|
|
if (dwLength == 0 || dwRegType != REG_SZ)
|
|
|
|
|
return ERROR_FILE_NOT_FOUND;
|
|
|
|
|
|
|
|
|
|
lpBuffer = HeapAlloc(GetProcessHeap(), 0, dwLength + sizeof(WCHAR));
|
|
|
|
|
if (lpBuffer == NULL)
|
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
|
|
|
|
|
rc = RegQueryValueExW(hKey, lpValueName, NULL, NULL, (LPBYTE)lpBuffer, &dwLength);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpBuffer);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lpBuffer[dwLength / sizeof(WCHAR)] = UNICODE_NULL;
|
|
|
|
|
|
|
|
|
|
*lpString = lpBuffer;
|
|
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2006-06-02 09:06:05 +00:00
|
|
|
|
/***********************************************************************
|
|
|
|
|
* SetupDiGetClassDevPropertySheetsW(SETUPAPI.@)
|
|
|
|
|
*/
|
|
|
|
|
BOOL WINAPI
|
|
|
|
|
SetupDiGetClassDevPropertySheetsW(
|
|
|
|
|
IN HDEVINFO DeviceInfoSet,
|
|
|
|
|
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
|
|
|
|
|
IN OUT LPPROPSHEETHEADERW PropertySheetHeader,
|
|
|
|
|
IN DWORD PropertySheetHeaderPageListSize,
|
|
|
|
|
OUT PDWORD RequiredSize OPTIONAL,
|
|
|
|
|
IN DWORD PropertySheetType)
|
|
|
|
|
{
|
2018-09-26 21:42:00 +00:00
|
|
|
|
struct DeviceInfoSet *devInfoSet = NULL;
|
|
|
|
|
struct DeviceInfo *devInfo = NULL;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
|
|
TRACE("%p %p %p 0%lx %p 0x%lx\n", DeviceInfoSet, DeviceInfoData,
|
|
|
|
|
PropertySheetHeader, PropertySheetHeaderPageListSize,
|
|
|
|
|
RequiredSize, PropertySheetType);
|
|
|
|
|
|
|
|
|
|
if (!DeviceInfoSet)
|
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
2007-11-10 14:04:55 +00:00
|
|
|
|
else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
2018-09-26 21:42:00 +00:00
|
|
|
|
else if ((devInfoSet = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
|
else if (!PropertySheetHeader)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (PropertySheetHeader->dwFlags & PSH_PROPSHEETPAGE)
|
|
|
|
|
SetLastError(ERROR_INVALID_FLAGS);
|
|
|
|
|
else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
|
|
|
|
|
SetLastError(ERROR_INVALID_USER_BUFFER);
|
2018-09-26 21:42:00 +00:00
|
|
|
|
else if (!DeviceInfoData && IsEqualIID(&devInfoSet->ClassGuid, &GUID_NULL))
|
2006-06-02 09:06:05 +00:00
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else if (PropertySheetType != DIGCDP_FLAG_ADVANCED
|
|
|
|
|
&& PropertySheetType != DIGCDP_FLAG_BASIC
|
|
|
|
|
&& PropertySheetType != DIGCDP_FLAG_REMOTE_ADVANCED
|
|
|
|
|
&& PropertySheetType != DIGCDP_FLAG_REMOTE_BASIC)
|
|
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HKEY hKey = INVALID_HANDLE_VALUE;
|
|
|
|
|
SP_PROPSHEETPAGE_REQUEST Request;
|
|
|
|
|
LPWSTR PropPageProvider = NULL;
|
|
|
|
|
HMODULE hModule = NULL;
|
|
|
|
|
PROPERTY_PAGE_PROVIDER pPropPageProvider = NULL;
|
|
|
|
|
struct ClassDevPropertySheetsData PropPageData;
|
2011-05-27 15:07:43 +00:00
|
|
|
|
DWORD InitialNumberOfPages;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
DWORD rc;
|
|
|
|
|
|
|
|
|
|
if (DeviceInfoData)
|
2018-09-26 21:42:00 +00:00
|
|
|
|
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2018-09-26 21:42:00 +00:00
|
|
|
|
/* Get the class property page provider */
|
|
|
|
|
if (devInfoSet->hmodClassPropPageProvider == NULL)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
2018-09-26 21:42:00 +00:00
|
|
|
|
hKey = SetupDiOpenClassRegKeyExW(devInfo ? &devInfo->ClassGuid : &devInfoSet->ClassGuid, KEY_QUERY_VALUE,
|
|
|
|
|
DIOCR_INSTALLER, NULL/*devInfoSet->MachineName + 2*/, NULL);
|
|
|
|
|
if (hKey != INVALID_HANDLE_VALUE)
|
|
|
|
|
{
|
|
|
|
|
rc = SETUP_GetValueString(hKey, REGSTR_VAL_ENUMPROPPAGES_32, &PropPageProvider);
|
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
rc = GetFunctionPointer(PropPageProvider, &hModule, (PVOID*)&pPropPageProvider);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_INVALID_PROPPAGE_PROVIDER);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2018-09-26 21:42:00 +00:00
|
|
|
|
devInfoSet->hmodClassPropPageProvider = hModule;
|
|
|
|
|
devInfoSet->pClassPropPageProvider = pPropPageProvider;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
2018-09-26 21:42:00 +00:00
|
|
|
|
HeapFree(GetProcessHeap(), 0, PropPageProvider);
|
|
|
|
|
PropPageProvider = NULL;
|
|
|
|
|
}
|
2014-10-13 18:31:55 +00:00
|
|
|
|
|
2018-09-26 21:42:00 +00:00
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
hKey = INVALID_HANDLE_VALUE;
|
2014-10-13 18:31:55 +00:00
|
|
|
|
}
|
2014-10-12 17:13:36 +00:00
|
|
|
|
}
|
2014-10-13 18:31:55 +00:00
|
|
|
|
|
2018-09-26 21:42:00 +00:00
|
|
|
|
/* Get the device property page provider */
|
|
|
|
|
if (devInfo != NULL && devInfo->hmodDevicePropPageProvider == NULL)
|
|
|
|
|
{
|
|
|
|
|
hKey = SETUPDI_OpenDrvKey(devInfoSet->HKLM, devInfo, KEY_QUERY_VALUE);
|
|
|
|
|
if (hKey != INVALID_HANDLE_VALUE)
|
2014-10-13 18:31:55 +00:00
|
|
|
|
{
|
2018-09-26 21:42:00 +00:00
|
|
|
|
rc = SETUP_GetValueString(hKey, REGSTR_VAL_ENUMPROPPAGES_32, &PropPageProvider);
|
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
rc = GetFunctionPointer(PropPageProvider, &hModule, (PVOID*)&pPropPageProvider);
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_INVALID_PROPPAGE_PROVIDER);
|
|
|
|
|
goto cleanup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
devInfo->hmodDevicePropPageProvider = hModule;
|
|
|
|
|
devInfo->pDevicePropPageProvider = pPropPageProvider;
|
|
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, PropPageProvider);
|
|
|
|
|
PropPageProvider = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
hKey = INVALID_HANDLE_VALUE;
|
2014-10-13 18:31:55 +00:00
|
|
|
|
}
|
2014-10-12 17:13:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-27 15:07:43 +00:00
|
|
|
|
InitialNumberOfPages = PropertySheetHeader->nPages;
|
|
|
|
|
|
2006-06-02 09:06:05 +00:00
|
|
|
|
Request.cbSize = sizeof(SP_PROPSHEETPAGE_REQUEST);
|
|
|
|
|
Request.PageRequested = SPPSR_ENUM_ADV_DEVICE_PROPERTIES;
|
|
|
|
|
Request.DeviceInfoSet = DeviceInfoSet;
|
|
|
|
|
Request.DeviceInfoData = DeviceInfoData;
|
2011-05-27 15:07:43 +00:00
|
|
|
|
|
|
|
|
|
PropPageData.PropertySheetHeader = PropertySheetHeader;
|
|
|
|
|
PropPageData.PropertySheetHeaderPageListSize = PropertySheetHeaderPageListSize;
|
2006-06-02 09:06:05 +00:00
|
|
|
|
PropPageData.NumberOfPages = 0;
|
2011-05-27 15:07:43 +00:00
|
|
|
|
PropPageData.DontCancel = (RequiredSize != NULL) ? TRUE : FALSE;
|
|
|
|
|
|
2018-09-26 21:42:00 +00:00
|
|
|
|
/* Call the class property page provider */
|
|
|
|
|
if (devInfoSet->pClassPropPageProvider != NULL)
|
|
|
|
|
((PROPERTY_PAGE_PROVIDER)devInfoSet->pClassPropPageProvider)(&Request, SETUP_GetClassDevPropertySheetsCallback, (LPARAM)&PropPageData);
|
|
|
|
|
|
|
|
|
|
/* Call the device property page provider */
|
|
|
|
|
if (devInfo != NULL && devInfo->pDevicePropPageProvider != NULL)
|
|
|
|
|
((PROPERTY_PAGE_PROVIDER)devInfo->pDevicePropPageProvider)(&Request, SETUP_GetClassDevPropertySheetsCallback, (LPARAM)&PropPageData);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
|
|
|
|
|
if (RequiredSize)
|
2011-05-27 15:07:43 +00:00
|
|
|
|
*RequiredSize = PropPageData.NumberOfPages;
|
|
|
|
|
|
|
|
|
|
if (InitialNumberOfPages + PropPageData.NumberOfPages <= PropertySheetHeaderPageListSize)
|
2006-06-02 09:06:05 +00:00
|
|
|
|
{
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
|
if (hKey != INVALID_HANDLE_VALUE)
|
|
|
|
|
RegCloseKey(hKey);
|
2018-09-26 21:42:00 +00:00
|
|
|
|
|
|
|
|
|
if (PropPageProvider != NULL)
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, PropPageProvider);
|
2006-06-02 09:06:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE("Returning %d\n", ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|