source: trunk/include/regfi.h @ 161

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

added support for UTF-16LE key names

  • Property svn:keywords set to Id
File size: 23.0 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 161 2009-12-07 17:01:22Z 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/* XXX: This next flag may be incorrect.  According to Jeffrey Muir,
140*       this may actually indicate that the value name is stored in
141*       UTF-16LE.
142*/
143#define REGFI_VK_FLAG_NAME_PRESENT 0x0001
144#define REGFI_VK_DATA_IN_OFFSET    0x80000000
145#define REGFI_VK_MAX_DATA_LENGTH   1024*1024  /* XXX: This is arbitrary */
146
147
148/* Known key flags */
149/*******************/
150/* These next two show up on normal-seeming keys in Vista and W2K3 registries */
151#define REGFI_NK_FLAG_UNKNOWN1     0x4000
152#define REGFI_NK_FLAG_UNKNOWN2     0x1000
153
154/* This next one shows up on root keys in some Vista "software" registries */
155#define REGFI_NK_FLAG_UNKNOWN3     0x0080
156
157/* Predefined handle.  Rumor has it that the valuelist count for this key is
158 * where the handle is stored.
159 * http://msdn.microsoft.com/en-us/library/ms724836(VS.85).aspx
160 */
161#define REGFI_NK_FLAG_PREDEF_KEY   0x0040
162
163/* The name will be in ASCII if this next bit is set, otherwise UTF-16LE */
164#define REGFI_NK_FLAG_ASCIINAME    0x0020
165
166/* Symlink key. 
167 * See: http://www.codeproject.com/KB/system/regsymlink.aspx
168 */
169#define REGFI_NK_FLAG_LINK         0x0010
170
171/* This key cannot be deleted */
172#define REGFI_NK_FLAG_NO_RM        0x0008
173
174/* Root of a hive */
175#define REGFI_NK_FLAG_ROOT         0x0004
176
177/* Mount point of another hive.  NULL/(default) value indicates which hive
178 * and where in the hive it points to.
179 */
180#define REGFI_NK_FLAG_HIVE_LINK    0x0002
181
182/* These keys shouldn't be stored on disk, according to:
183 * http://geekswithblogs.net/sdorman/archive/2007/12/24/volatile-registry-keys.aspx
184 */
185#define REGFI_NK_FLAG_VOLATILE     0x0001
186
187/* Useful for identifying unknown flag types */
188#define REGFI_NK_KNOWN_FLAGS       (REGFI_NK_FLAG_PREDEF_KEY\
189                                    | REGFI_NK_FLAG_ASCIINAME\
190                                    | REGFI_NK_FLAG_LINK\
191                                    | REGFI_NK_FLAG_NO_RM\
192                                    | REGFI_NK_FLAG_ROOT\
193                                    | REGFI_NK_FLAG_HIVE_LINK\
194                                    | REGFI_NK_FLAG_VOLATILE\
195                                    | REGFI_NK_FLAG_UNKNOWN1\
196                                    | REGFI_NK_FLAG_UNKNOWN2)
197
198/* HBIN block */
199typedef struct _regfi_hbin
200{
201  uint32 file_off;       /* my offset in the registry file */
202  uint32 ref_count;      /* how many active records are pointing to this
203                          * block (not used currently)
204                          */
205 
206  uint32 first_hbin_off; /* offset from first hbin block */
207  uint32 block_size;     /* block size of this block
208                          * Should be a multiple of 4096 (0x1000)
209                          */
210  uint32 next_block;     /* relative offset to next block. 
211                          * NOTE: This value may be unreliable!
212                          */
213
214  uint8 magic[REGFI_HBIN_MAGIC_SIZE]; /* "hbin" */
215} REGFI_HBIN;
216
217
218/* Subkey List -- list of key offsets and hashed names for consistency */
219typedef struct 
220{
221  /* Virtual offset of NK record or additional subkey list,
222   * depending on this list's type.
223   */
224  uint32 offset;
225
226  uint32 hash;
227} REGFI_SUBKEY_LIST_ELEM;
228
229
230typedef struct _regfi_subkey_list
231{
232  /* Real offset of this record's cell in the file */
233  uint32 offset;
234
235  uint32 cell_size;
236 
237  /* Number of immediate children */
238  uint32 num_children; 
239
240  /* Total number of keys referenced by this list and it's children */
241  uint32 num_keys;     
242
243  REGFI_SUBKEY_LIST_ELEM* elements;
244  uint8 magic[REGFI_CELL_MAGIC_SIZE];
245
246  /* Set if the magic indicates this subkey list points to child subkey lists */
247  bool recursive_type; 
248} REGFI_SUBKEY_LIST;
249
250
251typedef uint32 REGFI_VALUE_LIST_ELEM;
252typedef struct _regfi_value_list
253{
254  /* Actual number of values referenced by this list. 
255   * May differ from parent key's num_values if there were parsing errors.
256   */
257  uint32 num_values;
258
259  REGFI_VALUE_LIST_ELEM* elements;
260} REGFI_VALUE_LIST;
261
262
263typedef struct _regfi_classname
264{
265  /* As converted to requested character encoding. */
266  char* interpreted;
267
268  /* Represents raw buffer read from classname cell. */
269  uint8* raw;
270
271  /* Length of the raw data. May be shorter than that indicated by parent key.*/
272  uint16 size;
273} REGFI_CLASSNAME;
274
275
276typedef struct _regfi_data
277{
278  uint32 type;
279
280  /* Length of the raw data. */
281  uint32 size;
282
283  /* This is always present, representing the raw data cell contents. */
284  uint8* raw;
285
286  /* Represents the length of the interpreted value. Meaning is type-specific.*/
287  uint32 interpreted_size;
288
289  /* These items represent interpreted versions of the raw attribute above.
290   * Only use the appropriate member according to the type field. 
291   * In the event of an unknown type, use only the raw field.
292   */
293  union _regfi_data_interpreted
294  {
295    uint8* none; /* */
296    uint8* string;
297    uint8* expand_string;
298    uint8* binary; /* */
299    uint32 dword;
300    uint32 dword_be;
301    uint8* link;
302    uint8** multiple_string;
303    uint64 qword;
304
305    /* The following are treated as binary currently, but this may change in
306     * the future as the formats become better understood.
307     */
308    uint8* resource_list;
309    uint8* full_resource_descriptor;
310    uint8* resource_requirements_list;
311  } interpreted;
312} REGFI_DATA;
313
314
315/* Value record */
316typedef struct 
317{
318  uint32 offset;        /* Real offset of this record's cell in the file */
319  uint32 cell_size;     /* ((start_offset - end_offset) & 0xfffffff8) */
320
321  REGFI_DATA* data;     /* XXX: deprecated */
322
323  char*  valuename;
324  uint8* valuename_raw;
325  uint16 name_length;
326  uint32 hbin_off;      /* offset from beginning of this hbin block */
327 
328  uint32 data_size;     /* As reported in the VK record.  May be different than
329                         * That obtained while parsing the data cell itself. */
330  uint32 data_off;      /* Offset of data cell (virtual) */
331  uint32 type;
332  uint8  magic[REGFI_CELL_MAGIC_SIZE];
333  uint16 flag;
334  uint16 unknown1;
335  bool data_in_offset;
336} REGFI_VK_REC;
337
338
339/* Key Security */
340struct _regfi_sk_rec;
341
342typedef struct _regfi_sk_rec
343{
344  uint32 offset;        /* Real file offset of this record */
345  uint32 cell_size;     /* ((start_offset - end_offset) & 0xfffffff8) */
346
347  WINSEC_DESC* sec_desc;
348  uint32 hbin_off;      /* offset from beginning of this hbin block */
349 
350  uint32 prev_sk_off;
351  uint32 next_sk_off;
352  uint32 ref_count;
353  uint32 desc_size;     /* size of security descriptor */
354  uint16 unknown_tag;
355  uint8  magic[REGFI_CELL_MAGIC_SIZE];
356} REGFI_SK_REC;
357
358
359/* Key Name */
360typedef struct
361{
362  uint32 offset;        /* Real offset of this record's cell in the file */
363  uint32 cell_size;     /* Actual or estimated length of the cell. 
364                         * Always in multiples of 8.
365                         */
366
367  /* link in the other records here */
368  REGFI_VALUE_LIST* values;
369  REGFI_SUBKEY_LIST* subkeys;
370 
371  /* header information */
372  uint16 flags;
373  uint8  magic[REGFI_CELL_MAGIC_SIZE];
374  NTTIME mtime;
375  uint16 name_length;
376  uint16 classname_length;
377  char* keyname;
378  uint8* keyname_raw;
379  uint32 parent_off;                /* pointer to parent key */
380  uint32 classname_off;
381 
382  /* max lengths */
383  uint32 max_bytes_subkeyname;      /* max subkey name * 2 */
384  uint32 max_bytes_subkeyclassname; /* max subkey classname length (as if) */
385  uint32 max_bytes_valuename;       /* max valuename * 2 */
386  uint32 max_bytes_value;           /* max value data size */
387 
388  /* unknowns */
389  uint32 unknown1;
390  uint32 unknown2;
391  uint32 unknown3;
392  uint32 unk_index;                 /* nigel says run time index ? */
393 
394  /* children */
395  uint32 num_subkeys;
396  uint32 subkeys_off;   /* offset of subkey list that points to NK records */
397  uint32 num_values;
398  uint32 values_off;    /* value lists which point to VK records */
399  uint32 sk_off;        /* offset to SK record */
400} REGFI_NK_REC;
401
402
403
404/* REGF block */
405typedef struct 
406{
407  /* Run-time information */
408  /************************/
409  /* file descriptor */
410  int fd;
411
412  /* For sanity checking (not part of the registry header) */
413  uint32 file_length;
414
415  /* Metadata about hbins */
416  range_list* hbins;
417
418  /* SK record cached since they're repeatedly reused */
419  lru_cache* sk_cache;
420
421  /* Error/warning/info messages returned by lower layer functions */
422  char* last_message;
423
424  /* Mask for error message types that will be stored. */
425  uint16 msg_mask;
426
427
428  /* Data parsed from file header */
429  /********************************/
430  uint8  magic[REGFI_REGF_MAGIC_SIZE];/* "regf" */
431
432 /* These sequence numbers should match if
433  * the hive was properly synced to disk.
434  */
435  uint32 sequence1;           
436  uint32 sequence2;
437
438  NTTIME mtime;
439  uint32 major_version;  /* Set to 1 in all known hives */
440  uint32 minor_version;  /* Set to 3 or 5 in all known hives */
441  uint32 type;           /* XXX: Unverified.  Set to 0 in all known hives */
442  uint32 format;         /* XXX: Unverified.  Set to 1 in all known hives */
443
444  uint32 root_cell;  /* Offset to root cell in the first (or any?) hbin block */
445  uint32 last_block; /* Offset to last hbin block in file */
446
447  uint32 cluster;    /* XXX: Unverified. Set to 1 in all known hives */
448
449  /* Matches hive's base file name. Stored in UTF-16LE */
450  uint8 file_name[REGFI_REGF_NAME_SIZE];
451
452  WINSEC_UUID* rm_id;       /* XXX: Unverified. */
453  WINSEC_UUID* log_id;      /* XXX: Unverified. */
454  WINSEC_UUID* tm_id;       /* XXX: Unverified. */
455  uint32 flags;             /* XXX: Unverified. */
456  uint32 guid_signature;    /* XXX: Unverified. */
457
458  uint32 checksum;          /* Stored checksum from file */
459  uint32 computed_checksum; /* Our own calculation of the checksum.
460                             * (XOR of bytes 0x0000 - 0x01FB) */
461
462  WINSEC_UUID* thaw_tm_id;  /* XXX: Unverified. */
463  WINSEC_UUID* thaw_rm_id;  /* XXX: Unverified. */
464  WINSEC_UUID* thaw_log_id; /* XXX: Unverified. */
465  uint32 boot_type;         /* XXX: Unverified. */
466  uint32 boot_recover;      /* XXX: Unverified. */
467
468  /* This seems to include random junk.  Possibly unsanitized memory left over
469   * from when header block was written.  For instance, chunks of nk records
470   * can be found, though often it's all 0s. */
471  uint8 reserved1[REGFI_REGF_RESERVED1_SIZE];
472
473  /* This is likely reserved and unusued currently.  (Should be all 0s.)
474   * Included here for easier access in looking for hidden data
475   * or doing research. */
476  uint8 reserved2[REGFI_REGF_RESERVED2_SIZE];
477
478} REGFI_FILE;
479
480
481/* XXX: Should move all caching (SK records, HBINs, NKs, etc) to a single
482 *      structure, probably REGFI_FILE.  Once key caching is in place,
483 *      convert key_positions stack to store just key offsets rather than
484 *      whole keys.
485 */
486typedef struct _regfi_iterator
487{
488  REGFI_FILE* f;
489  void_stack* key_positions;
490  REGFI_NK_REC* cur_key;
491  REGFI_ENCODING string_encoding;
492  uint32 cur_subkey;
493  uint32 cur_value;
494} REGFI_ITERATOR;
495
496
497typedef struct _regfi_iter_position
498{
499  REGFI_NK_REC* nk;
500  uint32 cur_subkey;
501  /* We could store a cur_value here as well, but didn't see
502   * the use in it right now.
503   */
504} REGFI_ITER_POSITION;
505
506
507typedef struct _regfi_buffer
508{
509  uint8* buf;
510  uint32_t len;
511} REGFI_BUFFER;
512
513
514
515
516/******************************************************************************/
517/*                         Main iterator API                                  */
518/******************************************************************************/
519REGFI_FILE*           regfi_open(const char* filename);
520int                   regfi_close(REGFI_FILE* r);
521
522/* regfi_get_messages: Get errors, warnings, and/or verbose information
523 *                     relating to processing of the given registry file.
524 *
525 * Arguments:
526 *   file     -- the structure for the registry file
527 *
528 * Returns:
529 *   A newly allocated char* which must be free()d by the caller.
530 */
531char*                 regfi_get_messages(REGFI_FILE* file);
532
533void                  regfi_set_message_mask(REGFI_FILE* file, uint16 mask);
534
535
536/* regfi_iterator_new: Creates a new iterator for the provided registry file.
537 *
538 * Arguments:
539 *   file            -- The opened registry file the iterator should be
540 *                      created for.
541 *   output_encoding -- Character encoding that strings should be returned in.
542 *                      Only supply the REGFI_ENCODING_* constants, as others
543 *                      will be rejected.
544 *                      The following values are currently accepted:
545 *                      REGFI_ENCODING_DEFAULT (currently REGFI_ENCODING_ASCII)
546 *                      REGFI_ENCODING_ASCII
547 *                      REGFI_ENCODING_UTF8
548 *
549 *                      XXX: This encoding only applies to specific data
550 *                           strings currently, but should apply to key
551 *                           names and value names in the future.
552 *
553 * Returns:
554 *   A newly allocated REGFI_ITERATOR. Must be free()d with regfi_iterator_free.
555 */
556REGFI_ITERATOR*       regfi_iterator_new(REGFI_FILE* file,
557                                         REGFI_ENCODING output_encoding);
558void                  regfi_iterator_free(REGFI_ITERATOR* i);
559bool                  regfi_iterator_down(REGFI_ITERATOR* i);
560bool                  regfi_iterator_up(REGFI_ITERATOR* i);
561bool                  regfi_iterator_to_root(REGFI_ITERATOR* i);
562
563bool                  regfi_iterator_walk_path(REGFI_ITERATOR* i, 
564                                               const char** path);
565const REGFI_NK_REC*   regfi_iterator_cur_key(REGFI_ITERATOR* i);
566const REGFI_SK_REC*   regfi_iterator_cur_sk(REGFI_ITERATOR* i);
567
568REGFI_NK_REC*         regfi_iterator_first_subkey(REGFI_ITERATOR* i);
569REGFI_NK_REC*         regfi_iterator_cur_subkey(REGFI_ITERATOR* i);
570REGFI_NK_REC*         regfi_iterator_next_subkey(REGFI_ITERATOR* i);
571bool                  regfi_iterator_find_subkey(REGFI_ITERATOR* i, 
572                                                 const char* subkey_name);
573
574REGFI_VK_REC*         regfi_iterator_first_value(REGFI_ITERATOR* i);
575REGFI_VK_REC*         regfi_iterator_cur_value(REGFI_ITERATOR* i);
576REGFI_VK_REC*         regfi_iterator_next_value(REGFI_ITERATOR* i);
577bool                  regfi_iterator_find_value(REGFI_ITERATOR* i, 
578                                                const char* value_name);
579
580REGFI_CLASSNAME*      regfi_iterator_fetch_classname(REGFI_ITERATOR* i, 
581                                                     const REGFI_NK_REC* key);
582REGFI_DATA*           regfi_iterator_fetch_data(REGFI_ITERATOR* i, 
583                                                const REGFI_VK_REC* value);
584
585
586/********************************************************/
587/* Middle-layer structure loading, linking, and caching */
588/********************************************************/
589REGFI_NK_REC*         regfi_load_key(REGFI_FILE* file, uint32 offset, 
590                                     REGFI_ENCODING output_encoding, 
591                                     bool strict);
592REGFI_VK_REC*         regfi_load_value(REGFI_FILE* file, uint32 offset, 
593                                       bool strict);
594REGFI_SUBKEY_LIST*    regfi_load_subkeylist(REGFI_FILE* file, uint32 offset,
595                                            uint32 num_keys, uint32 max_size,
596                                            bool strict);
597REGFI_VALUE_LIST*     regfi_load_valuelist(REGFI_FILE* file, uint32 offset, 
598                                           uint32 num_values, uint32 max_size,
599                                           bool strict);
600
601REGFI_BUFFER          regfi_load_data(REGFI_FILE* file, uint32 voffset,
602                                      uint32 length, bool data_in_offset,
603                                      bool strict);
604
605REGFI_BUFFER          regfi_load_big_data(REGFI_FILE* file, uint32 offset, 
606                                          uint32 data_length,uint32 cell_length,
607                                          range_list* used_ranges,
608                                          bool strict);
609bool                  regfi_interpret_data(REGFI_FILE* file, 
610                                           REGFI_ENCODING string_encoding,
611                                           uint32 type, REGFI_DATA* data);
612void                  regfi_free_classname(REGFI_CLASSNAME* classname);
613void                  regfi_free_data(REGFI_DATA* data);
614
615
616/* These are cached so return values don't need to be freed. */
617const REGFI_SK_REC*   regfi_load_sk(REGFI_FILE* file, uint32 offset,
618                                    bool strict);
619const REGFI_HBIN*     regfi_lookup_hbin(REGFI_FILE* file, uint32 offset);
620
621
622/************************************/
623/*  Low-layer data structure access */
624/************************************/
625REGFI_FILE*           regfi_parse_regf(int fd, bool strict);
626REGFI_HBIN*           regfi_parse_hbin(REGFI_FILE* file, uint32 offset, 
627                                       bool strict);
628
629
630/* regfi_parse_nk: Parses an NK record.
631 *
632 * Arguments:
633 *   f        -- the registry file structure
634 *   offset   -- the offset of the cell (not the record) to be parsed.
635 *   max_size -- the maximum size the NK cell could be. (for validation)
636 *   strict   -- if true, rejects any malformed records.  Otherwise,
637 *               tries to minimally validate integrity.
638 * Returns:
639 *   A newly allocated NK record structure, or NULL on failure.
640 */
641REGFI_NK_REC*         regfi_parse_nk(REGFI_FILE* file, uint32 offset,
642                                     uint32 max_size, bool strict);
643
644REGFI_SUBKEY_LIST*    regfi_parse_subkeylist(REGFI_FILE* file, uint32 offset,
645                                             uint32 max_size, bool strict);
646
647REGFI_VK_REC*         regfi_parse_vk(REGFI_FILE* file, uint32 offset, 
648                                     uint32 max_size, bool strict);
649
650REGFI_SK_REC*         regfi_parse_sk(REGFI_FILE* file, uint32 offset, 
651                                     uint32 max_size, bool strict);
652
653range_list*           regfi_parse_unalloc_cells(REGFI_FILE* file);
654
655bool                  regfi_parse_cell(int fd, uint32 offset, 
656                                       uint8* hdr, uint32 hdr_len,
657                                       uint32* cell_length, bool* unalloc);
658
659uint8*                regfi_parse_classname(REGFI_FILE* file, uint32 offset,
660                                            uint16* name_length, 
661                                            uint32 max_size, bool strict);
662
663REGFI_BUFFER          regfi_parse_data(REGFI_FILE* file, uint32 offset,
664                                       uint32 length, bool strict);
665
666REGFI_BUFFER          regfi_parse_little_data(REGFI_FILE* file, uint32 voffset, 
667                                              uint32 length, bool strict);
668
669
670/* Dispose of previously parsed records */
671void                  regfi_free_key(REGFI_NK_REC* nk);
672void                  regfi_free_value(REGFI_VK_REC* vk);
673
674
675
676/************************************/
677/*    Private Functions             */
678/************************************/
679REGFI_NK_REC*         regfi_rootkey(REGFI_FILE* file, 
680                                    REGFI_ENCODING output_encoding);
681void                  regfi_subkeylist_free(REGFI_SUBKEY_LIST* list);
682uint32                regfi_read(int fd, uint8* buf, uint32* length);
683
684const char*           regfi_type_val2str(unsigned int val);
685int                   regfi_type_str2val(const char* str);
686
687char*                 regfi_get_sacl(WINSEC_DESC* sec_desc);
688char*                 regfi_get_dacl(WINSEC_DESC* sec_desc);
689char*                 regfi_get_owner(WINSEC_DESC* sec_desc);
690char*                 regfi_get_group(WINSEC_DESC* sec_desc);
691
692REGFI_SUBKEY_LIST*    regfi_merge_subkeylists(uint16 num_lists, 
693                                              REGFI_SUBKEY_LIST** lists,
694                                              bool strict);
695REGFI_SUBKEY_LIST*    regfi_load_subkeylist_aux(REGFI_FILE* file, uint32 offset,
696                                                uint32 max_size, bool strict,
697                                                uint8 depth_left);
698void                  regfi_add_message(REGFI_FILE* file, uint16 msg_type, 
699                                        const char* fmt, ...);
700REGFI_NK_REC*         regfi_copy_nk(const REGFI_NK_REC* nk);
701REGFI_VK_REC*         regfi_copy_vk(const REGFI_VK_REC* vk);
702int32                 regfi_calc_maxsize(REGFI_FILE* file, uint32 offset);
703int32                 regfi_conv_charset(const char* input_charset, 
704                                         const char* output_charset,
705                                         uint8* input, char* output, 
706                                         uint32 input_len, uint32 output_max);
707REGFI_DATA*           regfi_buffer_to_data(REGFI_BUFFER raw_data);
708
709#endif  /* _REGFI_H */
Note: See TracBrowser for help on using the repository browser.