hivexsh: Document some peculiarities of the "cd" command.
[libguestfs.git] / hivex / hivexsh.pod
1 =encoding utf8
2
3 =head1 NAME
4
5 hivexsh - Windows Registry hive shell
6
7 =head1 SYNOPSIS
8
9  hivexsh [-options] [hivefile]
10
11 =head1 DESCRIPTION
12
13 This program provides a simple shell for navigating Windows Registry
14 'hive' files.  It uses the hivex library for access to these binary
15 files.
16
17 Firstly you will need to provide a hive file from a Windows operating
18 system.  The hive files are usually located in
19 C<C:\Windows\System32\Config> and have names like C<software>,
20 C<system> etc (without any file extension).  For more information
21 about hive files, read L<hivex(3)>.  For information about downloading
22 files from virtual machines, read L<virt-cat(1)> and L<guestfish(1)>.
23
24 You can provide the name of the hive file to examine on the command
25 line.  For example:
26
27  hivexsh software
28
29 Or you can start C<hivexsh> without any arguments, and immediately use
30 the C<load> command to load a hive:
31
32  $ hivexsh
33  
34  Welcome to hivexsh, the hivex interactive shell for examining
35  Windows Registry binary hive files.
36  
37  Type: 'help' for help with commands
38        'quit' to quit the shell
39  
40  > load software
41  software\>
42
43 Navigate through the hive's keys using the C<cd> command, as if it
44 contained a filesystem, and use C<ls> to list the subkeys of the
45 current key.  Other commands are listed below.
46
47 =head1 OPTIONS
48
49 =over 4
50
51 =item B<-d>
52
53 Enable lots of debug messages.  If you find a Registry file that this
54 program cannot parse, please enable this option and post the complete
55 output I<and> the Registry hive file in your bug report.
56
57 =item B<-f> filename
58
59 Read commands from C<filename> instead of stdin.  To write a hivexsh
60 script, use:
61
62  #!/usr/bin/hivexsh -f
63
64 =item B<-w>
65
66 If this option is given, then writes are allowed to the hive
67 (see L</commit> command below, and the discussion of
68 modifying hives in L<hivex(3)/WRITING TO HIVE FILES>).
69
70 B<Important Note:> Even if you specify this option, nothing is written
71 to a hive unless you call the L</commit> command.  If you exit the
72 shell without committing, all changes will be discarded.
73
74 If this option is not given, then write commands are disabled.
75
76 =back
77
78 =head1 COMMANDS
79
80 =over 4
81
82 =item B<cd> path
83
84 Change to the subkey C<path>.  Use Windows-style backslashes to
85 separate path elements, and start with a backslash in order to start
86 from the root of the hive.  For example:
87
88  cd \Classes\*
89
90 moves from the root node, to the C<Classes> node, to the C<*> node.
91 If you were already at the root node, you could do this instead:
92
93  cd Classes\*
94
95 or even:
96
97  cd Classes
98  cd *
99
100 Path elements (node names) are matched case insensitively, and
101 characters like space, C<*>, and C<?> have I<no> special significance.
102
103 C<cd ..> may be used to go to the parent directory.
104
105 C<cd> without any arguments prints the current path.
106
107 Be careful with C<cd \> since the readline library has an undocumented
108 behaviour where it will think the final backslash is a continuation
109 (it reads the next line of input and appends it).  Put a single space
110 after the backslash.
111
112 =item B<close> | B<unload>
113
114 Close the currently loaded hive.
115
116 If you modified the hive, all uncommitted writes are lost when you
117 call this command (or if the shell exits).  You have to call C<commit>
118 to write changes.
119
120 =item B<commit> [newfile]
121
122 Commit changes to the hive.  If the optional C<newfile> parameter is
123 supplied, then the hive is written to that file, else the original
124 file is overwritten.
125
126 Note that you have to specify the C<-w> flag, otherwise no writes are
127 allowed.
128
129 =item B<del>
130
131 Delete the current node and everything beneath it.  The current
132 directory is moved up one level (as if you did C<cd ..>) after
133 this command.
134
135 You cannot delete the root node.
136
137 =item B<exit> | B<quit>
138
139 Exit the shell.
140
141 =item B<load> hivefile
142
143 Load the binary hive named C<hivefile>.  The currently loaded hive, if
144 any, is closed.  The current directory is changed back to the root
145 node.
146
147 =item B<ls>
148
149 List the subkeys of the current hive Registry key.  Note this command
150 does not take any arguments.
151
152 =item B<lsval> [key]
153
154 List the (key, value) pairs of the current hive Registry key.  If no
155 argument is given then all pairs are displayed.  If C<key> is given,
156 then the value of the named key is displayed.  If C<@> is given, then
157 the value of the default key is displayed.
158
159 =item B<setval> nrvals
160
161 This command replaces all (key, value) pairs at the current node with
162 the values in subsequent input.  C<nrvals> is the number of values
163 (ie. (key, value) pairs), and any existing values at this node are
164 deleted.  So C<setval 0> just deletes any values at the current node.
165
166 The command reads 2 * nrvals lines of input, with each pair of
167 lines of input corresponding to a key and a value to add.
168
169 For example, the following setval command replaces whatever is at the
170 current node with two (key, value) pairs.  The default key is set to
171 the UTF16-LE-encoded string "abcd".  The other value is named
172 "ANumber" and is a little-endian DWORD 0x12345678.
173
174  setval 2
175  @
176  string:abcd
177  ANumber
178  dword:12345678
179
180 The first line of each pair is the key (the special key C<@> means
181 the default key, but you can also use a blank line).
182
183 The second line of each pair is the value, which has a special format
184 C<type:value> with possible types summarized in the table below:
185
186  none                 No data is stored, and the type is set to 0.
187  
188  string:abc           "abc" is stored as a UTF16-LE-encoded
189                       string (type 1).  Note that only 7 bit
190                       ASCII strings are supported as input.
191  
192  expandstring:...     Same as string but with type 2.
193  
194  dword:0x01234567     A DWORD (type 4) with the hex value
195                       0x01234567.  You can also use decimal
196                       or octal numbers here.
197  
198  qword:0x0123456789abcdef
199                       A QWORD (type 11) with the hex value
200                       0x0123456789abcdef.  You can also use
201                       decimal or octal numbers here.
202  
203  hex:<type>:<hexbytes>
204  hex:1:41,00,42,00,43,00,44,00,00,00
205                       This is the generic way to enter any
206                       value.  <type> is the integer value type.
207                       <hexbytes> is a list of pairs of hex
208                       digits which are treated as bytes.
209                       (Any non-hex-digits here are ignored,
210                       so you can separate bytes with commas
211                       or spaces if you want).
212
213 =back
214
215 =head1 EXAMPLE
216
217  $ guestfish --ro -i Windows7
218  ><fs> download win:c:\windows\system32\config\software software
219  ><fs> quit
220  
221  $ hivexsh software
222  
223  Welcome to hivexsh, the hivex interactive shell for examining
224  Windows Registry binary hive files.
225  
226  Type: 'help' for help with commands
227        'quit' to quit the shell
228  
229  software\> ls
230  ATI Technologies
231  Classes
232  Clients
233  Intel
234  Microsoft
235  ODBC
236  Policies
237  RegisteredApplications
238  Sonic
239  Wow6432Node
240  software\> quit
241
242 =head1 SEE ALSO
243
244 L<hivex(3)>,
245 L<hivexget(1)>,
246 L<hivexml(1)>,
247 L<virt-win-reg(1)>,
248 L<guestfs(3)>,
249 L<http://libguestfs.org/>,
250 L<virt-cat(1)>,
251 L<virt-edit(1)>.
252
253 =head1 AUTHORS
254
255 Richard W.M. Jones (C<rjones at redhat dot com>)
256
257 =head1 COPYRIGHT
258
259 Copyright (C) 2009-2010 Red Hat Inc.
260
261 This program is free software; you can redistribute it and/or modify
262 it under the terms of the GNU General Public License as published by
263 the Free Software Foundation; either version 2 of the License, or
264 (at your option) any later version.
265
266 This program is distributed in the hope that it will be useful,
267 but WITHOUT ANY WARRANTY; without even the implied warranty of
268 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
269 GNU General Public License for more details.
270
271 You should have received a copy of the GNU General Public License along
272 with this program; if not, write to the Free Software Foundation, Inc.,
273 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.