From d9e20ae3fe8e68701812782b35a3e9da8c30feef Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 7 Dec 2020 23:16:39 +0100 Subject: [PATCH] Implement the StorageCoInstaller and configure it for CD-ROM and Disk devices This sets the friendly name for CD-ROM and Disk devices. --- boot/bootdata/hivesys.inf | 4 +- dll/win32/syssetup/classinst.c | 75 +++++++++++++++++++++++++++++++--- dll/win32/syssetup/install.c | 4 +- dll/win32/syssetup/precomp.h | 1 + 4 files changed, 75 insertions(+), 9 deletions(-) diff --git a/boot/bootdata/hivesys.inf b/boot/bootdata/hivesys.inf index e5aba999df0..bbb94bc2ffd 100644 --- a/boot/bootdata/hivesys.inf +++ b/boot/bootdata/hivesys.inf @@ -402,8 +402,8 @@ HKLM,"SYSTEM\CurrentControlSet\Control\Class\{9D6D66A6-0B0C-4563-9077-A0E9A7955A ; Class Co-Installers HKLM,"SYSTEM\CurrentControlSet\Control\CoDeviceInstallers",,0x00000012 -HKLM,"SYSTEM\CurrentControlSet\Control\CoDeviceInstallers","{4D36E965-E325-11CE-BFC1-08002BE10318}",0x00010000,"syssetup.dll,CriticalDeviceCoInstaller" -HKLM,"SYSTEM\CurrentControlSet\Control\CoDeviceInstallers","{4D36E967-E325-11CE-BFC1-08002BE10318}",0x00010000,"syssetup.dll,CriticalDeviceCoInstaller" +HKLM,"SYSTEM\CurrentControlSet\Control\CoDeviceInstallers","{4D36E965-E325-11CE-BFC1-08002BE10318}",0x00010000,"syssetup.dll,StorageCoInstaller","syssetup.dll,CriticalDeviceCoInstaller" +HKLM,"SYSTEM\CurrentControlSet\Control\CoDeviceInstallers","{4D36E967-E325-11CE-BFC1-08002BE10318}",0x00010000,"syssetup.dll,StorageCoInstaller","syssetup.dll,CriticalDeviceCoInstaller" HKLM,"SYSTEM\CurrentControlSet\Control\CoDeviceInstallers","{4D36E96A-E325-11CE-BFC1-08002BE10318}",0x00010000,"syssetup.dll,CriticalDeviceCoInstaller" HKLM,"SYSTEM\CurrentControlSet\Control\CoDeviceInstallers","{4D36E96B-E325-11CE-BFC1-08002BE10318}",0x00010000,"syssetup.dll,CriticalDeviceCoInstaller" HKLM,"SYSTEM\CurrentControlSet\Control\CoDeviceInstallers","{4D36E96F-E325-11CE-BFC1-08002BE10318}",0x00010000,"syssetup.dll,CriticalDeviceCoInstaller" diff --git a/dll/win32/syssetup/classinst.c b/dll/win32/syssetup/classinst.c index d7ea97e1d0a..9ba49989ed2 100644 --- a/dll/win32/syssetup/classinst.c +++ b/dll/win32/syssetup/classinst.c @@ -377,7 +377,7 @@ ScsiClassInstaller( /* - * @unimplemented + * @implemented */ DWORD WINAPI @@ -387,12 +387,77 @@ StorageCoInstaller( IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL, IN OUT PCOINSTALLER_CONTEXT_DATA Context) { - switch (InstallFunction) + ULONG ulStatus, ulProblem; + DWORD dwBufferSize = 0; + PWSTR pszDeviceDescription; + CONFIGRET ret; + + DPRINT("StorageCoInstaller(%u %p %p %p)\n", + InstallFunction, DeviceInfoSet, DeviceInfoData, Context); + + if (InstallFunction != DIF_INSTALLDEVICE) + return ERROR_SUCCESS; + + if (Context->PostProcessing) { - default: - DPRINT1("Install function %u ignored\n", InstallFunction); - return ERROR_SUCCESS; + if (Context->PrivateData != NULL) + { + pszDeviceDescription = (PWSTR)Context->PrivateData; + + /* Store the device description as the friendly name */ + SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet, + DeviceInfoData, + SPDRP_FRIENDLYNAME, + (PBYTE)pszDeviceDescription, + (wcslen(pszDeviceDescription) + 1) * sizeof(WCHAR)); + + /* Free the device description */ + HeapFree(GetProcessHeap(), 0, Context->PrivateData); + Context->PrivateData = NULL; + } } + else + { + if (DeviceInfoData == NULL) + return ERROR_SUCCESS; + + ret = CM_Get_DevNode_Status(&ulStatus, &ulProblem, DeviceInfoData->DevInst, 0); + if (ret != CR_SUCCESS) + return ERROR_SUCCESS; + + if (ulStatus & DN_ROOT_ENUMERATED) + return ERROR_SUCCESS; + + /* Get the device description size */ + SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet, + DeviceInfoData, + SPDRP_DEVICEDESC, + NULL, + NULL, + 0, + &dwBufferSize); + if (dwBufferSize == 0) + return ERROR_SUCCESS; + + /* Allocate the device description buffer */ + pszDeviceDescription = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwBufferSize); + if (pszDeviceDescription == NULL) + return ERROR_SUCCESS; + + /* Get the device description */ + SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet, + DeviceInfoData, + SPDRP_DEVICEDESC, + NULL, + (PBYTE)pszDeviceDescription, + dwBufferSize, + &dwBufferSize); + + Context->PrivateData = (PVOID)pszDeviceDescription; + return ERROR_DI_POSTPROCESSING_REQUIRED; + } + + return ERROR_SUCCESS; } diff --git a/dll/win32/syssetup/install.c b/dll/win32/syssetup/install.c index 5f5f92bcf7f..348ca43d663 100644 --- a/dll/win32/syssetup/install.c +++ b/dll/win32/syssetup/install.c @@ -26,8 +26,8 @@ #define NDEBUG #include -DWORD WINAPI -CMP_WaitNoPendingInstallEvents(DWORD dwTimeout); +//DWORD WINAPI +//CMP_WaitNoPendingInstallEvents(DWORD dwTimeout); DWORD WINAPI SetupStartService(LPCWSTR lpServiceName, BOOL bWait); diff --git a/dll/win32/syssetup/precomp.h b/dll/win32/syssetup/precomp.h index 18fdf66d807..e1e4c3f352c 100644 --- a/dll/win32/syssetup/precomp.h +++ b/dll/win32/syssetup/precomp.h @@ -17,6 +17,7 @@ #include #include #include +#include #include "globals.h" #include "resource.h"