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.
| Recipe | What it does |
|---|---|
just windows-check | cargo 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-build | The release binary with the UI embedded, dist/build/windows/probeward.exe. |
just windows-msi | The binary and its installer, dist/probeward-probe-<version>-x64.msi. |
just release-artifacts | Everything 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/Dockerfilehas three targets.toolchainis the official Rust Alpine image with thex86_64-pc-windows-gnutarget and Alpine'smingw-w64-gcc.binarybuilds the UI and the release binary in it, with+crt-staticand the build paths remapped, and lists the DLLs the binary imports.msitoolsis Alpine withmsitools(wixl) andlibfaketime.packaging/windows/build.shbuilds 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 runsmake-msi.shin themsitoolsimage.packaging/windows/probeward-probe.wxsis the installer source;make-msi.shcompiles 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.shchecks 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
windowscrates, which support both targets.
What is different on Windows
Every Unix-only piece has a Windows implementation or a clear error:
| Piece | Linux | Windows |
|---|---|---|
| ICMP ping | unprivileged ICMP sockets | Win32_PingStatus over local WMI, 1 ms resolution |
WQL for win_* sensors | WinRM | WinRM, or native WMI (COM/DCOM), chosen per device |
| Script and Nagios plugin sensors | run from PROBEWARD_SCRIPT_DIR | refused: "not available on a Windows probe" |
| State directory protection | mode 0700, others refused | an ACL for SYSTEM, Administrators and the service, inheritance off; anything else refused |
| Self-update | rename over the binary, exec | rename the running binary aside, rename the new one in, exit 75; the service manager's recovery starts it |
| Service | systemd unit | Windows service ProbewardProbe, through the Service Control Manager |
probeward serve | the core | refused: the core runs on Linux |
| Settings | environment | environment, 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.