* SetupAPI device installer
*
* Copyright 2000 Andreas Mohr for CodeWeavers
- * 2005 Hervé Poussineau (hpoussin@reactos.com)
+ * 2005 Hervé 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "config.h"
-#include "wine/port.h"
-
-#include <stdarg.h>
-
-#include <windows.h>
-#include "setupapi.h"
-#include "wine/debug.h"
-#include "wine/unicode.h"
-#include "cfgmgr32.h"
-#include "initguid.h"
-#define NTOS_MODE_USER
-#include <ndk/ntndk.h>
-
+#define INITGUID
#include "setupapi_private.h"
-
WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
/* Unicode constants */
(WINAPI* DEFAULT_CLASS_INSTALL_PROC) (
IN HDEVINFO DeviceInfoSet,
IN OUT PSP_DEVINFO_DATA DeviceInfoData);
-typedef DWORD
+typedef DWORD
(CALLBACK* COINSTALLER_PROC) (
IN DI_FUNCTION InstallFunction,
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
IN OUT PCOINSTALLER_CONTEXT_DATA Context);
-
-#define SETUP_DEV_INFO_SET_MAGIC 0xd00ff057
+typedef BOOL
+(WINAPI* PROPERTY_PAGE_PROVIDER) (
+ IN PSP_PROPSHEETPAGE_REQUEST PropPageRequest,
+ IN LPFNADDPROPSHEETPAGE fAddFunc,
+ IN LPARAM lParam);
struct CoInstallerElement
{
PVOID PrivateData;
};
-struct DeviceInterface /* Element of DeviceInfoElement.InterfaceListHead */
-{
- LIST_ENTRY ListEntry;
-
- struct DeviceInfoElement* DeviceInfo;
- GUID InterfaceClassGuid;
-
-
- /* SPINT_ACTIVE : the interface is active/enabled
- * SPINT_DEFAULT: the interface is the default interface for the device class FIXME???
- * SPINT_REMOVED: the interface is removed
- */
- DWORD Flags;
-
- WCHAR SymbolicLink[0]; /* \\?\ACPI#PNP0501#4&2658d0a0&0#{GUID} */
-};
-
-/* We don't want to open the .inf file to read only one information in it, so keep a handle to it once it
- * has been already loaded once. Keep also a reference counter */
-struct InfFileDetails
-{
- HINF hInf;
- ULONG References;
-};
-
-struct DriverInfoElement /* Element of DeviceInfoSet.DriverListHead and DeviceInfoElement.DriverListHead */
-{
- LIST_ENTRY ListEntry;
-
- DWORD DriverRank;
- SP_DRVINFO_DATA_V2_W Info;
- SP_DRVINFO_DETAIL_DATA_W Details;
- GUID ClassGuid;
- LPWSTR MatchingId;
- struct InfFileDetails *InfFileDetails;
-};
-
-struct DeviceInfoElement /* Element of DeviceInfoSet.ListHead */
-{
- LIST_ENTRY ListEntry;
-
- /* Reserved Field points to a struct DriverInfoElement */
- SP_DEVINSTALL_PARAMS_W InstallParams;
-
- /* Information about devnode:
- * - DeviceName:
- * "Root\*PNP0501" for example.
- * It doesn't contain the unique ID for the device
- * (points into the Data field at the end of the structure)
- * WARNING: no NULL char exist between DeviceName and UniqueId
- * in Data field!
- * - UniqueId
- * "5&1be2108e&0" or "0000"
- * If DICD_GENERATE_ID is specified in creation flags,
- * this unique ID is autogenerated using 4 digits, base 10
- * (points into the Data field at the end of the structure)
- * - DeviceDescription
- * String which identifies the device. Can be NULL. If not NULL,
- * points into the Data field at the end of the structure
- * - ClassGuid
- * Identifies the class of this device. FIXME: can it be GUID_NULL?
- * - CreationFlags
- * Is a combination of:
- * - DICD_GENERATE_ID
- * the unique ID needs to be generated
- * - DICD_INHERIT_CLASSDRVS
- * inherit driver of the device info set (== same pointer)
- */
- PCWSTR DeviceName;
- PCWSTR UniqueId;
- PCWSTR DeviceDescription;
- GUID ClassGuid;
- DWORD CreationFlags;
-
- /* If CreationFlags contains DICD_INHERIT_CLASSDRVS, this list is invalid */
- /* If the driver is not searched/detected, this list is empty */
- LIST_ENTRY DriverListHead; /* List of struct DriverInfoElement */
-
- /* List of interfaces implemented by this device */
- LIST_ENTRY InterfaceListHead; /* List of struct DeviceInterface */
-
- WCHAR Data[0];
-};
-
-struct DeviceInfoSet /* HDEVINFO */
-{
- DWORD magic; /* SETUP_DEV_INFO_SET_MAGIC */
- GUID ClassGuid; /* If != GUID_NULL, only devices of this class can be in the device info set */
- HKEY HKLM; /* Local or distant HKEY_LOCAL_MACHINE registry key */
-
- /* Reserved Field points to a struct DriverInfoElement */
- SP_DEVINSTALL_PARAMS_W InstallParams;
-
- /* If the driver is not searched/detected, this list is empty */
- LIST_ENTRY DriverListHead; /* List of struct DriverInfoElement */
-
- LIST_ENTRY ListHead; /* List of struct DeviceInfoElement */
-};
-
/***********************************************************************
* SetupDiBuildClassInfoList (SETUPAPI.@)
*/
LONG lError;
DWORD dwGuidListIndex = 0;
- TRACE("\n");
+ TRACE("0x%lx %p %lu %p %s %p\n", Flags, ClassGuidList,
+ ClassGuidListSize, RequiredSize, debugstr_w(MachineName), Reserved);
if (RequiredSize != NULL)
*RequiredSize = 0;
hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
- KEY_ALL_ACCESS,
+ KEY_ENUMERATE_SUB_KEYS,
DIOCR_INSTALLER,
MachineName,
Reserved);
TRACE("RegEnumKeyExW() returns %ld\n", lError);
if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
{
- TRACE("Key name: %p\n", szKeyName);
+ TRACE("Key name: %s\n", debugstr_w(szKeyName));
if (RegOpenKeyExW(hClassesKey,
szKeyName,
0,
- KEY_ALL_ACCESS,
+ KEY_QUERY_VALUE,
&hClassKey))
{
RegCloseKey(hClassesKey);
RegCloseKey(hClassKey);
- TRACE("Guid: %p\n", szKeyName);
+ TRACE("Guid: %s\n", debugstr_w(szKeyName));
if (dwGuidListIndex < ClassGuidListSize)
{
if (szKeyName[0] == L'{' && szKeyName[37] == L'}')
{
szKeyName[37] = 0;
}
- TRACE("Guid: %p\n", &szKeyName[1]);
+ TRACE("Guid: %s\n", debugstr_w(&szKeyName[1]));
UuidFromStringW(&szKeyName[1],
&ClassGuidList[dwGuidListIndex]);
LONG lError;
DWORD dwGuidListIndex = 0;
+ TRACE("%s %p %lu %p %s %p\n", debugstr_w(ClassName), ClassGuidList,
+ ClassGuidListSize, RequiredSize, debugstr_w(MachineName), Reserved);
+
if (RequiredSize != NULL)
*RequiredSize = 0;
TRACE("RegEnumKeyExW() returns %ld\n", lError);
if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
{
- TRACE("Key name: %p\n", szKeyName);
+ TRACE("Key name: %s\n", debugstr_w(szKeyName));
if (RegOpenKeyExW(hClassesKey,
szKeyName,
(LPBYTE)szClassName,
&dwLength))
{
- TRACE("Class name: %p\n", szClassName);
+ TRACE("Class name: %s\n", debugstr_w(szClassName));
if (strcmpiW(szClassName, ClassName) == 0)
{
TRACE("Found matching class name\n");
- TRACE("Guid: %p\n", szKeyName);
+ TRACE("Guid: %s\n", debugstr_w(szKeyName));
if (dwGuidListIndex < ClassGuidListSize)
{
if (szKeyName[0] == L'{' && szKeyName[37] == L'}')
{
szKeyName[37] = 0;
}
- TRACE("Guid: %p\n", &szKeyName[1]);
+ TRACE("Guid: %s\n", debugstr_w(&szKeyName[1]));
UuidFromStringW(&szKeyName[1],
&ClassGuidList[dwGuidListIndex]);
DWORD dwLength;
LONG rc;
+ TRACE("%s %p %lu %p %s %p\n", debugstr_guid(ClassGuid), ClassName,
+ ClassNameSize, RequiredSize, debugstr_w(MachineName), Reserved);
+
hKey = SetupDiOpenClassRegKeyExW(ClassGuid,
KEY_QUERY_VALUE,
DIOCR_INSTALLER,
LPWSTR MachineNameW = NULL;
HDEVINFO hDevInfo;
- TRACE("%p %p %s %p\n", ClassGuid, hwndParent, MachineName, Reserved);
+ TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent,
+ debugstr_a(MachineName), Reserved);
if (MachineName)
{
return hDevInfo;
}
+static DWORD
+GetErrorCodeFromCrCode(const IN CONFIGRET cr)
+{
+ switch (cr)
+ {
+ case CR_INVALID_MACHINENAME: return ERROR_INVALID_COMPUTERNAME;
+ case CR_OUT_OF_MEMORY: return ERROR_NOT_ENOUGH_MEMORY;
+ case CR_SUCCESS: return ERROR_SUCCESS;
+ default:
+ /* FIXME */
+ return ERROR_GEN_FAILURE;
+ }
+
+ /* Does not happen */
+}
+
/***********************************************************************
* SetupDiCreateDeviceInfoListExW (SETUPAPI.@)
*/
PVOID Reserved)
{
struct DeviceInfoSet *list;
+ LPWSTR UNCServerName = NULL;
+ DWORD size;
DWORD rc;
+ //CONFIGRET cr;
+ HDEVINFO ret = (HDEVINFO)INVALID_HANDLE_VALUE;;
- TRACE("%p %p %S %p\n", ClassGuid, hwndParent, MachineName, Reserved);
+ TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent,
+ debugstr_w(MachineName), Reserved);
- list = HeapAlloc(GetProcessHeap(), 0, sizeof(struct DeviceInfoSet));
+ size = FIELD_OFFSET(struct DeviceInfoSet, szData);
+ if (MachineName)
+ size += (wcslen(MachineName) + 3) * sizeof(WCHAR);
+ list = HeapAlloc(GetProcessHeap(), 0, size);
if (!list)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return (HDEVINFO)INVALID_HANDLE_VALUE;
+ goto cleanup;
}
memset(list, 0, sizeof(struct DeviceInfoSet));
if (rc != ERROR_SUCCESS)
{
SetLastError(rc);
- HeapFree(GetProcessHeap(), 0, list);
- return (HDEVINFO)INVALID_HANDLE_VALUE;
+ goto cleanup;
}
+ UNCServerName = HeapAlloc(GetProcessHeap(), 0, (strlenW(MachineName) + 3) * sizeof(WCHAR));
+ if (!UNCServerName)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+
+ strcpyW(UNCServerName + 2, MachineName);
+ list->szData[0] = list->szData[1] = '\\';
+ strcpyW(list->szData + 2, MachineName);
+ list->MachineName = list->szData;
}
else
{
+ DWORD Size = MAX_PATH;
list->HKLM = HKEY_LOCAL_MACHINE;
+ UNCServerName = HeapAlloc(GetProcessHeap(), 0, (MAX_PATH + 2) * sizeof(WCHAR));
+ if (!UNCServerName)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ if (!GetComputerNameW(UNCServerName + 2, &Size))
+ goto cleanup;
+ list->MachineName = NULL;
+ }
+#if 0
+ UNCServerName[0] = UNCServerName[1] = '\\';
+ cr = CM_Connect_MachineW(UNCServerName, &list->hMachine);
+ if (cr != CR_SUCCESS)
+ {
+ SetLastError(GetErrorCodeFromCrCode(cr));
+ goto cleanup;
}
+#endif
InitializeListHead(&list->DriverListHead);
InitializeListHead(&list->ListHead);
- return (HDEVINFO)list;
+
+ ret = (HDEVINFO)list;
+
+cleanup:
+ if (ret == INVALID_HANDLE_VALUE)
+ {
+ if (list && list->HKLM != 0 && list->HKLM != HKEY_LOCAL_MACHINE)
+ RegCloseKey(list->HKLM);
+ HeapFree(GetProcessHeap(), 0, list);
+ }
+ HeapFree(GetProcessHeap(), 0, UNCServerName);
+ return ret;
}
/***********************************************************************
memcpy(&DeviceInfoData->ClassGuid,
&DevInfo->ClassGuid,
sizeof(GUID));
- DeviceInfoData->DevInst = 0; /* FIXME */
- /* Note: this appears to be dangerous, passing a private
- * pointer a heap-allocated datum to the caller. However, the
- * expected lifetime of the device data is the same as the
- * HDEVINFO; once that is closed, the data are no longer valid.
- */
+ DeviceInfoData->DevInst = DevInfo->dnDevInst;
DeviceInfoData->Reserved = (ULONG_PTR)DevInfo;
ret = TRUE;
}
DWORD dwFullLength;
LONG lLineCount = -1;
+ TRACE("%p %s %p %lu %p %p\n", InfHandle, debugstr_w(InfSectionName),
+ InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension);
+
lstrcpyW(szBuffer, InfSectionName);
dwLength = lstrlenW(szBuffer);
HKEY hKey;
DWORD dwLength;
+ TRACE("%s %p %lu %p %s %p\n", debugstr_guid(ClassGuid), ClassDescription,
+ ClassDescriptionSize, RequiredSize, debugstr_w(MachineName), Reserved);
+
hKey = SetupDiOpenClassRegKeyExW(ClassGuid,
- KEY_ALL_ACCESS,
+ KEY_QUERY_VALUE,
DIOCR_INSTALLER,
MachineName,
Reserved);
static BOOL
CreateDeviceInfoElement(
+ IN struct DeviceInfoSet *list,
IN LPCWSTR InstancePath,
IN LPCGUID pClassGuid,
OUT struct DeviceInfoElement **pDeviceInfo)
{
DWORD size;
+ CONFIGRET cr;
struct DeviceInfoElement *deviceInfo;
*pDeviceInfo = NULL;
- size = sizeof(struct DeviceInfoElement) + (wcslen(InstancePath) + 1) * sizeof(WCHAR);
+ size = FIELD_OFFSET(struct DeviceInfoElement, Data) + (wcslen(InstancePath) + 1) * sizeof(WCHAR);
deviceInfo = HeapAlloc(GetProcessHeap(), 0, size);
if (!deviceInfo)
{
return FALSE;
}
memset(deviceInfo, 0, size);
+
+ cr = CM_Locate_DevNode_ExW(&deviceInfo->dnDevInst, (DEVINSTID_W)InstancePath, CM_LOCATE_DEVNODE_PHANTOM, list->hMachine);
+ if (cr != CR_SUCCESS)
+ {
+ SetLastError(GetErrorCodeFromCrCode(cr));
+ return FALSE;
+ }
+
deviceInfo->InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
wcscpy(deviceInfo->Data, InstancePath);
deviceInfo->DeviceName = deviceInfo->Data;
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)
{
RegCloseKey(hDeviceIdKey);
return ERROR_GEN_FAILURE;
}
-
- KeyBuffer[37] = '\0'; /* Replace the } by a NULL character */
- if (UuidFromStringW(&KeyBuffer[1], &KeyGuid) != RPC_S_OK)
+ else
{
- RegCloseKey(hDeviceIdKey);
- return GetLastError();
+ KeyBuffer[37] = '\0'; /* Replace the } by a NULL character */
+ 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 */
}
/* Add the entry to the list */
- if (!CreateDeviceInfoElement(InstancePath, &KeyGuid, &deviceInfo))
+ if (!CreateDeviceInfoElement(list, InstancePath, &KeyGuid, &deviceInfo))
{
RegCloseKey(hDeviceIdKey);
return GetLastError();
DWORD dwLength;
DWORD rc;
- if (IsEqualIID(class, &GUID_NULL))
+ if (class && IsEqualIID(class, &GUID_NULL))
class = NULL;
/* Open Enum key */
return rc;
/* If enumerator is provided, call directly SETUP_CreateDevListFromEnumerator.
- * Else, enumerate all enumerators all call SETUP_CreateDevListFromEnumerator
+ * Else, enumerate all enumerators and call SETUP_CreateDevListFromEnumerator
* for each one.
*/
if (Enumerator)
struct DeviceInterface *interfaceInfo;
TRACE("Adding %s to list\n", debugstr_w(ptr));
/* Step 1. Create a device info element */
- if (!CreateDeviceInfoElement(ptr, &GUID_SERENUM_BUS_ENUMERATOR, &deviceInfo))
+ if (!CreateDeviceInfoElement(list, ptr, &GUID_SERENUM_BUS_ENUMERATOR, &deviceInfo))
{
if (devices != buf)
HeapFree(GetProcessHeap(), 0, devices);
/* We have found a device */
/* Step 1. Create a device info element */
- if (!CreateDeviceInfoElement(InstancePath, &ClassGuid, &deviceInfo))
+ if (!CreateDeviceInfoElement(list, InstancePath, &ClassGuid, &deviceInfo))
{
RegCloseKey(hReferenceKey);
RegCloseKey(hDeviceInstanceKey);
}
}
+/***********************************************************************
+ * SetupDiGetClassImageIndex (SETUPAPI.@)
+ */
+
+static BOOL GetIconIndex(
+ IN HKEY hClassKey,
+ OUT PINT ImageIndex)
+{
+ LPWSTR Buffer = NULL;
+ DWORD dwRegType, dwLength;
+ LONG rc;
+ BOOL ret = FALSE;
+
+ /* Read "Icon" registry key */
+ rc = RegQueryValueExW(hClassKey, L"Icon", 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;
+ }
+ Buffer[dwLength / sizeof(WCHAR)] = 0;
+ rc = RegQueryValueExW(hClassKey, L"Icon", NULL, NULL, (LPBYTE)Buffer, &dwLength);
+ if (rc != ERROR_SUCCESS)
+ {
+ SetLastError(rc);
+ goto cleanup;
+ }
+
+ /* Transform "Icon" value to a INT */
+ *ImageIndex = atoiW(Buffer);
+ ret = TRUE;
+
+cleanup:
+ MyFree(Buffer);
+ return ret;
+}
+
+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 if (!ImageIndex)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else
+ {
+ HKEY hKey = INVALID_HANDLE_VALUE;
+ INT iconIndex;
+
+ /* Read Icon registry entry into Buffer */
+ hKey = SetupDiOpenClassRegKeyExW(ClassGuid, KEY_QUERY_VALUE, DIOCR_INTERFACE, list->MachineName, NULL);
+ if (hKey == INVALID_HANDLE_VALUE)
+ goto cleanup;
+ if (!GetIconIndex(hKey, &iconIndex))
+ goto cleanup;
+
+ if (iconIndex >= 0)
+ {
+ SetLastError(ERROR_INVALID_INDEX);
+ goto cleanup;
+ }
+
+ *ImageIndex = -iconIndex;
+ ret = TRUE;
+
+cleanup:
+ if (hKey != INVALID_HANDLE_VALUE)
+ RegCloseKey(hKey);
+ }
+
+ 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)
+ {
+ MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
+ if (MachineNameW == NULL)
+ return FALSE;
+ }
+
+ ret = SetupDiGetClassImageListExW(ClassImageListData, MachineNameW, Reserved);
+
+ if (MachineNameW)
+ MyFree(MachineNameW);
+
+ return ret;
+}
+
+/***********************************************************************
+ * 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;
+ DWORD size;
+
+ size = FIELD_OFFSET(struct ClassImageList, szData);
+ if (MachineName)
+ size += (wcslen(MachineName) + 3) * sizeof(WCHAR);
+ list = HeapAlloc(GetProcessHeap(), 0, size);
+ if (!list)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ list->magic = SETUP_CLASS_IMAGE_LIST_MAGIC;
+ if (MachineName)
+ {
+ list->szData[0] = list->szData[1] = '\\';
+ strcpyW(list->szData + 2, MachineName);
+ list->MachineName = list->szData;
+ }
+ else
+ {
+ list->MachineName = NULL;
+ }
+
+ ClassImageListData->Reserved = (DWORD)list; /* FIXME: 64 bit portability issue */
+ ret = TRUE;
+
+cleanup:
+ if (!ret)
+ MyFree(list);
+ }
+
+ TRACE("Returning %d\n", ret);
+ return ret;
+}
+
+/***********************************************************************
+ * SetupDiLoadClassIcon(SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiLoadClassIcon(
+ IN CONST GUID *ClassGuid,
+ OUT HICON *LargeIcon OPTIONAL,
+ OUT PINT MiniIconIndex OPTIONAL)
+{
+ BOOL ret = FALSE;
+
+ if (!ClassGuid)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else
+ {
+ LPWSTR Buffer = NULL;
+ LPCWSTR DllName;
+ INT iconIndex;
+ HKEY hKey = INVALID_HANDLE_VALUE;
+
+ hKey = SetupDiOpenClassRegKey(ClassGuid, KEY_QUERY_VALUE);
+ if (hKey == INVALID_HANDLE_VALUE)
+ goto cleanup;
+
+ if (!GetIconIndex(hKey, &iconIndex))
+ goto cleanup;
+
+ if (iconIndex > 0)
+ {
+ /* Look up icon in dll specified by Installer32 or EnumPropPages32 key */
+ PWCHAR Comma;
+ LONG rc;
+ DWORD dwRegType, dwLength;
+ rc = RegQueryValueExW(hKey, L"Installer32", NULL, &dwRegType, NULL, &dwLength);
+ if (rc == ERROR_SUCCESS && dwRegType == REG_SZ)
+ {
+ Buffer = MyMalloc(dwLength);
+ if (Buffer == NULL)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ rc = RegQueryValueExW(hKey, L"Installer32", NULL, NULL, (LPBYTE)Buffer, &dwLength);
+ if (rc != ERROR_SUCCESS)
+ {
+ SetLastError(rc);
+ goto cleanup;
+ }
+ }
+ else if
+ (ERROR_SUCCESS == (rc = RegQueryValueExW(hKey, L"EnumPropPages32", NULL, &dwRegType, NULL, &dwLength))
+ && dwRegType == REG_SZ)
+ {
+ Buffer = MyMalloc(dwLength);
+ if (Buffer == NULL)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ rc = RegQueryValueExW(hKey, L"EnumPropPages32", NULL, NULL, (LPBYTE)Buffer, &dwLength);
+ if (rc != ERROR_SUCCESS)
+ {
+ SetLastError(rc);
+ goto cleanup;
+ }
+ }
+ 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';
+ }
+ else
+ {
+ /* Look up icon in setupapi.dll */
+ DllName = L"setupapi.dll";
+ iconIndex = -iconIndex;
+ }
+
+ TRACE("Icon index %d, dll name %s\n", iconIndex, debugstr_w(DllName));
+ if (LargeIcon)
+ {
+ if (1 != ExtractIconEx(DllName, iconIndex, LargeIcon, NULL, 1))
+ {
+ SetLastError(ERROR_INVALID_INDEX);
+ goto cleanup;
+ }
+ }
+ if (MiniIconIndex)
+ *MiniIconIndex = iconIndex;
+ ret = TRUE;
+
+cleanup:
+ if (hKey != INVALID_HANDLE_VALUE)
+ RegCloseKey(hKey);
+ MyFree(Buffer);
+ }
+
+ TRACE("Returning %d\n", ret);
+ return ret;
+}
+
/***********************************************************************
* SetupDiEnumDeviceInterfaces (SETUPAPI.@)
*/
&DevItf->InterfaceClassGuid,
sizeof(GUID));
DeviceInterfaceData->Flags = 0; /* FIXME */
- /* Note: this appears to be dangerous, passing a private
- * pointer a heap-allocated datum to the caller. However, the
- * expected lifetime of the device data is the same as the
- * HDEVINFO; once that is closed, the data are no longer valid.
- */
DeviceInterfaceData->Reserved = (ULONG_PTR)DevItf;
Found = TRUE;
}
}
if (list->HKLM != HKEY_LOCAL_MACHINE)
RegCloseKey(list->HKLM);
+ CM_Disconnect_Machine(list->hMachine);
HeapFree(GetProcessHeap(), 0, list);
return TRUE;
}
DWORD sizeW = 0, sizeA;
BOOL ret = FALSE;
- TRACE("(%p, %p, %p, %ld, %p, %p)\n", DeviceInfoSet,
+ TRACE("%p %p %p %lu %p %p\n", DeviceInfoSet,
DeviceInterfaceData, DeviceInterfaceDetailData,
DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
{
BOOL ret = FALSE;
- TRACE("(%p, %p, %p, %ld, %p, %p): stub\n", DeviceInfoSet,
+ TRACE("%p %p %p %lu %p %p\n", DeviceInfoSet,
DeviceInterfaceData, DeviceInterfaceDetailData,
DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
memcpy(&DeviceInfoData->ClassGuid,
&deviceInterface->DeviceInfo->ClassGuid,
sizeof(GUID));
- DeviceInfoData->DevInst = 0; /* FIXME */
- /* Note: this appears to be dangerous, passing a private
- * pointer a heap-allocated datum to the caller. However, the
- * expected lifetime of the device data is the same as the
- * HDEVINFO; once that is closed, the data are no longer valid.
- */
+ DeviceInfoData->DevInst = deviceInterface->DeviceInfo->dnDevInst;
DeviceInfoData->Reserved = (ULONG_PTR)deviceInterface->DeviceInfo;
}
ret = TRUE;
default:
{
- FIXME("Property 0x%lx not implemented\n", Property);
+ ERR("Property 0x%lx not implemented\n", Property);
SetLastError(ERROR_NOT_SUPPORTED);
}
}
default:
{
- FIXME("Property 0x%lx not implemented\n", Property);
+ ERR("Property 0x%lx not implemented\n", Property);
SetLastError(ERROR_NOT_SUPPORTED);
}
}
0,
NULL,
REG_OPTION_NON_VOLATILE,
- KEY_ALL_ACCESS,
+ KEY_SET_VALUE,
NULL,
&hClassKey,
NULL))
BOOL bFileQueueCreated = FALSE;
HKEY hClassKey;
+ TRACE("%p %s 0x%lx %p\n", hwndParent, debugstr_w(InfFileName),
+ Flags, FileQueue);
+
FIXME("not fully implemented\n");
if ((Flags & DI_NOVCP) && (FileQueue == NULL || FileQueue == INVALID_HANDLE_VALUE))
* SetupDiOpenClassRegKeyExA (SETUPAPI.@)
*/
HKEY WINAPI SetupDiOpenClassRegKeyExA(
- const GUID* ClassGuid,
+ const GUID* ClassGuid OPTIONAL,
REGSAM samDesired,
DWORD Flags,
- PCSTR MachineName,
+ PCSTR MachineName OPTIONAL,
PVOID Reserved)
{
PWSTR MachineNameW = NULL;
* SetupDiOpenClassRegKeyExW (SETUPAPI.@)
*/
HKEY WINAPI SetupDiOpenClassRegKeyExW(
- const GUID* ClassGuid,
+ const GUID* ClassGuid OPTIONAL,
REGSAM samDesired,
DWORD Flags,
- PCWSTR MachineName,
+ PCWSTR MachineName OPTIONAL,
PVOID Reserved)
{
LPWSTR lpGuidString;
DWORD rc;
LPCWSTR lpKeyName;
+ TRACE("%s 0x%lx 0x%lx %s %p\n", debugstr_guid(ClassGuid), samDesired,
+ Flags, debugstr_w(MachineName), Reserved);
+
if (Flags == DIOCR_INSTALLER)
{
lpKeyName = ControlClass;
else
{
ERR("Invalid Flags parameter!\n");
- SetLastError(ERROR_INVALID_PARAMETER);
+ SetLastError(ERROR_INVALID_FLAGS);
return INVALID_HANDLE_VALUE;
}
rc = RegOpenKeyExW(HKLM,
lpKeyName,
0,
- KEY_ALL_ACCESS,
+ ClassGuid ? KEY_ENUMERATE_SUB_KEYS : samDesired,
&hClassesKey);
if (MachineName != NULL) RegCloseKey(HKLM);
if (rc != ERROR_SUCCESS)
rc = RegOpenKeyExW(hClassesKey,
lpFullGuidString,
0,
- KEY_ALL_ACCESS,
+ samDesired,
&hClassKey);
if (rc != ERROR_SUCCESS)
{
return FALSE;
}
+/***********************************************************************
+ * SetupDiSetClassInstallParamsW (SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiSetClassInstallParamsW(
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ PSP_CLASSINSTALL_HEADER ClassInstallParams,
+ DWORD ClassInstallParamsSize)
+{
+ FIXME("%p %p %x %lu\n",DeviceInfoSet, DeviceInfoData,
+ ClassInstallParams->InstallFunction, ClassInstallParamsSize);
+ return FALSE;
+}
+
static DWORD
GetFunctionPointer(
IN PWSTR InstallerName,
{
BOOL ret = FALSE;
- TRACE("%ld %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData);
+ TRACE("%u %p %p\n", InstallFunction, DeviceInfoSet, DeviceInfoData);
if (!DeviceInfoSet)
SetLastError(ERROR_INVALID_PARAMETER);
DefaultHandler = SetupDiSelectBestCompatDrv;
break;
default:
- FIXME("Install function %ld not implemented\n", InstallFunction);
- SetLastError(ERROR_INVALID_PARAMETER);
+ ERR("Install function %u not supported\n", InstallFunction);
+ SetLastError(ERROR_NOT_SUPPORTED);
}
InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
return ret;
}
+/***********************************************************************
+ * SetupDiGetDeviceInfoListDetailW (SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiGetDeviceInfoListDetailW(
+ IN HDEVINFO DeviceInfoSet,
+ OUT PSP_DEVINFO_LIST_DETAIL_DATA_W DeviceInfoListDetailData)
+{
+ struct DeviceInfoSet *list;
+ BOOL ret = FALSE;
+
+ TRACE("%p %p\n", DeviceInfoSet, DeviceInfoListDetailData);
+
+ if (!DeviceInfoSet)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEV_INFO_SET_MAGIC)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if (!DeviceInfoListDetailData)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else if (DeviceInfoListDetailData->cbSize != sizeof(SP_DEVINFO_LIST_DETAIL_DATA_W))
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ else
+ {
+ memcpy(
+ &DeviceInfoListDetailData->ClassGuid,
+ &list->ClassGuid,
+ sizeof(GUID));
+ DeviceInfoListDetailData->RemoteMachineHandle = list->hMachine;
+ if (list->MachineName)
+ strcpyW(DeviceInfoListDetailData->RemoteMachineName, list->MachineName + 2);
+ else
+ DeviceInfoListDetailData->RemoteMachineName[0] = 0;
+
+ ret = TRUE;
+ }
+
+ TRACE("Returning %d\n", ret);
+ return ret;
+}
+
/***********************************************************************
* SetupDiGetDeviceInstallParamsA (SETUPAPI.@)
*/
struct DeviceInfoSet *list;
BOOL ret = FALSE;
- TRACE("%p %p %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstallParams);
+ TRACE("%p %p %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstallParams);
+
+ if (!DeviceInfoSet)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEV_INFO_SET_MAGIC)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ else if (!DeviceInstallParams)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else if (DeviceInstallParams->cbSize != sizeof(SP_DEVINSTALL_PARAMS_W))
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ else
+ {
+ PSP_DEVINSTALL_PARAMS_W Source;
+
+ if (DeviceInfoData)
+ Source = &((struct DeviceInfoElement *)DeviceInfoData->Reserved)->InstallParams;
+ else
+ Source = &list->InstallParams;
+ memcpy(DeviceInstallParams, Source, Source->cbSize);
+ ret = TRUE;
+ }
+
+ TRACE("Returning %d\n", ret);
+ return ret;
+}
+
+/***********************************************************************
+ * SetupDiSetDeviceInstallParamsW (SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiSetDeviceInstallParamsW(
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData,
+ IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
+{
+ struct DeviceInfoSet *list;
+ BOOL ret = FALSE;
+
+ TRACE("%p %p %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstallParams);
+
+ if (!DeviceInfoSet)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEV_INFO_SET_MAGIC)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ else if (!DeviceInstallParams)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else if (DeviceInstallParams->cbSize != sizeof(SP_DEVINSTALL_PARAMS_W))
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ else
+ {
+ PSP_DEVINSTALL_PARAMS_W Destination;
+
+ /* FIXME: Validate parameters */
+
+ if (DeviceInfoData)
+ Destination = &((struct DeviceInfoElement *)DeviceInfoData->Reserved)->InstallParams;
+ else
+ Destination = &list->InstallParams;
+ memcpy(Destination, DeviceInstallParams, DeviceInstallParams->cbSize);
+ ret = TRUE;
+ }
+
+ TRACE("Returning %d\n", ret);
+ return ret;
+}
+
+/***********************************************************************
+ * SetupDiGetDeviceInstanceIdA(SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiGetDeviceInstanceIdA(
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData,
+ OUT PSTR DeviceInstanceId OPTIONAL,
+ IN DWORD DeviceInstanceIdSize,
+ OUT PDWORD RequiredSize OPTIONAL)
+{
+ PWSTR DeviceInstanceIdW = NULL;
+ BOOL ret = FALSE;
+
+ TRACE("%p %p %p %lu %p\n", DeviceInfoSet, DeviceInfoData,
+ DeviceInstanceId, DeviceInstanceIdSize, RequiredSize);
+
+ if (!DeviceInstanceId && DeviceInstanceIdSize > 0)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else
+ {
+ if (DeviceInstanceIdSize != 0)
+ {
+ DeviceInstanceIdW = MyMalloc(DeviceInstanceIdSize * sizeof(WCHAR));
+ if (DeviceInstanceIdW == NULL)
+ return FALSE;
+ }
+
+ ret = SetupDiGetDeviceInstanceIdW(DeviceInfoSet, DeviceInfoData,
+ DeviceInstanceIdW, DeviceInstanceIdSize,
+ RequiredSize);
+
+ if (ret && DeviceInstanceIdW != NULL)
+ {
+ if (WideCharToMultiByte(CP_ACP, 0, DeviceInstanceIdW, -1,
+ DeviceInstanceId, DeviceInstanceIdSize, NULL, NULL) == 0)
+ {
+ DeviceInstanceId[0] = '\0';
+ ret = FALSE;
+ }
+ }
+ }
+
+ TRACE("Returning %d\n", ret);
+ return ret;
+}
+
+/***********************************************************************
+ * SetupDiGetDeviceInstanceIdW(SETUPAPI.@)
+ */
+BOOL WINAPI SetupDiGetDeviceInstanceIdW(
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData,
+ OUT PWSTR DeviceInstanceId OPTIONAL,
+ IN DWORD DeviceInstanceIdSize,
+ OUT PDWORD RequiredSize OPTIONAL)
+{
+ BOOL ret = FALSE;
+
+ TRACE("%p %p %p %lu %p\n", DeviceInfoSet, DeviceInfoData,
+ DeviceInstanceId, DeviceInstanceIdSize, RequiredSize);
+
+ if (!DeviceInfoSet)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEV_INFO_SET_MAGIC)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if (!DeviceInfoData)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else if (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ else if (!DeviceInstanceId && DeviceInstanceIdSize > 0)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else if (DeviceInstanceId && DeviceInstanceIdSize == 0)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else
+ {
+ struct DeviceInfoElement *DevInfo = (struct DeviceInfoElement *)DeviceInfoData->Reserved;
+ DWORD required;
+
+ required = (wcslen(DevInfo->DeviceName) + 1) * sizeof(WCHAR);
+ if (RequiredSize)
+ *RequiredSize = required;
+
+ if (required <= DeviceInstanceIdSize)
+ {
+ wcscpy(DeviceInstanceId, DevInfo->DeviceName);
+ ret = TRUE;
+ }
+ else
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ }
+
+ 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);
+
+ psh.dwFlags = PropertySheetHeader->dwFlags;
+ psh.phpage = PropertySheetHeader->phpage;
+ psh.nPages = PropertySheetHeader->nPages;
+
+ 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
+{
+ HPROPSHEETPAGE *PropertySheetPages;
+ DWORD MaximumNumberOfPages;
+ DWORD NumberOfPages;
+};
+
+static BOOL WINAPI GetClassDevPropertySheetsCallback(
+ IN HPROPSHEETPAGE hPropSheetPage,
+ IN OUT LPARAM lParam)
+{
+ struct ClassDevPropertySheetsData *PropPageData;
+
+ PropPageData = (struct ClassDevPropertySheetsData *)lParam;
+
+ if (PropPageData->NumberOfPages < PropPageData->MaximumNumberOfPages)
+ {
+ *PropPageData->PropertySheetPages = hPropSheetPage;
+ PropPageData->PropertySheetPages++;
+ }
+
+ PropPageData->NumberOfPages++;
+ return TRUE;
+}
+
+/***********************************************************************
+ * 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)
+{
+ struct DeviceInfoSet *list;
+ 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);
+ else if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEV_INFO_SET_MAGIC)
+ SetLastError(ERROR_INVALID_HANDLE);
else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEV_INFO_SET_MAGIC)
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);
- else if (!DeviceInstallParams)
+ else if (!DeviceInfoData && IsEqualIID(&list->ClassGuid, &GUID_NULL))
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else if (!PropertySheetHeader)
+ 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 if (DeviceInstallParams->cbSize != sizeof(SP_DEVINSTALL_PARAMS_W))
- SetLastError(ERROR_INVALID_USER_BUFFER);
else
{
- PSP_DEVINSTALL_PARAMS_W Source;
+ HKEY hKey = INVALID_HANDLE_VALUE;
+ SP_PROPSHEETPAGE_REQUEST Request;
+ LPWSTR PropPageProvider = NULL;
+ HMODULE hModule = NULL;
+ PROPERTY_PAGE_PROVIDER pPropPageProvider = NULL;
+ struct ClassDevPropertySheetsData PropPageData;
+ DWORD dwLength, dwRegType;
+ DWORD rc;
if (DeviceInfoData)
- Source = &((struct DeviceInfoElement *)DeviceInfoData->Reserved)->InstallParams;
+ hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DRV, KEY_QUERY_VALUE);
else
- Source = &list->InstallParams;
- memcpy(DeviceInstallParams, Source, Source->cbSize);
- ret = TRUE;
+ {
+ hKey = SetupDiOpenClassRegKeyExW(&list->ClassGuid, KEY_QUERY_VALUE,
+ DIOCR_INSTALLER, list->MachineName + 2, NULL);
+ }
+ if (hKey == INVALID_HANDLE_VALUE)
+ goto cleanup;
+
+ rc = RegQueryValueExW(hKey, L"EnumPropPages32", NULL, &dwRegType, NULL, &dwLength);
+ if (rc == ERROR_FILE_NOT_FOUND)
+ {
+ /* No registry key. As it is optional, don't say it's a bad error */
+ if (RequiredSize)
+ *RequiredSize = 0;
+ ret = TRUE;
+ goto cleanup;
+ }
+ else if (rc != ERROR_SUCCESS && dwRegType != REG_SZ)
+ {
+ SetLastError(rc);
+ goto cleanup;
+ }
+
+ PropPageProvider = HeapAlloc(GetProcessHeap(), 0, dwLength + sizeof(WCHAR));
+ if (!PropPageProvider)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+ rc = RegQueryValueExW(hKey, L"EnumPropPages32", NULL, NULL, (LPBYTE)PropPageProvider, &dwLength);
+ if (rc != ERROR_SUCCESS)
+ {
+ SetLastError(rc);
+ goto cleanup;
+ }
+ PropPageProvider[dwLength / sizeof(WCHAR)] = 0;
+
+ rc = GetFunctionPointer(PropPageProvider, &hModule, (PVOID*)&pPropPageProvider);
+ if (rc != ERROR_SUCCESS)
+ {
+ SetLastError(ERROR_INVALID_PROPPAGE_PROVIDER);
+ goto cleanup;
+ }
+
+ Request.cbSize = sizeof(SP_PROPSHEETPAGE_REQUEST);
+ Request.PageRequested = SPPSR_ENUM_ADV_DEVICE_PROPERTIES;
+ Request.DeviceInfoSet = DeviceInfoSet;
+ Request.DeviceInfoData = DeviceInfoData;
+ PropPageData.PropertySheetPages = &PropertySheetHeader->phpage[PropertySheetHeader->nPages];
+ PropPageData.MaximumNumberOfPages = PropertySheetHeaderPageListSize - PropertySheetHeader->nPages;
+ PropPageData.NumberOfPages = 0;
+ ret = pPropPageProvider(&Request, GetClassDevPropertySheetsCallback, (LPARAM)&PropPageData);
+ if (!ret)
+ goto cleanup;
+
+ if (RequiredSize)
+ *RequiredSize = PropPageData.NumberOfPages + PropertySheetHeader->nPages;
+ if (PropPageData.NumberOfPages <= PropPageData.MaximumNumberOfPages)
+ {
+ PropertySheetHeader->nPages += PropPageData.NumberOfPages;
+ ret = TRUE;
+ }
+ else
+ {
+ PropertySheetHeader->nPages += PropPageData.MaximumNumberOfPages;
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ }
+
+cleanup:
+ if (hKey != INVALID_HANDLE_VALUE)
+ RegCloseKey(hKey);
+ HeapFree(GetProcessHeap(), 0, PropPageProvider);
+ FreeFunctionPointer(hModule, pPropPageProvider);
}
TRACE("Returning %d\n", ret);
}
/***********************************************************************
- * SetupDiSetDeviceInstallParamsW (SETUPAPI.@)
+ * SetupDiCreateDevRegKeyA (SETUPAPI.@)
*/
-BOOL WINAPI SetupDiSetDeviceInstallParamsW(
- IN HDEVINFO DeviceInfoSet,
- IN PSP_DEVINFO_DATA DeviceInfoData,
- IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
+HKEY WINAPI SetupDiCreateDevRegKeyA(
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData,
+ IN DWORD Scope,
+ IN DWORD HwProfile,
+ IN DWORD KeyType,
+ IN HINF InfHandle OPTIONAL,
+ IN PCSTR InfSectionName OPTIONAL)
{
- struct DeviceInfoSet *list;
- BOOL ret = FALSE;
-
- TRACE("%p %p %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstallParams);
+ PCWSTR InfSectionNameW = NULL;
+ HKEY ret = INVALID_HANDLE_VALUE;
- if (!DeviceInfoSet)
- SetLastError(ERROR_INVALID_HANDLE);
- else if ((list = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEV_INFO_SET_MAGIC)
- SetLastError(ERROR_INVALID_HANDLE);
- else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
- SetLastError(ERROR_INVALID_USER_BUFFER);
- else if (!DeviceInstallParams)
- SetLastError(ERROR_INVALID_PARAMETER);
- else if (DeviceInstallParams->cbSize != sizeof(SP_DEVINSTALL_PARAMS_W))
- SetLastError(ERROR_INVALID_USER_BUFFER);
- else
+ if (InfSectionName)
{
- PSP_DEVINSTALL_PARAMS_W Destination;
+ InfSectionNameW = MultiByteToUnicode(InfSectionName, CP_ACP);
+ if (InfSectionNameW == NULL) return INVALID_HANDLE_VALUE;
+ }
- /* FIXME: Validate parameters */
+ ret = SetupDiCreateDevRegKeyW(DeviceInfoSet,
+ DeviceInfoData,
+ Scope,
+ HwProfile,
+ KeyType,
+ InfHandle,
+ InfSectionNameW);
- if (DeviceInfoData)
- Destination = &((struct DeviceInfoElement *)DeviceInfoData->Reserved)->InstallParams;
- else
- Destination = &list->InstallParams;
- memcpy(Destination, DeviceInstallParams, DeviceInstallParams->cbSize);
- ret = TRUE;
- }
+ if (InfSectionNameW != NULL)
+ MyFree((PVOID)InfSectionNameW);
- TRACE("Returning %d\n", ret);
return ret;
}
/***********************************************************************
- * SetupDiCreateDevRegKey (SETUPAPI.@)
+ * SetupDiCreateDevRegKeyW (SETUPAPI.@)
*/
HKEY WINAPI SetupDiCreateDevRegKeyW(
IN HDEVINFO DeviceInfoSet,
else if (CreationFlags & ~(DICD_GENERATE_ID | DICD_INHERIT_CLASSDRVS))
{
TRACE("Unknown flags: 0x%08lx\n", CreationFlags & ~(DICD_GENERATE_ID | DICD_INHERIT_CLASSDRVS));
- SetLastError(ERROR_INVALID_PARAMETER);
+ SetLastError(ERROR_INVALID_FLAGS);
}
else
{
if (CreationFlags & DICD_GENERATE_ID)
{
/* Generate a new unique ID for this device */
- SetLastError(ERROR_GEN_FAILURE);
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
FIXME("not implemented\n");
}
else
{
struct DeviceInfoElement *deviceInfo;
- /* FIXME: ClassGuid can be NULL */
- if (CreateDeviceInfoElement(DeviceName, ClassGuid, &deviceInfo))
+ if (CreateDeviceInfoElement(list, DeviceName, ClassGuid, &deviceInfo))
{
InsertTailList(&list->ListHead, &deviceInfo->ListEntry);
else
{
memcpy(&DeviceInfoData->ClassGuid, ClassGuid, sizeof(GUID));
- DeviceInfoData->DevInst = 0; /* FIXME */
+ DeviceInfoData->DevInst = deviceInfo->dnDevInst;
DeviceInfoData->Reserved = (ULONG_PTR)deviceInfo;
ret = TRUE;
}
InsertHeadList(PreviousEntry, &driverInfo->ListEntry);
break;
}
+ PreviousEntry = PreviousEntry->Flink;
}
if (PreviousEntry == DriverListHead)
{
HeapFree(GetProcessHeap(), 0, ProviderName);
HeapFree(GetProcessHeap(), 0, DriverVer);
- TRACE("Returning %d\n", ret);
return ret;
}
WCHAR ManufacturerSection[LINE_LEN + 1];
LPWSTR HardwareIDs = NULL;
LPWSTR CompatibleIDs = NULL;
+ LPWSTR FullInfFileName = NULL;
FILETIME DriverDate;
DWORDLONG DriverVersion = 0;
DWORD RequiredSize;
if (Result)
{
LPCWSTR filename;
+ LPWSTR pFullFilename;
+
+ if (*InstallParams.DriverPath)
+ {
+ DWORD len;
+ len = GetFullPathNameW(InstallParams.DriverPath, 0, NULL, NULL);
+ if (len == 0)
+ goto done;
+ FullInfFileName = HeapAlloc(GetProcessHeap(), 0, len + MAX_PATH);
+ if (!FullInfFileName)
+ goto done;
+ len = GetFullPathNameW(InstallParams.DriverPath, len, FullInfFileName, NULL);
+ if (len == 0)
+ goto done;
+ if (*FullInfFileName && FullInfFileName[wcslen(FullInfFileName) - 1] != '\\')
+ wcscat(FullInfFileName, L"\\");
+ pFullFilename = &FullInfFileName[wcslen(FullInfFileName)];
+ }
+ else
+ {
+ FullInfFileName = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
+ if (!FullInfFileName)
+ goto done;
+ pFullFilename = &FullInfFileName[0];
+ }
for (filename = (LPCWSTR)Buffer; *filename; filename += wcslen(filename) + 1)
{
INFCONTEXT ContextManufacturer, ContextDevice;
GUID ClassGuid;
- TRACE("Opening file %S\n", filename);
- currentInfFileDetails = HeapAlloc(GetProcessHeap(), 0, sizeof(struct InfFileDetails));
+ wcscpy(pFullFilename, filename);
+ TRACE("Opening file %S\n", FullInfFileName);
+
+ currentInfFileDetails = HeapAlloc(
+ GetProcessHeap(),
+ 0,
+ FIELD_OFFSET(struct InfFileDetails, FullInfFileName) + wcslen(FullInfFileName) * sizeof(WCHAR) + UNICODE_NULL);
if (!currentInfFileDetails)
continue;
memset(currentInfFileDetails, 0, sizeof(struct InfFileDetails));
+ wcscpy(currentInfFileDetails->FullInfFileName, FullInfFileName);
- currentInfFileDetails->hInf = SetupOpenInfFileW(filename, NULL, INF_STYLE_WIN4, NULL);
+ currentInfFileDetails->hInf = SetupOpenInfFileW(FullInfFileName, NULL, INF_STYLE_WIN4, NULL);
ReferenceInfFile(currentInfFileDetails);
if (currentInfFileDetails->hInf == INVALID_HANDLE_VALUE)
{
DriverAlreadyAdded = FALSE;
for (DriverRank = 0, currentId = (LPCWSTR)HardwareIDs; !DriverAlreadyAdded && *currentId; currentId += wcslen(currentId) + 1, DriverRank++)
{
- if (wcscmp(DeviceId, currentId) == 0)
+ if (wcsicmp(DeviceId, currentId) == 0)
{
AddDriverToList(
&((struct DeviceInfoElement *)DeviceInfoData->Reserved)->DriverListHead,
{
for (DriverRank = 0, currentId = (LPCWSTR)CompatibleIDs; !DriverAlreadyAdded && *currentId; currentId += wcslen(currentId) + 1, DriverRank++)
{
- if (wcscmp(DeviceId, currentId) == 0)
+ if (wcsicmp(DeviceId, currentId) == 0)
{
AddDriverToList(
&((struct DeviceInfoElement *)DeviceInfoData->Reserved)->DriverListHead,
HeapFree(GetProcessHeap(), 0, ManufacturerName);
HeapFree(GetProcessHeap(), 0, HardwareIDs);
HeapFree(GetProcessHeap(), 0, CompatibleIDs);
+ HeapFree(GetProcessHeap(), 0, FullInfFileName);
if (currentInfFileDetails)
DereferenceInfFile(currentInfFileDetails);
HeapFree(GetProcessHeap(), 0, Buffer);
TRACE("%p %p\n", DeviceInfoSet, DeviceInfoData);
FIXME("not implemented\n");
- SetLastError(ERROR_GEN_FAILURE);
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
else if (OpenFlags & ~(DIOD_CANCEL_REMOVE | DIOD_INHERIT_CLASSDRVS))
{
TRACE("Unknown flags: 0x%08lx\n", OpenFlags & ~(DIOD_CANCEL_REMOVE | DIOD_INHERIT_CLASSDRVS));
- SetLastError(ERROR_INVALID_PARAMETER);
+ SetLastError(ERROR_INVALID_FLAGS);
}
else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
SetLastError(ERROR_INVALID_USER_BUFFER);
RegCloseKey(hEnumKey);
if (rc != ERROR_SUCCESS)
{
+ if (rc == ERROR_FILE_NOT_FOUND)
+ rc = ERROR_NO_SUCH_DEVINST;
SetLastError(rc);
return FALSE;
}
- /* FIXME: GUID_NULL is not allowed */
- if (!CreateDeviceInfoElement(DeviceInstanceId, &GUID_NULL /* FIXME */, &deviceInfo))
+ /* FIXME: try to get ClassGUID from registry, instead of
+ * sending GUID_NULL to CreateDeviceInfoElement
+ */
+ if (!CreateDeviceInfoElement(list, DeviceInstanceId, &GUID_NULL, &deviceInfo))
{
RegCloseKey(hKey);
return FALSE;
if (ret && deviceInfo && DeviceInfoData)
{
memcpy(&DeviceInfoData->ClassGuid, &deviceInfo->ClassGuid, sizeof(GUID));
- DeviceInfoData->DevInst = 0; /* FIXME */
+ DeviceInfoData->DevInst = deviceInfo->dnDevInst;
DeviceInfoData->Reserved = (ULONG_PTR)deviceInfo;
}
}
return ret;
}
+
+/***********************************************************************
+ * SetupDiGetSelectedDriverA (SETUPAPI.@)
+ */
+BOOL WINAPI
+SetupDiGetSelectedDriverA(
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
+ OUT PSP_DRVINFO_DATA_A DriverInfoData)
+{
+ SP_DRVINFO_DATA_V2_W driverInfoData2W;
+ BOOL ret = FALSE;
+
+ if (DriverInfoData == NULL)
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else if (DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V1_A) && DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V2_A))
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ else
+ {
+ driverInfoData2W.cbSize = sizeof(SP_DRVINFO_DATA_V2_W);
+
+ ret = SetupDiGetSelectedDriverW(DeviceInfoSet,
+ DeviceInfoData,
+ &driverInfoData2W);
+
+ if (ret)
+ {
+ /* Do W->A conversion */
+ DriverInfoData->DriverType = driverInfoData2W.DriverType;
+ DriverInfoData->Reserved = driverInfoData2W.Reserved;
+ if (WideCharToMultiByte(CP_ACP, 0, driverInfoData2W.Description, -1,
+ DriverInfoData->Description, LINE_LEN, NULL, NULL) == 0)
+ {
+ DriverInfoData->Description[0] = '\0';
+ ret = FALSE;
+ }
+ if (WideCharToMultiByte(CP_ACP, 0, driverInfoData2W.MfgName, -1,
+ DriverInfoData->MfgName, LINE_LEN, NULL, NULL) == 0)
+ {
+ DriverInfoData->MfgName[0] = '\0';
+ ret = FALSE;
+ }
+ if (WideCharToMultiByte(CP_ACP, 0, driverInfoData2W.ProviderName, -1,
+ DriverInfoData->ProviderName, LINE_LEN, NULL, NULL) == 0)
+ {
+ DriverInfoData->ProviderName[0] = '\0';
+ ret = FALSE;
+ }
+ if (DriverInfoData->cbSize == sizeof(SP_DRVINFO_DATA_V2_A))
+ {
+ /* Copy more fields */
+ DriverInfoData->DriverDate = driverInfoData2W.DriverDate;
+ DriverInfoData->DriverVersion = driverInfoData2W.DriverVersion;
+ }
+ }
+ }
+
+ return ret;
+}
+
+
/***********************************************************************
* SetupDiGetSelectedDriverW (SETUPAPI.@)
*/
return ret;
}
+
+/***********************************************************************
+ * SetupDiSetSelectedDriverA (SETUPAPI.@)
+ */
+BOOL WINAPI
+SetupDiSetSelectedDriverA(
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
+ IN OUT PSP_DRVINFO_DATA_A DriverInfoData OPTIONAL)
+{
+ SP_DRVINFO_DATA_V1_W DriverInfoDataW;
+ PSP_DRVINFO_DATA_W pDriverInfoDataW = NULL;
+ BOOL ret = FALSE;
+
+ if (DriverInfoData != NULL)
+ {
+ if (DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V2_A) &&
+ DriverInfoData->cbSize != sizeof(SP_DRVINFO_DATA_V1_A));
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ DriverInfoDataW.cbSize = sizeof(SP_DRVINFO_DATA_V1_W);
+ DriverInfoDataW.Reserved = DriverInfoData->Reserved;
+
+ if (DriverInfoDataW.Reserved == 0)
+ {
+ DriverInfoDataW.DriverType = DriverInfoData->DriverType;
+
+ /* convert the strings to unicode */
+ if (!MultiByteToWideChar(CP_ACP,
+ 0,
+ DriverInfoData->Description,
+ LINE_LEN,
+ DriverInfoDataW.Description,
+ LINE_LEN) ||
+ !MultiByteToWideChar(CP_ACP,
+ 0,
+ DriverInfoData->ProviderName,
+ LINE_LEN,
+ DriverInfoDataW.ProviderName,
+ LINE_LEN))
+ {
+ return FALSE;
+ }
+ }
+
+ pDriverInfoDataW = (PSP_DRVINFO_DATA_W)&DriverInfoDataW;
+ }
+
+ ret = SetupDiSetSelectedDriverW(DeviceInfoSet,
+ DeviceInfoData,
+ pDriverInfoDataW);
+
+ if (ret && pDriverInfoDataW != NULL)
+ {
+ DriverInfoData->Reserved = DriverInfoDataW.Reserved;
+ }
+
+ return ret;
+}
+
+
/***********************************************************************
* SetupDiSetSelectedDriverW (SETUPAPI.@)
*/
{
BOOL ret = FALSE;
+ TRACE("%p %p %p %p %lu %p\n", DeviceInfoSet, DeviceInfoData,
+ DriverInfoData, DriverInfoDetailData,
+ DriverInfoDetailDataSize, RequiredSize);
+
if (!DeviceInfoSet)
SetLastError(ERROR_INVALID_PARAMETER);
else if (DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
SetLastError(ERROR_INVALID_PARAMETER);
else if (DriverInfoDetailData && DriverInfoDetailData->cbSize != sizeof(SP_DRVINFO_DETAIL_DATA_W))
SetLastError(ERROR_INVALID_USER_BUFFER);
- else if (DriverInfoDetailData && DriverInfoDetailData->Reserved == 0)
- SetLastError(ERROR_INVALID_PARAMETER);
+ else if (DriverInfoData->Reserved == 0)
+ SetLastError(ERROR_NO_DRIVER_SELECTED);
else
{
struct DriverInfoElement *driverInfoElement;
DWORD DoAction;
WCHAR SectionName[MAX_PATH];
DWORD SectionNameLength = 0;
- HKEY hKey = INVALID_HANDLE_VALUE;;
+ HKEY hKey = INVALID_HANDLE_VALUE;
InstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
Result = SetupDiGetDeviceInstallParamsW(DeviceInfoSet, DeviceInfoData, &InstallParams);
return TRUE;
}
+BOOL
+InfIsFromOEMLocation(
+ IN PCWSTR FullName,
+ OUT LPBOOL IsOEMLocation)
+{
+ PWCHAR last;
+
+ last = strrchrW(FullName, '\\');
+ if (!last)
+ {
+ /* No directory specified */
+ *IsOEMLocation = FALSE;
+ }
+ else
+ {
+ WCHAR Windir[MAX_PATH];
+ UINT ret;
+
+ ret = GetWindowsDirectory(Windir, MAX_PATH);
+ if (ret == 0 || ret >= MAX_PATH)
+ {
+ SetLastError(ERROR_GEN_FAILURE);
+ return FALSE;
+ }
+
+ if (strncmpW(FullName, Windir, last - FullName) == 0)
+ {
+ /* The path is %SYSTEMROOT%\Inf */
+ *IsOEMLocation = FALSE;
+ }
+ else
+ {
+ /* The file is in another place */
+ *IsOEMLocation = TRUE;
+ }
+ }
+ return TRUE;
+}
+
/***********************************************************************
* SetupDiInstallDevice (SETUPAPI.@)
*/
BOOL RebootRequired = FALSE;
HKEY hKey = INVALID_HANDLE_VALUE;
HKEY hClassKey = INVALID_HANDLE_VALUE;
+ BOOL NeedtoCopyFile;
LONG rc;
BOOL ret = FALSE; /* Return value */
NULL, 0,
&RequiredSize);
if (!Result)
- goto nextfile;
+ {
+ if (GetLastError() == ERROR_INVALID_PARAMETER)
+ {
+ /* This first is probably missing. It is not
+ * required, so ignore the error */
+ RequiredSize = 0;
+ Result = TRUE;
+ }
+ else
+ goto nextfile;
+ }
if (RequiredSize > 0)
{
/* We got the needed size for the buffer */
&RequiredSize);
if (!Result)
goto nextfile;
+
+ SetLastError(ERROR_SUCCESS);
+ Result = SetupInstallServicesFromInfSectionExW(
+ SelectedDriver->InfFileDetails->hInf,
+ ServiceSection, Flags, DeviceInfoSet, DeviceInfoData, ServiceName, NULL);
}
- SetLastError(ERROR_SUCCESS);
- Result = SetupInstallServicesFromInfSectionExW(
- SelectedDriver->InfFileDetails->hInf,
- ServiceSection, Flags, DeviceInfoSet, DeviceInfoData, ServiceName, NULL);
if (Result && (Flags & SPSVCINST_ASSOCSERVICE))
{
AssociatedService = ServiceName;
Result = SetupFindNextLine(&ContextService, &ContextService);
}
- /* Copy .inf file to Inf\ directory */
- FIXME("FIXME: Copy .inf file to Inf\\ directory\n"); /* SetupCopyOEMInf */
+ /* Copy .inf file to Inf\ directory (if needed) */
+ Result = InfIsFromOEMLocation(SelectedDriver->InfFileDetails->FullInfFileName, &NeedtoCopyFile);
+ if (!Result)
+ goto cleanup;
+ if (NeedtoCopyFile)
+ {
+ Result = SetupCopyOEMInfW(
+ SelectedDriver->InfFileDetails->FullInfFileName,
+ NULL,
+ SPOST_NONE,
+ SP_COPY_NOOVERWRITE,
+ NULL, 0,
+ NULL,
+ NULL);
+ if (!Result)
+ goto cleanup;
+ /* FIXME: create a new struct InfFileDetails, and set it to SelectedDriver->InfFileDetails,
+ * to release use of current InfFile */
+ }
/* Open device registry key */
hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_SET_VALUE);
/* Write information to enum key */
TRACE("Write information to enum key\n");
- TRACE("Service : '%S'\n", AssociatedService);
TRACE("Class : '%S'\n", ClassName);
TRACE("ClassGUID : '%S'\n", lpFullGuidString);
TRACE("DeviceDesc : '%S'\n", SelectedDriver->Info.Description);
TRACE("Mfg : '%S'\n", SelectedDriver->Info.MfgName);
- rc = RegSetValueEx(hKey, L"Service", 0, REG_SZ, (const BYTE *)AssociatedService, (wcslen(AssociatedService) + 1) * sizeof(WCHAR));
- if (rc == ERROR_SUCCESS)
- rc = RegSetValueEx(hKey, L"Class", 0, REG_SZ, (const BYTE *)ClassName, (wcslen(ClassName) + 1) * sizeof(WCHAR));
+ TRACE("Service : '%S'\n", AssociatedService);
+ rc = RegSetValueEx(hKey, L"Class", 0, REG_SZ, (const BYTE *)ClassName, (wcslen(ClassName) + 1) * sizeof(WCHAR));
if (rc == ERROR_SUCCESS)
rc = RegSetValueEx(hKey, L"ClassGUID", 0, REG_SZ, (const BYTE *)lpFullGuidString, (wcslen(lpFullGuidString) + 1) * sizeof(WCHAR));
if (rc == ERROR_SUCCESS)
rc = RegSetValueEx(hKey, L"DeviceDesc", 0, REG_SZ, (const BYTE *)SelectedDriver->Info.Description, (wcslen(SelectedDriver->Info.Description) + 1) * sizeof(WCHAR));
if (rc == ERROR_SUCCESS)
rc = RegSetValueEx(hKey, L"Mfg", 0, REG_SZ, (const BYTE *)SelectedDriver->Info.MfgName, (wcslen(SelectedDriver->Info.MfgName) + 1) * sizeof(WCHAR));
+ if (rc == ERROR_SUCCESS && *AssociatedService)
+ rc = RegSetValueEx(hKey, L"Service", 0, REG_SZ, (const BYTE *)AssociatedService, (wcslen(AssociatedService) + 1) * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
SetLastError(rc);