source: trunk/include/regfi.h @ 182

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

redesigned regfi logging API to utilize thread-local storage

  • Property svn:keywords set to Id
File size: 42.3 KB
Line 
1/*
2 * Copyright (C) 2005-2010 Timothy D. Morgan
3 * Copyright (C) 2005 Gerald (Jerry) Carter
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 * $Id: regfi.h 182 2010-03-17 06:41:17Z tim $
19 */
20
21/**
22 * @file
23 * Windows NT (and later) read-only registry library
24 *
25 * This library is intended for use in digital forensics investigations, but
26 * is likely useful in other applications.
27 *
28 * Branched from Samba project Subversion repository, version #6903:
29 *   http://viewcvs.samba.org/cgi-bin/viewcvs.cgi/trunk/source/include/regfio.h?rev=6903&view=auto
30 *
31 * Since then, it has been heavily rewritten, simplified, and improved.
32 */
33
34/**
35 * @mainpage Home
36 *
37 * The regfi library is a read-only NT registry library which serves as the main
38 * engine behind the reglookup tool.  It is designed with digital forensic
39 * analysis in mind, but it should also be useful in other tools which need to
40 * efficiently traverse and query registry data structures.
41 *
42 * The library is broken down into four main parts, the
43 * @ref regfiBase "Base Layer", which any code dependent on the library will
44 * likely need to rely on, as well as three main functional layers:
45 * @li @ref regfiIteratorLayer
46 * @li @ref regfiGlueLayer
47 * @li @ref regfiParseLayer
48 *
49 * Most users will find that a combination of the Base Layer and the Iterator Layer
50 * will be sufficient for accessing registry hive files.  Those who are wiling
51 * to dive deep into registry data structures, for instance to recover deleted
52 * data structures or to research Windows registry behavior in detail, will
53 * find the Parse Layer to be quite useful.
54 */
55
56
57#ifndef _REGFI_H
58#define _REGFI_H
59
60#include <stdlib.h>
61#include <stdio.h>
62#include <stdbool.h>
63#include <string.h>
64#include <errno.h>
65#include <time.h>
66#include <fcntl.h>
67#include <sys/stat.h>
68#include <sys/types.h>
69#include <unistd.h>
70#include <iconv.h>
71#include <pthread.h>
72
73#include "byteorder.h"
74#include "talloc.h"
75#include "winsec.h"
76#include "void_stack.h"
77#include "range_list.h"
78#include "lru_cache.h"
79
80/******************************************************************************/
81
82/* regfi library error message types */
83#define REGFI_LOG_INFO  0x0001
84#define REGFI_LOG_WARN  0x0004
85#define REGFI_LOG_ERROR 0x0010
86
87/* For internal use */
88pthread_key_t REGFI_LOG_KEY;
89
90typedef uint8_t REGFI_ENCODING;
91/* regfi library supported character encodings */
92#define REGFI_ENCODING_ASCII   0
93#define REGFI_ENCODING_UTF8    1
94#define REGFI_ENCODING_DEFAULT REGFI_ENCODING_ASCII
95/* UTF16LE is not supported for output */
96#define REGFI_ENCODING_UTF16LE 2
97
98#define REGFI_NUM_ENCODINGS    3
99
100/* Registry data types */
101#define REG_NONE                       0
102#define REG_SZ                         1
103#define REG_EXPAND_SZ                  2
104#define REG_BINARY                     3
105#define REG_DWORD                      4
106#define REG_DWORD_LE                   4  /* DWORD, little endian */
107#define REG_DWORD_BE                   5  /* DWORD, big endian */
108#define REG_LINK                       6
109#define REG_MULTI_SZ                   7
110#define REG_RESOURCE_LIST              8
111#define REG_FULL_RESOURCE_DESCRIPTOR   9
112#define REG_RESOURCE_REQUIREMENTS_LIST 10
113#define REG_QWORD                      11 /* 64-bit little endian */
114/* XXX: Has MS defined a REG_QWORD_BE? */
115/* Not a real type in the registry */
116#define REG_KEY                    0x7FFFFFFF
117
118#define REGFI_OFFSET_NONE          0xffffffff
119
120
121/* This maximum depth is described here:
122 * http://msdn.microsoft.com/en-us/library/ms724872%28VS.85%29.aspx
123 */
124#define REGFI_MAX_DEPTH            512
125
126/* This limit defines the maximum number of levels deep that ri subkey list
127 * trees can go.
128 */
129/* XXX: This is totally arbitrary right now.
130 *      The actual limit may need to be discovered by experimentation.
131 */
132#define REGFI_MAX_SUBKEY_DEPTH     255
133
134
135/* Header sizes and magic number lengths for various records */
136#define REGFI_HBIN_ALLOC           0x1000 /* Minimum allocation unit for HBINs */
137#define REGFI_REGF_SIZE            0x1000 /* "regf" header block size */
138#define REGFI_REGF_MAGIC_SIZE      4
139#define REGFI_REGF_NAME_SIZE       64
140#define REGFI_REGF_RESERVED1_SIZE  340
141#define REGFI_REGF_RESERVED2_SIZE  3528
142#define REGFI_HBIN_MAGIC_SIZE      4
143#define REGFI_CELL_MAGIC_SIZE      2
144#define REGFI_HBIN_HEADER_SIZE     0x20
145#define REGFI_NK_MIN_LENGTH        0x4C
146#define REGFI_VK_MIN_LENGTH        0x14
147#define REGFI_SK_MIN_LENGTH        0x14
148#define REGFI_SUBKEY_LIST_MIN_LEN  0x4
149#define REGFI_BIG_DATA_MIN_LENGTH  0xC
150
151
152/* Constants used for validation */
153/* XXX: Can we add clock resolution validation as well as range?  It has
154 *      been reported that Windows timestamps are never more than a
155 *      certain granularity (250ms?), which could be used to help
156 *      eliminate false positives.  Would need to verify this and
157 *      perhaps conservatively implement a check.
158 */
159 /* Minimum time is Jan 1, 1990 00:00:00 */
160#define REGFI_MTIME_MIN_HIGH       0x01B41E6D
161
162 /* Maximum time is Jan 1, 2290 00:00:00
163  * (We hope no one is using Windows by then...)
164  */
165#define REGFI_MTIME_MAX_HIGH       0x03047543
166
167
168/* Flags for the vk records */
169#define REGFI_VK_FLAG_ASCIINAME    0x0001
170#define REGFI_VK_DATA_IN_OFFSET    0x80000000
171#define REGFI_VK_MAX_DATA_LENGTH   1024*1024  /* XXX: This is arbitrary */
172
173
174/* Known key flags */
175/*******************/
176/* These next two show up on normal-seeming keys in Vista and W2K3 registries */
177#define REGFI_NK_FLAG_UNKNOWN1     0x4000
178#define REGFI_NK_FLAG_UNKNOWN2     0x1000
179
180/* This next one shows up in some Vista "software" registries */
181/* XXX: This shows up in the following two SOFTWARE keys in Vista:
182 *   /Wow6432Node/Microsoft
183 *   /Wow6432Node/Microsoft/Cryptography
184 * 
185 * It comes along with UNKNOWN2 and ASCIINAME for a total flags value of 0x10A0
186 */
187#define REGFI_NK_FLAG_UNKNOWN3     0x0080
188
189/* Predefined handle.  Rumor has it that the valuelist count for this key is
190 * where the handle is stored.
191 * http://msdn.microsoft.com/en-us/library/ms724836(VS.85).aspx
192 */
193#define REGFI_NK_FLAG_PREDEF_KEY   0x0040
194
195/* The name will be in ASCII if this next bit is set, otherwise UTF-16LE */
196#define REGFI_NK_FLAG_ASCIINAME    0x0020
197
198/* Symlink key. 
199 * See: http://www.codeproject.com/KB/system/regsymlink.aspx
200 */
201#define REGFI_NK_FLAG_LINK         0x0010
202
203/* This key cannot be deleted */
204#define REGFI_NK_FLAG_NO_RM        0x0008
205
206/* Root of a hive */
207#define REGFI_NK_FLAG_ROOT         0x0004
208
209/* Mount point of another hive.  NULL/(default) value indicates which hive
210 * and where in the hive it points to.
211 */
212#define REGFI_NK_FLAG_HIVE_LINK    0x0002
213
214/* These keys shouldn't be stored on disk, according to:
215 * http://geekswithblogs.net/sdorman/archive/2007/12/24/volatile-registry-keys.aspx
216 */
217#define REGFI_NK_FLAG_VOLATILE     0x0001
218
219/* Useful for identifying unknown flag types */
220#define REGFI_NK_KNOWN_FLAGS       (REGFI_NK_FLAG_PREDEF_KEY\
221                                    | REGFI_NK_FLAG_ASCIINAME\
222                                    | REGFI_NK_FLAG_LINK\
223                                    | REGFI_NK_FLAG_NO_RM\
224                                    | REGFI_NK_FLAG_ROOT\
225                                    | REGFI_NK_FLAG_HIVE_LINK\
226                                    | REGFI_NK_FLAG_VOLATILE\
227                                    | REGFI_NK_FLAG_UNKNOWN1\
228                                    | REGFI_NK_FLAG_UNKNOWN2\
229                                    | REGFI_NK_FLAG_UNKNOWN3)
230
231
232#define CHAR_BIT 8
233#define TIME_T_MIN ((time_t)0 < (time_t) -1 ? (time_t) 0 \
234                    : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))
235#define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN)
236#define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
237
238typedef struct _regfi_nttime
239{
240  uint32_t low;
241  uint32_t high;
242} REGFI_NTTIME;
243
244
245typedef struct _regfi_log
246{
247  /* Error/warning/info messages returned by lower layer functions */
248  char* messages;
249
250  /* Mask for error message types that will be stored. */
251  uint16_t msg_mask;
252
253} REGFI_LOG;
254
255
256/** HBIN block information
257 * @ingroup regfiMiddleLayer
258 */
259typedef struct _regfi_hbin
260{
261  /** Offset of this HBIN in the registry file */
262  uint32_t file_off;
263
264  /** Number of active records pointing to this block (not used currently) */
265  uint32_t ref_count;
266
267  /** Offset from first hbin block */
268  uint32_t first_hbin_off;
269
270  /** Block size of this block Should be a multiple of 4096 (0x1000) */
271  uint32_t block_size;
272
273  /** Relative offset to next block. 
274   *
275   * @note This value may be unreliable!
276   */
277  uint32_t next_block;
278
279  /** Magic number for the HBIN (should be "hbin"). */
280  uint8_t magic[REGFI_HBIN_MAGIC_SIZE];
281} REGFI_HBIN;
282
283
284/* Subkey List -- list of key offsets and hashed names for consistency */
285typedef struct 
286{
287  /* Virtual offset of NK record or additional subkey list,
288   * depending on this list's type.
289   */
290  uint32_t offset;
291
292  uint32_t hash;
293} REGFI_SUBKEY_LIST_ELEM;
294
295
296/** Subkey-list structure
297 * @ingroup regfiMiddleLayer
298 */
299typedef struct _regfi_subkey_list
300{
301  /* Real offset of this record's cell in the file */
302  uint32_t offset;
303
304  uint32_t cell_size;
305 
306  /* Number of immediate children */
307  uint32_t num_children; 
308
309  /* Total number of keys referenced by this list and it's children */
310  uint32_t num_keys;     
311
312  REGFI_SUBKEY_LIST_ELEM* elements;
313  uint8_t magic[REGFI_CELL_MAGIC_SIZE];
314
315  /* Set if the magic indicates this subkey list points to child subkey lists */
316  bool recursive_type; 
317} REGFI_SUBKEY_LIST;
318
319
320typedef uint32_t REGFI_VALUE_LIST_ELEM;
321/** Value-list structure
322 * @ingroup regfiMiddleLayer
323 */
324typedef struct _regfi_value_list
325{
326  /* Actual number of values referenced by this list. 
327   * May differ from parent key's num_values if there were parsing errors.
328   */
329  uint32_t num_values;
330
331  REGFI_VALUE_LIST_ELEM* elements;
332} REGFI_VALUE_LIST;
333
334
335/** Class name structure (used in storing SysKeys)
336 * @ingroup regfiBase
337 */
338typedef struct _regfi_classname
339{
340  /** As converted to requested REGFI_ENCODING */
341  char* interpreted;
342
343  /** Represents raw buffer read from classname cell.
344   *
345   * Length of this item is specified in the size field.
346   */
347  uint8_t* raw;
348
349  /** Length of the raw data.
350   *
351   * May be shorter than that indicated by parent key.
352   */
353  uint16_t size;
354} REGFI_CLASSNAME;
355
356
357/** Data record structure
358 * @ingroup regfiBase
359 */
360typedef struct _regfi_data
361{
362  /** Data type of this data, as indicated by the referencing VK record. */
363  uint32_t type;
364
365  /** Length of the raw data. */
366  uint32_t size;
367
368  /** This is always present, representing the raw data cell contents. */
369  uint8_t* raw;
370
371  /** Represents the length of the interpreted value. Meaning is type-specific. */
372  uint32_t interpreted_size;
373
374  /** These items represent interpreted versions of the REGFI_DATA::raw field.
375   *
376   * Only use the appropriate member according to the REGFI_DATA::type field.
377   * In the event of an unknown type, use only the REGFI_DATA::raw field.
378   */
379  union _regfi_data_interpreted
380  {
381    /** REG_NONE
382     *
383     * Stored as a raw buffer.  Use REGFI_DATA::interpreted_size to determine
384     * length.
385     */
386    uint8_t* none; 
387
388    /** REG_SZ
389     *
390     * Stored as a NUL terminated string.  Converted to the specified
391     * REGFI_ENCODING.
392     */
393    uint8_t* string;
394
395    /** REG_EXPAND_SZ
396     *
397     * Stored as a NUL terminated string.  Converted to the specified
398     * REGFI_ENCODING.
399     */
400    uint8_t* expand_string;
401
402    /** REG_BINARY
403     *
404     * Stored as a raw buffer.  Use REGFI_DATA::interpreted_size to determine
405     * length.
406     */
407    uint8_t* binary;
408
409    /** REG_DWORD */
410    uint32_t dword;
411
412    /** REG_DWORD_BE */
413    uint32_t dword_be;
414
415    /** REG_LINK
416     *
417     * Stored as a NUL terminated string.  Converted to the specified
418     * REGFI_ENCODING.
419     */
420    uint8_t* link;
421
422    /** REG_MULTI_SZ
423     *
424     * Stored as a list of uint8_t* pointers, terminated with a NULL pointer.
425     * Each string element in the list is NUL terminated, and the character set
426     * is determined by the specified REGFI_ENCODING.
427     */
428    uint8_t** multiple_string;
429
430    /** REG_QWORD */
431    uint64_t qword;
432
433    /* The following are treated as binary currently, but this may change in
434     * the future as the formats become better understood.
435     */
436
437    /** REG_RESOURCE_LIST
438     *
439     * Stored as a raw buffer.  Use REGFI_DATA::interpreted_size to determine
440     * length.
441     */
442    uint8_t* resource_list;
443
444    /** REG_FULL_RESOURCE_DESCRIPTOR
445     *
446     * Stored as a raw buffer.  Use REGFI_DATA::interpreted_size to determine
447     * length.
448     */
449    uint8_t* full_resource_descriptor;
450
451    /** REG_RESOURCE_REQUIREMENTS_LIST
452     *
453     * Stored as a raw buffer.  Use REGFI_DATA::interpreted_size to determine
454     * length.
455     */
456    uint8_t* resource_requirements_list;
457  } interpreted;
458} REGFI_DATA;
459
460
461/** Value structure
462 * @ingroup regfiBase
463 */
464typedef struct
465{
466  /** Real offset of this record's cell in the file */
467  uint32_t offset;     
468
469  /** ((start_offset - end_offset) & 0xfffffff8) */
470  uint32_t cell_size;
471
472  /* XXX: deprecated */
473  REGFI_DATA* data;
474
475  /** The name of this value converted to desired REGFI_ENCODING. 
476   *
477   * This conversion typically occurs automatically through REGFI_ITERATOR
478   * settings.  String is NUL terminated.
479   */
480  char*    valuename;
481
482  /** The raw value name
483   *
484   * Length of the buffer is stored in name_length.
485   */
486  uint8_t* valuename_raw;
487
488  /** Length of valuename_raw */
489  uint16_t name_length;
490
491  /** Offset from beginning of this hbin block */
492  uint32_t hbin_off;
493 
494  /** Size of the value's data as reported in the VK record.
495   *
496   * May be different than that obtained while parsing the data cell itself.
497   */
498  uint32_t data_size;
499
500  /** Virtual offset of data cell */
501  uint32_t data_off;
502
503  /** Value's data type */
504  uint32_t type;
505
506  /** VK record's magic number (should be "vk") */
507  uint8_t  magic[REGFI_CELL_MAGIC_SIZE];
508
509  /** VK record flags */
510  uint16_t flags;
511
512  /* XXX: A 2-byte field of unknown purpose stored in the VK record */
513  uint16_t unknown1;
514
515  /** Whether or not the data record is stored in the VK record's data_off field.
516   *
517   * This information is derived from the high bit of the raw data size field.
518   */
519  bool     data_in_offset;
520} REGFI_VK_REC;
521
522
523/* Key Security */
524struct _regfi_sk_rec;
525
526/** Security structure
527 * @ingroup regfiBase
528 */
529typedef struct _regfi_sk_rec
530{
531  /** Real file offset of this record */
532  uint32_t offset;
533
534  /** ((start_offset - end_offset) & 0xfffffff8) */
535  uint32_t cell_size;
536
537  /** The stored Windows security descriptor for this SK record */
538  WINSEC_DESC* sec_desc;
539
540  /** Offset of this record from beginning of this hbin block */
541  uint32_t hbin_off;
542 
543  /** Offset of the previous SK record in the linked list of SK records */
544  uint32_t prev_sk_off;
545
546  /** Offset of the next SK record in the linked list of SK records */
547  uint32_t next_sk_off;
548
549  /** Number of keys referencing this SK record */
550  uint32_t ref_count;
551
552  /** Size of security descriptor (sec_desc) */
553  uint32_t desc_size;
554
555  /* XXX: A 2-byte field of unknown purpose */
556  uint16_t unknown_tag;
557
558  /** The magic number for this record (should be "sk") */
559  uint8_t  magic[REGFI_CELL_MAGIC_SIZE];
560} REGFI_SK_REC;
561
562
563/** Key structure
564 * @ingroup regfiBase
565 */
566typedef struct
567{
568  /** Real offset of this record's cell in the file */
569  uint32_t offset;
570
571  /** Actual or estimated length of the cell. 
572   * Always in multiples of 8.
573   */
574  uint32_t cell_size;
575
576  /** Preloaded value-list for this key.
577   * This element is loaded automatically when using the iterator interface and
578   * possibly some lower layer interfaces.
579   */
580  REGFI_VALUE_LIST* values;
581
582
583  /** Preloaded subkey-list for this key.
584   * This element is loaded automatically when using the iterator interface and
585   * possibly some lower layer interfaces.
586   */
587  REGFI_SUBKEY_LIST* subkeys;
588 
589  /** Key flags */
590  uint16_t flags;
591
592  /** Magic number of key (should be "nk") */
593  uint8_t  magic[REGFI_CELL_MAGIC_SIZE];
594
595  /** Key's last modification time */
596  REGFI_NTTIME mtime;
597
598  /** Length of keyname_raw */
599  uint16_t name_length;
600
601  /** Length of referenced classname */
602  uint16_t classname_length;
603
604  /** The name of this key converted to desired REGFI_ENCODING. 
605   *
606   * This conversion typically occurs automatically through REGFI_ITERATOR
607   * settings.  String is NUL terminated.
608   */
609  char* keyname;
610
611  /** The raw key name
612   *
613   * Length of the buffer is stored in name_length.
614   */
615  uint8_t* keyname_raw;
616
617  /** Virutal offset of parent key */
618  uint32_t parent_off;
619
620  /** Virutal offset of classname key */
621  uint32_t classname_off;
622 
623  /* XXX: max subkey name * 2 */
624  uint32_t max_bytes_subkeyname;
625
626  /* XXX: max subkey classname length (as if) */
627  uint32_t max_bytes_subkeyclassname;
628
629  /* XXX: max valuename * 2 */
630  uint32_t max_bytes_valuename;
631
632  /* XXX: max value data size */
633  uint32_t max_bytes_value;
634 
635  /* XXX: Fields of unknown purpose */
636  uint32_t unknown1;
637  uint32_t unknown2;
638  uint32_t unknown3;
639  uint32_t unk_index;               /* nigel says run time index ? */
640 
641  /** Number of subkeys */
642  uint32_t num_subkeys;
643
644  /** Virtual offset of subkey-list */
645  uint32_t subkeys_off;
646
647  /** Number of values for this key */
648  uint32_t num_values;
649
650  /** Virtual offset of value-list */
651  uint32_t values_off;
652
653  /** Virtual offset of SK record */
654  uint32_t sk_off;
655} REGFI_NK_REC;
656
657
658typedef struct _regfi_raw_file
659{
660  off_t    (* seek)(); /* (REGFI_RAW_FILE* self, off_t offset, int whence) */
661  ssize_t  (* read)(); /* (REGFI_RAW_FILE* self, void* buf, size_t count) */
662
663  uint64_t cur_off;
664  uint64_t size;
665  void*    state;
666} REGFI_RAW_FILE;
667
668
669/** Registry hive file data structure
670 *
671 * This essential structure stores run-time information about a single open
672 * registry hive as well as file header (REGF block) data.  This structure
673 * also stores a list of warnings and error messages generated while parsing
674 * the registry hive.  These can be tuned using @ref regfi_set_message_mask. 
675 * Messages may be retrieved using @ref regfi_get_messages.
676 *
677 * @note If the message mask is set to record any messages, dependent code
678 *       must use @ref regfi_get_messages periodically to clear the message
679 *       queue. Otherwise, this structure will grow in size over time as
680 *       messages queue up.
681 *
682 * @ingroup regfiBase
683 */ 
684typedef struct _regfi_file
685{
686  /* Run-time information */
687  /************************/
688  /* Functions for accessing the file */
689  REGFI_RAW_FILE* cb;
690
691  /* Mutex for all cb access.  This is done to prevent one thread from moving
692   * the file offset while another thread is in the middle of a multi-read
693   * parsing transaction */
694  pthread_mutex_t* cb_lock;
695
696  /* For sanity checking (not part of the registry header) */
697  uint32_t file_length;
698
699  /* Metadata about hbins */
700  range_list* hbins;
701
702  /* Multiple read access allowed, write access is exclusive */
703  pthread_rwlock_t* hbins_lock;
704
705  /* SK record cached since they're repeatedly reused */
706  lru_cache* sk_cache;
707
708  /* Need exclusive access for LRUs, since lookups make changes */
709  pthread_mutex_t* sk_lock;
710
711  /* Data parsed from file header */
712  /********************************/
713  uint8_t  magic[REGFI_REGF_MAGIC_SIZE];/* "regf" */
714
715 /* These sequence numbers should match if
716  * the hive was properly synced to disk.
717  */
718  uint32_t sequence1;           
719  uint32_t sequence2;
720
721  REGFI_NTTIME mtime;
722  uint32_t major_version;  /* Set to 1 in all known hives */
723  uint32_t minor_version;  /* Set to 3 or 5 in all known hives */
724  uint32_t type;           /* XXX: Unverified.  Set to 0 in all known hives */
725  uint32_t format;         /* XXX: Unverified.  Set to 1 in all known hives */
726
727  uint32_t root_cell;  /* Offset to root cell in the first (or any?) hbin block */
728  uint32_t last_block; /* Offset to last hbin block in file */
729
730  uint32_t cluster;    /* XXX: Unverified. Set to 1 in all known hives */
731
732  /* Matches hive's base file name. Stored in UTF-16LE */
733  uint8_t file_name[REGFI_REGF_NAME_SIZE];
734
735  WINSEC_UUID* rm_id;       /* XXX: Unverified. */
736  WINSEC_UUID* log_id;      /* XXX: Unverified. */
737  WINSEC_UUID* tm_id;       /* XXX: Unverified. */
738  uint32_t flags;             /* XXX: Unverified. */
739  uint32_t guid_signature;    /* XXX: Unverified. */
740
741  uint32_t checksum;          /* Stored checksum from file */
742  uint32_t computed_checksum; /* Our own calculation of the checksum.
743                             * (XOR of bytes 0x0000 - 0x01FB) */
744
745  WINSEC_UUID* thaw_tm_id;  /* XXX: Unverified. */
746  WINSEC_UUID* thaw_rm_id;  /* XXX: Unverified. */
747  WINSEC_UUID* thaw_log_id; /* XXX: Unverified. */
748  uint32_t boot_type;         /* XXX: Unverified. */
749  uint32_t boot_recover;      /* XXX: Unverified. */
750
751  /* This seems to include random junk.  Possibly unsanitized memory left over
752   * from when header block was written.  For instance, chunks of nk records
753   * can be found, though often it's all 0s. */
754  uint8_t reserved1[REGFI_REGF_RESERVED1_SIZE];
755
756  /* This is likely reserved and unusued currently.  (Should be all 0s.)
757   * Included here for easier access in looking for hidden data
758   * or doing research. */
759  uint8_t reserved2[REGFI_REGF_RESERVED2_SIZE];
760
761} REGFI_FILE;
762
763
764/** Registry hive iterator
765 * @ingroup regfiIteratorLayer
766 */
767typedef struct _regfi_iterator
768{
769  /** The registry hive this iterator is associated with */
770  REGFI_FILE* f;
771
772  /** All current parent keys and associated iterator positions */
773  void_stack* key_positions;
774
775  /** The current key */
776  REGFI_NK_REC* cur_key;
777
778  /** The encoding that all strings are converted to as set during iterator
779   *  creation.
780   */
781  REGFI_ENCODING string_encoding;
782
783  /** Index of the current subkey */
784  uint32_t cur_subkey;
785
786  /** Index of the current value */
787  uint32_t cur_value;
788} REGFI_ITERATOR;
789
790
791typedef struct _regfi_iter_position
792{
793  REGFI_NK_REC* nk;
794  uint32_t cur_subkey;
795  /* We could store a cur_value here as well, but didn't see
796   * the use in it right now.
797   */
798} REGFI_ITER_POSITION;
799
800
801/** General purpose buffer with stored length
802 * @ingroup regfiBottomLayer
803 */
804typedef struct _regfi_buffer
805{
806  uint8_t* buf;
807  uint32_t len;
808} REGFI_BUFFER;
809
810
811
812/******************************************************************************/
813/**
814 * @defgroup regfiBase Base Layer: Essential Functions and Data Structures
815 *
816 * These functions are either necessary for normal use of the regfi API or just
817 * don't fit particularly well in any of the other layers.
818 */
819/******************************************************************************/
820
821/** Parses file headers of an already open registry hive file and
822 *  allocates related structures for further parsing.
823 *
824 * @param fd A file descriptor of an already open file.  Must be seekable.
825 *
826 * @return A reference to a newly allocated REGFI_FILE structure, if successful;
827 *         NULL on error.
828 *
829 * @ingroup regfiBase
830 */
831REGFI_FILE*           regfi_alloc(int fd);
832
833
834/** Parses file headers returned by supplied callback functions.
835 *
836 * This interface is useful if you have a registry hive in memory
837 * or have some other reason to emulate a real file.
838 *
839 * @param file_cb A structure defining the callback functions needed to access the file.
840 *
841 * @return A reference to a newly allocated REGFI_FILE structure, if successful;
842 *         NULL on error.
843 *
844 * @ingroup regfiBase
845 */
846REGFI_FILE*           regfi_alloc_cb(REGFI_RAW_FILE* file_cb);
847
848
849/** Frees a hive's data structures without closing the underlying file.
850 *
851 * @param file The registry structure to free.
852 *
853 * @ingroup regfiBase
854 */
855void                  regfi_free(REGFI_FILE* file);
856
857
858/** Enables regfi library logging for the current thread.
859 *
860 * XXX: finish documenting
861 *
862 * @ingroup regfiBase
863 */
864void regfi_log_start(uint16_t mask);
865
866
867/** Get errors, warnings, and/or verbose information relating to processing of
868 *  the given registry file.
869 *
870 * @return A newly allocated char* which must be free()d by the caller.
871 *
872 * @ingroup regfiBase
873 */
874char* regfi_log_get_str();
875
876
877/** Set the verbosity level of errors and warnings generated by the library
878 *  (as accessible via regfi_get_messages).
879 *
880 * This may be called at any time and will take effect immediately.
881 *
882 * @param mask   an integer representing the types of messages desired.
883 *               Acceptable values are created through bitwise ORs of
884 *               REGFI_MSG_* values.  For instance, if only errors and
885 *               informational messages were desired (but not warnings),
886 *               then one would specify: REGFI_MSG_ERROR|REGFI_MSG_INFO
887 *               New REGFI_FILE structures are created with:
888 *                REGFI_MSG_ERROR|REGFI_MSG_WARN
889 *               Note that error and warning messages will continue to
890 *               accumulate in memory if they are not fetched using
891 *               regfi_get_messages and then freed by the caller.
892 *               To disable error messages entirely, supply 0, which
893 *               will prevent message accumulation. 
894 *
895 * @ingroup regfiBase
896 */
897void regfi_log_set_mask(uint16_t mask);
898
899
900/** Disables regfi library logging for the current thread.
901 *
902 * XXX: finish documenting
903 *
904 * @ingroup regfiBase
905 */
906void regfi_log_stop();
907
908
909/* Dispose of previously parsed records */
910
911/** Frees a key structure previously returned by one of the API functions
912 *
913 * XXX: finish documenting
914 *
915 * @ingroup regfiBase
916 */
917void                  regfi_free_key(REGFI_NK_REC* nk);
918
919
920/** Frees a value structure previously returned by one of the API functions
921 *
922 * XXX: finish documenting
923 *
924 * @ingroup regfiBase
925 */
926void                  regfi_free_value(REGFI_VK_REC* vk);
927
928
929
930/******************************************************************************/
931/**
932 * @defgroup regfiIteratorLayer Iterator Layer: Primary regfi Library Interface
933 *
934 * This top layer of API functions provides an iterator interface which makes
935 * traversing registry data structures easy in both single-threaded and
936 * multi-threaded scenarios.
937 */
938/******************************************************************************/
939
940/** Creates a new iterator for the provided registry file.
941 *
942 * @param file The opened registry file the iterator should be created for.
943 *
944 * @param output_encoding Character encoding that strings should be returned in.
945 *                        Only supply the REGFI_ENCODING_* constants, as others
946 *                        will be rejected.
947 *                        The following values are currently accepted:
948 *                        REGFI_ENCODING_DEFAULT (currently REGFI_ENCODING_ASCII)
949 *                        REGFI_ENCODING_ASCII
950 *                        REGFI_ENCODING_UTF8
951 *
952 * @return A newly allocated REGFI_ITERATOR.
953 *         Must be free()d with regfi_iterator_free.
954 *
955 * @ingroup regfiIteratorLayer
956 */
957REGFI_ITERATOR*       regfi_iterator_new(REGFI_FILE* file,
958                                         REGFI_ENCODING output_encoding);
959
960
961/** Frees a registry file iterator previously created by regfi_iterator_new.
962 *
963 * This does not affect the underlying registry file's allocation status.
964 *
965 * @param i the iterator to be freed
966 *
967 * @ingroup regfiIteratorLayer
968 */
969void                  regfi_iterator_free(REGFI_ITERATOR* i);
970
971
972/** Traverse deeper into the registry tree at the current subkey.
973 *
974 * @param i the iterator
975 *
976 * @return  true on success, false on failure. 
977 *          Note that subkey and value indexes are preserved.  That is, if a
978 *          regfi_iterator_up call occurs later (reversing the effect of this
979 *          call) then the subkey and value referenced prior to the
980 *          regfi_iterator_down call will still be referenced.  This  makes
981 *          depth-first iteration particularly easy.
982 *
983 * @ingroup regfiIteratorLayer
984 */
985bool                  regfi_iterator_down(REGFI_ITERATOR* i);
986
987
988/** Traverse up to the current key's parent key.
989 *
990 * @param i the iterator
991 *
992 * @return  true on success, false on failure.  Any subkey or value state
993 *          associated with the current key is lost.
994 *
995 * @ingroup regfiIteratorLayer
996 */
997bool                  regfi_iterator_up(REGFI_ITERATOR* i);
998
999
1000/** Traverse up to the root key of the hive.
1001 *
1002 * @param i the iterator
1003 *
1004 * @return true on success, false on failure.
1005 *
1006 * @ingroup regfiIteratorLayer
1007 */
1008bool                  regfi_iterator_to_root(REGFI_ITERATOR* i);
1009
1010
1011/** Traverse down multiple levels in the registry hive.
1012 *
1013 * XXX: This currently only accepts ASCII key names.  Need to look into
1014 *      accepting other encodings.
1015 *
1016 * @param i    the iterator
1017 * @param path a list of key names representing the path.  This list must
1018 *             contain NUL terminated strings.  The list itself is
1019 *             terminated with a NULL pointer.  All path elements must be
1020 *             keys; value names are not accepted (even as the last
1021 *             element).
1022 *
1023 * @return true on success, false on failure.  If any element of path is not
1024 *                 found, false will be returned and the iterator will remain
1025 *                 in its original position.
1026 *
1027 * @ingroup regfiIteratorLayer
1028 */
1029bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path);
1030
1031
1032/** Returns the currently referenced key.
1033 *
1034 * @param i the iterator
1035 *
1036 * @return A read-only key structure for the current key, or NULL on failure.
1037 *
1038 * @ingroup regfiIteratorLayer
1039 */
1040const REGFI_NK_REC*   regfi_iterator_cur_key(REGFI_ITERATOR* i);
1041
1042
1043/** Returns the SK (security) record referenced by the current key.
1044 *
1045 * @param i the iterator
1046 *
1047 * @return A read-only SK structure, or NULL on failure.
1048 *
1049 * @ingroup regfiIteratorLayer
1050 */
1051const REGFI_SK_REC*   regfi_iterator_cur_sk(REGFI_ITERATOR* i);
1052
1053
1054/** Sets the internal subkey index to the first subkey referenced by the current
1055 *  key and returns that key.
1056 *
1057 * @param i the iterator
1058 *
1059 * @return A newly allocated key structure for the newly referenced first
1060 *         subkey, or NULL on failure.  Failure may be due to a lack of any
1061 *         subkeys or other errors.  Newly allocated keys must be freed with
1062 *         regfi_free_key.
1063 *
1064 * @ingroup regfiIteratorLayer
1065 */
1066REGFI_NK_REC*         regfi_iterator_first_subkey(REGFI_ITERATOR* i);
1067
1068
1069/** Returns the currently indexed subkey.
1070 *
1071 * @param i the iterator
1072 *
1073 * @return A newly allocated key structure for the currently referenced subkey,
1074 *         or NULL on failure.  Newly allocated keys must be freed with
1075 *         regfi_free_key.
1076 *
1077 * @ingroup regfiIteratorLayer
1078 */
1079REGFI_NK_REC*         regfi_iterator_cur_subkey(REGFI_ITERATOR* i);
1080
1081
1082/** Increments the internal subkey index to the next key in the subkey-list and
1083 *  returns the subkey for that index.
1084 *
1085 * @param i the iterator
1086 *
1087 * @return A newly allocated key structure for the next subkey or NULL on
1088 *         failure.  Newly allocated keys must be freed with regfi_free_key.
1089 *
1090 * @ingroup regfiIteratorLayer
1091 */
1092REGFI_NK_REC*         regfi_iterator_next_subkey(REGFI_ITERATOR* i);
1093
1094
1095/** Searches for a subkey with a given name under the current key.
1096 *
1097 * @param i           the iterator
1098 * @param subkey_name subkey name to search for
1099 *
1100 * @return True if such a subkey was found, false otherwise.  If a subkey is
1101 *         found, the current subkey index is set to that subkey.  Otherwise,
1102 *         the subkey index remains at the same location as before the call.
1103 *
1104 * @ingroup regfiIteratorLayer
1105 */
1106bool                  regfi_iterator_find_subkey(REGFI_ITERATOR* i, 
1107                                                 const char* subkey_name);
1108
1109/** Sets the internal value index to the first value referenced by the current
1110 *  key and returns that value.
1111 *
1112 * @param i the iterator
1113 *
1114 * @return  A newly allocated value structure for the newly referenced first
1115 *          value, or NULL on failure.  Failure may be due to a lack of any
1116 *          values or other errors.  Newly allocated keys must be freed with
1117 *          regfi_free_value.
1118 *
1119 * @ingroup regfiIteratorLayer
1120 */
1121REGFI_VK_REC*         regfi_iterator_first_value(REGFI_ITERATOR* i);
1122
1123
1124/** Returns the currently indexed value.
1125 *
1126 * @param i the iterator
1127 *
1128 * @return A newly allocated value structure for the currently referenced value,
1129 *         or NULL on failure.  Newly allocated values must be freed with
1130 *         regfi_free_value.
1131 *
1132 * @ingroup regfiIteratorLayer
1133 */
1134REGFI_VK_REC*         regfi_iterator_cur_value(REGFI_ITERATOR* i);
1135
1136
1137/** Increments the internal value index to the next value in the value-list and
1138 *  returns the value for that index.
1139 *
1140 * @param i the iterator
1141 *
1142 * @return  A newly allocated key structure for the next value or NULL on
1143 *          failure.  Newly allocated keys must be freed with regfi_free_value.
1144 *
1145 * @ingroup regfiIteratorLayer
1146 */
1147REGFI_VK_REC*         regfi_iterator_next_value(REGFI_ITERATOR* i);
1148
1149
1150/** Searches for a value with a given name under the current key.
1151 *
1152 * @param i          the iterator
1153 * @param value_name value name to search for
1154 *
1155 * @return True if such a value was found, false otherwise.  If a value is
1156 *         found, the current value index is set to that value.  Otherwise,
1157 *         the value index remains at the same location as before the call.
1158 *
1159 * @ingroup regfiIteratorLayer
1160 */
1161bool                  regfi_iterator_find_value(REGFI_ITERATOR* i, 
1162                                                const char* value_name);
1163
1164/** Retrieves classname for a given key.
1165 *
1166 * @param i   the iterator
1167 * @param key the key whose classname is desired
1168 *
1169 * @return Returns a newly allocated classname structure, or NULL on failure.
1170 *         Classname structures must be freed with regfi_free_classname.
1171 *
1172 * @ingroup regfiIteratorLayer
1173 */
1174REGFI_CLASSNAME*      regfi_iterator_fetch_classname(REGFI_ITERATOR* i, 
1175                                                     const REGFI_NK_REC* key);
1176
1177
1178/** Retrieves data for a given value.
1179 *
1180 * @param i     the iterator
1181 * @param value the value whose data is desired
1182 *
1183 * @return Returns a newly allocated data structure, or NULL on failure.
1184 *         Data structures must be freed with regfi_free_data.
1185 *
1186 * @ingroup regfiIteratorLayer
1187 */
1188REGFI_DATA*           regfi_iterator_fetch_data(REGFI_ITERATOR* i, 
1189                                                const REGFI_VK_REC* value);
1190
1191
1192
1193/******************************************************************************/
1194/**
1195 * @defgroup regfiGlueLayer Glue Layer: Logical Data Structure Loading
1196 */
1197/******************************************************************************/
1198
1199/** Loads a key at a given file offset along with associated data structures.
1200 *
1201 * XXX: finish documenting
1202 *
1203 * @ingroup regfiGlueLayer
1204 */
1205REGFI_NK_REC*         regfi_load_key(REGFI_FILE* file, uint32_t offset, 
1206                                     REGFI_ENCODING output_encoding, 
1207                                     bool strict);
1208
1209
1210/** Loads a value at a given file offset alng with associated data structures.
1211 *
1212 * XXX: finish documenting
1213 *
1214 * @ingroup regfiGlueLayer
1215 */
1216REGFI_VK_REC*         regfi_load_value(REGFI_FILE* file, uint32_t offset, 
1217                                       REGFI_ENCODING output_encoding, 
1218                                       bool strict);
1219
1220
1221/** Loads a logical subkey list in its entirety which may span multiple records.
1222 *
1223 * XXX: finish documenting
1224 *
1225 * @ingroup regfiGlueLayer
1226 */
1227REGFI_SUBKEY_LIST*    regfi_load_subkeylist(REGFI_FILE* file, uint32_t offset,
1228                                            uint32_t num_keys, uint32_t max_size,
1229                                            bool strict);
1230
1231
1232/** Loads a valuelist.
1233 *
1234 * XXX: finish documenting
1235 *
1236 * @ingroup regfiGlueLayer
1237 */
1238REGFI_VALUE_LIST*     regfi_load_valuelist(REGFI_FILE* file, uint32_t offset, 
1239                                           uint32_t num_values, uint32_t max_size,
1240                                           bool strict);
1241
1242
1243/** Loads a data record which may be contained in the virtual offset, in a
1244 *  single cell, or in multiple cells through big data records.
1245 *
1246 * XXX: finish documenting
1247 *
1248 * @ingroup regfiGlueLayer
1249 */
1250REGFI_BUFFER          regfi_load_data(REGFI_FILE* file, uint32_t voffset,
1251                                      uint32_t length, bool data_in_offset,
1252                                      bool strict);
1253
1254
1255/** Loads the data associated with a big data record at the specified offset.
1256 *
1257 * XXX: finish documenting
1258 *
1259 * @ingroup regfiGlueLayer
1260 */
1261REGFI_BUFFER          regfi_load_big_data(REGFI_FILE* file, uint32_t offset, 
1262                                          uint32_t data_length,uint32_t cell_length,
1263                                          range_list* used_ranges,
1264                                          bool strict);
1265
1266
1267/** Given raw data, attempts to interpret the data based on a specified registry
1268 *  data type.
1269 *
1270 * XXX: finish documenting
1271 *
1272 * @ingroup regfiGlueLayer
1273 */
1274bool                  regfi_interpret_data(REGFI_FILE* file, 
1275                                           REGFI_ENCODING string_encoding,
1276                                           uint32_t type, REGFI_DATA* data);
1277
1278
1279/** Frees the memory associated with a REGFI_CLASSNAME data structure.
1280 *
1281 * XXX: finish documenting
1282 *
1283 * @ingroup regfiGlueLayer
1284 */
1285void                  regfi_free_classname(REGFI_CLASSNAME* classname);
1286
1287
1288/** Frees the memory associated with a REGFI_DATA data structure.
1289 *
1290 * XXX: finish documenting
1291 *
1292 * @ingroup regfiGlueLayer
1293 */
1294void                  regfi_free_data(REGFI_DATA* data);
1295
1296
1297/* These are cached so return values don't need to be freed. */
1298
1299/** Loads an "sk" security record at the specified offset.
1300 *
1301 * XXX: finish documenting
1302 *
1303 * @ingroup regfiGlueLayer
1304 */
1305const REGFI_SK_REC*   regfi_load_sk(REGFI_FILE* file, uint32_t offset,
1306                                    bool strict);
1307
1308
1309/** Retrieves the HBIN data structure stored at the specified offset.
1310 *
1311 * XXX: finish documenting
1312 *
1313 * @ingroup regfiGlueLayer
1314 */
1315const REGFI_HBIN*     regfi_lookup_hbin(REGFI_FILE* file, uint32_t offset);
1316
1317
1318
1319/******************************************************************************/
1320/**
1321 * @defgroup regfiParseLayer Parsing Layer: Direct Data Structure Access
1322 */
1323/******************************************************************************/
1324
1325REGFI_FILE*           regfi_parse_regf(REGFI_RAW_FILE* file_cb, bool strict);
1326REGFI_HBIN*           regfi_parse_hbin(REGFI_FILE* file, uint32_t offset, 
1327                                       bool strict);
1328
1329
1330/** Parses an NK record at the specified offset
1331 *
1332 * @param file     the registry file structure
1333 * @param offset   the offset of the cell (not the record) to be parsed.
1334 * @param max_size the maximum size the NK cell could be. (for validation)
1335 * @param strict   if true, rejects any malformed records.  Otherwise,
1336 *                 tries to minimally validate integrity.
1337 *
1338 * @return A newly allocated NK record structure, or NULL on failure.
1339 *
1340 * @ingroup regfiParseLayer
1341 */
1342REGFI_NK_REC*         regfi_parse_nk(REGFI_FILE* file, uint32_t offset,
1343                                     uint32_t max_size, bool strict);
1344
1345
1346/** Parses a single cell containing a subkey-list record.
1347 *
1348 * XXX: finish documenting
1349 *
1350 * @ingroup regfiParseLayer
1351 */
1352REGFI_SUBKEY_LIST*    regfi_parse_subkeylist(REGFI_FILE* file, uint32_t offset,
1353                                             uint32_t max_size, bool strict);
1354
1355
1356/** Parses a VK (value) record at the specified offset
1357 *
1358 * XXX: finish documenting
1359 *
1360 * @ingroup regfiParseLayer
1361 */
1362REGFI_VK_REC*         regfi_parse_vk(REGFI_FILE* file, uint32_t offset, 
1363                                     uint32_t max_size, bool strict);
1364
1365
1366/** Parses an SK (security) record at the specified offset
1367 *
1368 * XXX: finish documenting
1369 *
1370 * @ingroup regfiParseLayer
1371 */
1372REGFI_SK_REC*         regfi_parse_sk(REGFI_FILE* file, uint32_t offset, 
1373                                     uint32_t max_size, bool strict);
1374
1375
1376/** Retrieves information on all cells in the registry hive which are
1377 *  currently in the unallocated status. 
1378 *
1379 * The unallocated status is determined based soley on the cell length sign.
1380 *
1381 * XXX: finish documenting
1382 *
1383 * @ingroup regfiParseLayer
1384 */
1385range_list*           regfi_parse_unalloc_cells(REGFI_FILE* file);
1386
1387
1388/** Helper function to parse a cell
1389 *
1390 * XXX: finish documenting
1391 *
1392 * @ingroup regfiParseLayer
1393 */
1394bool                  regfi_parse_cell(REGFI_RAW_FILE* file_cb, uint32_t offset,
1395                                       uint8_t* hdr, uint32_t hdr_len,
1396                                       uint32_t* cell_length, bool* unalloc);
1397
1398
1399/** Parses a classname cell
1400 *
1401 * XXX: finish documenting
1402 *
1403 * @ingroup regfiParseLayer
1404 */
1405uint8_t*                regfi_parse_classname(REGFI_FILE* file, uint32_t offset,
1406                                            uint16_t* name_length, 
1407                                            uint32_t max_size, bool strict);
1408
1409
1410/** Parses a single-cell data record
1411 *
1412 * XXX: finish documenting
1413 *
1414 * @ingroup regfiParseLayer
1415 */
1416REGFI_BUFFER          regfi_parse_data(REGFI_FILE* file, uint32_t offset,
1417                                       uint32_t length, bool strict);
1418
1419
1420/** Parses a "little data" record which is stored entirely within the
1421 *  provided virtual offset.
1422 *
1423 * XXX: finish documenting
1424 *
1425 * @ingroup regfiParseLayer
1426 */
1427REGFI_BUFFER          regfi_parse_little_data(REGFI_FILE* file, uint32_t voffset, 
1428                                              uint32_t length, bool strict);
1429
1430
1431/******************************************************************************/
1432/*    Private Functions                                                       */
1433/******************************************************************************/
1434REGFI_NK_REC*         regfi_rootkey(REGFI_FILE* file, 
1435                                    REGFI_ENCODING output_encoding);
1436void                  regfi_subkeylist_free(REGFI_SUBKEY_LIST* list);
1437
1438off_t                 regfi_raw_seek(REGFI_RAW_FILE* self, 
1439                                     off_t offset, int whence);
1440ssize_t               regfi_raw_read(REGFI_RAW_FILE* self, 
1441                                     void* buf, size_t count);
1442off_t                 regfi_seek(REGFI_RAW_FILE* file_cb, 
1443                                 off_t offset, int whence);
1444uint32_t              regfi_read(REGFI_RAW_FILE* file_cb, 
1445                                 uint8_t* buf, uint32_t* length);
1446
1447const char*           regfi_type_val2str(unsigned int val);
1448int                   regfi_type_str2val(const char* str);
1449
1450char*                 regfi_get_sacl(WINSEC_DESC* sec_desc);
1451char*                 regfi_get_dacl(WINSEC_DESC* sec_desc);
1452char*                 regfi_get_owner(WINSEC_DESC* sec_desc);
1453char*                 regfi_get_group(WINSEC_DESC* sec_desc);
1454
1455REGFI_SUBKEY_LIST*    regfi_merge_subkeylists(uint16_t num_lists, 
1456                                              REGFI_SUBKEY_LIST** lists,
1457                                              bool strict);
1458REGFI_SUBKEY_LIST*    regfi_load_subkeylist_aux(REGFI_FILE* file, uint32_t offset,
1459                                                uint32_t max_size, bool strict,
1460                                                uint8_t depth_left);
1461void                  regfi_add_message(REGFI_FILE* file, uint16_t msg_type, 
1462                                        const char* fmt, ...);
1463REGFI_NK_REC*         regfi_copy_nk(const REGFI_NK_REC* nk);
1464REGFI_VK_REC*         regfi_copy_vk(const REGFI_VK_REC* vk);
1465int32_t               regfi_calc_maxsize(REGFI_FILE* file, uint32_t offset);
1466int32_t               regfi_conv_charset(const char* input_charset, 
1467                                         const char* output_charset,
1468                                         uint8_t* input, char* output, 
1469                                         uint32_t input_len, uint32_t output_max);
1470REGFI_DATA*           regfi_buffer_to_data(REGFI_BUFFER raw_data);
1471
1472/* XXX: move to base API and document */
1473void                  regfi_unix2nt_time(REGFI_NTTIME* nt, time_t t);
1474time_t                regfi_nt2unix_time(const REGFI_NTTIME* nt);
1475
1476
1477void regfi_interpret_keyname(REGFI_FILE* file, REGFI_NK_REC* nk, 
1478                             REGFI_ENCODING output_encoding, bool strict);
1479void regfi_interpret_valuename(REGFI_FILE* file, REGFI_VK_REC* vk, 
1480                               REGFI_ENCODING output_encoding, bool strict);
1481
1482
1483#endif  /* _REGFI_H */
Note: See TracBrowser for help on using the repository browser.