Skip to main content

Crate preg

Crate preg 

Source
Expand description

Reader and writer for Registry.pol — the PReg file that carries the registry half of a Group Policy Object.

Every GPO stores its Administrative-Template settings as a Registry.pol under SYSVOL\<domain>\Policies\{GUID}\{Machine,User}\Registry.pol. The format is a 8-byte header followed by a flat list of [key;value;type;size;data] records, all strings UTF-16LE and NUL-terminated.

use preg::{PolicyFile, RegData};

let mut pol = PolicyFile::new();
pol.set(
    r"Software\Policies\Microsoft\Windows NT\DNSClient",
    "EnableMulticast",
    RegData::Dword(0),
);
let bytes = pol.to_bytes();
assert_eq!(PolicyFile::parse(&bytes).unwrap(), pol);

Parsing never panics on malformed input and never allocates on a length field it has not validated against the buffer.

Structs§

PolicyEntry
One [key;value;type;size;data] record.
PolicyFile
A parsed Registry.pol.

Enums§

Directive
What a record instructs the client to do, decoded from the magic ** value prefixes ([MS-GPREG] §2.2.1). Anything without a prefix simply sets a value.
PolError
RegData
A registry value type as stored in the type field of a record.

Constants§

SIGNATURE
PReg — the 4-byte signature every policy file starts with.
VERSION
The only format version Windows writes or accepts.