Author: janderwald
Date: Sat Mar 7 17:33:13 2015
New Revision: 66599
URL:
http://svn.reactos.org/svn/reactos?rev=66599&view=rev
Log:
[MMSYS]
- install software bus pnp enumerator when an audio device is installed
Modified:
trunk/reactos/dll/cpl/mmsys/mmsys.c
Modified: trunk/reactos/dll/cpl/mmsys/mmsys.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/mmsys.c?rev=…
==============================================================================
--- trunk/reactos/dll/cpl/mmsys/mmsys.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/mmsys/mmsys.c [iso-8859-1] Sat Mar 7 17:33:13 2015
@@ -15,6 +15,7 @@
#include <shlwapi.h>
#include <debug.h>
+#include <newdev.h>
#include <initguid.h>
#include <devguid.h>
@@ -87,6 +88,14 @@
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 @@
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 @@
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)