Skip to content

Commit

Permalink
fix windows build failures
Browse files Browse the repository at this point in the history
  • Loading branch information
GyulyVGC committed Mar 13, 2024
1 parent c5cdade commit 69fa29c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/platform/windows/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::Listener;
use socket_table::SocketTable;
use std::collections::HashSet;
use tcp_listener::TcpListener;

Expand Down
6 changes: 3 additions & 3 deletions src/platform/windows/tcp_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl TcpListener {
fn pname(&self) -> Option<String> {
let pid = self.pid;

let h = unsafe { CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)? };
let h = unsafe { CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0).ok()? };

let mut process = unsafe { zeroed::<PROCESSENTRY32>() };
process.dwSize = size_of::<PROCESSENTRY32>() as u32;
Expand All @@ -66,14 +66,14 @@ impl TcpListener {
}
}

unsafe { CloseHandle(h)? };
unsafe { CloseHandle(h).ok()? };

let name = process.szExeFile;
let len = name.iter().position(|&x| x == 0)?;

Some(String::from_utf8(
name[0..len].iter().map(|e| *e as u8).collect(),
)?)
).ok()?)
}

pub(super) fn to_listener(&self) -> Option<Listener> {
Expand Down

0 comments on commit 69fa29c

Please sign in to comment.