case CR_NO_SUCH_VALUE: return ERROR_FILE_NOT_FOUND;
case CR_OUT_OF_MEMORY: return ERROR_NOT_ENOUGH_MEMORY;
case CR_REGISTRY_ERROR: return ERROR_GEN_FAILURE;
+ case CR_ALREADY_SUCH_DEVINST: return ERROR_DEVINST_ALREADY_EXISTS;
case CR_SUCCESS: return ERROR_SUCCESS;
default: return ERROR_GEN_FAILURE;
}
OUT PDWORD ScoreSuiteMask)
{
LPWSTR Section = NULL;
- LPCWSTR pExtensionPlatform, pExtensionArchitecture;
+ //LPCWSTR pExtensionPlatform;
+ LPCWSTR pExtensionArchitecture;
LPWSTR Fields[6];
DWORD i;
BOOL ret = FALSE;
- static const WCHAR ExtensionPlatformNone[] = {'.',0};
+ //static const WCHAR ExtensionPlatformNone[] = {'.',0};
static const WCHAR ExtensionPlatformNT[] = {'.','N','T',0};
static const WCHAR ExtensionPlatformWindows[] = {'.','W','i','n',0};
*ScorePlatform = *ScoreMajorVersion = *ScoreMinorVersion = *ScoreProductType = *ScoreSuiteMask = 0;
- Section = DuplicateString(SectionName);
+ Section = pSetupDuplicateString(SectionName);
if (!Section)
{
- TRACE("DuplicateString() failed\n");
+ TRACE("pSetupDuplicateString() failed\n");
goto cleanup;
}
switch (PlatformInfo->Platform)
{
case VER_PLATFORM_WIN32_WINDOWS:
- pExtensionPlatform = ExtensionPlatformWindows;
+ //pExtensionPlatform = ExtensionPlatformWindows;
break;
case VER_PLATFORM_WIN32_NT:
- pExtensionPlatform = ExtensionPlatformNT;
+ //pExtensionPlatform = ExtensionPlatformNT;
break;
default:
ERR("Unknown platform 0x%lx\n", PlatformInfo->Platform);
- pExtensionPlatform = ExtensionPlatformNone;
+ //pExtensionPlatform = ExtensionPlatformNone;
break;
}
switch (PlatformInfo->ProcessorArchitecture)
if (MachineName)
{
- MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
+ MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
if (MachineNameW == NULL) return FALSE;
}
Reserved);
if (hClassesKey == INVALID_HANDLE_VALUE)
{
- return FALSE;
+ return FALSE;
}
for (dwIndex = 0; ; dwIndex++)
{
- dwLength = 40;
- lError = RegEnumKeyExW(hClassesKey,
- dwIndex,
- szKeyName,
- &dwLength,
- NULL,
- NULL,
- NULL,
- NULL);
- TRACE("RegEnumKeyExW() returns %d\n", lError);
- if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
- {
- TRACE("Key name: %s\n", debugstr_w(szKeyName));
-
- if (RegOpenKeyExW(hClassesKey,
- szKeyName,
- 0,
- KEY_QUERY_VALUE,
- &hClassKey))
- {
- RegCloseKey(hClassesKey);
- return FALSE;
- }
-
- if (!RegQueryValueExW(hClassKey,
- REGSTR_VAL_NOUSECLASS,
- NULL,
- NULL,
- NULL,
- NULL))
- {
- TRACE("'NoUseClass' value found!\n");
- RegCloseKey(hClassKey);
- continue;
- }
-
- if ((Flags & DIBCI_NOINSTALLCLASS) &&
- (!RegQueryValueExW(hClassKey,
- REGSTR_VAL_NOINSTALLCLASS,
- NULL,
- NULL,
- NULL,
- NULL)))
- {
- TRACE("'NoInstallClass' value found!\n");
- RegCloseKey(hClassKey);
- continue;
- }
-
- if ((Flags & DIBCI_NODISPLAYCLASS) &&
- (!RegQueryValueExW(hClassKey,
- REGSTR_VAL_NODISPLAYCLASS,
- NULL,
- NULL,
- NULL,
- NULL)))
- {
- TRACE("'NoDisplayClass' value found!\n");
- RegCloseKey(hClassKey);
- continue;
- }
-
- RegCloseKey(hClassKey);
-
- TRACE("Guid: %s\n", debugstr_w(szKeyName));
- if (dwGuidListIndex < ClassGuidListSize)
- {
- if (szKeyName[0] == '{' && szKeyName[37] == '}')
- {
- szKeyName[37] = 0;
- }
- TRACE("Guid: %p\n", &szKeyName[1]);
-
- UuidFromStringW(&szKeyName[1],
- &ClassGuidList[dwGuidListIndex]);
- }
-
- dwGuidListIndex++;
- }
-
- if (lError != ERROR_SUCCESS)
- break;
+ dwLength = 40;
+ lError = RegEnumKeyExW(hClassesKey,
+ dwIndex,
+ szKeyName,
+ &dwLength,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ TRACE("RegEnumKeyExW() returns %d\n", lError);
+ if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
+ {
+ TRACE("Key name: %s\n", debugstr_w(szKeyName));
+
+ if (RegOpenKeyExW(hClassesKey,
+ szKeyName,
+ 0,
+ KEY_QUERY_VALUE,
+ &hClassKey))
+ {
+ RegCloseKey(hClassesKey);
+ return FALSE;
+ }
+
+ if (!RegQueryValueExW(hClassKey,
+ REGSTR_VAL_NOUSECLASS,
+ NULL,
+ NULL,
+ NULL,
+ NULL))
+ {
+ TRACE("'NoUseClass' value found!\n");
+ RegCloseKey(hClassKey);
+ continue;
+ }
+
+ if ((Flags & DIBCI_NOINSTALLCLASS) &&
+ (!RegQueryValueExW(hClassKey,
+ REGSTR_VAL_NOINSTALLCLASS,
+ NULL,
+ NULL,
+ NULL,
+ NULL)))
+ {
+ TRACE("'NoInstallClass' value found!\n");
+ RegCloseKey(hClassKey);
+ continue;
+ }
+
+ if ((Flags & DIBCI_NODISPLAYCLASS) &&
+ (!RegQueryValueExW(hClassKey,
+ REGSTR_VAL_NODISPLAYCLASS,
+ NULL,
+ NULL,
+ NULL,
+ NULL)))
+ {
+ TRACE("'NoDisplayClass' value found!\n");
+ RegCloseKey(hClassKey);
+ continue;
+ }
+
+ RegCloseKey(hClassKey);
+
+ TRACE("Guid: %s\n", debugstr_w(szKeyName));
+ if (dwGuidListIndex < ClassGuidListSize)
+ {
+ if (szKeyName[0] == '{' && szKeyName[37] == '}')
+ {
+ szKeyName[37] = 0;
+ }
+ TRACE("Guid: %p\n", &szKeyName[1]);
+
+ UuidFromStringW(&szKeyName[1],
+ &ClassGuidList[dwGuidListIndex]);
+ }
+
+ dwGuidListIndex++;
+ }
+
+ if (lError != ERROR_SUCCESS)
+ break;
}
RegCloseKey(hClassesKey);
if (RequiredSize != NULL)
- *RequiredSize = dwGuidListIndex;
+ *RequiredSize = dwGuidListIndex;
if (ClassGuidListSize < dwGuidListIndex)
{
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return FALSE;
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ return FALSE;
}
return TRUE;
DWORD ClassGuidListSize,
PDWORD RequiredSize)
{
- return SetupDiClassGuidsFromNameExA(ClassName, ClassGuidList,
- ClassGuidListSize, RequiredSize,
- NULL, NULL);
+ return SetupDiClassGuidsFromNameExA(ClassName, ClassGuidList,
+ ClassGuidListSize, RequiredSize,
+ NULL, NULL);
}
/***********************************************************************
DWORD ClassGuidListSize,
PDWORD RequiredSize)
{
- return SetupDiClassGuidsFromNameExW(ClassName, ClassGuidList,
- ClassGuidListSize, RequiredSize,
- NULL, NULL);
+ return SetupDiClassGuidsFromNameExW(ClassName, ClassGuidList,
+ ClassGuidListSize, RequiredSize,
+ NULL, NULL);
}
/***********************************************************************
return FALSE;
}
- ClassNameW = MultiByteToUnicode(ClassName, CP_ACP);
+ ClassNameW = pSetupMultiByteToUnicode(ClassName, CP_ACP);
if (ClassNameW == NULL)
return FALSE;
if (MachineName)
{
- MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
+ MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
if (MachineNameW == NULL)
{
MyFree(ClassNameW);
ClassGuidListSize, RequiredSize, debugstr_w(MachineName), Reserved);
if (!ClassName || !RequiredSize)
- {
+ {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- *RequiredSize = 0;
+ *RequiredSize = 0;
hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
KEY_ENUMERATE_SUB_KEYS,
Reserved);
if (hClassesKey == INVALID_HANDLE_VALUE)
{
- return FALSE;
+ return FALSE;
}
for (dwIndex = 0; ; dwIndex++)
{
- dwLength = 40;
- lError = RegEnumKeyExW(hClassesKey,
- dwIndex,
- szKeyName,
- &dwLength,
- NULL,
- NULL,
- NULL,
- NULL);
- TRACE("RegEnumKeyExW() returns %d\n", lError);
- if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
- {
- TRACE("Key name: %p\n", szKeyName);
-
- if (RegOpenKeyExW(hClassesKey,
- szKeyName,
- 0,
- KEY_QUERY_VALUE,
- &hClassKey))
- {
- RegCloseKey(hClassesKey);
- return FALSE;
- }
-
- dwLength = MAX_CLASS_NAME_LEN * sizeof(WCHAR);
- if (!RegQueryValueExW(hClassKey,
- Class,
- NULL,
- NULL,
- (LPBYTE)szClassName,
- &dwLength))
- {
- TRACE("Class name: %p\n", szClassName);
-
- if (strcmpiW(szClassName, ClassName) == 0)
- {
- TRACE("Found matching class name\n");
-
- TRACE("Guid: %p\n", szKeyName);
- if (dwGuidListIndex < ClassGuidListSize)
- {
- if (szKeyName[0] == '{' && szKeyName[37] == '}')
- {
- szKeyName[37] = 0;
- }
- TRACE("Guid: %p\n", &szKeyName[1]);
-
- UuidFromStringW(&szKeyName[1],
- &ClassGuidList[dwGuidListIndex]);
- }
-
- dwGuidListIndex++;
- }
- }
-
- RegCloseKey(hClassKey);
- }
-
- if (lError != ERROR_SUCCESS)
- break;
+ dwLength = 40;
+ lError = RegEnumKeyExW(hClassesKey,
+ dwIndex,
+ szKeyName,
+ &dwLength,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ TRACE("RegEnumKeyExW() returns %d\n", lError);
+ if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
+ {
+ TRACE("Key name: %p\n", szKeyName);
+
+ if (RegOpenKeyExW(hClassesKey,
+ szKeyName,
+ 0,
+ KEY_QUERY_VALUE,
+ &hClassKey))
+ {
+ RegCloseKey(hClassesKey);
+ return FALSE;
+ }
+
+ dwLength = MAX_CLASS_NAME_LEN * sizeof(WCHAR);
+ if (!RegQueryValueExW(hClassKey,
+ Class,
+ NULL,
+ NULL,
+ (LPBYTE)szClassName,
+ &dwLength))
+ {
+ TRACE("Class name: %p\n", szClassName);
+
+ if (strcmpiW(szClassName, ClassName) == 0)
+ {
+ TRACE("Found matching class name\n");
+
+ TRACE("Guid: %p\n", szKeyName);
+ if (dwGuidListIndex < ClassGuidListSize)
+ {
+ if (szKeyName[0] == '{' && szKeyName[37] == '}')
+ {
+ szKeyName[37] = 0;
+ }
+ TRACE("Guid: %p\n", &szKeyName[1]);
+
+ UuidFromStringW(&szKeyName[1],
+ &ClassGuidList[dwGuidListIndex]);
+ }
+
+ dwGuidListIndex++;
+ }
+ }
+
+ RegCloseKey(hClassKey);
+ }
+
+ if (lError != ERROR_SUCCESS)
+ break;
}
RegCloseKey(hClassesKey);
if (RequiredSize != NULL)
- *RequiredSize = dwGuidListIndex;
+ *RequiredSize = dwGuidListIndex;
if (ClassGuidListSize < dwGuidListIndex)
{
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return FALSE;
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ return FALSE;
}
return TRUE;
DWORD ClassNameSize,
PDWORD RequiredSize)
{
- return SetupDiClassNameFromGuidExA(ClassGuid, ClassName,
- ClassNameSize, RequiredSize,
- NULL, NULL);
+ return SetupDiClassNameFromGuidExA(ClassGuid, ClassName,
+ ClassNameSize, RequiredSize,
+ NULL, NULL);
}
/***********************************************************************
DWORD ClassNameSize,
PDWORD RequiredSize)
{
- return SetupDiClassNameFromGuidExW(ClassGuid, ClassName,
- ClassNameSize, RequiredSize,
- NULL, NULL);
+ return SetupDiClassNameFromGuidExW(ClassGuid, ClassName,
+ ClassNameSize, RequiredSize,
+ NULL, NULL);
}
/***********************************************************************
BOOL ret;
if (MachineName)
- MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
+ MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
ret = SetupDiClassNameFromGuidExW(ClassGuid, ClassNameW, MAX_CLASS_NAME_LEN,
- NULL, MachineNameW, Reserved);
+ RequiredSize, MachineNameW, Reserved);
if (ret)
{
int len = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName,
- ClassNameSize, NULL, NULL);
+ ClassNameSize, NULL, NULL);
if (len == 0 || len > ClassNameSize)
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
ret = FALSE;
}
- else if (RequiredSize)
- *RequiredSize = len;
}
MyFree(MachineNameW);
return ret;
DWORD dwLength;
DWORD dwRegType;
LONG rc;
+ PWSTR Buffer;
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,
- MachineName,
- Reserved);
- if (hKey == INVALID_HANDLE_VALUE)
+ /* Make sure there's a GUID */
+ if (ClassGuid == NULL)
{
- return FALSE;
+ SetLastError(ERROR_INVALID_CLASS); /* On Vista: ERROR_INVALID_USER_BUFFER */
+ return FALSE;
}
- if (RequiredSize != NULL)
+ /* Make sure there's a real buffer when there's a size */
+ if ((ClassNameSize > 0) && (ClassName == NULL))
{
- dwLength = 0;
- if (RegQueryValueExW(hKey,
- Class,
- NULL,
- NULL,
- NULL,
- &dwLength))
- {
- RegCloseKey(hKey);
- return FALSE;
- }
-
- *RequiredSize = dwLength / sizeof(WCHAR) + 1;
+ SetLastError(ERROR_INVALID_PARAMETER); /* On Vista: ERROR_INVALID_USER_BUFFER */
+ return FALSE;
}
- if (!ClassGuid)
+ /* Open the key for the GUID */
+ hKey = SetupDiOpenClassRegKeyExW(ClassGuid, KEY_QUERY_VALUE, DIOCR_INSTALLER, MachineName, Reserved);
+
+ if (hKey == INVALID_HANDLE_VALUE)
+ return FALSE;
+
+ /* Retrieve the class name data and close the key */
+ rc = QueryRegistryValue(hKey, Class, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
+ RegCloseKey(hKey);
+
+ /* Make sure we got the data */
+ if (rc != ERROR_SUCCESS)
{
- SetLastError(ERROR_INVALID_CLASS);
- RegCloseKey(hKey);
+ SetLastError(rc);
return FALSE;
}
- if (!ClassName && ClassNameSize > 0)
+
+ /* Make sure the data is a string */
+ if (dwRegType != REG_SZ)
{
- SetLastError(ERROR_INVALID_PARAMETER);
- RegCloseKey(hKey);
+ MyFree(Buffer);
+ SetLastError(ERROR_GEN_FAILURE);
return FALSE;
}
- dwLength = ClassNameSize * sizeof(WCHAR) - sizeof(UNICODE_NULL);
- rc = RegQueryValueExW(hKey,
- Class,
- NULL,
- &dwRegType,
- (LPBYTE)ClassName,
- &dwLength);
- if (rc != ERROR_SUCCESS)
+ /* Determine the length of the class name */
+ dwLength /= sizeof(WCHAR);
+
+ if ((dwLength == 0) || (Buffer[dwLength - 1] != UNICODE_NULL))
+ /* Count the null-terminator */
+ dwLength++;
+
+ /* Inform the caller about the class name */
+ if ((ClassName != NULL) && (dwLength <= ClassNameSize))
{
- SetLastError(rc);
- RegCloseKey(hKey);
- return FALSE;
+ memcpy(ClassName, Buffer, (dwLength - 1) * sizeof(WCHAR));
+ ClassName[dwLength - 1] = UNICODE_NULL;
}
- if (dwRegType != REG_SZ)
+
+ /* Inform the caller about the required size */
+ if (RequiredSize != NULL)
+ *RequiredSize = dwLength;
+
+ /* Clean up the buffer */
+ MyFree(Buffer);
+
+ /* Make sure the buffer was large enough */
+ if ((ClassName == NULL) || (dwLength > ClassNameSize))
{
- SetLastError(ERROR_GEN_FAILURE);
- RegCloseKey(hKey);
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
-
- if (ClassNameSize > 1)
- ClassName[ClassNameSize] = UNICODE_NULL;
- RegCloseKey(hKey);
return TRUE;
}
*/
HDEVINFO WINAPI
SetupDiCreateDeviceInfoList(const GUID *ClassGuid,
- HWND hwndParent)
+ HWND hwndParent)
{
- return SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent, NULL, NULL);
+ return SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent, NULL, NULL);
}
/***********************************************************************
*/
HDEVINFO WINAPI
SetupDiCreateDeviceInfoListExA(const GUID *ClassGuid,
- HWND hwndParent,
- PCSTR MachineName,
- PVOID Reserved)
+ HWND hwndParent,
+ PCSTR MachineName,
+ PVOID Reserved)
{
LPWSTR MachineNameW = NULL;
HDEVINFO hDevInfo;
if (MachineName)
{
- MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
+ MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
if (MachineNameW == NULL)
return INVALID_HANDLE_VALUE;
}
*/
HDEVINFO WINAPI
SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid,
- HWND hwndParent,
- PCWSTR MachineName,
- PVOID Reserved)
+ HWND hwndParent,
+ PCWSTR MachineName,
+ PVOID Reserved)
{
struct DeviceInfoSet *list = NULL;
DWORD size = FIELD_OFFSET(struct DeviceInfoSet, szData);
SetLastError(ERROR_INVALID_MACHINENAME);
goto cleanup;
}
- size += (len + 3) * sizeof(WCHAR);
+ if(len > 0)
+ size += (len + 3) * sizeof(WCHAR);
+ else
+ MachineName = NULL;
}
if (Reserved != NULL)
}
else
{
- InfSectionNameW = MultiByteToUnicode(InfSectionName, CP_ACP);
+ InfSectionNameW = pSetupMultiByteToUnicode(InfSectionName, CP_ACP);
if (InfSectionNameW == NULL) return INVALID_HANDLE_VALUE;
}
}
LPWSTR DriverKey = NULL; /* {GUID}\Index */
LPWSTR pDeviceInstance; /* Points into DriverKey, on the Index field */
DWORD Index; /* Index used in the DriverKey name */
+ DWORD dwSize;
+ DWORD Disposition;
DWORD rc;
HKEY hHWProfileKey = INVALID_HANDLE_VALUE;
HKEY hEnumKey = NULL;
}
else /* KeyType == DIREG_DRV */
{
- if (UuidToStringW((UUID*)&DeviceInfoData->ClassGuid, &lpGuidString) != RPC_S_OK)
- goto cleanup;
- /* The driver key is in \System\CurrentControlSet\Control\Class\{GUID}\Index */
- DriverKey = HeapAlloc(GetProcessHeap(), 0, (strlenW(lpGuidString) + 7) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
- if (!DriverKey)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ /* Open device key, to read Driver value */
+ hDeviceKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, Scope, HwProfile, DIREG_DEV, KEY_QUERY_VALUE | KEY_SET_VALUE);
+ if (hDeviceKey == INVALID_HANDLE_VALUE)
goto cleanup;
- }
- DriverKey[0] = '{';
- strcpyW(&DriverKey[1], lpGuidString);
- pDeviceInstance = &DriverKey[strlenW(DriverKey)];
- *pDeviceInstance++ = '}';
- *pDeviceInstance++ = '\\';
- rc = RegOpenKeyExW(RootKey,
- REGSTR_PATH_CLASS_NT,
- 0,
- KEY_CREATE_SUB_KEY,
- &hClassKey);
+
+ rc = RegOpenKeyExW(RootKey, REGSTR_PATH_CLASS_NT, 0, KEY_CREATE_SUB_KEY, &hClassKey);
if (rc != ERROR_SUCCESS)
{
SetLastError(rc);
goto cleanup;
}
- /* Try all values for Index between 0 and 9999 */
- Index = 0;
- while (Index <= 9999)
+ rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, NULL, &dwSize);
+ if (rc != ERROR_SUCCESS)
+ {
+ /* Create a new driver key */
+
+ if (UuidToStringW((UUID*)&DeviceInfoData->ClassGuid, &lpGuidString) != RPC_S_OK)
+ goto cleanup;
+
+ /* The driver key is in \System\CurrentControlSet\Control\Class\{GUID}\Index */
+ DriverKey = HeapAlloc(GetProcessHeap(), 0, (strlenW(lpGuidString) + 7) * sizeof(WCHAR) + sizeof(UNICODE_NULL));
+ if (!DriverKey)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+
+ DriverKey[0] = '{';
+ strcpyW(&DriverKey[1], lpGuidString);
+ pDeviceInstance = &DriverKey[strlenW(DriverKey)];
+ *pDeviceInstance++ = '}';
+ *pDeviceInstance++ = '\\';
+
+ /* Try all values for Index between 0 and 9999 */
+ Index = 0;
+ while (Index <= 9999)
+ {
+ sprintfW(pDeviceInstance, InstanceKeyFormat, Index);
+ rc = RegCreateKeyExW(hClassKey,
+ DriverKey,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+#if _WIN32_WINNT >= 0x502
+ KEY_READ | KEY_WRITE,
+#else
+ KEY_ALL_ACCESS,
+#endif
+ NULL,
+ &hKey,
+ &Disposition);
+ if (rc != ERROR_SUCCESS)
+ {
+ SetLastError(rc);
+ goto cleanup;
+ }
+ if (Disposition == REG_CREATED_NEW_KEY)
+ break;
+ RegCloseKey(hKey);
+ hKey = NULL;
+ Index++;
+ }
+
+ if (Index > 9999)
+ {
+ /* Unable to create more than 9999 devices within the same class */
+ SetLastError(ERROR_GEN_FAILURE);
+ goto cleanup;
+ }
+
+ /* Write the new Driver value */
+ rc = RegSetValueExW(hDeviceKey, REGSTR_VAL_DRIVER, 0, REG_SZ, (const BYTE *)DriverKey, (strlenW(DriverKey) + 1) * sizeof(WCHAR));
+ if (rc != ERROR_SUCCESS)
+ {
+ SetLastError(rc);
+ goto cleanup;
+ }
+
+ }
+ else
{
- DWORD Disposition;
- sprintfW(pDeviceInstance, InstanceKeyFormat, Index);
+ /* Open the existing driver key */
+
+ DriverKey = HeapAlloc(GetProcessHeap(), 0, dwSize);
+ if (!DriverKey)
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ goto cleanup;
+ }
+
+ rc = RegQueryValueExW(hDeviceKey, REGSTR_VAL_DRIVER, NULL, NULL, (LPBYTE)DriverKey, &dwSize);
+ if (rc != ERROR_SUCCESS)
+ {
+ SetLastError(rc);
+ goto cleanup;
+ }
+
rc = RegCreateKeyExW(hClassKey,
DriverKey,
0,
SetLastError(rc);
goto cleanup;
}
- if (Disposition == REG_CREATED_NEW_KEY)
- break;
- RegCloseKey(hKey);
- hKey = NULL;
- Index++;
- }
- if (Index > 9999)
- {
- /* Unable to create more than 9999 devices within the same class */
- SetLastError(ERROR_GEN_FAILURE);
- goto cleanup;
- }
-
- /* Open device key, to write Driver value */
- hDeviceKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, Scope, HwProfile, DIREG_DEV, KEY_SET_VALUE);
- if (hDeviceKey == INVALID_HANDLE_VALUE)
- goto cleanup;
- rc = RegSetValueExW(hDeviceKey, REGSTR_VAL_DRIVER, 0, REG_SZ, (const BYTE *)DriverKey, (strlenW(DriverKey) + 1) * sizeof(WCHAR));
- if (rc != ERROR_SUCCESS)
- {
- SetLastError(rc);
- goto cleanup;
}
}
* SetupDiCreateDeviceInfoA (SETUPAPI.@)
*/
BOOL WINAPI SetupDiCreateDeviceInfoA(
- HDEVINFO DeviceInfoSet,
- PCSTR DeviceName,
- CONST GUID *ClassGuid,
- PCSTR DeviceDescription,
- HWND hwndParent,
- DWORD CreationFlags,
- PSP_DEVINFO_DATA DeviceInfoData)
+ HDEVINFO DeviceInfoSet,
+ PCSTR DeviceName,
+ CONST GUID *ClassGuid,
+ PCSTR DeviceDescription,
+ HWND hwndParent,
+ DWORD CreationFlags,
+ PSP_DEVINFO_DATA DeviceInfoData)
{
BOOL ret;
LPWSTR DeviceNameW = NULL;
if (DeviceName)
{
- DeviceNameW = MultiByteToUnicode(DeviceName, CP_ACP);
+ DeviceNameW = pSetupMultiByteToUnicode(DeviceName, CP_ACP);
if (DeviceNameW == NULL) return FALSE;
}
if (DeviceDescription)
{
- DeviceDescriptionW = MultiByteToUnicode(DeviceDescription, CP_ACP);
+ DeviceDescriptionW = pSetupMultiByteToUnicode(DeviceDescription, CP_ACP);
if (DeviceDescriptionW == NULL)
{
MyFree(DeviceNameW);
* SetupDiCreateDeviceInfoW (SETUPAPI.@)
*/
BOOL WINAPI SetupDiCreateDeviceInfoW(
- HDEVINFO DeviceInfoSet,
- PCWSTR DeviceName,
- CONST GUID *ClassGuid,
- PCWSTR DeviceDescription,
- HWND hwndParent,
- DWORD CreationFlags,
- PSP_DEVINFO_DATA DeviceInfoData)
+ HDEVINFO DeviceInfoSet,
+ PCWSTR DeviceName,
+ CONST GUID *ClassGuid,
+ PCWSTR DeviceDescription,
+ HWND hwndParent,
+ DWORD CreationFlags,
+ PSP_DEVINFO_DATA DeviceInfoData)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
+ struct DeviceInfo *deviceInfo = NULL;
BOOL ret = FALSE;
- SP_DEVINFO_DATA DevInfo;
+ CONFIGRET cr;
+ DEVINST RootDevInst;
+ DEVINST DevInst;
TRACE("%p %s %s %s %p %x %p\n", DeviceInfoSet, debugstr_w(DeviceName),
debugstr_guid(ClassGuid), debugstr_w(DeviceDescription),
return FALSE;
}
- if (CreationFlags & DICD_GENERATE_ID)
- {
- /* Generate a new unique ID for this device */
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- FIXME("not implemented\n");
- }
+ /* Get the root device instance */
+ cr = CM_Locate_DevInst_ExW(&RootDevInst,
+ NULL,
+ CM_LOCATE_DEVINST_NORMAL,
+ set->hMachine);
+ if (cr != CR_SUCCESS)
+ {
+ SetLastError(ERROR_INVALID_DATA);
+ return FALSE;
+ }
+
+ /* Create the new device instance */
+ cr = CM_Create_DevInst_ExW(&DevInst,
+ (DEVINSTID)DeviceName,
+ RootDevInst,
+ 0,
+ set->hMachine);
+ if (cr != CR_SUCCESS)
+ {
+ SetLastError(GetErrorCodeFromCrCode(cr));
+ return FALSE;
+ }
+
+ if (CreateDeviceInfo(set, DeviceName, ClassGuid, &deviceInfo))
+ {
+ InsertTailList(&set->ListHead, &deviceInfo->ListEntry);
+
+ if (!DeviceInfoData)
+ ret = TRUE;
else
{
- /* Device name is fully qualified. Try to open it */
- BOOL rc;
-
- DevInfo.cbSize = sizeof(SP_DEVINFO_DATA);
- rc = SetupDiOpenDeviceInfoW(
- DeviceInfoSet,
- DeviceName,
- NULL, /* hwndParent */
- CreationFlags & DICD_INHERIT_CLASSDRVS ? DIOD_INHERIT_CLASSDRVS : 0,
- &DevInfo);
-
- if (rc)
+ if (DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
{
- /* SetupDiOpenDeviceInfoW has already added
- * the device info to the device info set
- */
- SetLastError(ERROR_DEVINST_ALREADY_EXISTS);
+ SetLastError(ERROR_INVALID_USER_BUFFER);
}
- else if (GetLastError() == ERROR_FILE_NOT_FOUND)
+ else
{
- struct DeviceInfo *deviceInfo;
+ memcpy(&DeviceInfoData->ClassGuid, ClassGuid, sizeof(GUID));
+ DeviceInfoData->DevInst = deviceInfo->dnDevInst;
+ DeviceInfoData->Reserved = (ULONG_PTR)deviceInfo;
+ ret = TRUE;
+ }
+ }
+ }
- if (CreateDeviceInfo(set, DeviceName, ClassGuid, &deviceInfo))
- {
- InsertTailList(&set->ListHead, &deviceInfo->ListEntry);
+ if (ret == FALSE)
+ {
+ if (deviceInfo != NULL)
+ {
+ /* Remove deviceInfo from List */
+ RemoveEntryList(&deviceInfo->ListEntry);
- if (!DeviceInfoData)
- ret = TRUE;
- else
- {
- if (DeviceInfoData->cbSize != sizeof(PSP_DEVINFO_DATA))
- {
- SetLastError(ERROR_INVALID_USER_BUFFER);
- }
- else
- {
- memcpy(&DeviceInfoData->ClassGuid, ClassGuid, sizeof(GUID));
- DeviceInfoData->DevInst = deviceInfo->dnDevInst;
- DeviceInfoData->Reserved = (ULONG_PTR)deviceInfo;
- ret = TRUE;
- }
- }
- }
- }
+ /* Destroy deviceInfo */
+ DestroyDeviceInfo(deviceInfo);
}
+ }
TRACE("Returning %d\n", ret);
return ret;
PSP_DEVINFO_DATA DupDeviceInfoData)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
+ WCHAR DevInstId[MAX_DEVICE_ID_LEN];
+ DEVINST ParentDevInst;
+ CONFIGRET cr;
+ DWORD dwError = ERROR_SUCCESS;
TRACE("%p %p %08x %p %p %p\n", DeviceInfoSet, DeviceInfoData, Flags,
CompareProc, CompareContext, DupDeviceInfoData);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- FIXME("Stub %p %p 0x%lx %p %p %p\n", DeviceInfoSet, DeviceInfoData, Flags,
- CompareProc, CompareContext, DupDeviceInfoData);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+
+ if (Flags & ~SPRDI_FIND_DUPS)
+ {
+ TRACE("Unknown flags: 0x%08lx\n", Flags & ~SPRDI_FIND_DUPS);
+ SetLastError(ERROR_INVALID_FLAGS);
+ return FALSE;
+ }
+
+ if (Flags & SPRDI_FIND_DUPS)
+ {
+ FIXME("Unimplemented codepath!\n");
+ }
+
+ CM_Get_Device_ID_Ex(DeviceInfoData->DevInst,
+ DevInstId,
+ MAX_DEVICE_ID_LEN,
+ 0,
+ set->hMachine);
+
+ CM_Get_Parent_Ex(&ParentDevInst,
+ DeviceInfoData->DevInst,
+ 0,
+ set->hMachine);
+
+ cr = CM_Create_DevInst_Ex(&DeviceInfoData->DevInst,
+ DevInstId,
+ ParentDevInst,
+ CM_CREATE_DEVINST_NORMAL | CM_CREATE_DEVINST_DO_NOT_INSTALL,
+ set->hMachine);
+ if (cr != CR_SUCCESS)
+ {
+ dwError = ERROR_NO_SUCH_DEVINST;
+ }
+
+ SetLastError(dwError);
+
+ return (dwError == ERROR_SUCCESS);
}
/***********************************************************************
* SetupDiGetDeviceInstanceIdA (SETUPAPI.@)
*/
BOOL WINAPI SetupDiGetDeviceInstanceIdA(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- PSTR DeviceInstanceId,
- DWORD DeviceInstanceIdSize,
- PDWORD RequiredSize)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ PSTR DeviceInstanceId,
+ DWORD DeviceInstanceIdSize,
+ PDWORD RequiredSize)
{
BOOL ret = FALSE;
DWORD size;
PWSTR instanceId;
TRACE("%p %p %p %d %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstanceId,
- DeviceInstanceIdSize, RequiredSize);
+ DeviceInstanceIdSize, RequiredSize);
if (!DeviceInstanceId && DeviceInstanceIdSize > 0)
{
* SetupDiGetDeviceInstanceIdW (SETUPAPI.@)
*/
BOOL WINAPI SetupDiGetDeviceInstanceIdW(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- PWSTR DeviceInstanceId,
- DWORD DeviceInstanceIdSize,
- PDWORD RequiredSize)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ PWSTR DeviceInstanceId,
+ DWORD DeviceInstanceIdSize,
+ PDWORD RequiredSize)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
struct DeviceInfo *devInfo;
TRACE("%p %p %p %d %p\n", DeviceInfoSet, DeviceInfoData, DeviceInstanceId,
- DeviceInstanceIdSize, RequiredSize);
+ DeviceInstanceIdSize, RequiredSize);
if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
{
*/
BOOL WINAPI
SetupDiGetActualSectionToInstallExA(
- IN HINF InfHandle,
- IN PCSTR InfSectionName,
- IN PSP_ALTPLATFORM_INFO AlternatePlatformInfo OPTIONAL,
- OUT PSTR InfSectionWithExt OPTIONAL,
- IN DWORD InfSectionWithExtSize,
- OUT PDWORD RequiredSize OPTIONAL,
- OUT PSTR* Extension OPTIONAL,
- IN PVOID Reserved)
+ IN HINF InfHandle,
+ IN PCSTR InfSectionName,
+ IN PSP_ALTPLATFORM_INFO AlternatePlatformInfo OPTIONAL,
+ OUT PSTR InfSectionWithExt OPTIONAL,
+ IN DWORD InfSectionWithExtSize,
+ OUT PDWORD RequiredSize OPTIONAL,
+ OUT PSTR* Extension OPTIONAL,
+ IN PVOID Reserved)
{
LPWSTR InfSectionNameW = NULL;
LPWSTR InfSectionWithExtW = NULL;
if (InfSectionName)
{
- InfSectionNameW = MultiByteToUnicode(InfSectionName, CP_ACP);
+ InfSectionNameW = pSetupMultiByteToUnicode(InfSectionName, CP_ACP);
if (InfSectionNameW == NULL)
goto cleanup;
}
DWORD ClassDescriptionSize,
PDWORD RequiredSize)
{
- return SetupDiGetClassDescriptionExA(ClassGuid, ClassDescription,
- ClassDescriptionSize,
- RequiredSize, NULL, NULL);
+ return SetupDiGetClassDescriptionExA(ClassGuid, ClassDescription,
+ ClassDescriptionSize,
+ RequiredSize, NULL, NULL);
}
/***********************************************************************
DWORD ClassDescriptionSize,
PDWORD RequiredSize)
{
- return SetupDiGetClassDescriptionExW(ClassGuid, ClassDescription,
- ClassDescriptionSize,
- RequiredSize, NULL, NULL);
+ return SetupDiGetClassDescriptionExW(ClassGuid, ClassDescription,
+ ClassDescriptionSize,
+ RequiredSize, NULL, NULL);
}
/***********************************************************************
if (MachineName)
{
- MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
+ MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
if (!MachineNameW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
DWORD dwLength;
DWORD dwRegType;
LONG rc;
+ PWSTR Buffer;
TRACE("%s %p %lu %p %s %p\n", debugstr_guid(ClassGuid), ClassDescription,
ClassDescriptionSize, RequiredSize, debugstr_w(MachineName), Reserved);
+ /* Make sure there's a GUID */
if (!ClassGuid)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- else if (!ClassDescription && ClassDescriptionSize > 0)
+
+ /* Make sure there's a real buffer when there's a size */
+ if (!ClassDescription && ClassDescriptionSize > 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
+ /* Open the key for the GUID */
hKey = SetupDiOpenClassRegKeyExW(ClassGuid,
KEY_QUERY_VALUE,
DIOCR_INSTALLER,
MachineName,
Reserved);
if (hKey == INVALID_HANDLE_VALUE)
- {
- WARN("SetupDiOpenClassRegKeyExW() failed (Error %u)\n", GetLastError());
- return FALSE;
- }
-
- if (ClassDescriptionSize < sizeof(UNICODE_NULL) || !ClassDescription)
- dwLength = 0;
- else
- dwLength = ClassDescriptionSize * sizeof(WCHAR) - sizeof(UNICODE_NULL);
+ return FALSE;
- rc = RegQueryValueExW(hKey,
- NULL,
- NULL,
- &dwRegType,
- (LPBYTE)ClassDescription,
- &dwLength);
+ /* Retrieve the class description data and close the key */
+ rc = QueryRegistryValue(hKey, NULL, (LPBYTE *) &Buffer, &dwRegType, &dwLength);
RegCloseKey(hKey);
- if (rc != ERROR_MORE_DATA && rc != ERROR_SUCCESS)
+
+ /* Make sure we got the data */
+ if (rc != ERROR_SUCCESS)
{
SetLastError(rc);
return FALSE;
}
- else if (dwRegType != REG_SZ)
+
+ /* Make sure the data is a string */
+ if (dwRegType != REG_SZ)
{
+ MyFree(Buffer);
SetLastError(ERROR_GEN_FAILURE);
return FALSE;
}
- if (RequiredSize)
- *RequiredSize = dwLength / sizeof(WCHAR) + 1;
+ /* Determine the length of the class description */
+ dwLength /= sizeof(WCHAR);
- if (ClassDescriptionSize * sizeof(WCHAR) >= dwLength + sizeof(UNICODE_NULL))
+ /* Count the null-terminator if none is present */
+ if ((dwLength == 0) || (Buffer[dwLength - 1] != UNICODE_NULL))
+ dwLength++;
+
+ /* Inform the caller about the class description */
+ if ((ClassDescription != NULL) && (dwLength <= ClassDescriptionSize))
{
- if (ClassDescriptionSize > sizeof(UNICODE_NULL))
- ClassDescription[ClassDescriptionSize / sizeof(WCHAR)] = UNICODE_NULL;
- return TRUE;
+ memcpy(ClassDescription, Buffer, (dwLength - 1) * sizeof(WCHAR));
+ ClassDescription[dwLength - 1] = UNICODE_NULL;
}
- else
+
+ /* Inform the caller about the required size */
+ if (RequiredSize != NULL)
+ *RequiredSize = dwLength;
+
+ /* Clean up the buffer */
+ MyFree(Buffer);
+
+ /* Make sure the buffer was large enough */
+ if ((ClassDescription == NULL) || (dwLength > ClassDescriptionSize))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
+
+ return TRUE;
}
/***********************************************************************
* SetupDiGetClassDevsA (SETUPAPI.@)
*/
HDEVINFO WINAPI SetupDiGetClassDevsA(
- CONST GUID *class,
- LPCSTR enumstr,
- HWND parent,
- DWORD flags)
+ CONST GUID *class,
+ LPCSTR enumstr,
+ HWND parent,
+ DWORD flags)
{
return SetupDiGetClassDevsExA(class, enumstr, parent,
flags, NULL, NULL, NULL);
if (enumstr)
{
- enumstrW = MultiByteToUnicode(enumstr, CP_ACP);
+ enumstrW = pSetupMultiByteToUnicode(enumstr, CP_ACP);
if (!enumstrW)
{
ret = INVALID_HANDLE_VALUE;
}
if (machine)
{
- machineW = MultiByteToUnicode(machine, CP_ACP);
+ machineW = pSetupMultiByteToUnicode(machine, CP_ACP);
if (!machineW)
{
MyFree(enumstrW);
* SetupDiGetClassDevsW (SETUPAPI.@)
*/
HDEVINFO WINAPI SetupDiGetClassDevsW(
- CONST GUID *class,
- LPCWSTR enumstr,
- HWND parent,
- DWORD flags)
+ CONST GUID *class,
+ LPCWSTR enumstr,
+ HWND parent,
+ DWORD flags)
{
return SetupDiGetClassDevsExW(class, enumstr, parent, flags, NULL, NULL,
NULL);
if (!(flags & DIGCF_ALLCLASSES) && !class)
{
SetLastError(ERROR_INVALID_PARAMETER);
- return NULL;
+ return INVALID_HANDLE_VALUE;
}
/* Create the deviceset if not set */
if (ReferenceString)
{
- ReferenceStringW = MultiByteToUnicode(ReferenceString, CP_ACP);
+ ReferenceStringW = pSetupMultiByteToUnicode(ReferenceString, CP_ACP);
if (ReferenceStringW == NULL) return FALSE;
}
SetLastError(ERROR_INVALID_PARAMETER);
return INVALID_HANDLE_VALUE;
}
- InfSectionNameW = MultiByteToUnicode(InfSectionName, CP_ACP);
+ InfSectionNameW = pSetupMultiByteToUnicode(InfSectionName, CP_ACP);
if (!InfSectionNameW)
return INVALID_HANDLE_VALUE;
}
* Failure: FALSE. Call GetLastError() for more info.
*/
BOOL WINAPI SetupDiEnumDeviceInterfaces(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- CONST GUID * InterfaceClassGuid,
- DWORD MemberIndex,
- PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ CONST GUID * InterfaceClassGuid,
+ DWORD MemberIndex,
+ PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
BOOL ret = FALSE;
* SetupDiGetDeviceInterfaceDetailA (SETUPAPI.@)
*/
BOOL WINAPI SetupDiGetDeviceInterfaceDetailA(
- HDEVINFO DeviceInfoSet,
- PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
- PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData,
- DWORD DeviceInterfaceDetailDataSize,
- PDWORD RequiredSize,
- PSP_DEVINFO_DATA DeviceInfoData)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData,
+ DWORD DeviceInterfaceDetailDataSize,
+ PDWORD RequiredSize,
+ PSP_DEVINFO_DATA DeviceInfoData)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailDataW = NULL;
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- if (DeviceInterfaceDetailData && (DeviceInterfaceDetailData->cbSize <
- FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + 1 ||
- DeviceInterfaceDetailData->cbSize > sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A)))
+ if (DeviceInterfaceDetailData && (DeviceInterfaceDetailData->cbSize != sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A)))
{
SetLastError(ERROR_INVALID_USER_BUFFER);
return FALSE;
}
+
+ if((DeviceInterfaceDetailDataSize != 0) &&
+ (DeviceInterfaceDetailDataSize < (FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath) + sizeof(CHAR))))
+ {
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ return FALSE;
+ }
+
if (!DeviceInterfaceDetailData && DeviceInterfaceDetailDataSize)
{
SetLastError(ERROR_INVALID_USER_BUFFER);
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
}
+ DeviceInterfaceDetailDataW->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
}
if (!DeviceInterfaceDetailData || (DeviceInterfaceDetailData && DeviceInterfaceDetailDataW))
{
- DeviceInterfaceDetailDataW->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);
ret = SetupDiGetDeviceInterfaceDetailW(
DeviceInfoSet,
DeviceInterfaceData,
+ FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath);
if (RequiredSize)
*RequiredSize = bytesNeeded;
- if (ret && DeviceInterfaceDetailData && DeviceInterfaceDetailDataSize <= bytesNeeded)
+ if (ret && DeviceInterfaceDetailData && DeviceInterfaceDetailDataSize >= bytesNeeded)
{
if (!WideCharToMultiByte(
CP_ACP, 0,
* SetupDiGetDeviceInterfaceDetailW (SETUPAPI.@)
*/
BOOL WINAPI SetupDiGetDeviceInterfaceDetailW(
- HDEVINFO DeviceInfoSet,
- PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
- PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData,
- DWORD DeviceInterfaceDetailDataSize,
- PDWORD RequiredSize,
- PSP_DEVINFO_DATA DeviceInfoData)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
+ PSP_DEVICE_INTERFACE_DETAIL_DATA_W DeviceInterfaceDetailData,
+ DWORD DeviceInterfaceDetailDataSize,
+ PDWORD RequiredSize,
+ PSP_DEVINFO_DATA DeviceInfoData)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
BOOL ret = FALSE;
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- if (DeviceInterfaceDetailData != NULL && DeviceInterfaceDetailDataSize < FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath) + sizeof(WCHAR))
+ if ((DeviceInterfaceDetailData != NULL)
+ && (DeviceInterfaceDetailDataSize < (FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath)) + sizeof(WCHAR)))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
}
- ret = SetupDiGetDeviceRegistryPropertyW(
- DeviceInfoSet,
- DeviceInfoData,
- Property,
- &RegType,
- PropertyBufferW,
- PropertyBufferSizeW,
- &RequiredSizeW);
+ ret = SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet,
+ DeviceInfoData,
+ Property,
+ &RegType,
+ PropertyBufferW,
+ PropertyBufferSizeW,
+ &RequiredSizeW);
if (ret || GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
* SetupDiSetDeviceRegistryPropertyA (SETUPAPI.@)
*/
BOOL WINAPI SetupDiSetDeviceRegistryPropertyA(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- DWORD Property,
- const BYTE *PropertyBuffer,
- DWORD PropertyBufferSize)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ DWORD Property,
+ const BYTE *PropertyBuffer,
+ DWORD PropertyBufferSize)
{
BOOL ret = FALSE;
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
* SetupDiSetDeviceRegistryPropertyW (SETUPAPI.@)
*/
BOOL WINAPI SetupDiSetDeviceRegistryPropertyW(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- DWORD Property,
- const BYTE *PropertyBuffer,
- DWORD PropertyBufferSize)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ DWORD Property,
+ const BYTE *PropertyBuffer,
+ DWORD PropertyBufferSize)
{
BOOL ret = FALSE;
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
&& PropertyMap[Property].nameW)
{
- HKEY hKey;
- LONG l;
+ HKEY hKey;
+ LONG l;
hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_SET_VALUE);
if (hKey == INVALID_HANDLE_VALUE)
return FALSE;
}
else
{
- InfFileNameW = MultiByteToUnicode(InfFileName, CP_ACP);
+ InfFileNameW = pSetupMultiByteToUnicode(InfFileName, CP_ACP);
if (InfFileNameW == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
HKEY hClassKey;
if (!SetupGetLineTextW(NULL,
- hInf,
- Version,
- ClassGUID,
- Buffer,
- MAX_PATH,
- &RequiredSize))
+ hInf,
+ Version,
+ ClassGUID,
+ Buffer,
+ MAX_PATH,
+ &RequiredSize))
{
- return INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
lstrcpyW(FullBuffer, REGSTR_PATH_CLASS_NT);
lstrcatW(FullBuffer, Buffer);
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
- FullBuffer,
- 0,
- KEY_SET_VALUE,
- &hClassKey))
- {
- if (!SetupGetLineTextW(NULL,
- hInf,
- Version,
- Class,
- Buffer,
- MAX_PATH,
- &RequiredSize))
- {
- return INVALID_HANDLE_VALUE;
- }
-
- if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,
- FullBuffer,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_SET_VALUE,
- NULL,
- &hClassKey,
- NULL))
- {
- return INVALID_HANDLE_VALUE;
- }
+ FullBuffer,
+ 0,
+ KEY_SET_VALUE,
+ &hClassKey))
+ {
+ if (!SetupGetLineTextW(NULL,
+ hInf,
+ Version,
+ Class,
+ Buffer,
+ MAX_PATH,
+ &RequiredSize))
+ {
+ return INVALID_HANDLE_VALUE;
+ }
+ if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,
+ FullBuffer,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_SET_VALUE,
+ NULL,
+ &hClassKey,
+ NULL))
+ {
+ return INVALID_HANDLE_VALUE;
+ }
}
if (RegSetValueExW(hClassKey,
- Class,
- 0,
- REG_SZ,
- (LPBYTE)Buffer,
- RequiredSize * sizeof(WCHAR)))
- {
- RegCloseKey(hClassKey);
- RegDeleteKeyW(HKEY_LOCAL_MACHINE,
- FullBuffer);
- return INVALID_HANDLE_VALUE;
+ Class,
+ 0,
+ REG_SZ,
+ (LPBYTE)Buffer,
+ RequiredSize * sizeof(WCHAR)))
+ {
+ RegCloseKey(hClassKey);
+ RegDeleteKeyW(HKEY_LOCAL_MACHINE,
+ FullBuffer);
+ return INVALID_HANDLE_VALUE;
}
return hClassKey;
if (MachineName)
{
- MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
+ MachineNameW = pSetupMultiByteToUnicode(MachineName, CP_ACP);
if (MachineNameW == NULL)
return INVALID_HANDLE_VALUE;
}
if (!ClassGuid)
{
if ((l = RegOpenKeyExW(HKLM,
- lpKeyName,
- 0,
- samDesired,
- &hClassesKey)))
+ lpKeyName,
+ 0,
+ samDesired,
+ &hClassesKey)))
{
SetLastError(ERROR_INVALID_CLASS);
hClassesKey = INVALID_HANDLE_VALUE;
SETUPDI_GuidToString(ClassGuid, bracedGuidString);
if (!(l = RegOpenKeyExW(HKLM,
- lpKeyName,
- 0,
- samDesired,
- &hClassesKey)))
+ lpKeyName,
+ 0,
+ samDesired,
+ &hClassesKey)))
{
- if (MachineName != NULL)
- RegCloseKey(HKLM);
-
+ if (MachineName != NULL)
+ RegCloseKey(HKLM);
+
if ((l = RegOpenKeyExW(hClassesKey,
- bracedGuidString,
- 0,
- samDesired,
- &key)))
+ bracedGuidString,
+ 0,
+ samDesired,
+ &key)))
{
SetLastError(l);
key = INVALID_HANDLE_VALUE;
* SetupDiOpenDeviceInterfaceW (SETUPAPI.@)
*/
BOOL WINAPI SetupDiOpenDeviceInterfaceW(
- HDEVINFO DeviceInfoSet,
- PCWSTR DevicePath,
- DWORD OpenFlags,
- PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
+ HDEVINFO DeviceInfoSet,
+ PCWSTR DevicePath,
+ DWORD OpenFlags,
+ PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
{
- FIXME("%p %s %08x %p\n",
+ struct DeviceInfoSet * list;
+ PCWSTR pEnd;
+ DWORD dwLength, dwError, dwIndex, dwKeyName, dwSubIndex;
+ CLSID ClassId;
+ WCHAR Buffer[MAX_PATH + 1];
+ WCHAR SymBuffer[MAX_PATH + 1];
+ WCHAR InstancePath[MAX_PATH + 1];
+ HKEY hKey, hDevKey, hSymKey;
+ struct DeviceInfo * deviceInfo;
+ struct DeviceInterface *deviceInterface;
+ BOOL Ret;
+ PLIST_ENTRY ItemList;
+ PLIST_ENTRY InterfaceListEntry;
+
+ TRACE("%p %s %08x %p\n",
DeviceInfoSet, debugstr_w(DevicePath), OpenFlags, DeviceInterfaceData);
+
+
+ if (DeviceInterfaceData && DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ list = (struct DeviceInfoSet * )DeviceInfoSet;
+
+ dwLength = wcslen(DevicePath);
+ if (dwLength < 39)
+ {
+ /* path must be at least a guid length + L'\0' */
+ SetLastError(ERROR_BAD_PATHNAME);
+ return FALSE;
+ }
+
+ if (DevicePath[0] != L'\\' ||
+ DevicePath[1] != L'\\' ||
+ (DevicePath[2] != L'?' && DevicePath[2] != L'.') ||
+ DevicePath[3] != L'\\')
+ {
+ /* invalid formatted path */
+ SetLastError(ERROR_BAD_PATHNAME);
+ return FALSE;
+ }
+
+ /* check for reference strings */
+ pEnd = wcschr(&DevicePath[4], L'\\');
+ if (!pEnd)
+ {
+ /* no reference string */
+ pEnd = DevicePath + dwLength;
+ }
+
+ /* copy guid */
+ wcscpy(Buffer, pEnd - 37);
+ Buffer[36] = L'\0';
+
+ dwError = UuidFromStringW(Buffer, &ClassId);
+ if (dwError != NOERROR)
+ {
+ /* invalid formatted path */
+ SetLastError(ERROR_BAD_PATHNAME);
+ return FALSE;
+ }
+
+ hKey = SetupDiOpenClassRegKeyExW(&ClassId, KEY_READ, DIOCR_INTERFACE, list->MachineName, NULL);
+
+ if (hKey == INVALID_HANDLE_VALUE)
+ {
+ /* invalid device class */
+ return FALSE;
+ }
+
+ ItemList = list->ListHead.Flink;
+ while (ItemList != &list->ListHead)
+ {
+ deviceInfo = CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry);
+ InterfaceListEntry = deviceInfo->InterfaceListHead.Flink;
+ while (InterfaceListEntry != &deviceInfo->InterfaceListHead)
+ {
+ deviceInterface = CONTAINING_RECORD(InterfaceListEntry, struct DeviceInterface, ListEntry);
+ if (!IsEqualIID(&deviceInterface->InterfaceClassGuid, &ClassId))
+ {
+ InterfaceListEntry = InterfaceListEntry->Flink;
+ continue;
+ }
+
+ if (!wcsicmp(deviceInterface->SymbolicLink, DevicePath))
+ {
+ if (DeviceInterfaceData)
+ {
+ DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface;
+ DeviceInterfaceData->Flags = deviceInterface->Flags;
+ CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID));
+ }
+
+ return TRUE;
+ }
+
+ }
+ }
+
+
+ dwIndex = 0;
+ do
+ {
+ Buffer[0] = 0;
+ dwKeyName = sizeof(Buffer) / sizeof(WCHAR);
+ dwError = RegEnumKeyExW(hKey, dwIndex, Buffer, &dwKeyName, NULL, NULL, NULL, NULL);
+
+ if (dwError != ERROR_SUCCESS)
+ break;
+
+ if (RegOpenKeyExW(hKey, Buffer, 0, KEY_READ, &hDevKey) != ERROR_SUCCESS)
+ break;
+
+ dwSubIndex = 0;
+ InstancePath[0] = 0;
+ dwKeyName = sizeof(InstancePath);
+
+ dwError = RegQueryValueExW(hDevKey, L"DeviceInstance", NULL, NULL, (LPBYTE)InstancePath, &dwKeyName);
+
+ while(TRUE)
+ {
+ Buffer[0] = 0;
+ dwKeyName = sizeof(Buffer) / sizeof(WCHAR);
+ dwError = RegEnumKeyExW(hDevKey, dwSubIndex, Buffer, &dwKeyName, NULL, NULL, NULL, NULL);
+
+ if (dwError != ERROR_SUCCESS)
+ break;
+
+ dwError = RegOpenKeyExW(hDevKey, Buffer, 0, KEY_READ, &hSymKey);
+ if (dwError != ERROR_SUCCESS)
+ break;
+
+ /* query for symbolic link */
+ dwKeyName = sizeof(SymBuffer);
+ SymBuffer[0] = L'\0';
+ dwError = RegQueryValueExW(hSymKey, L"SymbolicLink", NULL, NULL, (LPBYTE)SymBuffer, &dwKeyName);
+
+ if (dwError != ERROR_SUCCESS)
+ {
+ RegCloseKey(hSymKey);
+ break;
+ }
+
+ if (!wcsicmp(SymBuffer, DevicePath))
+ {
+ Ret = CreateDeviceInfo(list, InstancePath, &ClassId, &deviceInfo);
+ RegCloseKey(hSymKey);
+ RegCloseKey(hDevKey);
+ RegCloseKey(hKey);
+
+ if (Ret)
+ {
+ deviceInterface = HeapAlloc(GetProcessHeap(), 0, sizeof(struct DeviceInterface) + (wcslen(SymBuffer) + 1) * sizeof(WCHAR));
+ if (deviceInterface)
+ {
+
+ CopyMemory(&deviceInterface->InterfaceClassGuid, &ClassId, sizeof(GUID));
+ deviceInterface->DeviceInfo = deviceInfo;
+ deviceInterface->Flags = SPINT_ACTIVE; //FIXME
+
+ wcscpy(deviceInterface->SymbolicLink, SymBuffer);
+
+ InsertTailList(&deviceInfo->InterfaceListHead, &deviceInterface->ListEntry);
+ InsertTailList(&list->ListHead, &deviceInfo->ListEntry);
+
+
+ if (DeviceInterfaceData)
+ {
+ DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface;
+ DeviceInterfaceData->Flags = deviceInterface->Flags;
+ CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID));
+ }
+ else
+ {
+ Ret = FALSE;
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ }
+ }
+ }
+ else
+ {
+ HeapFree(GetProcessHeap(), 0, deviceInfo);
+ Ret = FALSE;
+ }
+ return Ret;
+ }
+ RegCloseKey(hSymKey);
+ dwSubIndex++;
+ }
+
+ RegCloseKey(hDevKey);
+ dwIndex++;
+ } while(TRUE);
+
+ RegCloseKey(hKey);
return FALSE;
}
* SetupDiOpenDeviceInterfaceA (SETUPAPI.@)
*/
BOOL WINAPI SetupDiOpenDeviceInterfaceA(
- HDEVINFO DeviceInfoSet,
- PCSTR DevicePath,
- DWORD OpenFlags,
- PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
+ HDEVINFO DeviceInfoSet,
+ PCSTR DevicePath,
+ DWORD OpenFlags,
+ PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData)
{
LPWSTR DevicePathW = NULL;
BOOL bResult;
TRACE("%p %s %08lx %p\n", DeviceInfoSet, debugstr_a(DevicePath), OpenFlags, DeviceInterfaceData);
- DevicePathW = MultiByteToUnicode(DevicePath, CP_ACP);
+ DevicePathW = pSetupMultiByteToUnicode(DevicePath, CP_ACP);
if (DevicePathW == NULL)
return FALSE;
* SetupDiSetClassInstallParamsA (SETUPAPI.@)
*/
BOOL WINAPI SetupDiSetClassInstallParamsA(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- PSP_CLASSINSTALL_HEADER ClassInstallParams,
- DWORD ClassInstallParamsSize)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ PSP_CLASSINSTALL_HEADER ClassInstallParams,
+ DWORD ClassInstallParamsSize)
{
FIXME("%p %p %x %u\n",DeviceInfoSet, DeviceInfoData,
ClassInstallParams->InstallFunction, ClassInstallParamsSize);
static BOOL WINAPI
IntSetupDiRegisterDeviceInfo(
- IN HDEVINFO DeviceInfoSet,
- IN OUT PSP_DEVINFO_DATA DeviceInfoData)
+ IN HDEVINFO DeviceInfoSet,
+ IN OUT PSP_DEVINFO_DATA DeviceInfoData)
{
return SetupDiRegisterDeviceInfo(DeviceInfoSet, DeviceInfoData, 0, NULL, NULL, NULL);
}
* SetupDiCallClassInstaller (SETUPAPI.@)
*/
BOOL WINAPI SetupDiCallClassInstaller(
- DI_FUNCTION InstallFunction,
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData)
+ DI_FUNCTION InstallFunction,
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData)
{
BOOL ret = FALSE;
* SetupDiGetDeviceInstallParamsA (SETUPAPI.@)
*/
BOOL WINAPI SetupDiGetDeviceInstallParamsA(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- PSP_DEVINSTALL_PARAMS_A DeviceInstallParams)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ PSP_DEVINSTALL_PARAMS_A DeviceInstallParams)
{
SP_DEVINSTALL_PARAMS_W deviceInstallParamsW;
BOOL ret = FALSE;
*/
BOOL WINAPI
SetupDiGetDeviceInfoListClass(
- IN HDEVINFO DeviceInfoSet,
- OUT LPGUID ClassGuid)
+ IN HDEVINFO DeviceInfoSet,
+ OUT LPGUID ClassGuid)
{
struct DeviceInfoSet *list;
BOOL ret = FALSE;
*/
BOOL WINAPI
SetupDiGetDeviceInstallParamsW(
- IN HDEVINFO DeviceInfoSet,
- IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
- OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
+ OUT PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
{
struct DeviceInfoSet *list;
BOOL ret = FALSE;
static BOOL
CheckDeviceInstallParameters(
- IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
+ IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
{
DWORD SupportedFlags =
DI_NOVCP | /* 0x00000008 */
*/
BOOL WINAPI
SetupDiSetDeviceInstallParamsW(
- IN HDEVINFO DeviceInfoSet,
- IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
- IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
+ IN PSP_DEVINSTALL_PARAMS_W DeviceInstallParams)
{
struct DeviceInfoSet *list;
BOOL ret = FALSE;
return ret;
}
-BOOL WINAPI SetupDiSetDeviceInstallParamsA(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- PSP_DEVINSTALL_PARAMS_A DeviceInstallParams)
+/***********************************************************************
+ * SetupDiSetDeviceInstallParamsW (SETUPAPI.@)
+ */
+BOOL WINAPI
+SetupDiSetDeviceInstallParamsA(
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ PSP_DEVINSTALL_PARAMS_A DeviceInstallParams)
{
SP_DEVINSTALL_PARAMS_W deviceInstallParamsW;
int len = 0;
static HKEY
OpenHardwareProfileKey(
- IN HKEY HKLM,
- IN DWORD HwProfile,
- IN DWORD samDesired)
+ IN HKEY HKLM,
+ IN DWORD HwProfile,
+ IN DWORD samDesired)
{
HKEY hHWProfilesKey = NULL;
HKEY hHWProfileKey = NULL;
LONG rc;
rc = RegOpenKeyExW(HKLM,
- REGSTR_PATH_HWPROFILES,
- 0,
- 0,
- &hHWProfilesKey);
+ REGSTR_PATH_HWPROFILES,
+ 0,
+ 0,
+ &hHWProfilesKey);
if (rc != ERROR_SUCCESS)
{
SetLastError(rc);
}
if (HwProfile == 0)
{
- rc = RegOpenKeyExW(
- hHWProfilesKey,
- REGSTR_KEY_CURRENT,
- 0,
- KEY_CREATE_SUB_KEY,
- &hHWProfileKey);
+ rc = RegOpenKeyExW(hHWProfilesKey,
+ REGSTR_KEY_CURRENT,
+ 0,
+ KEY_CREATE_SUB_KEY,
+ &hHWProfileKey);
}
else
{
WCHAR subKey[5];
snprintfW(subKey, 4, InstanceKeyFormat, HwProfile);
subKey[4] = '\0';
- rc = RegOpenKeyExW(
- hHWProfilesKey,
- subKey,
- 0,
- KEY_CREATE_SUB_KEY,
- &hHWProfileKey);
+ rc = RegOpenKeyExW(hHWProfilesKey,
+ subKey,
+ 0,
+ KEY_CREATE_SUB_KEY,
+ &hHWProfileKey);
}
if (rc != ERROR_SUCCESS)
{
return ret;
}
+static BOOL
+IsDeviceInfoInDeviceInfoSet(
+ struct DeviceInfoSet *deviceInfoSet,
+ struct DeviceInfo *deviceInfo)
+{
+ PLIST_ENTRY ListEntry;
+
+ ListEntry = deviceInfoSet->ListHead.Flink;
+ while (ListEntry != &deviceInfoSet->ListHead)
+ {
+ if (deviceInfo == CONTAINING_RECORD(ListEntry, struct DeviceInfo, ListEntry))
+ return TRUE;
+
+ ListEntry = ListEntry->Flink;
+ }
+
+ return FALSE;
+}
+
/***********************************************************************
* SetupDiDeleteDeviceInfo (SETUPAPI.@)
*/
BOOL WINAPI
SetupDiDeleteDeviceInfo(
- IN HDEVINFO DeviceInfoSet,
- IN PSP_DEVINFO_DATA DeviceInfoData)
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData)
{
+ struct DeviceInfoSet *deviceInfoSet;
+ struct DeviceInfo *deviceInfo = (struct DeviceInfo *)DeviceInfoData;
+ BOOL ret = FALSE;
+
TRACE("%p %p\n", DeviceInfoSet, DeviceInfoData);
- FIXME("not implemented\n");
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ if (!DeviceInfoSet)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if ((deviceInfoSet = (struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC)
+ SetLastError(ERROR_INVALID_HANDLE);
+ else if (DeviceInfoData && DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA))
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ else if (!IsDeviceInfoInDeviceInfoSet(deviceInfoSet, deviceInfo))
+ SetLastError(ERROR_INVALID_PARAMETER);
+ else
+ {
+ RemoveEntryList(&deviceInfo->ListEntry);
+ DestroyDeviceInfo(deviceInfo);
+ ret = TRUE;
+ }
+
+ return ret;
}
*/
BOOL WINAPI
SetupDiOpenDeviceInfoA(
- IN HDEVINFO DeviceInfoSet,
- IN PCSTR DeviceInstanceId,
- IN HWND hwndParent OPTIONAL,
- IN DWORD OpenFlags,
- OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
+ IN HDEVINFO DeviceInfoSet,
+ IN PCSTR DeviceInstanceId,
+ IN HWND hwndParent OPTIONAL,
+ IN DWORD OpenFlags,
+ OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
{
LPWSTR DeviceInstanceIdW = NULL;
BOOL bResult;
TRACE("%p %s %p %lx %p\n", DeviceInfoSet, DeviceInstanceId, hwndParent, OpenFlags, DeviceInfoData);
- DeviceInstanceIdW = MultiByteToUnicode(DeviceInstanceId, CP_ACP);
+ DeviceInstanceIdW = pSetupMultiByteToUnicode(DeviceInstanceId, CP_ACP);
if (DeviceInstanceIdW == NULL)
return FALSE;
*/
BOOL WINAPI
SetupDiOpenDeviceInfoW(
- IN HDEVINFO DeviceInfoSet,
- IN PCWSTR DeviceInstanceId,
- IN HWND hwndParent OPTIONAL,
- IN DWORD OpenFlags,
- OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
+ IN HDEVINFO DeviceInfoSet,
+ IN PCWSTR DeviceInstanceId,
+ IN HWND hwndParent OPTIONAL,
+ IN DWORD OpenFlags,
+ OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
{
struct DeviceInfoSet *list;
HKEY hEnumKey, hKey = NULL;
PLIST_ENTRY ItemList = list->ListHead.Flink;
while (ItemList != &list->ListHead)
{
- // TODO
- //if (good one)
- // break;
- FIXME("not implemented\n");
+ deviceInfo = CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry);
+ if (!wcscmp(deviceInfo->instanceId, DeviceInstanceId))
+ break;
+ deviceInfo = NULL;
ItemList = ItemList->Flink;
}
*/
BOOL WINAPI
SetupDiGetSelectedDevice(
- IN HDEVINFO DeviceInfoSet,
- OUT PSP_DEVINFO_DATA DeviceInfoData)
+ IN HDEVINFO DeviceInfoSet,
+ OUT PSP_DEVINFO_DATA DeviceInfoData)
{
struct DeviceInfoSet *list;
BOOL ret = FALSE;
*/
BOOL WINAPI
SetupDiSetSelectedDevice(
- IN HDEVINFO DeviceInfoSet,
- IN PSP_DEVINFO_DATA DeviceInfoData)
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData)
{
struct DeviceInfoSet *list;
BOOL ret = FALSE;
/* Return the current hardware profile id, or -1 if error */
static DWORD
SETUPAPI_GetCurrentHwProfile(
- IN HDEVINFO DeviceInfoSet)
+ IN HDEVINFO DeviceInfoSet)
{
HKEY hKey = NULL;
DWORD dwRegType, dwLength;
LONG rc;
DWORD ret = (DWORD)-1;
- rc = RegOpenKeyExW(
- ((struct DeviceInfoSet *)DeviceInfoSet)->HKLM,
- REGSTR_PATH_IDCONFIGDB,
- 0, /* Options */
- KEY_QUERY_VALUE,
- &hKey);
+ rc = RegOpenKeyExW(((struct DeviceInfoSet *)DeviceInfoSet)->HKLM,
+ REGSTR_PATH_IDCONFIGDB,
+ 0, /* Options */
+ KEY_QUERY_VALUE,
+ &hKey);
if (rc != ERROR_SUCCESS)
{
SetLastError(rc);
}
dwLength = sizeof(DWORD);
- rc = RegQueryValueExW(
- hKey,
- REGSTR_VAL_CURRENTCONFIG,
- NULL,
- &dwRegType,
- (LPBYTE)&hwProfile, &dwLength);
+ rc = RegQueryValueExW(hKey,
+ REGSTR_VAL_CURRENTCONFIG,
+ NULL,
+ &dwRegType,
+ (LPBYTE)&hwProfile, &dwLength);
if (rc != ERROR_SUCCESS)
{
SetLastError(rc);
static BOOL
ResetDevice(
- IN HDEVINFO DeviceInfoSet,
- IN PSP_DEVINFO_DATA DeviceInfoData)
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData)
{
#ifndef __WINESRC__
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
}
static BOOL StopDevice(
- IN HDEVINFO DeviceInfoSet,
- IN PSP_DEVINFO_DATA DeviceInfoData)
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData)
{
FIXME("Stub: StopDevice(%p %p)\n", DeviceInfoSet, DeviceInfoData);
return TRUE;
*/
BOOL WINAPI
SetupDiChangeState(
- IN HDEVINFO DeviceInfoSet,
- IN OUT PSP_DEVINFO_DATA DeviceInfoData)
+ IN HDEVINFO DeviceInfoSet,
+ IN OUT PSP_DEVINFO_DATA DeviceInfoData)
{
PSP_PROPCHANGE_PARAMS PropChange;
HKEY hKey = INVALID_HANDLE_VALUE;
*/
BOOL WINAPI
SetupDiSelectDevice(
- IN HDEVINFO DeviceInfoSet,
- IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
+ IN HDEVINFO DeviceInfoSet,
+ IN OUT PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
{
- FIXME("%p %p\n", DeviceInfoSet, DeviceInfoData);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ FIXME("%p %p\n", DeviceInfoSet, DeviceInfoData);
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ return FALSE;
}
*/
BOOL WINAPI
SetupDiRegisterCoDeviceInstallers(
- IN HDEVINFO DeviceInfoSet,
- IN PSP_DEVINFO_DATA DeviceInfoData)
+ IN HDEVINFO DeviceInfoSet,
+ IN PSP_DEVINFO_DATA DeviceInfoData)
{
BOOL ret = FALSE; /* Return value */
static BOOL
InfIsFromOEMLocation(
- IN PCWSTR FullName,
- OUT LPBOOL IsOEMLocation)
+ IN PCWSTR FullName,
+ OUT LPBOOL IsOEMLocation)
{
PWCHAR last;
*/
BOOL WINAPI
SetupDiInstallDevice(
- IN HDEVINFO DeviceInfoSet,
- IN OUT PSP_DEVINFO_DATA DeviceInfoData)
+ IN HDEVINFO DeviceInfoSet,
+ IN OUT PSP_DEVINFO_DATA DeviceInfoData)
{
SP_DEVINSTALL_PARAMS_W InstallParams;
struct DriverInfoElement *SelectedDriver;
NewFileName, MAX_PATH,
NULL,
NULL);
- if (!Result)
+ if (!Result && GetLastError() != ERROR_FILE_EXISTS)
goto cleanup;
/* Create a new struct InfFileDetails, and set it to
* SelectedDriver->InfFileDetails, to release use of
* SetupDiOpenDevRegKey (SETUPAPI.@)
*/
HKEY WINAPI SetupDiOpenDevRegKey(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- DWORD Scope,
- DWORD HwProfile,
- DWORD KeyType,
- REGSAM samDesired)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ DWORD Scope,
+ DWORD HwProfile,
+ DWORD KeyType,
+ REGSAM samDesired)
{
struct DeviceInfoSet *set = DeviceInfoSet;
struct DeviceInfo *devInfo;
* SetupDiDeleteDevRegKey (SETUPAPI.@)
*/
BOOL WINAPI SetupDiDeleteDevRegKey(
- HDEVINFO DeviceInfoSet,
- PSP_DEVINFO_DATA DeviceInfoData,
- DWORD Scope,
- DWORD HwProfile,
- DWORD KeyType)
+ HDEVINFO DeviceInfoSet,
+ PSP_DEVINFO_DATA DeviceInfoData,
+ DWORD Scope,
+ DWORD HwProfile,
+ DWORD KeyType)
{
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
struct DeviceInfo *devInfo;