Conversation
Co-authored-by: ibigbug <543405+ibigbug@users.noreply.github.com>
Co-authored-by: ibigbug <543405+ibigbug@users.noreply.github.com>
Co-authored-by: ibigbug <543405+ibigbug@users.noreply.github.com>
…ATH constant Co-authored-by: ibigbug <543405+ibigbug@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements Windows support for socket-to-process resolution using the Windows IP Helper API, enabling the library to work cross-platform on Linux, macOS, and Windows.
Key Changes:
- Added Windows-specific implementation using
GetExtendedTcpTable/GetExtendedUdpTableAPIs for IPv4/IPv6 TCP/UDP connection enumeration - Integrated process path retrieval via
QueryFullProcessImageNameW - Extended CI pipeline to include Windows testing
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| src/platform/windows.rs | Core Windows implementation with TCP/UDP v4/v6 socket-to-PID resolution and process path lookup |
| src/platform/mod.rs | Conditional compilation directives to include Windows platform module |
| Cargo.toml | Added windows-sys dependency with required Win32 API features |
| .github/workflows/rust.yml | Added windows-latest to CI test matrix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| dst: Option<SocketAddr>, | ||
| ) -> Result<u32, io::Error> { | ||
| let mut size: u32 = 0; | ||
|
|
There was a problem hiding this comment.
Trailing whitespace on line 67. Remove the extra spaces for consistency with coding standards.
| // Parse the table | ||
| let table = unsafe { &*(buffer.as_ptr() as *const MIB_TCPTABLE_OWNER_PID) }; | ||
| let num_entries = table.dwNumEntries as usize; | ||
|
|
There was a problem hiding this comment.
Trailing whitespace on line 104. Remove the extra spaces for consistency with coding standards.
| dst: Option<SocketAddr>, | ||
| ) -> Result<u32, io::Error> { | ||
| let mut size: u32 = 0; | ||
|
|
There was a problem hiding this comment.
Trailing whitespace on line 144. Remove the extra spaces for consistency with coding standards.
| // Parse the table | ||
| let table = unsafe { &*(buffer.as_ptr() as *const MIB_TCP6TABLE_OWNER_PID) }; | ||
| let num_entries = table.dwNumEntries as usize; | ||
|
|
There was a problem hiding this comment.
Trailing whitespace on line 181. Remove the extra spaces for consistency with coding standards.
| dst: Option<SocketAddr>, | ||
| ) -> Result<u32, io::Error> { | ||
| let mut size: u32 = 0; | ||
|
|
There was a problem hiding this comment.
Trailing whitespace on line 221. Remove the extra spaces for consistency with coding standards.
| // Parse the table | ||
| let table = unsafe { &*(buffer.as_ptr() as *const MIB_UDPTABLE_OWNER_PID) }; | ||
| let num_entries = table.dwNumEntries as usize; | ||
|
|
There was a problem hiding this comment.
Trailing whitespace on line 258. Remove the extra spaces for consistency with coding standards.
| dst: Option<SocketAddr>, | ||
| ) -> Result<u32, io::Error> { | ||
| let mut size: u32 = 0; | ||
|
|
There was a problem hiding this comment.
Trailing whitespace on line 295. Remove the extra spaces for consistency with coding standards.
| // Parse the table | ||
| let table = unsafe { &*(buffer.as_ptr() as *const MIB_UDP6TABLE_OWNER_PID) }; | ||
| let num_entries = table.dwNumEntries as usize; | ||
|
|
There was a problem hiding this comment.
Trailing whitespace on line 332. Remove the extra spaces for consistency with coding standards.
| let mut size = buffer.len() as u32; | ||
|
|
||
| let result = QueryFullProcessImageNameW(handle, 0, buffer.as_mut_ptr(), &mut size); | ||
|
|
There was a problem hiding this comment.
Trailing whitespace on line 375. Remove the extra spaces for consistency with coding standards.
Closes #[issue_number]
Implements socket-to-process resolution for Windows using IP Helper API.
Implementation
Core API Integration:
GetExtendedTcpTable/GetExtendedUdpTableenumerate connections with PIDs (IPv4/IPv6, TCP/UDP)QueryFullProcessImageNameWretrieves process executable pathsu32::from_be,u16::from_be) per Windows API specPlatform Module:
src/platform/windows.rs(387 lines)src/platform/mod.rswindows-sys = "0.52"with Win32 IpHelper, Threading, WinSock featuresCI:
windows-latestto test matrixTradeoffs
Windows UDP tables lack remote address/port fields—destination matching unsupported for UDP (API limitation, not implementation choice).
Example
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.