Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/impl/list_ports/list_ports_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "serial_cpp/serial.h"
#include <tchar.h>
#include <windows.h>
#include <winioctl.h>
#include <setupapi.h>
#include <initguid.h>
#include <devguid.h>
Expand Down Expand Up @@ -38,10 +39,10 @@ serial_cpp::list_ports()
vector<PortInfo> devices_found;

HDEVINFO device_info_set = SetupDiGetClassDevs(
(const GUID *) &GUID_DEVCLASS_PORTS,
(const GUID *) &GUID_DEVINTERFACE_COMPORT,
NULL,
NULL,
DIGCF_PRESENT);
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
Comment on lines 40 to +45
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using DIGCF_DEVICEINTERFACE flag with SetupDiGetClassDevs, the subsequent enumeration should use SetupDiEnumDeviceInterfaces instead of SetupDiEnumDeviceInfo (line 51). The current code at line 51 calls SetupDiEnumDeviceInfo which is designed for device class enumeration, not device interface enumeration. This mismatch may cause the function to miss COM ports or behave incorrectly. Consider either: (1) keeping the original GUID_DEVCLASS_PORTS without DIGCF_DEVICEINTERFACE, or (2) refactoring the enumeration logic to use SetupDiEnumDeviceInterfaces followed by SetupDiGetDeviceInterfaceDetail.

Copilot uses AI. Check for mistakes.

unsigned int device_info_set_index = 0;
SP_DEVINFO_DATA device_info_data;
Expand Down