From 242d38781fcfc9cba866398b37660041a577c395 Mon Sep 17 00:00:00 2001 From: raspopov Date: Tue, 23 Jul 2024 18:41:09 +0300 Subject: [PATCH] Fixed infinite WMI enumeration. --- VisualDiskImager/DeviceEnum.cpp | 2 +- VisualDiskImager/VisualDiskImager.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/VisualDiskImager/DeviceEnum.cpp b/VisualDiskImager/DeviceEnum.cpp index 68612d6..8187223 100644 --- a/VisualDiskImager/DeviceEnum.cpp +++ b/VisualDiskImager/DeviceEnum.cpp @@ -62,7 +62,7 @@ void CVisualDiskImagerDlg::EnumDevices(bool bSilent) { CComPtr< IWbemClassObject > disk; ULONG uReturn = 0; - hr = disks->Next( WBEM_INFINITE, 1, &disk, &uReturn ); + hr = disks->Next( WMI_TIMEOUT, 1, &disk, &uReturn ); if ( FAILED( hr ) || uReturn == 0 ) { break; diff --git a/VisualDiskImager/VisualDiskImager.h b/VisualDiskImager/VisualDiskImager.h index 0865b47..12c6261 100644 --- a/VisualDiskImager/VisualDiskImager.h +++ b/VisualDiskImager/VisualDiskImager.h @@ -43,6 +43,8 @@ extern CVisualDiskImagerApp theApp; #define REG_VERIFY _T("Verify") #define REG_OFFSET _T("Offset") +#define WMI_TIMEOUT 5000 // WMI query timeout (ms) + // Log priority enum LogPriority { LOG_ERROR = 0, LOG_INFO, LOG_WARNING, LOG_ACTION, LOG_DEVICE, LOG_VOLUME };