- install software bus pnp enumerator when an audio device is installed

svn path=/trunk/; revision=66599
This commit is contained in:
Johannes Anderwald
2015-03-07 17:33:13 +00:00
parent 3eba2a1fe4
commit 4f6af40fc9
+96
View File
@@ -15,6 +15,7 @@
#include <shlwapi.h>
#include <debug.h>
#include <newdev.h>
#include <initguid.h>
#include <devguid.h>
@@ -87,6 +88,14 @@ DeviceCreateHardwarePageEx(HWND hWndParent,
UINT uNumberOfGuids,
HWPAGE_DISPLAYMODE DisplayMode);
typedef BOOL (WINAPI *UpdateDriverForPlugAndPlayDevicesProto)(IN OPTIONAL HWND hwndParent,
IN LPCTSTR HardwareId,
IN LPCTSTR FullInfPath,
IN DWORD InstallFlags,
OUT OPTIONAL PBOOL bRebootRequired
);
#define UPDATEDRIVERFORPLUGANDPLAYDEVICES "UpdateDriverForPlugAndPlayDevicesW"
#define NUM_APPLETS (1)
@@ -328,6 +337,80 @@ InstallSystemSoundScheme()
RegCloseKey(hKey);
}
DWORD
InstallSoftwareBusPnpEnumerator(LPWSTR InfPath, LPCWSTR HardwareIdList)
{
HDEVINFO DeviceInfoSet = INVALID_HANDLE_VALUE;
SP_DEVINFO_DATA DeviceInfoData;
GUID ClassGUID;
TCHAR ClassName[50];
int Result = 0;
HMODULE hModule = NULL;
UpdateDriverForPlugAndPlayDevicesProto UpdateProc;
BOOL reboot = FALSE;
DWORD flags = 0;
if (!SetupDiGetINFClass(InfPath,&ClassGUID,ClassName,sizeof(ClassName)/sizeof(ClassName[0]),0))
{
return -1;
}
DeviceInfoSet = SetupDiCreateDeviceInfoList(&ClassGUID,0);
if(DeviceInfoSet == INVALID_HANDLE_VALUE)
{
return -1;
}
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
if (!SetupDiCreateDeviceInfo(DeviceInfoSet, ClassName, &ClassGUID, NULL, 0, DICD_GENERATE_ID, &DeviceInfoData))
{
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
return -1;
}
if(!SetupDiSetDeviceRegistryProperty(DeviceInfoSet, &DeviceInfoData, SPDRP_HARDWAREID, (LPBYTE)HardwareIdList, (lstrlen(HardwareIdList)+1+1)*sizeof(TCHAR)))
{
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
return -1;
}
if (!SetupDiCallClassInstaller(DIF_REGISTERDEVICE, DeviceInfoSet, &DeviceInfoData))
{
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
return -1;
}
if(GetFileAttributes(InfPath)==(DWORD)(-1)) {
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
return -1;
}
flags |= INSTALLFLAG_FORCE;
hModule = LoadLibraryW(L"newdev.dll");
if(!hModule) {
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
return -1;
}
UpdateProc = (UpdateDriverForPlugAndPlayDevicesProto)GetProcAddress(hModule,UPDATEDRIVERFORPLUGANDPLAYDEVICES);
if(!UpdateProc)
{
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
FreeLibrary(hModule);
return -1;
}
if(!UpdateProc(NULL, HardwareIdList, InfPath, flags, &reboot))
{
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
FreeLibrary(hModule);
return -1;
}
FreeLibrary(hModule);
SetupDiDestroyDeviceInfoList(DeviceInfoSet);
return Result;
}
DWORD
MMSYS_InstallDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoData)
@@ -401,7 +484,20 @@ MMSYS_InstallDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pspDevInfoData)
SetupTermDefaultQueueCallback(Context);
SetupCloseInfFile(hInf);
Length = GetWindowsDirectoryW(szBuffer, MAX_PATH);
if (!Length || Length >= MAX_PATH - 14)
{
return ERROR_GEN_FAILURE;
}
pBuffer = PathAddBackslashW(szBuffer);
if (!pBuffer)
{
return ERROR_GEN_FAILURE;
}
wcscpy(pBuffer, L"inf\\machine.inf");
InstallSoftwareBusPnpEnumerator(szBuffer, L"ROOT\\SWENUM");
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
if (!hSCManager)