source: trunk/include/regfi.h @ 193

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

added Michael's patch for enums and an error message fix

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