- Check that mandatory arguments are provided
- Better tracing system
- Prepend private function names with SETUP_
- Use MultiByteToUnicode instead of MultiByteToUnicode + HeapAlloc
- ...

svn path=/trunk/; revision=22299
This commit is contained in:
Hervé Poussineau 2006-06-10 20:48:17 +00:00
parent ac6a23b01f
commit b76c5a1315

View file

@ -45,7 +45,7 @@ typedef BOOL
IN DWORD ClassInstallParamsSize); IN DWORD ClassInstallParamsSize);
static BOOL static BOOL
PropertyChangeHandler( SETUP_PropertyChangeHandler(
IN HDEVINFO DeviceInfoSet, IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL,
IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL, IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
@ -69,7 +69,7 @@ static const UPDATE_CLASS_PARAM_HANDLER UpdateClassInstallParamHandlers[] = {
NULL, /* DIF_DETECT */ NULL, /* DIF_DETECT */
NULL, /* DIF_INSTALLWIZARD */ NULL, /* DIF_INSTALLWIZARD */
NULL, /* DIF_DESTROYWIZARDDATA */ NULL, /* DIF_DESTROYWIZARDDATA */
PropertyChangeHandler, /* DIF_PROPERTYCHANGE */ SETUP_PropertyChangeHandler, /* DIF_PROPERTYCHANGE */
NULL, /* DIF_ENABLECLASS */ NULL, /* DIF_ENABLECLASS */
NULL, /* DIF_DETECTVERIFY */ NULL, /* DIF_DETECTVERIFY */
NULL, /* DIF_INSTALLDEVICEFILES */ NULL, /* DIF_INSTALLDEVICEFILES */
@ -153,7 +153,8 @@ SetupDiBuildClassInfoListExA(
LPWSTR MachineNameW = NULL; LPWSTR MachineNameW = NULL;
BOOL bResult; BOOL bResult;
TRACE("\n"); TRACE("0x%lx %p %lu %p %s %p\n", Flags, ClassGuidList,
ClassGuidListSize, RequiredSize, debugstr_a(MachineName), Reserved);
if (MachineName) if (MachineName)
{ {
@ -165,7 +166,6 @@ SetupDiBuildClassInfoListExA(
ClassGuidListSize, RequiredSize, ClassGuidListSize, RequiredSize,
MachineNameW, Reserved); MachineNameW, Reserved);
if (MachineNameW)
MyFree(MachineNameW); MyFree(MachineNameW);
return bResult; return bResult;
@ -210,8 +210,16 @@ SetupDiBuildClassInfoListExW(
TRACE("0x%lx %p %lu %p %s %p\n", Flags, ClassGuidList, TRACE("0x%lx %p %lu %p %s %p\n", Flags, ClassGuidList,
ClassGuidListSize, RequiredSize, debugstr_w(MachineName), Reserved); ClassGuidListSize, RequiredSize, debugstr_w(MachineName), Reserved);
if (RequiredSize != NULL) if (!RequiredSize)
*RequiredSize = 0; {
SetLastError(ERROR_INVALID_PARAMETER);
goto cleanup;
}
else if (!ClassGuidList && ClassGuidListSize > 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
goto cleanup;
}
hClassesKey = SetupDiOpenClassRegKeyExW(NULL, hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
KEY_ENUMERATE_SUB_KEYS, KEY_ENUMERATE_SUB_KEYS,
@ -232,7 +240,6 @@ SetupDiBuildClassInfoListExW(
NULL, NULL,
NULL, NULL,
NULL); NULL);
TRACE("RegEnumKeyExW() returns %ld\n", lError);
if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA) if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
{ {
TRACE("Key name: %s\n", debugstr_w(szKeyName)); TRACE("Key name: %s\n", debugstr_w(szKeyName));
@ -288,7 +295,6 @@ SetupDiBuildClassInfoListExW(
{ {
if (szKeyName[0] == L'{' && szKeyName[37] == L'}') if (szKeyName[0] == L'{' && szKeyName[37] == L'}')
szKeyName[37] = 0; szKeyName[37] = 0;
TRACE("Guid: %s\n", debugstr_w(&szKeyName[1]));
UuidFromStringW(&szKeyName[1], UuidFromStringW(&szKeyName[1],
&ClassGuidList[dwGuidListIndex]); &ClassGuidList[dwGuidListIndex]);
@ -296,6 +302,8 @@ SetupDiBuildClassInfoListExW(
dwGuidListIndex++; dwGuidListIndex++;
} }
else
TRACE("RegEnumKeyExW() returns 0x%lx\n", lError);
if (lError != ERROR_SUCCESS) if (lError != ERROR_SUCCESS)
break; break;
@ -360,31 +368,34 @@ SetupDiClassGuidsFromNameExA(
{ {
LPWSTR ClassNameW = NULL; LPWSTR ClassNameW = NULL;
LPWSTR MachineNameW = NULL; LPWSTR MachineNameW = NULL;
BOOL bResult; BOOL bResult = FALSE;
TRACE("\n"); TRACE("%s %p %lu %p %s %p\n", debugstr_a(ClassName), ClassGuidList,
ClassGuidListSize, RequiredSize, debugstr_a(MachineName), Reserved);
if (!ClassName)
{
SetLastError(ERROR_INVALID_PARAMETER);
goto cleanup;
}
ClassNameW = MultiByteToUnicode(ClassName, CP_ACP); ClassNameW = MultiByteToUnicode(ClassName, CP_ACP);
if (ClassNameW == NULL) if (ClassNameW == NULL)
return FALSE; goto cleanup;
if (MachineNameW) if (MachineName)
{ {
MachineNameW = MultiByteToUnicode(MachineName, CP_ACP); MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
if (MachineNameW == NULL) if (MachineNameW == NULL)
{ goto cleanup;
MyFree(ClassNameW);
return FALSE;
}
} }
bResult = SetupDiClassGuidsFromNameExW(ClassNameW, ClassGuidList, bResult = SetupDiClassGuidsFromNameExW(ClassNameW, ClassGuidList,
ClassGuidListSize, RequiredSize, ClassGuidListSize, RequiredSize,
MachineNameW, Reserved); MachineNameW, Reserved);
if (MachineNameW) cleanup:
MyFree(MachineNameW); MyFree(MachineNameW);
MyFree(ClassNameW); MyFree(ClassNameW);
return bResult; return bResult;
@ -403,7 +414,7 @@ SetupDiClassGuidsFromNameExW(
IN PVOID Reserved) IN PVOID Reserved)
{ {
WCHAR szKeyName[MAX_GUID_STRING_LEN + 1]; WCHAR szKeyName[MAX_GUID_STRING_LEN + 1];
WCHAR szClassName[256]; WCHAR szClassName[MAX_CLASS_NAME_LEN];
HKEY hClassesKey = INVALID_HANDLE_VALUE; HKEY hClassesKey = INVALID_HANDLE_VALUE;
HKEY hClassKey = NULL; HKEY hClassKey = NULL;
DWORD dwLength; DWORD dwLength;
@ -415,7 +426,16 @@ SetupDiClassGuidsFromNameExW(
TRACE("%s %p %lu %p %s %p\n", debugstr_w(ClassName), ClassGuidList, TRACE("%s %p %lu %p %s %p\n", debugstr_w(ClassName), ClassGuidList,
ClassGuidListSize, RequiredSize, debugstr_w(MachineName), Reserved); ClassGuidListSize, RequiredSize, debugstr_w(MachineName), Reserved);
if (RequiredSize != NULL) if (!ClassName || !RequiredSize)
{
SetLastError(ERROR_INVALID_PARAMETER);
goto cleanup;
}
else if (!ClassGuidList && ClassGuidListSize > 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
goto cleanup;
}
*RequiredSize = 0; *RequiredSize = 0;
hClassesKey = SetupDiOpenClassRegKeyExW(NULL, hClassesKey = SetupDiOpenClassRegKeyExW(NULL,
@ -437,7 +457,6 @@ SetupDiClassGuidsFromNameExW(
NULL, NULL,
NULL, NULL,
NULL); NULL);
TRACE("RegEnumKeyExW() returns %ld\n", lError);
if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA) if (lError == ERROR_SUCCESS || lError == ERROR_MORE_DATA)
{ {
TRACE("Key name: %s\n", debugstr_w(szKeyName)); TRACE("Key name: %s\n", debugstr_w(szKeyName));
@ -453,7 +472,7 @@ SetupDiClassGuidsFromNameExW(
goto cleanup; goto cleanup;
} }
dwLength = 256 * sizeof(WCHAR); dwLength = MAX_CLASS_NAME_LEN * sizeof(WCHAR);
if (RegQueryValueExW(hClassKey, if (RegQueryValueExW(hClassKey,
Class, Class,
NULL, NULL,
@ -472,7 +491,6 @@ SetupDiClassGuidsFromNameExW(
{ {
if (szKeyName[0] == L'{' && szKeyName[37] == L'}') if (szKeyName[0] == L'{' && szKeyName[37] == L'}')
szKeyName[37] = 0; szKeyName[37] = 0;
TRACE("Guid: %s\n", debugstr_w(&szKeyName[1]));
UuidFromStringW(&szKeyName[1], UuidFromStringW(&szKeyName[1],
&ClassGuidList[dwGuidListIndex]); &ClassGuidList[dwGuidListIndex]);
@ -482,6 +500,8 @@ SetupDiClassGuidsFromNameExW(
} }
} }
} }
else
TRACE("RegEnumKeyExW() returns 0x%lx\n", lError);
if (lError != ERROR_SUCCESS) if (lError != ERROR_SUCCESS)
break; break;
@ -552,14 +572,16 @@ SetupDiClassNameFromGuidExA(
if (MachineName) if (MachineName)
MachineNameW = MultiByteToUnicode(MachineName, CP_ACP); MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
ret = SetupDiClassNameFromGuidExW(ClassGuid, ClassNameW, MAX_CLASS_NAME_LEN, ret = SetupDiClassNameFromGuidExW(ClassGuid, ClassNameW, MAX_CLASS_NAME_LEN,
NULL, MachineNameW, Reserved); RequiredSize, MachineNameW, Reserved);
if (ret) if (ret)
{ {
int len = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName, int len = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName,
ClassNameSize, NULL, NULL); ClassNameSize, NULL, NULL);
if (len > ClassNameSize)
if (!ClassNameSize && RequiredSize) {
*RequiredSize = len; SetLastError(ERROR_INSUFFICIENT_BUFFER);
ret = FALSE;
}
} }
MyFree(MachineNameW); MyFree(MachineNameW);
return ret; return ret;
@ -674,23 +696,22 @@ SetupDiGetClassDescriptionExA(
IN PCSTR MachineName OPTIONAL, IN PCSTR MachineName OPTIONAL,
IN PVOID Reserved) IN PVOID Reserved)
{ {
PWCHAR ClassDescriptionW; PWCHAR ClassDescriptionW = NULL;
LPWSTR MachineNameW = NULL; LPWSTR MachineNameW = NULL;
BOOL ret; BOOL ret = FALSE;
TRACE("%s %p %lu %p %s %p\n", debugstr_guid(ClassGuid), ClassDescription,
ClassDescriptionSize, RequiredSize, debugstr_a(MachineName), Reserved);
TRACE("\n");
if (ClassDescriptionSize > 0) if (ClassDescriptionSize > 0)
{ {
ClassDescriptionW = HeapAlloc(GetProcessHeap(), 0, ClassDescriptionSize * sizeof(WCHAR)); ClassDescriptionW = MyMalloc(ClassDescriptionSize * sizeof(WCHAR));
if (!ClassDescriptionW) if (!ClassDescriptionW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
ret = FALSE; goto cleanup;
goto end;
} }
} }
else
ClassDescriptionW = NULL;
if (MachineName) if (MachineName)
{ {
@ -698,24 +719,25 @@ SetupDiGetClassDescriptionExA(
if (!MachineNameW) if (!MachineNameW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
ret = FALSE; goto cleanup;
goto end;
} }
} }
ret = SetupDiGetClassDescriptionExW(ClassGuid, ClassDescriptionW, ClassDescriptionSize * sizeof(WCHAR), ret = SetupDiGetClassDescriptionExW(ClassGuid, ClassDescriptionW,
NULL, MachineNameW, Reserved); ClassDescriptionSize * sizeof(WCHAR), RequiredSize, MachineNameW, Reserved);
if (ret) if (ret)
{ {
int len = WideCharToMultiByte(CP_ACP, 0, ClassDescriptionW, -1, ClassDescription, int len = WideCharToMultiByte(CP_ACP, 0, ClassDescriptionW, -1, ClassDescription,
ClassDescriptionSize, NULL, NULL); ClassDescriptionSize, NULL, NULL);
if (len > ClassDescriptionSize)
if (!ClassDescriptionSize && RequiredSize) {
*RequiredSize = len; SetLastError(ERROR_INSUFFICIENT_BUFFER);
ret = FALSE;
}
} }
end: cleanup:
HeapFree(GetProcessHeap(), 0, ClassDescriptionW); MyFree(ClassDescriptionW);
MyFree(MachineNameW); MyFree(MachineNameW);
return ret; return ret;
} }
@ -782,7 +804,6 @@ SetupDiGetClassDescriptionExW(
cleanup: cleanup:
if (hKey != INVALID_HANDLE_VALUE) if (hKey != INVALID_HANDLE_VALUE)
RegCloseKey(hKey); RegCloseKey(hKey);
return ret; return ret;
} }
@ -827,49 +848,50 @@ SetupDiGetClassDevsExA(
IN PCSTR MachineName OPTIONAL, IN PCSTR MachineName OPTIONAL,
IN PVOID Reserved) IN PVOID Reserved)
{ {
HDEVINFO ret; LPWSTR EnumeratorW = NULL;
LPWSTR enumstrW = NULL; LPWSTR MachineNameW = NULL;
LPWSTR machineW = NULL; HDEVINFO ret = (HDEVINFO)INVALID_HANDLE_VALUE;
if (Enumerator) if (Enumerator)
{ {
int len = MultiByteToWideChar(CP_ACP, 0, Enumerator, -1, NULL, 0); EnumeratorW = MultiByteToUnicode(Enumerator, CP_ACP);
enumstrW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!EnumeratorW)
if (!enumstrW) goto cleanup;
{
ret = (HDEVINFO)INVALID_HANDLE_VALUE;
goto end;
}
MultiByteToWideChar(CP_ACP, 0, Enumerator, -1, enumstrW, len);
} }
if (MachineName) if (MachineName)
{ {
int len = MultiByteToWideChar(CP_ACP, 0, MachineName, -1, NULL, 0); MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
machineW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!MachineNameW)
if (!machineW) goto cleanup;
{
ret = (HDEVINFO)INVALID_HANDLE_VALUE;
goto end;
} }
MultiByteToWideChar(CP_ACP, 0, MachineName, -1, machineW, len); ret = SetupDiGetClassDevsExW(ClassGuid, EnumeratorW, hwndParent,
} Flags, DeviceInfoSet, MachineNameW, Reserved);
ret = SetupDiGetClassDevsExW(ClassGuid, enumstrW, hwndParent, Flags, DeviceInfoSet, machineW, Reserved);
end: cleanup:
HeapFree(GetProcessHeap(), 0, enumstrW); MyFree(EnumeratorW);
HeapFree(GetProcessHeap(), 0, machineW); MyFree(MachineNameW);
return ret; return ret;
} }
/*********************************************************************** /***********************************************************************
* Helper functions for SetupDiGetClassDevsExW * SETUP_CreateDevicesListFromEnumerator
*
* PARAMS
* list [I] Device info set to fill with discovered devices.
* pClassGuid [I] If specified, only devices which belong to this class will be added.
* Enumerator [I] Location to search devices to add.
* hEnumeratorKey [O] Registry key corresponding to Enumerator key. Must have KEY_ENUMERATE_SUB_KEYS right.
*
* RETURNS
* Success: ERROR_SUCCESS.
* Failure: an error code.
*/ */
static LONG static LONG
SETUP_CreateDevListFromEnumerator( SETUP_CreateDevicesListFromEnumerator(
struct DeviceInfoSet *list, IN OUT struct DeviceInfoSet *list,
CONST GUID *pClassGuid OPTIONAL, IN CONST GUID *pClassGuid OPTIONAL,
LPCWSTR Enumerator, IN LPCWSTR Enumerator,
HKEY hEnumeratorKey) /* handle to Enumerator registry key */ IN HKEY hEnumeratorKey) /* handle to Enumerator registry key */
{ {
HKEY hDeviceIdKey = NULL, hInstanceIdKey; HKEY hDeviceIdKey = NULL, hInstanceIdKey;
WCHAR KeyBuffer[MAX_PATH]; WCHAR KeyBuffer[MAX_PATH];
@ -947,7 +969,7 @@ SETUP_CreateDevListFromEnumerator(
} }
else else
{ {
KeyBuffer[37] = '\0'; /* Replace the } by a NULL character */ KeyBuffer[MAX_GUID_STRING_LEN - 2] = '\0'; /* Replace the } by a NULL character */
if (UuidFromStringW(&KeyBuffer[1], &KeyGuid) != RPC_S_OK) if (UuidFromStringW(&KeyBuffer[1], &KeyGuid) != RPC_S_OK)
/* Bad GUID, skip the entry */ /* Bad GUID, skip the entry */
continue; continue;
@ -979,11 +1001,11 @@ cleanup:
} }
static LONG static LONG
SETUP_CreateDevList( SETUP_CreateDevicesList(
struct DeviceInfoSet *list, IN OUT struct DeviceInfoSet *list,
PCWSTR MachineName OPTIONAL, IN PCWSTR MachineName OPTIONAL,
CONST GUID *class OPTIONAL, IN CONST GUID *Class OPTIONAL,
PCWSTR Enumerator OPTIONAL) IN PCWSTR Enumerator OPTIONAL)
{ {
HKEY HKLM = HKEY_LOCAL_MACHINE; HKEY HKLM = HKEY_LOCAL_MACHINE;
HKEY hEnumKey = NULL; HKEY hEnumKey = NULL;
@ -993,8 +1015,8 @@ SETUP_CreateDevList(
DWORD dwLength; DWORD dwLength;
DWORD rc; DWORD rc;
if (class && IsEqualIID(class, &GUID_NULL)) if (Class && IsEqualIID(Class, &GUID_NULL))
class = NULL; Class = NULL;
/* Open Enum key (if applicable) */ /* Open Enum key (if applicable) */
if (MachineName != NULL) if (MachineName != NULL)
@ -1013,8 +1035,8 @@ SETUP_CreateDevList(
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto cleanup; goto cleanup;
/* If enumerator is provided, call directly SETUP_CreateDevListFromEnumerator. /* If enumerator is provided, call directly SETUP_CreateDevicesListFromEnumerator.
* Else, enumerate all enumerators and call SETUP_CreateDevListFromEnumerator * Else, enumerate all enumerators and call SETUP_CreateDevicesListFromEnumerator
* for each one. * for each one.
*/ */
if (Enumerator) if (Enumerator)
@ -1027,7 +1049,7 @@ SETUP_CreateDevList(
&hEnumeratorKey); &hEnumeratorKey);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto cleanup; goto cleanup;
rc = SETUP_CreateDevListFromEnumerator(list, class, Enumerator, hEnumeratorKey); rc = SETUP_CreateDevicesListFromEnumerator(list, Class, Enumerator, hEnumeratorKey);
} }
else else
{ {
@ -1050,8 +1072,8 @@ SETUP_CreateDevList(
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto cleanup; goto cleanup;
/* Call SETUP_CreateDevListFromEnumerator */ /* Call SETUP_CreateDevicesListFromEnumerator */
rc = SETUP_CreateDevListFromEnumerator(list, class, KeyBuffer, hEnumeratorKey); rc = SETUP_CreateDevicesListFromEnumerator(list, Class, KeyBuffer, hEnumeratorKey);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto cleanup; goto cleanup;
} }
@ -1121,7 +1143,7 @@ SetupDiGetClassDevsExW(
if (Flags & DIGCF_ALLCLASSES) if (Flags & DIGCF_ALLCLASSES)
{ {
rc = SETUP_CreateDevList(list, MachineName, pClassGuid, Enumerator); rc = SETUP_CreateDevicesList(list, MachineName, pClassGuid, Enumerator);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
{ {
SetLastError(rc); SetLastError(rc);
@ -1147,7 +1169,7 @@ SetupDiGetClassDevsExW(
} }
else else
{ {
rc = SETUP_CreateDevList(list, MachineName, ClassGuid, Enumerator); rc = SETUP_CreateDevicesList(list, MachineName, ClassGuid, Enumerator);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
{ {
SetLastError(rc); SetLastError(rc);
@ -1166,7 +1188,7 @@ cleanup:
* SetupDiGetClassImageIndex (SETUPAPI.@) * SetupDiGetClassImageIndex (SETUPAPI.@)
*/ */
static BOOL static BOOL
GetIconIndex( SETUP_GetIconIndex(
IN HKEY hClassKey, IN HKEY hClassKey,
OUT PINT ImageIndex) OUT PINT ImageIndex)
{ {
@ -1240,7 +1262,7 @@ SetupDiGetClassImageIndex(
hKey = SetupDiOpenClassRegKeyExW(ClassGuid, KEY_QUERY_VALUE, DIOCR_INTERFACE, list->MachineName, NULL); hKey = SetupDiOpenClassRegKeyExW(ClassGuid, KEY_QUERY_VALUE, DIOCR_INTERFACE, list->MachineName, NULL);
if (hKey == INVALID_HANDLE_VALUE) if (hKey == INVALID_HANDLE_VALUE)
goto cleanup; goto cleanup;
if (!GetIconIndex(hKey, &iconIndex)) if (!SETUP_GetIconIndex(hKey, &iconIndex))
goto cleanup; goto cleanup;
if (iconIndex >= 0) if (iconIndex >= 0)
@ -1292,7 +1314,6 @@ SetupDiGetClassImageListExA(
ret = SetupDiGetClassImageListExW(ClassImageListData, MachineNameW, Reserved); ret = SetupDiGetClassImageListExW(ClassImageListData, MachineNameW, Reserved);
if (MachineNameW)
MyFree(MachineNameW); MyFree(MachineNameW);
return ret; return ret;
@ -1379,7 +1400,7 @@ SetupDiLoadClassIcon(
if (hKey == INVALID_HANDLE_VALUE) if (hKey == INVALID_HANDLE_VALUE)
goto cleanup; goto cleanup;
if (!GetIconIndex(hKey, &iconIndex)) if (!SETUP_GetIconIndex(hKey, &iconIndex))
goto cleanup; goto cleanup;
if (iconIndex > 0) if (iconIndex > 0)
@ -1534,7 +1555,7 @@ SetupDiInstallClassExA(
* Helper function for SetupDiInstallClassExW * Helper function for SetupDiInstallClassExW
*/ */
static HKEY static HKEY
CreateClassKey(HINF hInf) SETUP_CreateClassKey(HINF hInf)
{ {
WCHAR FullBuffer[MAX_PATH]; WCHAR FullBuffer[MAX_PATH];
WCHAR Buffer[MAX_PATH]; WCHAR Buffer[MAX_PATH];
@ -1698,7 +1719,7 @@ SetupDiInstallClassExW(
else else
{ {
/* Create or open the class registry key 'HKLM\CurrentControlSet\Class\{GUID}' */ /* Create or open the class registry key 'HKLM\CurrentControlSet\Class\{GUID}' */
hRootKey = CreateClassKey(hInf); hRootKey = SETUP_CreateClassKey(hInf);
if (hRootKey == INVALID_HANDLE_VALUE) if (hRootKey == INVALID_HANDLE_VALUE)
goto cleanup; goto cleanup;
@ -1788,7 +1809,8 @@ SetupDiOpenClassRegKeyExA(
PWSTR MachineNameW = NULL; PWSTR MachineNameW = NULL;
HKEY hKey; HKEY hKey;
TRACE("\n"); TRACE("%s 0x%lx 0x%lx %s %p\n", debugstr_guid(ClassGuid), samDesired,
Flags, debugstr_a(MachineName), Reserved);
if (MachineName) if (MachineName)
{ {
@ -1800,7 +1822,6 @@ SetupDiOpenClassRegKeyExA(
hKey = SetupDiOpenClassRegKeyExW(ClassGuid, samDesired, hKey = SetupDiOpenClassRegKeyExW(ClassGuid, samDesired,
Flags, MachineNameW, Reserved); Flags, MachineNameW, Reserved);
if (MachineNameW)
MyFree(MachineNameW); MyFree(MachineNameW);
return hKey; return hKey;
@ -1836,7 +1857,7 @@ SetupDiOpenClassRegKeyExW(
lpKeyName = REGSTR_PATH_DEVICE_CLASSES; lpKeyName = REGSTR_PATH_DEVICE_CLASSES;
else else
{ {
ERR("Invalid Flags parameter!\n"); TRACE("Unknown flags: 0x%lx\n", Flags);
SetLastError(ERROR_INVALID_FLAGS); SetLastError(ERROR_INVALID_FLAGS);
goto cleanup; goto cleanup;
} }
@ -1858,7 +1879,8 @@ SetupDiOpenClassRegKeyExW(
0, 0,
ClassGuid ? 0 : samDesired, ClassGuid ? 0 : samDesired,
&hClassesKey); &hClassesKey);
if (MachineName != NULL) RegCloseKey(HKLM); if (MachineName != NULL)
RegCloseKey(HKLM);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
{ {
SetLastError(rc); SetLastError(rc);
@ -1933,7 +1955,7 @@ SetupDiSetClassInstallParamsA(
* Helper functions for SetupDiSetClassInstallParamsW * Helper functions for SetupDiSetClassInstallParamsW
*/ */
static BOOL static BOOL
PropertyChangeHandler( SETUP_PropertyChangeHandler(
IN HDEVINFO DeviceInfoSet, IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData, IN PSP_DEVINFO_DATA DeviceInfoData,
IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL, IN PSP_CLASSINSTALL_HEADER ClassInstallParams OPTIONAL,
@ -2108,7 +2130,7 @@ struct ClassDevPropertySheetsData
}; };
static BOOL WINAPI static BOOL WINAPI
GetClassDevPropertySheetsCallback( SETUP_GetClassDevPropertySheetsCallback(
IN HPROPSHEETPAGE hPropSheetPage, IN HPROPSHEETPAGE hPropSheetPage,
IN OUT LPARAM lParam) IN OUT LPARAM lParam)
{ {
@ -2230,7 +2252,7 @@ SetupDiGetClassDevPropertySheetsW(
PropPageData.PropertySheetPages = &PropertySheetHeader->phpage[PropertySheetHeader->nPages]; PropPageData.PropertySheetPages = &PropertySheetHeader->phpage[PropertySheetHeader->nPages];
PropPageData.MaximumNumberOfPages = PropertySheetHeaderPageListSize - PropertySheetHeader->nPages; PropPageData.MaximumNumberOfPages = PropertySheetHeaderPageListSize - PropertySheetHeader->nPages;
PropPageData.NumberOfPages = 0; PropPageData.NumberOfPages = 0;
ret = pPropPageProvider(&Request, GetClassDevPropertySheetsCallback, (LPARAM)&PropPageData); ret = pPropPageProvider(&Request, SETUP_GetClassDevPropertySheetsCallback, (LPARAM)&PropPageData);
if (!ret) if (!ret)
goto cleanup; goto cleanup;