Skip to content

Commit

Permalink
fix(windows,process): UDP pid
Browse files Browse the repository at this point in the history
  • Loading branch information
XOR-op committed Sep 16, 2024
1 parent fb47111 commit 1738095
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions boltconn/src/platform/process/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ impl RecordSearcher {
if data.len() < 4 {
return Err(std::io::ErrorKind::NotFound.into());
}
let mut possible_udp = None;
let record_cnt = slice_to_u32(&data[0..4]);
for i in 0..(record_cnt as usize) {
let record = data
Expand Down Expand Up @@ -250,10 +251,17 @@ impl RecordSearcher {
};
// the second clause only happens to 0.0.0.0/[::] UDP
if ip != addr.ip() && !(addr.ip().is_unspecified() && self.tcp_state.is_none()) {
if self.tcp_state.is_none() {
possible_udp = Some(slice_to_u32(&record[self.pid..self.pid + 4]));
continue;
}
continue;
}
return Ok(slice_to_u32(&record[self.pid..self.pid + 4]));
}
if let Some(pid) = possible_udp {
return Ok(pid);
}
Err(std::io::ErrorKind::NotFound.into())
}
}
Expand Down

0 comments on commit 1738095

Please sign in to comment.