From ae92a267d03389eff604cc17f9a311b160fdd21d Mon Sep 17 00:00:00 2001 From: Thamatip Chitpong Date: Mon, 30 Oct 2023 09:50:35 +0700 Subject: [PATCH] [HOTPLUG] Move device enumeration code to enum.c --- dll/cpl/hotplug/eject.c | 124 ++-------------- dll/cpl/hotplug/enum.c | 294 ++++++++++++++++++++++++++++++++++++++ dll/cpl/hotplug/hotplug.c | 227 ++--------------------------- dll/cpl/hotplug/hotplug.h | 18 +++ 4 files changed, 338 insertions(+), 325 deletions(-) diff --git a/dll/cpl/hotplug/eject.c b/dll/cpl/hotplug/eject.c index b5554e1b00108..16ab96f35a439 100644 --- a/dll/cpl/hotplug/eject.c +++ b/dll/cpl/hotplug/eject.c @@ -1,16 +1,12 @@ /* * PROJECT: ReactOS Safely Remove Hardware Applet * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) - * PURPOSE: Confirm Removal Dialog + * PURPOSE: Device Removal Support * COPYRIGHT: Copyright 2023 Thamatip Chitpong */ #include "hotplug.h" -#include -#include - -static DEVINST GetDeviceInstForRemoval( _In_ PHOTPLUG_DATA pHotplugData) @@ -37,90 +33,19 @@ GetDeviceInstForRemoval( return tvItem.lParam; } -static -VOID -InsertConfirmDeviceListItem( - _In_ HWND hwndCfmDeviceList, - _In_ DEVINST DevInst, - _In_ PHOTPLUG_DATA pHotplugData) -{ - WCHAR szDisplayName[40]; - WCHAR szGuidString[MAX_GUID_STRING_LEN]; - DWORD dwSize; - GUID ClassGuid; - INT nClassImage; - CONFIGRET cr; - LVITEMW lvItem; - - /* Get the device description */ - dwSize = sizeof(szDisplayName); - cr = CM_Get_DevNode_Registry_Property(DevInst, - CM_DRP_DEVICEDESC, - NULL, - szDisplayName, - &dwSize, - 0); - if (cr != CR_SUCCESS) - wcscpy(szDisplayName, L"Unknown Device"); - - /* Get the class GUID */ - dwSize = sizeof(szGuidString); - cr = CM_Get_DevNode_Registry_Property(DevInst, - CM_DRP_CLASSGUID, - NULL, - szGuidString, - &dwSize, - 0); - if (cr == CR_SUCCESS) - { - pSetupGuidFromString(szGuidString, &ClassGuid); - } - else - { - memcpy(&ClassGuid, &GUID_DEVCLASS_UNKNOWN, sizeof(GUID)); - } - - /* Get the image for the class this device is in */ - SetupDiGetClassImageIndex(&pHotplugData->ImageListData, - &ClassGuid, - &nClassImage); - - /* Add it to the confirm device list */ - ZeroMemory(&lvItem, sizeof(lvItem)); - lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; - lvItem.iItem = ListView_GetItemCount(hwndCfmDeviceList); - lvItem.pszText = szDisplayName; - lvItem.iImage = nClassImage; - lvItem.lParam = (LPARAM)DevInst; - - ListView_InsertItem(hwndCfmDeviceList, &lvItem); -} - -static VOID -CfmListRecursiveInsertSubDevices( - _In_ HWND hwndCfmDeviceList, - _In_ DEVINST ParentDevInst, - _In_ PHOTPLUG_DATA pHotplugData) +SafeRemoveDevice( + _In_ DEVINST DevInst) { - DEVINST ChildDevInst; + PNP_VETO_TYPE VetoType = PNP_VetoTypeUnknown; CONFIGRET cr; - cr = CM_Get_Child(&ChildDevInst, ParentDevInst, 0); - if (cr != CR_SUCCESS) - return; - - InsertConfirmDeviceListItem(hwndCfmDeviceList, ChildDevInst, pHotplugData); - CfmListRecursiveInsertSubDevices(hwndCfmDeviceList, ChildDevInst, pHotplugData); - - for (;;) + cr = CM_Request_Device_EjectW(DevInst, &VetoType, NULL, 0, 0); + if (cr != CR_SUCCESS && VetoType == PNP_VetoTypeUnknown) { - cr = CM_Get_Sibling(&ChildDevInst, ChildDevInst, 0); - if (cr != CR_SUCCESS) - return; - - InsertConfirmDeviceListItem(hwndCfmDeviceList, ChildDevInst, pHotplugData); - CfmListRecursiveInsertSubDevices(hwndCfmDeviceList, ChildDevInst, pHotplugData); + WCHAR szError[64]; + swprintf(szError, L"Failed to remove device (0x%x)", cr); + MessageBoxW(NULL, szError, NULL, MB_ICONEXCLAMATION | MB_OK); } } @@ -130,41 +55,18 @@ FillConfirmDeviceList( _In_ HWND hwndCfmDeviceList, _In_ PHOTPLUG_DATA pHotplugData) { - DEVINST DevInst; LVCOLUMNW lvColumn; - DevInst = GetDeviceInstForRemoval(pHotplugData); - if (DevInst == 0) - return; - ZeroMemory(&lvColumn, sizeof(lvColumn)); lvColumn.mask = LVCF_FMT; lvColumn.fmt = LVCFMT_LEFT | LVCFMT_IMAGE; ListView_InsertColumn(hwndCfmDeviceList, 0, &lvColumn); - InsertConfirmDeviceListItem(hwndCfmDeviceList, DevInst, pHotplugData); - CfmListRecursiveInsertSubDevices(hwndCfmDeviceList, DevInst, pHotplugData); + CfmListEnumDevices(hwndCfmDeviceList, pHotplugData); ListView_SetColumnWidth(hwndCfmDeviceList, 0, LVSCW_AUTOSIZE_USEHEADER); } -static -VOID -SafeRemoveDevice( - _In_ DEVINST DevInst) -{ - PNP_VETO_TYPE VetoType = PNP_VetoTypeUnknown; - CONFIGRET cr; - - cr = CM_Request_Device_EjectW(DevInst, &VetoType, NULL, 0, 0); - if (cr != CR_SUCCESS && VetoType == PNP_VetoTypeUnknown) - { - WCHAR szError[64]; - swprintf(szError, L"Failed to remove device (0x%x)", cr); - MessageBoxW(NULL, szError, NULL, MB_ICONEXCLAMATION | MB_OK); - } -} - INT_PTR CALLBACK ConfirmRemovalDlgProc( @@ -199,12 +101,8 @@ ConfirmRemovalDlgProc( switch (LOWORD(wParam)) { case IDOK: - SafeRemoveDevice(GetDeviceInstForRemoval(pHotplugData)); - EndDialog(hwndDlg, 0); - break; - case IDCANCEL: - EndDialog(hwndDlg, 0); + EndDialog(hwndDlg, LOWORD(wParam)); break; } diff --git a/dll/cpl/hotplug/enum.c b/dll/cpl/hotplug/enum.c index 26e25e660b896..9aa831492ecdd 100644 --- a/dll/cpl/hotplug/enum.c +++ b/dll/cpl/hotplug/enum.c @@ -4,4 +4,298 @@ * FILE: dll/cpl/hotplug/enum.c * PURPOSE: device enumeration * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org) + * Thamatip Chitpong (thamatip.chitpong@reactos.org) */ + +#include "hotplug.h" + +#include +#include + +#define MAX_DEVICE_DISPLAYNAME_LEN 40 + +static +HTREEITEM +InsertDeviceTreeItem( + _In_ HTREEITEM hParent, + _In_ DWORD DevInst, + _In_ PHOTPLUG_DATA pHotplugData) +{ + WCHAR szDisplayName[MAX_DEVICE_DISPLAYNAME_LEN]; + WCHAR szGuidString[MAX_GUID_STRING_LEN]; + TVINSERTSTRUCTW tvItem; + GUID ClassGuid; + INT nClassImage; + DWORD dwSize; + CONFIGRET cr; + + /* Get the device description */ + dwSize = sizeof(szDisplayName); + cr = CM_Get_DevNode_Registry_Property(DevInst, + CM_DRP_DEVICEDESC, + NULL, + szDisplayName, + &dwSize, + 0); + if (cr != CR_SUCCESS) + wcscpy(szDisplayName, L"Unknown Device"); + + /* Get the class GUID */ + dwSize = sizeof(szGuidString); + cr = CM_Get_DevNode_Registry_Property(DevInst, + CM_DRP_CLASSGUID, + NULL, + szGuidString, + &dwSize, + 0); + if (cr == CR_SUCCESS) + { + pSetupGuidFromString(szGuidString, &ClassGuid); + } + else + { + memcpy(&ClassGuid, &GUID_DEVCLASS_UNKNOWN, sizeof(GUID)); + } + + /* Get the image for the class this device is in */ + SetupDiGetClassImageIndex(&pHotplugData->ImageListData, + &ClassGuid, + &nClassImage); + + /* Add it to the device tree */ + ZeroMemory(&tvItem, sizeof(tvItem)); + tvItem.hParent = hParent; + tvItem.hInsertAfter = TVI_LAST; + + tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvItem.item.state = TVIS_EXPANDED; + tvItem.item.stateMask = TVIS_EXPANDED; + tvItem.item.pszText = szDisplayName; + tvItem.item.iImage = nClassImage; + tvItem.item.iSelectedImage = nClassImage; + tvItem.item.lParam = (LPARAM)DevInst; + + return TreeView_InsertItem(pHotplugData->hwndDeviceTree, &tvItem); +} + +static +VOID +DevTreeRecursiveInsertSubDevices( + _In_ HTREEITEM hParentItem, + _In_ DWORD ParentDevInst, + _In_ PHOTPLUG_DATA pHotplugData) +{ + HTREEITEM hTreeItem; + DEVINST ChildDevInst; + CONFIGRET cr; + + //DPRINT("DevTreeRecursiveInsertSubDevices()\n"); + + cr = CM_Get_Child(&ChildDevInst, ParentDevInst, 0); + if (cr != CR_SUCCESS) + { + //DPRINT("No child! %lu\n", cr); + return; + } + + hTreeItem = InsertDeviceTreeItem(hParentItem, + ChildDevInst, + pHotplugData); + if (hTreeItem != NULL) + { + DevTreeRecursiveInsertSubDevices(hTreeItem, + ChildDevInst, + pHotplugData); + } + + for (;;) + { + cr = CM_Get_Sibling(&ChildDevInst, ChildDevInst, 0); + if (cr != CR_SUCCESS) + { + //DPRINT("No sibling! %lu\n", cr); + return; + } + + hTreeItem = InsertDeviceTreeItem(hParentItem, + ChildDevInst, + pHotplugData); + if (hTreeItem != NULL) + { + DevTreeRecursiveInsertSubDevices(hTreeItem, + ChildDevInst, + pHotplugData); + } + } +} + +VOID +EnumHotpluggedDevices( + _In_ PHOTPLUG_DATA pHotplugData) +{ + SP_DEVINFO_DATA did = { 0 }; + HDEVINFO hdev; + int idev; + DWORD dwCapabilities, dwSize; + ULONG ulStatus, ulProblem; + HTREEITEM hTreeItem; + CONFIGRET cr; + + //DPRINT1("EnumHotpluggedDevices()\n"); + + TreeView_DeleteAllItems(pHotplugData->hwndDeviceTree); + + hdev = SetupDiGetClassDevs(NULL, NULL, 0, DIGCF_ALLCLASSES | DIGCF_PRESENT); + if (hdev == INVALID_HANDLE_VALUE) + return; + + did.cbSize = sizeof(did); + + /* Enumerate all the attached devices */ + for (idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); idev++) + { + ulStatus = 0; + ulProblem = 0; + + cr = CM_Get_DevNode_Status(&ulStatus, + &ulProblem, + did.DevInst, + 0); + if (cr != CR_SUCCESS) + continue; + + dwCapabilities = 0, + dwSize = sizeof(dwCapabilities); + cr = CM_Get_DevNode_Registry_Property(did.DevInst, + CM_DRP_CAPABILITIES, + NULL, + &dwCapabilities, + &dwSize, + 0); + if (cr != CR_SUCCESS) + continue; + + /* Add devices that require safe removal to the device tree */ + if ( (dwCapabilities & CM_DEVCAP_REMOVABLE) && + !(dwCapabilities & CM_DEVCAP_DOCKDEVICE) && + !(dwCapabilities & CM_DEVCAP_SURPRISEREMOVALOK) && + ((dwCapabilities & CM_DEVCAP_EJECTSUPPORTED) || (ulStatus & DN_DISABLEABLE)) && + ulProblem == 0) + { + hTreeItem = InsertDeviceTreeItem(TVI_ROOT, + did.DevInst, + pHotplugData); + + if ((hTreeItem != NULL) && (pHotplugData->dwFlags & HOTPLUG_DISPLAY_DEVICE_COMPONENTS)) + { + DevTreeRecursiveInsertSubDevices(hTreeItem, + did.DevInst, + pHotplugData); + } + } + } + + SetupDiDestroyDeviceInfoList(hdev); +} + +static +VOID +InsertConfirmDeviceListItem( + _In_ HWND hwndCfmDeviceList, + _In_ DEVINST DevInst, + _In_ PHOTPLUG_DATA pHotplugData) +{ + WCHAR szDisplayName[MAX_DEVICE_DISPLAYNAME_LEN]; + WCHAR szGuidString[MAX_GUID_STRING_LEN]; + DWORD dwSize; + GUID ClassGuid; + INT nClassImage; + CONFIGRET cr; + LVITEMW lvItem; + + /* Get the device description */ + dwSize = sizeof(szDisplayName); + cr = CM_Get_DevNode_Registry_Property(DevInst, + CM_DRP_DEVICEDESC, + NULL, + szDisplayName, + &dwSize, + 0); + if (cr != CR_SUCCESS) + wcscpy(szDisplayName, L"Unknown Device"); + + /* Get the class GUID */ + dwSize = sizeof(szGuidString); + cr = CM_Get_DevNode_Registry_Property(DevInst, + CM_DRP_CLASSGUID, + NULL, + szGuidString, + &dwSize, + 0); + if (cr == CR_SUCCESS) + { + pSetupGuidFromString(szGuidString, &ClassGuid); + } + else + { + memcpy(&ClassGuid, &GUID_DEVCLASS_UNKNOWN, sizeof(GUID)); + } + + /* Get the image for the class this device is in */ + SetupDiGetClassImageIndex(&pHotplugData->ImageListData, + &ClassGuid, + &nClassImage); + + /* Add it to the confirm device list */ + ZeroMemory(&lvItem, sizeof(lvItem)); + lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; + lvItem.iItem = ListView_GetItemCount(hwndCfmDeviceList); + lvItem.pszText = szDisplayName; + lvItem.iImage = nClassImage; + lvItem.lParam = (LPARAM)DevInst; + + ListView_InsertItem(hwndCfmDeviceList, &lvItem); +} + +static +VOID +CfmListRecursiveInsertSubDevices( + _In_ HWND hwndCfmDeviceList, + _In_ DEVINST ParentDevInst, + _In_ PHOTPLUG_DATA pHotplugData) +{ + DEVINST ChildDevInst; + CONFIGRET cr; + + cr = CM_Get_Child(&ChildDevInst, ParentDevInst, 0); + if (cr != CR_SUCCESS) + return; + + InsertConfirmDeviceListItem(hwndCfmDeviceList, ChildDevInst, pHotplugData); + CfmListRecursiveInsertSubDevices(hwndCfmDeviceList, ChildDevInst, pHotplugData); + + for (;;) + { + cr = CM_Get_Sibling(&ChildDevInst, ChildDevInst, 0); + if (cr != CR_SUCCESS) + return; + + InsertConfirmDeviceListItem(hwndCfmDeviceList, ChildDevInst, pHotplugData); + CfmListRecursiveInsertSubDevices(hwndCfmDeviceList, ChildDevInst, pHotplugData); + } +} + +VOID +CfmListEnumDevices( + _In_ HWND hwndCfmDeviceList, + _In_ PHOTPLUG_DATA pHotplugData) +{ + DEVINST DevInst; + + DevInst = GetDeviceInstForRemoval(pHotplugData); + if (DevInst != 0) + { + InsertConfirmDeviceListItem(hwndCfmDeviceList, DevInst, pHotplugData); + CfmListRecursiveInsertSubDevices(hwndCfmDeviceList, DevInst, pHotplugData); + } +} diff --git a/dll/cpl/hotplug/hotplug.c b/dll/cpl/hotplug/hotplug.c index 58c570fb6bd9c..55b3044952edb 100644 --- a/dll/cpl/hotplug/hotplug.c +++ b/dll/cpl/hotplug/hotplug.c @@ -8,9 +8,6 @@ #include "hotplug.h" -#include -#include - #define NDEBUG #include @@ -91,204 +88,6 @@ SetHotPlugFlags( return dwError; } - -static -HTREEITEM -InsertDeviceTreeItem( - _In_ HWND hwndDeviceTree, - _In_ HTREEITEM hParent, - _In_ DWORD DevInst, - _In_ PHOTPLUG_DATA pHotplugData) -{ - WCHAR szDisplayName[40]; - WCHAR szGuidString[MAX_GUID_STRING_LEN]; - TVINSERTSTRUCTW tvItem; - GUID ClassGuid; - INT nClassImage; - DWORD dwSize; - CONFIGRET cr; - - /* Get the device description */ - dwSize = sizeof(szDisplayName); - cr = CM_Get_DevNode_Registry_Property(DevInst, - CM_DRP_DEVICEDESC, - NULL, - szDisplayName, - &dwSize, - 0); - if (cr != CR_SUCCESS) - wcscpy(szDisplayName, L"Unknown Device"); - - /* Get the class GUID */ - dwSize = sizeof(szGuidString); - cr = CM_Get_DevNode_Registry_Property(DevInst, - CM_DRP_CLASSGUID, - NULL, - szGuidString, - &dwSize, - 0); - if (cr == CR_SUCCESS) - { - pSetupGuidFromString(szGuidString, &ClassGuid); - } - else - { - memcpy(&ClassGuid, &GUID_DEVCLASS_UNKNOWN, sizeof(GUID)); - } - - /* Get the image for the class this device is in */ - SetupDiGetClassImageIndex(&pHotplugData->ImageListData, - &ClassGuid, - &nClassImage); - - /* Add it to the device tree */ - ZeroMemory(&tvItem, sizeof(tvItem)); - tvItem.hParent = hParent; - tvItem.hInsertAfter = TVI_LAST; - - tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvItem.item.state = TVIS_EXPANDED; - tvItem.item.stateMask = TVIS_EXPANDED; - tvItem.item.pszText = szDisplayName; - tvItem.item.iImage = nClassImage; - tvItem.item.iSelectedImage = nClassImage; - tvItem.item.lParam = (LPARAM)DevInst; - - return TreeView_InsertItem(hwndDeviceTree, &tvItem); -} - - -static -VOID -RecursiveInsertSubDevices( - _In_ HWND hwndDeviceTree, - _In_ HTREEITEM hParentItem, - _In_ DWORD ParentDevInst, - _In_ PHOTPLUG_DATA pHotplugData) -{ - HTREEITEM hTreeItem; - DEVINST ChildDevInst; - CONFIGRET cr; - - DPRINT("RecursiveInsertSubDevices()\n"); - - cr = CM_Get_Child(&ChildDevInst, ParentDevInst, 0); - if (cr != CR_SUCCESS) - { - DPRINT("No child! %lu\n", cr); - return; - } - - hTreeItem = InsertDeviceTreeItem(hwndDeviceTree, - hParentItem, - ChildDevInst, - pHotplugData); - if (hTreeItem != NULL) - { - RecursiveInsertSubDevices(hwndDeviceTree, - hTreeItem, - ChildDevInst, - pHotplugData); - } - - for (;;) - { - cr = CM_Get_Sibling(&ChildDevInst, ChildDevInst, 0); - if (cr != CR_SUCCESS) - { - DPRINT("No sibling! %lu\n", cr); - return; - } - - hTreeItem = InsertDeviceTreeItem(hwndDeviceTree, - hParentItem, - ChildDevInst, - pHotplugData); - if (hTreeItem != NULL) - { - RecursiveInsertSubDevices(hwndDeviceTree, - hTreeItem, - ChildDevInst, - pHotplugData); - } - } -} - - -static -VOID -EnumHotpluggedDevices( - HWND hwndDeviceTree, - PHOTPLUG_DATA pHotplugData) -{ - SP_DEVINFO_DATA did = { 0 }; - HDEVINFO hdev; - int idev; - DWORD dwCapabilities, dwSize; - ULONG ulStatus, ulProblem; - HTREEITEM hTreeItem; - CONFIGRET cr; - - DPRINT1("EnumHotpluggedDevices()\n"); - - TreeView_DeleteAllItems(hwndDeviceTree); - - hdev = SetupDiGetClassDevs(NULL, NULL, 0, DIGCF_ALLCLASSES | DIGCF_PRESENT); - if (hdev == INVALID_HANDLE_VALUE) - return; - - did.cbSize = sizeof(did); - - /* Enumerate all the attached devices */ - for (idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); idev++) - { - ulStatus = 0; - ulProblem = 0; - - cr = CM_Get_DevNode_Status(&ulStatus, - &ulProblem, - did.DevInst, - 0); - if (cr != CR_SUCCESS) - continue; - - dwCapabilities = 0, - dwSize = sizeof(dwCapabilities); - cr = CM_Get_DevNode_Registry_Property(did.DevInst, - CM_DRP_CAPABILITIES, - NULL, - &dwCapabilities, - &dwSize, - 0); - if (cr != CR_SUCCESS) - continue; - - /* Add devices that require safe removal to the device tree */ - if ( (dwCapabilities & CM_DEVCAP_REMOVABLE) && - !(dwCapabilities & CM_DEVCAP_DOCKDEVICE) && - !(dwCapabilities & CM_DEVCAP_SURPRISEREMOVALOK) && - ((dwCapabilities & CM_DEVCAP_EJECTSUPPORTED) || (ulStatus & DN_DISABLEABLE)) && - ulProblem == 0) - { - hTreeItem = InsertDeviceTreeItem(hwndDeviceTree, - TVI_ROOT, - did.DevInst, - pHotplugData); - - if ((hTreeItem != NULL) && (pHotplugData->dwFlags & HOTPLUG_DISPLAY_DEVICE_COMPONENTS)) - { - RecursiveInsertSubDevices(hwndDeviceTree, - hTreeItem, - did.DevInst, - pHotplugData); - } - } - } - - SetupDiDestroyDeviceInfoList(hdev); -} - - static VOID UpdateButtons( @@ -455,8 +254,7 @@ SafeRemovalDlgProc( pHotplugData->ImageListData.ImageList, TVSIL_NORMAL); - EnumHotpluggedDevices(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE), - pHotplugData); + EnumHotpluggedDevices(pHotplugData); UpdateButtons(hwndDlg); } return TRUE; @@ -481,8 +279,7 @@ SafeRemovalDlgProc( SetHotPlugFlags(pHotplugData->dwFlags); - EnumHotpluggedDevices(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE), - pHotplugData); + EnumHotpluggedDevices(pHotplugData); } } break; @@ -500,11 +297,18 @@ SafeRemovalDlgProc( { if (pHotplugData != NULL) { - DialogBoxParamW(hApplet, - MAKEINTRESOURCEW(IDD_CONFIRM_STOP_HARDWARE_DIALOG), - hwndDlg, - ConfirmRemovalDlgProc, - (LPARAM)pHotplugData); + DEVINST DevInst; + INT_PTR nResult; + + DevInst = GetDeviceInstForRemoval(pHotplugData); + + nResult = DialogBoxParamW(hApplet, + MAKEINTRESOURCEW(IDD_CONFIRM_STOP_HARDWARE_DIALOG), + hwndDlg, + ConfirmRemovalDlgProc, + (LPARAM)pHotplugData); + if (nResult == IDOK) + SafeRemoveDevice(DevInst); } break; @@ -528,8 +332,7 @@ SafeRemovalDlgProc( if (pHotplugData != NULL) { - EnumHotpluggedDevices(GetDlgItem(hwndDlg, IDC_SAFE_REMOVE_DEVICE_TREE), - pHotplugData); + EnumHotpluggedDevices(pHotplugData); UpdateButtons(hwndDlg); } } diff --git a/dll/cpl/hotplug/hotplug.h b/dll/cpl/hotplug/hotplug.h index 66e8dccb9f9d2..92bc31a9e3678 100644 --- a/dll/cpl/hotplug/hotplug.h +++ b/dll/cpl/hotplug/hotplug.h @@ -49,6 +49,14 @@ typedef struct _HOTPLUG_DATA } HOTPLUG_DATA, *PHOTPLUG_DATA; // eject.c +DEVINST +GetDeviceInstForRemoval( + _In_ PHOTPLUG_DATA pHotplugData); + +VOID +SafeRemoveDevice( + _In_ DEVINST DevInst); + INT_PTR CALLBACK ConfirmRemovalDlgProc( @@ -57,6 +65,16 @@ ConfirmRemovalDlgProc( WPARAM wParam, LPARAM lParam); +// enum.c +VOID +EnumHotpluggedDevices( + _In_ PHOTPLUG_DATA pHotplugData); + +VOID +CfmListEnumDevices( + _In_ HWND hwndCfmDeviceList, + _In_ PHOTPLUG_DATA pHotplugData); + // hotplug.c LONG APIENTRY