Index: dll/win32/setupapi/devinst.c =================================================================== --- dll/win32/setupapi/devinst.c (revision 61145) +++ dll/win32/setupapi/devinst.c (working copy) @@ -659,7 +659,7 @@ * SetupDiBuildClassInfoListExA (SETUPAPI.@) * * Returns a list of setup class GUIDs that identify the classes - * that are installed on a local or remote macine. + * that are installed on a local or remote machine. * * PARAMS * Flags [I] control exclusion of classes from the list. @@ -706,7 +706,7 @@ * SetupDiBuildClassInfoListExW (SETUPAPI.@) * * Returns a list of setup class GUIDs that identify the classes - * that are installed on a local or remote macine. + * that are installed on a local or remote machine. * * PARAMS * Flags [I] control exclusion of classes from the list. @@ -739,16 +739,8 @@ TRACE("0x%lx %p %lu %p %s %p\n", Flags, ClassGuidList, ClassGuidListSize, RequiredSize, debugstr_w(MachineName), Reserved); - if (!RequiredSize) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - else if (!ClassGuidList && ClassGuidListSize > 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } + if (RequiredSize != NULL) + *RequiredSize = 0; hClassesKey = SetupDiOpenClassRegKeyExW(NULL, KEY_ENUMERATE_SUB_KEYS, @@ -959,17 +951,20 @@ TRACE("%s %p %lu %p %s %p\n", debugstr_w(ClassName), ClassGuidList, ClassGuidListSize, RequiredSize, debugstr_w(MachineName), Reserved); - if (!ClassName || !RequiredSize) + if (RequiredSize != NULL) + *RequiredSize = 0; + + if (!ClassName) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } + if (!ClassGuidList && ClassGuidListSize > 0) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - *RequiredSize = 0; hClassesKey = SetupDiOpenClassRegKeyExW(NULL, KEY_ENUMERATE_SUB_KEYS, @@ -1115,6 +1110,9 @@ SetLastError(ERROR_INSUFFICIENT_BUFFER); ret = FALSE; } + + if (!ClassNameSize && RequiredSize) + *RequiredSize = len; } MyFree(MachineNameW); return ret; @@ -1256,7 +1254,7 @@ * Create an empty DeviceInfoSet list. * * PARAMS - * ClassGuid [I] if not NULL only devices with GUID ClcassGuid are associated + * ClassGuid [I] if not NULL only devices with GUID ClassGuid are associated * with this list. * hwndParent [I] hwnd needed for interface related actions. * MachineName [I] name of machine to create emtpy DeviceInfoSet list, if NULL @@ -1459,16 +1457,6 @@ SetLastError(ERROR_INVALID_FLAGS); return INVALID_HANDLE_VALUE; } - if (InfHandle && !InfSectionName) - { - SetLastError(ERROR_INVALID_PARAMETER); - return INVALID_HANDLE_VALUE; - } - if (!InfHandle && InfSectionName) - { - SetLastError(ERROR_INVALID_PARAMETER); - return INVALID_HANDLE_VALUE; - } if (Scope == DICS_FLAG_GLOBAL) RootKey = set->HKLM; @@ -1643,8 +1631,9 @@ /* Do installation of the specified section */ if (InfHandle) { - FIXME("Need to install section %s in file %p\n", - debugstr_w(InfSectionName), InfHandle); + SetupInstallFromInfSectionW(NULL, InfHandle, InfSectionName, SPINST_ALL, + NULL, NULL, SP_COPY_NEWER_ONLY, NULL, NULL, DeviceInfoSet, + DeviceInfoData); } key = hKey; @@ -1944,9 +1933,8 @@ struct DeviceInfoSet *list = (struct DeviceInfoSet *)devinfo; if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC) { - if (info->cbSize != sizeof(SP_DEVINFO_DATA)) - SetLastError(ERROR_INVALID_USER_BUFFER); - else + + if (info->cbSize == sizeof(SP_DEVINFO_DATA)) { PLIST_ENTRY ItemList = list->ListHead.Flink; while (ItemList != &list->ListHead && index-- > 0) @@ -1964,6 +1952,9 @@ ret = TRUE; } } + else + SetLastError(ERROR_INVALID_USER_BUFFER); + } else SetLastError(ERROR_INVALID_HANDLE); @@ -2032,13 +2023,6 @@ } MyFree(instanceId); } - else - { - if (RequiredSize) - *RequiredSize = size; - SetLastError(ERROR_INSUFFICIENT_BUFFER); - ret = FALSE; - } return ret; } @@ -2075,16 +2059,11 @@ return FALSE; } devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved; - if (!DeviceInstanceId && DeviceInstanceIdSize > 0) + if (devInfo->set != set) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - if (DeviceInstanceId && DeviceInstanceIdSize == 0) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } TRACE("instance ID: %s\n", debugstr_w(devInfo->instanceId)); if (DeviceInstanceIdSize < lstrlenW(devInfo->instanceId) + 1) { @@ -2590,12 +2569,12 @@ if (set->MachineName) { FIXME("Stub\n"); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + DevInfoData->RemoteMachineName[0] = '\0'; } else - DevInfoData->RemoteMachineName[0] = 0; - + { + DevInfoData->RemoteMachineName[0] = '\0'; + } return TRUE; } @@ -2631,8 +2610,7 @@ if (set->MachineName) strcpyW(DevInfoData->RemoteMachineName, set->MachineName + 2); else - DevInfoData->RemoteMachineName[0] = 0; - + DevInfoData->RemoteMachineName[0] = '\0'; return TRUE; } @@ -2949,6 +2927,8 @@ SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } + /* In case application fails to check return value, clear output */ + memset(DeviceInterfaceData, 0, sizeof(*DeviceInterfaceData)); if (DeviceInfoData) { struct DeviceInfo *devInfo = @@ -3177,7 +3157,9 @@ SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - if (DeviceInterfaceDetailData && DeviceInterfaceDetailData->cbSize != sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W)) + if (DeviceInterfaceDetailData && (DeviceInterfaceDetailData->cbSize < + offsetof(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath) + sizeof(WCHAR) || + DeviceInterfaceDetailData->cbSize > sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W))) { SetLastError(ERROR_INVALID_USER_BUFFER); return FALSE; @@ -3286,28 +3268,50 @@ DWORD PropertyBufferSize, PDWORD RequiredSize) { - BOOL ret; + BOOL ret = FALSE; BOOL bIsStringProperty; DWORD RegType; DWORD RequiredSizeA, RequiredSizeW; DWORD PropertyBufferSizeW = 0; PBYTE PropertyBufferW = NULL; + struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet; TRACE("%p %p %d %p %p %d %p\n", DeviceInfoSet, DeviceInfoData, Property, PropertyRegDataType, PropertyBuffer, PropertyBufferSize, RequiredSize); - if (PropertyBufferSize != 0) + if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE) { - PropertyBufferSizeW = PropertyBufferSize * 2; - PropertyBufferW = HeapAlloc(GetProcessHeap(), 0, PropertyBufferSizeW); - if (!PropertyBufferW) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; } + if (set->magic != SETUP_DEVICE_INFO_SET_MAGIC) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (!DeviceInfoData || DeviceInfoData->cbSize != sizeof(SP_DEVINFO_DATA) + || !DeviceInfoData->Reserved) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + if (PropertyBufferSize && PropertyBuffer == NULL) + { + SetLastError(ERROR_INVALID_DATA); + return FALSE; + } + + PropertyBufferSizeW = PropertyBufferSize * 2; + PropertyBufferW = HeapAlloc(GetProcessHeap(), 0, PropertyBufferSizeW); + if (!PropertyBufferW) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + ret = SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, Property, @@ -3395,6 +3399,11 @@ SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } + if (PropertyBufferSize && PropertyBuffer == NULL) + { + SetLastError(ERROR_INVALID_DATA); + return FALSE; + } devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved; if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0]) && PropertyMap[Property].nameW) @@ -3482,9 +3491,25 @@ return FALSE; } - FIXME("%p %p 0x%lx %p 0x%lx\n", DeviceInfoSet, DeviceInfoData, - Property, PropertyBuffer, PropertyBufferSize); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0]) + && PropertyMap[Property].nameA) + { + HKEY hKey; + LONG l; + hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_SET_VALUE); + if (hKey == INVALID_HANDLE_VALUE) + return FALSE; + /* Write new data */ + l = RegSetValueExW( + hKey, PropertyMap[Property].nameW, 0, + PropertyMap[Property].regType, PropertyBuffer, + PropertyBufferSize); + if (!l) + ret = TRUE; + else + SetLastError(l); + RegCloseKey(hKey); + } return ret; } @@ -5942,4 +5967,4 @@ if (RootKey != set->HKLM) RegCloseKey(RootKey); return ret; -} +} \ No newline at end of file