win32_min/lib.rs
1//! # win32-min
2//!
3//! Minimal, hand-rolled Win32 FFI for Windows security, administration, and
4//! audit tooling, packaged as one small crate with **zero runtime dependencies**.
5//!
6//! ## Design
7//!
8//! - Pure `extern "system"` declarations + `#[repr(C)]` structs. No proc macros,
9//! no build script, no code generation.
10//! - Feature-gated by Win32 subsystem. Default = only the [`foundation`] types
11//! (HANDLE, LUID, NTSTATUS, PCWSTR, …). Enable only what you need.
12//! - Every declaration `unsafe` because Win32 FFI is `unsafe`; callers wrap.
13//! - Sub-second cold compile. Constant-fold in linker. No transitive deps.
14//!
15//! ## Features
16//!
17//! | Feature | Subsystem | Downstream consumer |
18//! |---|---|---|
19//! | `process` | Process discovery and inspection | security inventory tools |
20//! | `thread` | Thread discovery and control | diagnostics tools |
21//! | `module` | DLL loading and symbol lookup | dynamic integrations |
22//! | `file` | File identity and metadata | DFIR tools |
23//! | `security` | ACL/security-descriptor inspection | ACL auditors |
24//! | `security-token` | Token / privilege / impersonation | `windows-token` |
25//! | `services` | Service Control Manager (local) | `windows-scm` |
26//! | `lsa-auth` | LSA authentication package | `windows-lsa` |
27//! | `eventlog` | EventLog v6 (Evt* API) | `windows-eventlog-native` |
28//! | `registry` | Registry open/query/enumeration | — |
29//! | `process-thread` | Compatibility alias for `process` + `thread` | — |
30//! | `security-descriptor` | Compatibility alias for `security` | `windows-sddl` ecosystem |
31//! | `full` | every subsystem | — |
32//!
33//! ## Why not `windows-rs` or `winapi`
34//!
35//! - `windows-rs` — official Microsoft, correct + comprehensive, but 100+ MB
36//! artifacts, feature-flag puzzle, and version churn (0.48 → 0.51 → 0.58 → 0.61)
37//! creates dep-graph duplication in binaries that pull multiple `windows-rs`-
38//! based crates. Use it for COM (which this crate does not attempt to cover).
39//! - `winapi` — deprecated de-facto since 2021. Last release 0.3.9.
40//!
41//! `win32-min` covers only what a hand-audited surface actually needs — no COM,
42//! no WinRT, no DirectX, no auto-generated bindings. If you need those, use
43//! `windows-rs`. If you need one of the four subsystems above and don't want to
44//! pay the `windows-rs` cost, use this.
45//!
46//! ## Non-goals
47//!
48//! - Not a Win32 SDK replacement. Missing ~99% of the Win32 API surface.
49//! - Not a COM host. COM interfaces require vtable layouts + `IUnknown` support
50//! that `windows-rs` handles cleanly; hand-rolling that is not worth the LOC.
51//! - Not portable — Windows-only, no fallback stubs.
52
53// Win32 header convention — mirror upstream naming so cross-reference with MSDN docs is
54// mechanical. Not a style choice we can override.
55#![allow(
56 non_snake_case,
57 non_camel_case_types,
58 non_upper_case_globals,
59 clippy::upper_case_acronyms
60)]
61#![warn(missing_docs)]
62#![no_std]
63
64mod error;
65pub mod foundation;
66pub mod handles;
67
68pub use error::Win32Error;
69
70#[cfg(feature = "process")]
71pub mod process;
72
73#[cfg(feature = "thread")]
74pub mod thread;
75
76#[cfg(feature = "module")]
77pub mod module;
78
79#[cfg(feature = "file")]
80pub mod file;
81
82#[cfg(feature = "security-token")]
83pub mod security_token;
84
85#[cfg(feature = "services")]
86pub mod services;
87
88#[cfg(feature = "lsa-auth")]
89pub mod lsa_auth;
90
91#[cfg(feature = "eventlog")]
92pub mod eventlog;
93
94#[cfg(all(feature = "process", feature = "thread"))]
95pub mod process_thread;
96
97#[cfg(feature = "registry")]
98pub mod registry;
99
100#[cfg(feature = "security")]
101pub mod security_descriptor;
102
103/// ACL and security-descriptor primitives.
104///
105/// The `security_descriptor` module name remains available for compatibility
106/// with 0.1.1; new code should prefer this shorter module name.
107#[cfg(feature = "security")]
108pub mod security {
109 pub use crate::security_descriptor::*;
110}