● v1.0.0 · standalone executable on GitHub ReleasesSystem tools · Windows desktop

Port Manager

See which process holds each port, and act behind safeguards.

native tables per query (TCP and UDP, IPv4 and IPv6)
4
layered projects: UI, core, and infrastructure
3
xUnit test methods
18

Technologies: C# · .NET 9 · WPF · CommunityToolkit.Mvvm · Microsoft.Extensions.DependencyInjection · P/Invoke (IP Helper) · WMI (System.Management) · ServiceController · xUnit

The problem

Ending the wrong process can destabilize the system, and processes such as svchost host several services at once. On top of that, Windows hides some details without elevation, and a process can disappear between the query and the action.

Goal

See at a glance which process is listening on or using each port in Windows, and free it up without jumping between several system tools. It had to work with standard permissions for browsing and ask for elevation only when an action needs it.

My contribution

I built the solution as three projects: the WPF interface with MVVM, a logic core that makes no Windows API calls, and a native infrastructure layer. I implemented reading the TCP and UDP tables, mapping them to processes and services through WMI, the protected-process policy, local persistence, and the xUnit tests.

LIVE ARCHITECTURE

Architecture

Every moving dot is data; amber marks alerts. Tap a component to see what it does and what it connects to.

Architecture: Port ManagerData flowToward the output
SourcesAt the stationIngestionCoreOutputInterface
SourcesAt the stationIngestionCoreOutputInterface

Tap a piece, or press Enter on it, to see what it does and what it connects to.

See every connection as a list
  • Windows to Infrastructuremanual polling or every 2, 5, 10, or 30 s
  • Infrastructure to Coreconnection snapshot
  • Core to WPF interfacefiltered rows and summary
  • WPF interface to Corerequested action
  • Core to Infrastructurevalidated action
  • Infrastructure to Windowsend process or stop service
  • Infrastructure to Local datahistory and preferences
  • WPF interface to Exportvisible rows
Ending a process or stopping a service goes through the protection rules before it reaches Windows.

Decisions

  1. Native queries, no PowerShell

    I read the connection tables with GetExtendedTcpTable and GetExtendedUdpTable through P/Invoke, for IPv4 and IPv6, and enrich each row with WMI. Neither PowerShell nor Electron is used for querying or managing.

  2. Protect before trusting

    A policy blocks PIDs 0 and 4, Port Manager itself, critical Windows processes, and any process that could not be verified, and it re-checks name and PID right before ending one. A conservative list of essential services cannot be stopped.

  3. Elevation the official way

    The app runs without admin rights and, when an action needs them, offers to restart through the Windows UAC prompt instead of trying to bypass it.

  4. Logic kept apart from Windows

    Filtering, sorting, summaries, and protection rules live in a project that makes no Windows API calls, which makes them testable with xUnit. A separate test reads the live system tables to check the native layer.

What it does

  • Connections with context

    Each TCP or UDP connection, over IPv4 or IPv6, shows its PID, process, service, executable, owner, start time, command line, and memory.

  • Combinable filters

    By text, protocol, state, and port range, with sorting, multi-select, copy, and CSV export of the visible rows.

  • Incremental refresh

    Manual or automatic every 2, 5, 10, or 30 seconds; rows update without losing the selection.

  • Confirmed actions

    End a process or its whole process tree, and stop non-essential services, after a dialog showing the process, PID, path, service, and affected ports.

  • Local history

    A log of every action and its result, capped at 500 entries and without storing command lines.

  • Themes and system shortcuts

    Light and dark themes, remembered window position and filters, and shortcuts to Task Manager, Resource Monitor, and Windows Firewall.

Screenshots

Outcome

Version 1.0.0 ships as a single self-contained .exe of about 60 MB that bundles .NET and opens with a double click. The solution keeps the interface, logic, and Windows access apart, and its filtering, protection, and command logic is covered by xUnit tests.

Limits

The protected-process list is a conservative safeguard, not a complete catalog, so the confirmation dialog should always be reviewed. Windows may refuse to end protected processes even with elevation, and some details cannot be read without admin rights. Data is gathered by polling rather than real-time events, and the executable is not code-signed.

NEXT CASEBaliza