Skip to content

Building the Windows probe ​

The Windows probe is the same probeward program as on Linux, compiled for x86_64-pc-windows-gnu on a Linux machine. Everything runs in containers; the host needs Docker and just.

RecipeWhat it does
just windows-checkcargo clippy --workspace --all-targets --all-features -- -D warnings for the Windows target, in the cross toolchain container. CI runs it in its own job.
just windows-buildThe release binary with the UI embedded, dist/build/windows/probeward.exe.
just windows-msiThe binary and its installer, dist/probeward-probe-<version>-x64.msi.
just release-artifactsEverything a release publishes, the Windows probe and its MSI included.

packaging/windows/cargo.sh <cargo arguments> runs any other cargo command for the Windows target, for example packaging/windows/cargo.sh test -p probeward-sensors --no-run. Its output goes to target/windows/.

Running the Windows tests. The tests cannot run in the container. Build them with the command above, copy the probeward_sensors-*.exe it names from target/windows/x86_64-pc-windows-gnu/debug/deps/ to a Windows machine and run it with wmi as the filter; the native WMI tests then query the machine's own WMI. One test connects over DCOM to another machine and is skipped unless PROBEWARD_TEST_WMI_HOST, PROBEWARD_TEST_WMI_USER (DOMAIN\user or user) and PROBEWARD_TEST_WMI_PASSWORD are set; give it a machine other than the one running the test, since WMI refuses credentials on a local connection.

The pieces ​

  • packaging/windows/Dockerfile has three targets. toolchain is the official Rust Alpine image with the x86_64-pc-windows-gnu target and Alpine's mingw-w64-gcc. binary builds the UI and the release binary in it, with +crt-static and the build paths remapped, and lists the DLLs the binary imports. msitools is Alpine with msitools (wixl) and libfaketime.
  • packaging/windows/build.sh builds the binary, fails if it imports a DLL that is not part of Windows, collects the third-party licences with the same container target the Debian packages use, and runs make-msi.sh in the msitools image.
  • packaging/windows/probeward-probe.wxs is the installer source; make-msi.sh compiles it and then fixes, with SQL on the finished database, what wixl does not express or gets wrong. The script lists each adjustment and checks the result, so a wixl that changes its output fails the build instead of producing a broken installer.

Reproducible ​

The binary is built with --locked, the build paths are remapped and the toolchain comes from a pinned image (give RUST_IMAGE, NODE_IMAGE and MSI_IMAGE as digests to pin them fully). The MSI is the same file for the same inputs: its ProductCode is derived from the version, its package code from the version and the binary's hash, and every time stamp in it (summary information, the cabinet, the files) is SOURCE_DATE_EPOCH, which build.sh takes from the last commit. Two builds of one commit give the same SHA-256.

Why mingw-w64 and not MSVC ​

Rust has two Windows targets for x86-64. The choice is x86_64-pc-windows-gnu for these reasons:

  • Licences. The MSVC target links against the Microsoft C runtime and Windows SDK import libraries, which come with Visual Studio Build Tools under Microsoft's licence terms. Those terms restrict where and by whom the tools can be used, and they cannot be installed into a public container image. The gnu target needs only mingw-w64 (public domain and permissive licences) and GCC's runtime library, which carries the GCC Runtime Library Exception. Everything is installed from Alpine's repositories.
  • Built on Linux, in a container, by anyone. The release build runs on the same Linux CI as the Linux builds, with no Windows runner and no download behind a licence acceptance. A contributor reproduces it with Docker alone.
  • No runtime to install. With +crt-static, libgcc and winpthreads are linked in. The binary imports only DLLs that are part of Windows: the kernel, advapi32, the Winsock, cryptography, COM and OLE libraries, and the Universal C Runtime (api-ms-win-crt-*), which is part of Windows 10, Windows Server 2016 and later. build.sh checks the list on every build.
  • What it costs. No PDB files, so a crash on Windows gives addresses but no symbols without the matching build; and the MSVC target is the one Rust tests most heavily on Windows. Neither matters much for a service that logs its own errors. Nothing in the probe needs an MSVC-only crate: COM and WMI go through the windows crates, which support both targets.

What is different on Windows ​

Every Unix-only piece has a Windows implementation or a clear error:

PieceLinuxWindows
ICMP pingunprivileged ICMP socketsWin32_PingStatus over local WMI, 1 ms resolution
WQL for win_* sensorsWinRMWinRM, or native WMI (COM/DCOM), chosen per device
Script and Nagios plugin sensorsrun from PROBEWARD_SCRIPT_DIRrefused: "not available on a Windows probe"
State directory protectionmode 0700, others refusedan ACL for SYSTEM, Administrators and the service, inheritance off; anything else refused
Self-updaterename over the binary, execrename the running binary aside, rename the new one in, exit 75; the service manager's recovery starts it
Servicesystemd unitWindows service ProbewardProbe, through the Service Control Manager
probeward servethe corerefused: the core runs on Linux
Settingsenvironmentenvironment, then %ProgramData%\Probeward\probe.conf

Tests that need a Unix shell or Unix permissions are compiled for Unix only, with a comment that says why; their Windows counterparts sit next to them. See probes-windows.md for running the probe.

AGPL-3.0-only