source: trunk/include/regfi.h @ 185

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

reworked logging API again to simplify interface

updated regfi-threadtest to work with more recent commits

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