preg
Reader and writer for Registry.pol — the PReg file that carries the registry half of a
Windows Group Policy Object. Pure Rust, no FFI, no Windows required.
Every GPO stores its Administrative-Template settings under
SYSVOL\<domain>\Policies\{GUID}\{Machine,User}\Registry.pol: an 8-byte header followed by a
flat list of [key;value;type;size;data] records, all strings UTF-16LE and NUL-terminated.
use ;
let pol = parse?;
// Is LLMNR turned off by this GPO?
let off = pol.dword == Some;
for e in &pol.entries
Writing works the same way and is byte-for-byte round-trip stable:
let mut pol = new;
pol.set;
write?;
Features
- All value types —
REG_SZ,REG_EXPAND_SZ,REG_BINARY,REG_DWORD,REG_DWORD_BIG_ENDIAN,REG_LINK,REG_MULTI_SZ,REG_QWORD— plus a verbatim passthrough for anything else, so an unknown type still round-trips. - The
**instruction prefixes decoded:**del.,**delvals.,**deletekeys,**soft.,**SecureKey. - Case-insensitive
get/dword/set/remove, matching registry semantics. - Never panics on malformed or hostile input — a lying length field is a typed error, not an out-of-bounds read.
Who this is for
- Group Policy tooling that has to read or emit policy without a Windows host.
- Configuration management and drift detection over SYSVOL.
- Security auditing: many hardening settings (LLMNR, SMB signing, PowerShell logging, ASR
rules, WSUS, hardened UNC paths) exist only as a
Registry.polrecord. - DFIR on a SYSVOL copy.
License
MIT