Skip to main content

Crate win32_min

Crate win32_min 

Source
Expand description

§win32-min

Minimal, hand-rolled Win32 FFI for Windows security, administration, and audit tooling, packaged as one small crate with zero runtime dependencies.

§Design

  • Pure extern "system" declarations + #[repr(C)] structs. No proc macros, no build script, no code generation.
  • Feature-gated by Win32 subsystem. Default = only the foundation types (HANDLE, LUID, NTSTATUS, PCWSTR, …). Enable only what you need.
  • Every declaration unsafe because Win32 FFI is unsafe; callers wrap.
  • Sub-second cold compile. Constant-fold in linker. No transitive deps.

§Features

FeatureSubsystemDownstream consumer
processProcess discovery and inspectionsecurity inventory tools
threadThread discovery and controldiagnostics tools
moduleDLL loading and symbol lookupdynamic integrations
fileFile identity and metadataDFIR tools
securityACL/security-descriptor inspectionACL auditors
security-tokenToken / privilege / impersonationwindows-token
servicesService Control Manager (local)windows-scm
lsa-authLSA authentication packagewindows-lsa
eventlogEventLog v6 (Evt* API)windows-eventlog-native
registryRegistry open/query/enumeration—
process-threadCompatibility alias for process + thread—
security-descriptorCompatibility alias for securitywindows-sddl ecosystem
fullevery subsystem—

§Why not windows-rs or winapi

  • windows-rs — official Microsoft, correct + comprehensive, but 100+ MB artifacts, feature-flag puzzle, and version churn (0.48 → 0.51 → 0.58 → 0.61) creates dep-graph duplication in binaries that pull multiple windows-rs- based crates. Use it for COM (which this crate does not attempt to cover).
  • winapi — deprecated de-facto since 2021. Last release 0.3.9.

win32-min covers only what a hand-audited surface actually needs — no COM, no WinRT, no DirectX, no auto-generated bindings. If you need those, use windows-rs. If you need one of the four subsystems above and don’t want to pay the windows-rs cost, use this.

§Non-goals

  • Not a Win32 SDK replacement. Missing ~99% of the Win32 API surface.
  • Not a COM host. COM interfaces require vtable layouts + IUnknown support that windows-rs handles cleanly; hand-rolling that is not worth the LOC.
  • Not portable — Windows-only, no fallback stubs.

Modules§

foundation
Foundation types + a handful of always-linked functions.
handles
Small subsystem-specific owned-handle wrappers.

Structs§

Win32Error
A raw Win32 error code with zero-allocation message formatting.