.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "hivexregedit 1"
.TH hivexregedit 1 2024-11-17 hivex-1.3.23 "Windows Registry"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
hivexregedit \- Merge and export Registry changes from regedit\-format files.
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 2
\& hivexregedit \-\-merge [\-\-prefix prefix] [\-\-encoding enc] \e
\& hivefile [regfile]
\&
\& hivexregedit \-\-export [\-\-prefix prefix] hivefile key > regfile
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
Please note hivexregedit is a low-level tool for manipulating hive
files directly. To merge or export registry changes to Windows
virtual machines it's better to use \fBvirt\-win\-reg\fR\|(1).
.PP
Given a local binary ("hive") file, there are two modes. \f(CW\*(C`\-\-merge\*(C'\fR
imports (merges) changes from a regedit-format file into the hive. It
is similar to using the \f(CW\*(C`/s\*(C'\fR switch in Windows regedit.exe.
.PP
\&\f(CW\*(C`\-\-export\*(C'\fR exports a Registry key (recursively) into the regedit format.
.SS ENCODING
.IX Subsection "ENCODING"
\&\f(CW\*(C`hivexregedit\*(C'\fR expects that regedit files have already been re-encoded
in the local encoding. Usually on Linux hosts, this means UTF\-8 with
Unix-style line endings. Since Windows regedit files are often in
UTF\-16LE with Windows-style line endings, you may need to re-encode the
whole file before or after processing.
.PP
To re-encode a file from Windows format to Linux (before processing it
with the \f(CW\*(C`\-\-merge\*(C'\fR option), you would do something like this:
.PP
.Vb 1
\& iconv \-f utf\-16le \-t utf\-8 < win.reg | dos2unix > linux.reg
.Ve
.PP
To go in the opposite direction, after using \f(CW\*(C`\-\-export\*(C'\fR and before
sending the file to a Windows user, do something like this:
.PP
.Vb 1
\& unix2dos < linux.reg | iconv \-f utf\-8 \-t utf\-16le > win.reg
.Ve
.PP
For more information about encoding, see \fBWin::Hivex::Regedit\fR\|(3).
.PP
If you are unsure about the current encoding, use the \fBfile\fR\|(1)
command. Recent versions of Windows regedit.exe produce a UTF\-16LE
file with Windows-style (CRLF) line endings, like this:
.PP
.Vb 3
\& $ file software.reg
\& software.reg: Little\-endian UTF\-16 Unicode text, with very long lines,
\& with CRLF line terminators
.Ve
.PP
This file would need conversion before you could \f(CW\*(C`\-\-merge\*(C'\fR it.
.SS "SHELL QUOTING"
.IX Subsection "SHELL QUOTING"
Be careful when passing parameters containing \f(CW\*(C`\e\*(C'\fR (backslash) in the
shell. Usually you will have to use 'single quotes' or double
backslashes (but not both) to protect them from the shell.
.SS "CurrentControlSet etc."
.IX Subsection "CurrentControlSet etc."
Registry keys like \f(CW\*(C`CurrentControlSet\*(C'\fR don't really exist in the
Windows Registry at the level of the hive file, and therefore you
cannot modify these.
.PP
\&\f(CW\*(C`CurrentControlSet\*(C'\fR is usually an alias for \f(CW\*(C`ControlSet001\*(C'\fR. In
some circumstances it might refer to another control set. The way
to find out is to look at the \f(CW\*(C`HKLM\eSYSTEM\eSelect\*(C'\fR key:
.PP
.Vb 6
\& $ hivexregedit \-\-export SYSTEM \*(Aq\eSelect\*(Aq
\& [\eSelect]
\& "Current"=dword:00000001
\& "Default"=dword:00000001
\& "Failed"=dword:00000000
\& "LastKnownGood"=dword:00000002
.Ve
.PP
"Current" is the one which Windows will choose when it boots.
.PP
Similarly, other \f(CW\*(C`Current...\*(C'\fR keys in the path may need to
be replaced.
.SH EXAMPLE
.IX Header "EXAMPLE"
.Vb 4
\& $ virt\-cat WindowsGuest /Windows/System32/config/software > software.hive
\& $ hivexregedit \-\-export \e
\& \-\-prefix \*(AqHKEY_LOCAL_MACHINE\eSOFTWARE\*(Aq \e
\& software.hive \*(Aq\eMicrosoft\*(Aq > ms\-keys.reg
\&
\& $ hivexregedit \-\-merge system.hive \e
\& \-\-prefix \*(AqHKEY_LOCAL_MACHINE\eSYSTEM\*(Aq additions.reg
.Ve
.SH OPTIONS
.IX Header "OPTIONS"
.IP \fB\-\-help\fR 4
.IX Item "--help"
Display help.
.IP \fB\-\-debug\fR 4
.IX Item "--debug"
Enable debugging in the hivex library. This is useful for diagnosing
bugs and also malformed hive files.
.IP \fB\-\-merge\fR 4
.IX Item "--merge"
.Vb 2
\& hivexregedit \-\-merge [\-\-prefix prefix] [\-\-encoding enc] \e
\& hivefile [regfile]
.Ve
.Sp
Merge \f(CW\*(C`regfile\*(C'\fR (a regedit-format text file) into the hive
\&\f(CW\*(C`hivefile\*(C'\fR. If \f(CW\*(C`regfile\*(C'\fR is omitted, then the program reads from
standard input. (Also you can give multiple input files).
.Sp
\&\f(CW\*(C`\-\-prefix\*(C'\fR specifies the Windows Registry prefix. It is almost
always necessary to use this when dealing with real hive files.
.Sp
\&\f(CW\*(C`\-\-encoding\*(C'\fR specifies the encoding for unmarked strings in the
input. It defaults to \f(CW\*(C`UTF\-16LE\*(C'\fR which should work for recent
versions of Windows. Another possibility is to use \f(CW\*(C`ASCII\*(C'\fR.
.IP \fB\-\-export\fR 4
.IX Item "--export"
.Vb 1
\& hivexregedit \-\-export [\-\-prefix prefix] hivefile key > regfile
.Ve
.Sp
\&\f(CW\*(C`key\*(C'\fR is a path within the hive \f(CW\*(C`hivefile\*(C'\fR. (The key should not
contain any prefix and should be quoted to defend backslashes from the
shell). The key is exported, recursively, to standard output in the
textual regedit format.
.Sp
\&\f(CW\*(C`\-\-prefix\*(C'\fR specifies the Windows Registry prefix. It is almost
always necessary to use this when dealing with real hive files.
.IP "\fB\-\-prefix\fR prefix" 4
.IX Item "--prefix prefix"
Hive files and Windows Registry key names are indirectly related. For
example, inside the software hive, all keys are stored relative to
\&\f(CW\*(C`HKEY_LOCAL_MACHINE\eSOFTWARE\*(C'\fR. Thus
\&\f(CW\*(C`HKEY_LOCAL_MACHINE\eSOFTWARE\eMicrosoft\*(C'\fR appears in the hive file as
\&\f(CW\*(C`\eMicrosoft\*(C'\fR.
.Sp
The hive format itself does not store this prefix, so you have to
supply it based on outside knowledge. (\fBvirt\-win\-reg\fR\|(1), amongst
other things, already knows about this).
.Sp
Usually it is sufficient to pass the parameter
\&\f(CW\*(C`\-\-prefix \*(AqHKEY_LOCAL_MACHINE\eSOFTWARE\*(Aq\*(C'\fR or similar when doing
merges and exports.
.IP "\fB\-\-encoding\fR UTF\-16LE|ASCII" 4
.IX Item "--encoding UTF-16LE|ASCII"
When merging (only), you may need to specify the encoding for strings
to be used in the hive file. This is explained in detail in
"ENCODING STRINGS" in \fBWin::Hivex::Regedit\fR\|(3).
.Sp
The default is to use UTF\-16LE, which should work with recent versions
of Windows.
.IP \fB\-\-unsafe\-printable\-strings\fR 4
.IX Item "--unsafe-printable-strings"
When exporting (only), assume strings are UTF\-16LE and print them as
strings instead of hex sequences. Remove the final zero codepoint
from strings if present.
.Sp
This is unsafe and does not preserve the fidelity of strings in the
original hive for various reasons:
.RS 4
.IP \(bu 4
Assumes the original encoding is UTF\-16LE. ASCII strings and strings
in other encodings will be corrupted by this transformation.
.IP \(bu 4
Assumes that everything which has type 1 or 2 is really a string
and that everything else is not a string, but the type field in
real hives is not reliable.
.IP \(bu 4
Loses information about whether a zero codepoint followed the string
in the hive or not.
.RE
.RS 4
.Sp
This all happens because the hive itself contains no information about
how strings are encoded (see
"ENCODING STRINGS" in \fBWin::Hivex::Regedit\fR\|(3)).
.Sp
You should only use this option for quick hacking and debugging of the
hive contents, and \fInever\fR use it if the output is going to be passed
into another program or stored in another hive.
.RE
.IP \fB\-\-unsafe\fR 4
.IX Item "--unsafe"
Use heuristics to tolerate certain levels of corruption within hives.
.Sp
This is unsafe but may allow to export/merge valid keys/values in an
othewise corrupted hive.
.IP "\fB\-\-max\-depth\fR depth" 4
.IX Item "--max-depth depth"
Limits the recursion depth of the export. For example, an export
with a max depth of 1 will only include values directly under the
specified key/prefix. A max depth of 0 will return no values.
.Sp
Exports include all child keys by default (fully recursive),
which may take a while if the registry hive is large / bloated.
This behavior can also be achieved by providing a negative max depth.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBvirt\-win\-reg\fR\|(1),
\&\fBWin::Hivex::Regedit\fR\|(3),
\&\fBWin::Hivex\fR\|(3),
\&\fBhivexsh\fR\|(1),
\&\fBdos2unix\fR\|(1),
\&\fBunix2dos\fR\|(1),
\&\fBiconv\fR\|(1),
.
.SH AUTHOR
.IX Header "AUTHOR"
Richard W.M. Jones
.SH COPYRIGHT
.IX Header "COPYRIGHT"
Copyright (C) 2010 Red Hat Inc.
.PP
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.PP
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.PP
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.