source: trunk/include/regfi.h @ 162

Last change on this file since 162 was 162, checked in by tim, 14 years ago

added UTF-16LE support for value names

  • Property svn:keywords set to Id
File size: 22.8 KB
Line 
1/*
2 * Branched from Samba project Subversion repository, version #6903:
3 *   http://viewcvs.samba.org/cgi-bin/viewcvs.cgi/trunk/source/include/regfio.h?rev=6903&view=auto
4 *
5 * Windows NT (and later) registry parsing library
6 *
7 * Copyright (C) 2005-2009 Timothy D. Morgan
8 * Copyright (C) 2005 Gerald (Jerry) Carter
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 3 of the License.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 * $Id: regfi.h 162 2009-12-07 20:12:13Z tim $
24 */
25
26/************************************************************
27 * Most of this information was obtained from
28 * http://www.wednesday.demon.co.uk/dosreg.html
29 * Thanks Nigel!
30 ***********************************************************/
31
32#ifndef _REGFI_H
33#define _REGFI_H
34
35#include <stdlib.h>
36#include <stdio.h>
37#include <stdbool.h>
38#include <stdarg.h>
39#include <string.h>
40#include <errno.h>
41#include <time.h>
42#include <fcntl.h>
43#include <sys/stat.h>
44#include <sys/types.h>
45#include <unistd.h>
46#include <assert.h>
47#include <iconv.h>
48
49#include "talloc.h"
50#include "smb_deps.h"
51#include "winsec.h"
52#include "void_stack.h"
53#include "range_list.h"
54#include "lru_cache.h"
55
56/******************************************************************************/
57
58/* regfi library error message types */
59#define REGFI_MSG_INFO  0x0001
60#define REGFI_MSG_WARN  0x0004
61#define REGFI_MSG_ERROR 0x0010
62
63typedef uint8 REGFI_ENCODING;
64/* regfi library supported character encodings */
65#define REGFI_ENCODING_ASCII   0
66#define REGFI_ENCODING_UTF8    1
67#define REGFI_ENCODING_DEFAULT REGFI_ENCODING_ASCII
68/* UTF16LE is not supported for output */
69#define REGFI_ENCODING_UTF16LE 2
70
71#define REGFI_NUM_ENCODINGS    3
72
73/* Windows is lame */
74#ifdef O_BINARY
75#define REGFI_OPEN_FLAGS O_RDONLY|O_BINARY
76#else
77#define REGFI_OPEN_FLAGS O_RDONLY
78#endif
79
80/* Registry data types */
81#define REG_NONE                       0
82#define REG_SZ                         1
83#define REG_EXPAND_SZ                  2
84#define REG_BINARY                     3
85#define REG_DWORD                      4
86#define REG_DWORD_LE                   4  /* DWORD, little endian */
87#define REG_DWORD_BE                   5  /* DWORD, big endian */
88#define REG_LINK                       6
89#define REG_MULTI_SZ                   7
90#define REG_RESOURCE_LIST              8
91#define REG_FULL_RESOURCE_DESCRIPTOR   9
92#define REG_RESOURCE_REQUIREMENTS_LIST 10
93#define REG_QWORD                      11 /* 64-bit little endian */
94/* XXX: Has MS defined a REG_QWORD_BE? */
95/* Not a real type in the registry */
96#define REG_KEY                    0x7FFFFFFF
97
98#define REGFI_MAX_DEPTH            512
99#define REGFI_OFFSET_NONE          0xffffffff
100
101/* XXX: This is totally arbitrary right now. */
102#define REGFI_MAX_SUBKEY_DEPTH     255
103
104/* Header sizes and magic number lengths for various records */
105#define REGFI_HBIN_ALLOC           0x1000 /* Minimum allocation unit for HBINs */
106#define REGFI_REGF_SIZE            0x1000 /* "regf" header block size */
107#define REGFI_REGF_MAGIC_SIZE      4
108#define REGFI_REGF_NAME_SIZE       64
109#define REGFI_REGF_RESERVED1_SIZE  340
110#define REGFI_REGF_RESERVED2_SIZE  3528
111#define REGFI_HBIN_MAGIC_SIZE      4
112#define REGFI_CELL_MAGIC_SIZE      2
113#define REGFI_HBIN_HEADER_SIZE     0x20
114#define REGFI_NK_MIN_LENGTH        0x4C
115#define REGFI_VK_MIN_LENGTH        0x14
116#define REGFI_SK_MIN_LENGTH        0x14
117#define REGFI_SUBKEY_LIST_MIN_LEN  0x4
118#define REGFI_BIG_DATA_MIN_LENGTH  0xC
119
120
121/* Constants used for validation */
122/* XXX: Can we add clock resolution validation as well as range?  It has
123 *      been reported that Windows timestamps are never more than a
124 *      certain granularity (250ms?), which could be used to help
125 *      eliminate false positives.  Would need to verify this and
126 *      perhaps conservatively implement a check.
127 */
128 /* Minimum time is Jan 1, 1990 00:00:00 */
129#define REGFI_MTIME_MIN_HIGH       0x01B41E6D
130#define REGFI_MTIME_MIN_LOW        0x26F98000
131 /* Maximum time is Jan 1, 2290 00:00:00
132  * (We hope no one is using Windows by then...)
133  */
134#define REGFI_MTIME_MAX_HIGH       0x03047543
135#define REGFI_MTIME_MAX_LOW        0xC80A4000
136
137
138/* Flags for the vk records */
139#define REGFI_VK_FLAG_ASCIINAME    0x0001
140#define REGFI_VK_DATA_IN_OFFSET    0x80000000
141#define REGFI_VK_MAX_DATA_LENGTH   1024*1024  /* XXX: This is arbitrary */
142
143
144/* Known key flags */
145/*******************/
146/* These next two show up on normal-seeming keys in Vista and W2K3 registries */
147#define REGFI_NK_FLAG_UNKNOWN1     0x4000
148#define REGFI_NK_FLAG_UNKNOWN2     0x1000
149
150/* This next one shows up on root keys in some Vista "software" registries */
151#define REGFI_NK_FLAG_UNKNOWN3     0x0080
152
153/* Predefined handle.  Rumor has it that the valuelist count for this key is
154 * where the handle is stored.
155 * http://msdn.microsoft.com/en-us/library/ms724836(VS.85).aspx
156 */
157#define REGFI_NK_FLAG_PREDEF_KEY   0x0040
158
159/* The name will be in ASCII if this next bit is set, otherwise UTF-16LE */
160#define REGFI_NK_FLAG_ASCIINAME    0x0020
161
162/* Symlink key. 
163 * See: http://www.codeproject.com/KB/system/regsymlink.aspx
164 */
165#define REGFI_NK_FLAG_LINK         0x0010
166
167/* This key cannot be deleted */
168#define REGFI_NK_FLAG_NO_RM        0x0008
169
170/* Root of a hive */
171#define REGFI_NK_FLAG_ROOT         0x0004
172
173/* Mount point of another hive.  NULL/(default) value indicates which hive
174 * and where in the hive it points to.
175 */
176#define REGFI_NK_FLAG_HIVE_LINK    0x0002
177
178/* These keys shouldn't be stored on disk, according to:
179 * http://geekswithblogs.net/sdorman/archive/2007/12/24/volatile-registry-keys.aspx
180 */
181#define REGFI_NK_FLAG_VOLATILE     0x0001
182
183/* Useful for identifying unknown flag types */
184#define REGFI_NK_KNOWN_FLAGS       (REGFI_NK_FLAG_PREDEF_KEY\
185                                    | REGFI_NK_FLAG_ASCIINAME\
186                                    | REGFI_NK_FLAG_LINK\
187                                    | REGFI_NK_FLAG_NO_RM\
188                                    | REGFI_NK_FLAG_ROOT\
189                                    | REGFI_NK_FLAG_HIVE_LINK\
190                                    | REGFI_NK_FLAG_VOLATILE\
191                                    | REGFI_NK_FLAG_UNKNOWN1\
192                                    | REGFI_NK_FLAG_UNKNOWN2)
193
194/* HBIN block */
195typedef struct _regfi_hbin
196{
197  uint32 file_off;       /* my offset in the registry file */
198  uint32 ref_count;      /* how many active records are pointing to this
199                          * block (not used currently)
200                          */
201 
202  uint32 first_hbin_off; /* offset from first hbin block */
203  uint32 block_size;     /* block size of this block
204                          * Should be a multiple of 4096 (0x1000)
205                          */
206  uint32 next_block;     /* relative offset to next block. 
207                          * NOTE: This value may be unreliable!
208                          */
209
210  uint8 magic[REGFI_HBIN_MAGIC_SIZE]; /* "hbin" */
211} REGFI_HBIN;
212
213
214/* Subkey List -- list of key offsets and hashed names for consistency */
215typedef struct 
216{
217  /* Virtual offset of NK record or additional subkey list,
218   * depending on this list's type.
219   */
220  uint32 offset;
221
222  uint32 hash;
223} REGFI_SUBKEY_LIST_ELEM;
224
225
226typedef struct _regfi_subkey_list
227{
228  /* Real offset of this record's cell in the file */
229  uint32 offset;
230
231  uint32 cell_size;
232 
233  /* Number of immediate children */
234  uint32 num_children; 
235
236  /* Total number of keys referenced by this list and it's children */
237  uint32 num_keys;     
238
239  REGFI_SUBKEY_LIST_ELEM* elements;
240  uint8 magic[REGFI_CELL_MAGIC_SIZE];
241
242  /* Set if the magic indicates this subkey list points to child subkey lists */
243  bool recursive_type; 
244} REGFI_SUBKEY_LIST;
245
246
247typedef uint32 REGFI_VALUE_LIST_ELEM;
248typedef struct _regfi_value_list
249{
250  /* Actual number of values referenced by this list. 
251   * May differ from parent key's num_values if there were parsing errors.
252   */
253  uint32 num_values;
254
255  REGFI_VALUE_LIST_ELEM* elements;
256} REGFI_VALUE_LIST;
257
258
259typedef struct _regfi_classname
260{
261  /* As converted to requested character encoding. */
262  char* interpreted;
263
264  /* Represents raw buffer read from classname cell. */
265  uint8* raw;
266
267  /* Length of the raw data. May be shorter than that indicated by parent key.*/
268  uint16 size;
269} REGFI_CLASSNAME;
270
271
272typedef struct _regfi_data
273{
274  uint32 type;
275
276  /* Length of the raw data. */
277  uint32 size;
278
279  /* This is always present, representing the raw data cell contents. */
280  uint8* raw;
281
282  /* Represents the length of the interpreted value. Meaning is type-specific.*/
283  uint32 interpreted_size;
284
285  /* These items represent interpreted versions of the raw attribute above.
286   * Only use the appropriate member according to the type field. 
287   * In the event of an unknown type, use only the raw field.
288   */
289  union _regfi_data_interpreted
290  {
291    uint8* none; /* */
292    uint8* string;
293    uint8* expand_string;
294    uint8* binary; /* */
295    uint32 dword;
296    uint32 dword_be;
297    uint8* link;
298    uint8** multiple_string;
299    uint64 qword;
300
301    /* The following are treated as binary currently, but this may change in
302     * the future as the formats become better understood.
303     */
304    uint8* resource_list;
305    uint8* full_resource_descriptor;
306    uint8* resource_requirements_list;
307  } interpreted;
308} REGFI_DATA;
309
310
311/* Value record */
312typedef struct 
313{
314  uint32 offset;        /* Real offset of this record's cell in the file */
315  uint32 cell_size;     /* ((start_offset - end_offset) & 0xfffffff8) */
316
317  REGFI_DATA* data;     /* XXX: deprecated */
318
319  char*  valuename;
320  uint8* valuename_raw;
321  uint16 name_length;
322  uint32 hbin_off;      /* offset from beginning of this hbin block */
323 
324  uint32 data_size;     /* As reported in the VK record.  May be different than
325                         * That obtained while parsing the data cell itself. */
326  uint32 data_off;      /* Offset of data cell (virtual) */
327  uint32 type;
328  uint8  magic[REGFI_CELL_MAGIC_SIZE];
329  uint16 flags;
330  uint16 unknown1;
331  bool data_in_offset;
332} REGFI_VK_REC;
333
334
335/* Key Security */
336struct _regfi_sk_rec;
337
338typedef struct _regfi_sk_rec
339{
340  uint32 offset;        /* Real file offset of this record */
341  uint32 cell_size;     /* ((start_offset - end_offset) & 0xfffffff8) */
342
343  WINSEC_DESC* sec_desc;
344  uint32 hbin_off;      /* offset from beginning of this hbin block */
345 
346  uint32 prev_sk_off;
347  uint32 next_sk_off;
348  uint32 ref_count;
349  uint32 desc_size;     /* size of security descriptor */
350  uint16 unknown_tag;
351  uint8  magic[REGFI_CELL_MAGIC_SIZE];
352} REGFI_SK_REC;
353
354
355/* Key Name */
356typedef struct
357{
358  uint32 offset;        /* Real offset of this record's cell in the file */
359  uint32 cell_size;     /* Actual or estimated length of the cell. 
360                         * Always in multiples of 8.
361                         */
362
363  /* link in the other records here */
364  REGFI_VALUE_LIST* values;
365  REGFI_SUBKEY_LIST* subkeys;
366 
367  /* header information */
368  uint16 flags;
369  uint8  magic[REGFI_CELL_MAGIC_SIZE];
370  NTTIME mtime;
371  uint16 name_length;
372  uint16 classname_length;
373  char* keyname;
374  uint8* keyname_raw;
375  uint32 parent_off;                /* pointer to parent key */
376  uint32 classname_off;
377 
378  /* max lengths */
379  uint32 max_bytes_subkeyname;      /* max subkey name * 2 */
380  uint32 max_bytes_subkeyclassname; /* max subkey classname length (as if) */
381  uint32 max_bytes_valuename;       /* max valuename * 2 */
382  uint32 max_bytes_value;           /* max value data size */
383 
384  /* unknowns */
385  uint32 unknown1;
386  uint32 unknown2;
387  uint32 unknown3;
388  uint32 unk_index;                 /* nigel says run time index ? */
389 
390  /* children */
391  uint32 num_subkeys;
392  uint32 subkeys_off;   /* offset of subkey list that points to NK records */
393  uint32 num_values;
394  uint32 values_off;    /* value lists which point to VK records */
395  uint32 sk_off;        /* offset to SK record */
396} REGFI_NK_REC;
397
398
399
400/* REGF block */
401typedef struct 
402{
403  /* Run-time information */
404  /************************/
405  /* file descriptor */
406  int fd;
407
408  /* For sanity checking (not part of the registry header) */
409  uint32 file_length;
410
411  /* Metadata about hbins */
412  range_list* hbins;
413
414  /* SK record cached since they're repeatedly reused */
415  lru_cache* sk_cache;
416
417  /* Error/warning/info messages returned by lower layer functions */
418  char* last_message;
419
420  /* Mask for error message types that will be stored. */
421  uint16 msg_mask;
422
423
424  /* Data parsed from file header */
425  /********************************/
426  uint8  magic[REGFI_REGF_MAGIC_SIZE];/* "regf" */
427
428 /* These sequence numbers should match if
429  * the hive was properly synced to disk.
430  */
431  uint32 sequence1;           
432  uint32 sequence2;
433
434  NTTIME mtime;
435  uint32 major_version;  /* Set to 1 in all known hives */
436  uint32 minor_version;  /* Set to 3 or 5 in all known hives */
437  uint32 type;           /* XXX: Unverified.  Set to 0 in all known hives */
438  uint32 format;         /* XXX: Unverified.  Set to 1 in all known hives */
439
440  uint32 root_cell;  /* Offset to root cell in the first (or any?) hbin block */
441  uint32 last_block; /* Offset to last hbin block in file */
442
443  uint32 cluster;    /* XXX: Unverified. Set to 1 in all known hives */
444
445  /* Matches hive's base file name. Stored in UTF-16LE */
446  uint8 file_name[REGFI_REGF_NAME_SIZE];
447
448  WINSEC_UUID* rm_id;       /* XXX: Unverified. */
449  WINSEC_UUID* log_id;      /* XXX: Unverified. */
450  WINSEC_UUID* tm_id;       /* XXX: Unverified. */
451  uint32 flags;             /* XXX: Unverified. */
452  uint32 guid_signature;    /* XXX: Unverified. */
453
454  uint32 checksum;          /* Stored checksum from file */
455  uint32 computed_checksum; /* Our own calculation of the checksum.
456                             * (XOR of bytes 0x0000 - 0x01FB) */
457
458  WINSEC_UUID* thaw_tm_id;  /* XXX: Unverified. */
459  WINSEC_UUID* thaw_rm_id;  /* XXX: Unverified. */
460  WINSEC_UUID* thaw_log_id; /* XXX: Unverified. */
461  uint32 boot_type;         /* XXX: Unverified. */
462  uint32 boot_recover;      /* XXX: Unverified. */
463
464  /* This seems to include random junk.  Possibly unsanitized memory left over
465   * from when header block was written.  For instance, chunks of nk records
466   * can be found, though often it's all 0s. */
467  uint8 reserved1[REGFI_REGF_RESERVED1_SIZE];
468
469  /* This is likely reserved and unusued currently.  (Should be all 0s.)
470   * Included here for easier access in looking for hidden data
471   * or doing research. */
472  uint8 reserved2[REGFI_REGF_RESERVED2_SIZE];
473
474} REGFI_FILE;
475
476
477/* XXX: Should move all caching (SK records, HBINs, NKs, etc) to a single
478 *      structure, probably REGFI_FILE.  Once key caching is in place,
479 *      convert key_positions stack to store just key offsets rather than
480 *      whole keys.
481 */
482typedef struct _regfi_iterator
483{
484  REGFI_FILE* f;
485  void_stack* key_positions;
486  REGFI_NK_REC* cur_key;
487  REGFI_ENCODING string_encoding;
488  uint32 cur_subkey;
489  uint32 cur_value;
490} REGFI_ITERATOR;
491
492
493typedef struct _regfi_iter_position
494{
495  REGFI_NK_REC* nk;
496  uint32 cur_subkey;
497  /* We could store a cur_value here as well, but didn't see
498   * the use in it right now.
499   */
500} REGFI_ITER_POSITION;
501
502
503typedef struct _regfi_buffer
504{
505  uint8* buf;
506  uint32_t len;
507} REGFI_BUFFER;
508
509
510
511
512/******************************************************************************/
513/*                         Main iterator API                                  */
514/******************************************************************************/
515REGFI_FILE*           regfi_open(const char* filename);
516int                   regfi_close(REGFI_FILE* r);
517
518/* regfi_get_messages: Get errors, warnings, and/or verbose information
519 *                     relating to processing of the given registry file.
520 *
521 * Arguments:
522 *   file     -- the structure for the registry file
523 *
524 * Returns:
525 *   A newly allocated char* which must be free()d by the caller.
526 */
527char*                 regfi_get_messages(REGFI_FILE* file);
528
529void                  regfi_set_message_mask(REGFI_FILE* file, uint16 mask);
530
531
532/* regfi_iterator_new: Creates a new iterator for the provided registry file.
533 *
534 * Arguments:
535 *   file            -- The opened registry file the iterator should be
536 *                      created for.
537 *   output_encoding -- Character encoding that strings should be returned in.
538 *                      Only supply the REGFI_ENCODING_* constants, as others
539 *                      will be rejected.
540 *                      The following values are currently accepted:
541 *                      REGFI_ENCODING_DEFAULT (currently REGFI_ENCODING_ASCII)
542 *                      REGFI_ENCODING_ASCII
543 *                      REGFI_ENCODING_UTF8
544 *
545 *                      XXX: This encoding only applies to specific data
546 *                           strings currently, but should apply to key
547 *                           names and value names in the future.
548 *
549 * Returns:
550 *   A newly allocated REGFI_ITERATOR. Must be free()d with regfi_iterator_free.
551 */
552REGFI_ITERATOR*       regfi_iterator_new(REGFI_FILE* file,
553                                         REGFI_ENCODING output_encoding);
554void                  regfi_iterator_free(REGFI_ITERATOR* i);
555bool                  regfi_iterator_down(REGFI_ITERATOR* i);
556bool                  regfi_iterator_up(REGFI_ITERATOR* i);
557bool                  regfi_iterator_to_root(REGFI_ITERATOR* i);
558
559bool                  regfi_iterator_walk_path(REGFI_ITERATOR* i, 
560                                               const char** path);
561const REGFI_NK_REC*   regfi_iterator_cur_key(REGFI_ITERATOR* i);
562const REGFI_SK_REC*   regfi_iterator_cur_sk(REGFI_ITERATOR* i);
563
564REGFI_NK_REC*         regfi_iterator_first_subkey(REGFI_ITERATOR* i);
565REGFI_NK_REC*         regfi_iterator_cur_subkey(REGFI_ITERATOR* i);
566REGFI_NK_REC*         regfi_iterator_next_subkey(REGFI_ITERATOR* i);
567bool                  regfi_iterator_find_subkey(REGFI_ITERATOR* i, 
568                                                 const char* subkey_name);
569
570REGFI_VK_REC*         regfi_iterator_first_value(REGFI_ITERATOR* i);
571REGFI_VK_REC*         regfi_iterator_cur_value(REGFI_ITERATOR* i);
572REGFI_VK_REC*         regfi_iterator_next_value(REGFI_ITERATOR* i);
573bool                  regfi_iterator_find_value(REGFI_ITERATOR* i, 
574                                                const char* value_name);
575
576REGFI_CLASSNAME*      regfi_iterator_fetch_classname(REGFI_ITERATOR* i, 
577                                                     const REGFI_NK_REC* key);
578REGFI_DATA*           regfi_iterator_fetch_data(REGFI_ITERATOR* i, 
579                                                const REGFI_VK_REC* value);
580
581
582/********************************************************/
583/* Middle-layer structure loading, linking, and caching */
584/********************************************************/
585REGFI_NK_REC*         regfi_load_key(REGFI_FILE* file, uint32 offset, 
586                                     REGFI_ENCODING output_encoding, 
587                                     bool strict);
588REGFI_VK_REC*         regfi_load_value(REGFI_FILE* file, uint32 offset, 
589                                       REGFI_ENCODING output_encoding, 
590                                       bool strict);
591REGFI_SUBKEY_LIST*    regfi_load_subkeylist(REGFI_FILE* file, uint32 offset,
592                                            uint32 num_keys, uint32 max_size,
593                                            bool strict);
594REGFI_VALUE_LIST*     regfi_load_valuelist(REGFI_FILE* file, uint32 offset, 
595                                           uint32 num_values, uint32 max_size,
596                                           bool strict);
597
598REGFI_BUFFER          regfi_load_data(REGFI_FILE* file, uint32 voffset,
599                                      uint32 length, bool data_in_offset,
600                                      bool strict);
601
602REGFI_BUFFER          regfi_load_big_data(REGFI_FILE* file, uint32 offset, 
603                                          uint32 data_length,uint32 cell_length,
604                                          range_list* used_ranges,
605                                          bool strict);
606bool                  regfi_interpret_data(REGFI_FILE* file, 
607                                           REGFI_ENCODING string_encoding,
608                                           uint32 type, REGFI_DATA* data);
609void                  regfi_free_classname(REGFI_CLASSNAME* classname);
610void                  regfi_free_data(REGFI_DATA* data);
611
612
613/* These are cached so return values don't need to be freed. */
614const REGFI_SK_REC*   regfi_load_sk(REGFI_FILE* file, uint32 offset,
615                                    bool strict);
616const REGFI_HBIN*     regfi_lookup_hbin(REGFI_FILE* file, uint32 offset);
617
618
619/************************************/
620/*  Low-layer data structure access */
621/************************************/
622REGFI_FILE*           regfi_parse_regf(int fd, bool strict);
623REGFI_HBIN*           regfi_parse_hbin(REGFI_FILE* file, uint32 offset, 
624                                       bool strict);
625
626
627/* regfi_parse_nk: Parses an NK record.
628 *
629 * Arguments:
630 *   f        -- the registry file structure
631 *   offset   -- the offset of the cell (not the record) to be parsed.
632 *   max_size -- the maximum size the NK cell could be. (for validation)
633 *   strict   -- if true, rejects any malformed records.  Otherwise,
634 *               tries to minimally validate integrity.
635 * Returns:
636 *   A newly allocated NK record structure, or NULL on failure.
637 */
638REGFI_NK_REC*         regfi_parse_nk(REGFI_FILE* file, uint32 offset,
639                                     uint32 max_size, bool strict);
640
641REGFI_SUBKEY_LIST*    regfi_parse_subkeylist(REGFI_FILE* file, uint32 offset,
642                                             uint32 max_size, bool strict);
643
644REGFI_VK_REC*         regfi_parse_vk(REGFI_FILE* file, uint32 offset, 
645                                     uint32 max_size, bool strict);
646
647REGFI_SK_REC*         regfi_parse_sk(REGFI_FILE* file, uint32 offset, 
648                                     uint32 max_size, bool strict);
649
650range_list*           regfi_parse_unalloc_cells(REGFI_FILE* file);
651
652bool                  regfi_parse_cell(int fd, uint32 offset, 
653                                       uint8* hdr, uint32 hdr_len,
654                                       uint32* cell_length, bool* unalloc);
655
656uint8*                regfi_parse_classname(REGFI_FILE* file, uint32 offset,
657                                            uint16* name_length, 
658                                            uint32 max_size, bool strict);
659
660REGFI_BUFFER          regfi_parse_data(REGFI_FILE* file, uint32 offset,
661                                       uint32 length, bool strict);
662
663REGFI_BUFFER          regfi_parse_little_data(REGFI_FILE* file, uint32 voffset, 
664                                              uint32 length, bool strict);
665
666
667/* Dispose of previously parsed records */
668void                  regfi_free_key(REGFI_NK_REC* nk);
669void                  regfi_free_value(REGFI_VK_REC* vk);
670
671
672
673/************************************/
674/*    Private Functions             */
675/************************************/
676REGFI_NK_REC*         regfi_rootkey(REGFI_FILE* file, 
677                                    REGFI_ENCODING output_encoding);
678void                  regfi_subkeylist_free(REGFI_SUBKEY_LIST* list);
679uint32                regfi_read(int fd, uint8* buf, uint32* length);
680
681const char*           regfi_type_val2str(unsigned int val);
682int                   regfi_type_str2val(const char* str);
683
684char*                 regfi_get_sacl(WINSEC_DESC* sec_desc);
685char*                 regfi_get_dacl(WINSEC_DESC* sec_desc);
686char*                 regfi_get_owner(WINSEC_DESC* sec_desc);
687char*                 regfi_get_group(WINSEC_DESC* sec_desc);
688
689REGFI_SUBKEY_LIST*    regfi_merge_subkeylists(uint16 num_lists, 
690                                              REGFI_SUBKEY_LIST** lists,
691                                              bool strict);
692REGFI_SUBKEY_LIST*    regfi_load_subkeylist_aux(REGFI_FILE* file, uint32 offset,
693                                                uint32 max_size, bool strict,
694                                                uint8 depth_left);
695void                  regfi_add_message(REGFI_FILE* file, uint16 msg_type, 
696                                        const char* fmt, ...);
697REGFI_NK_REC*         regfi_copy_nk(const REGFI_NK_REC* nk);
698REGFI_VK_REC*         regfi_copy_vk(const REGFI_VK_REC* vk);
699int32                 regfi_calc_maxsize(REGFI_FILE* file, uint32 offset);
700int32                 regfi_conv_charset(const char* input_charset, 
701                                         const char* output_charset,
702                                         uint8* input, char* output, 
703                                         uint32 input_len, uint32 output_max);
704REGFI_DATA*           regfi_buffer_to_data(REGFI_BUFFER raw_data);
705
706#endif  /* _REGFI_H */
Note: See TracBrowser for help on using the repository browser.