Changeset 97 for trunk/include


Ignore:
Timestamp:
02/26/08 20:04:14 (17 years ago)
Author:
tim
Message:

begun the work of rewriting the lowest layer parsing routines

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/regfi.h

    r84 r97  
    7272
    7373#define REGF_BLOCKSIZE          0x1000
    74 #define REGF_ALLOC_BLOCK        0x1000
     74#define REGF_ALLOC_BLOCK        0x1000  /* Minimum allocation unit for hbins */
    7575#define REGF_MAX_DEPTH          512
    7676
    7777/* header sizes for various records */
    7878
    79 #define REGF_HDR_SIZE           4
    80 #define HBIN_HDR_SIZE           4
    81 #define HBIN_HEADER_REC_SIZE    0x24
     79#define REGF_MAGIC_SIZE         4
     80#define HBIN_MAGIC_SIZE         4
     81#define HBIN_HEADER_REC_SIZE    0x20
    8282#define REC_HDR_SIZE            2
    8383
     
    103103/* HBIN block */
    104104struct regf_hbin;
    105 typedef struct regf_hbin {
     105typedef struct regf_hbin
     106{
    106107  struct regf_hbin* prev;
    107108  struct regf_hbin* next;
    108109  uint32 file_off;       /* my offset in the registry file */
    109   uint32 free_off;       /* offset to free space within the hbin record */
    110   uint32 free_size;      /* amount of data left in the block */
    111110  uint32 ref_count;      /* how many active records are pointing to this
    112111                          * block (not used currently)
     
    114113 
    115114  uint32 first_hbin_off; /* offset from first hbin block */
    116   uint32 block_size;     /* block size of this block is
    117                           * usually a multiple of 4096Kb
     115  uint32 block_size;     /* block size of this block
     116                          * Should be a multiple of 4096 (0x1000)
    118117                          */
    119   uint8  header[HBIN_HDR_SIZE]; /* "hbin" */
     118  uint32 next_block;     /* relative offset to next block.  Should be
     119                          * exactly the same as block_size.  Stored just
     120                          * in case this is found to be different in the
     121                          * future.
     122                          */
     123
     124  uint8 magic[HBIN_MAGIC_SIZE]; /* "hbin" */
    120125  prs_struct ps;         /* data */
    121   bool dirty;            /* has this hbin block been modified? */
    122126} REGF_HBIN;
    123127
    124 /* ??? List -- list of key offsets and hashed names for consistency */
    125 typedef struct {
     128
     129/* Hash List -- list of key offsets and hashed names for consistency */
     130typedef struct
     131{
    126132  uint32 nk_off;
    127   uint8 keycheck[sizeof(uint32)];
     133  uint8 keycheck[4];
    128134} REGF_HASH_REC;
    129135
    130 typedef struct {
     136
     137typedef struct
     138{
    131139  REGF_HBIN* hbin;       /* pointer to HBIN record (in memory) containing
    132140                          * this nk record
     
    140148} REGF_LF_REC;
    141149
     150
    142151/* Key Value */
    143 
    144 typedef struct {
     152typedef struct
     153{
    145154  REGF_HBIN* hbin;      /* pointer to HBIN record (in memory) containing
    146155                         * this nk record
     
    163172struct _regf_sk_rec;
    164173
    165 typedef struct _regf_sk_rec {
     174typedef struct _regf_sk_rec
     175{
    166176  struct _regf_sk_rec* next;
    167177  struct _regf_sk_rec* prev;
     
    186196
    187197/* Key Name */
    188 typedef struct {
     198typedef struct
     199{
    189200  uint32 hbin_off;      /* offset from beginning of this hbin block */
    190201  uint32 rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     
    221232  uint32 num_values;
    222233  uint32 values_off;    /* value lists which point to VK records */
    223   uint32 sk_off;        /* offset to SK record */
    224  
     234  uint32 sk_off;        /* offset to SK record */ 
    225235} REGF_NK_REC;
    226236
    227237
     238
    228239/* REGF block */
    229 typedef struct {
     240typedef struct
     241{
    230242  /* run time information */
    231243  int fd;         /* file descriptor */
    232   int open_flags; /* flags passed to the open() call */
     244  /* For sanity checking (not part of the registry header) */
     245  uint32 file_length;
    233246  void* mem_ctx;  /* memory context for run-time file access information */
    234247  REGF_HBIN* block_list; /* list of open hbin blocks */
     
    239252                                 */
    240253 
    241   uint8  header[REGF_HDR_SIZE]; /* "regf" */
     254  uint8  magic[REGF_MAGIC_SIZE];/* "regf" */
    242255  NTTIME mtime;
    243256  uint32 data_offset;           /* offset to record in the first (or any?)
     
    245258                                 */
    246259  uint32 last_block;            /* offset to last hbin block in file */
    247   uint32 checksum;              /* XOR of bytes 0x0000 - 0x01FB */
    248  
    249   /* unknowns */
     260
     261  uint32 checksum;              /* Stored checksum. */
     262  uint32 computed_checksum;     /* Our own calculation of the checksum.
     263                                 * (XOR of bytes 0x0000 - 0x01FB)
     264                                 */
     265 
     266  /* unknown data structure values */
    250267  uint32 unknown1;
    251268  uint32 unknown2;
     
    254271  uint32 unknown5;
    255272  uint32 unknown6;
     273  uint32 unknown7;
    256274} REGF_FILE;
    257275
    258276
    259 typedef struct {
     277
     278typedef struct
     279{
    260280  REGF_FILE* f;
    261281  void_stack* key_positions;
     
    266286
    267287
    268 typedef struct {
     288typedef struct
     289{
    269290  REGF_NK_REC* nk;
    270291  uint32 cur_subkey;
     
    316337
    317338
     339
     340/****************/
     341/* Experimental */
     342/****************/
     343typedef struct
     344{
     345  uint32 offset;
     346  uint32 size;
     347} REGFI_CELL_INFO;
     348
     349typedef struct
     350{
     351  uint32 count;
     352  REGFI_CELL_INFO** cells;
     353} REGFI_CELL_LIST;
     354
     355
     356REGF_FILE* regfi_parse_regf(int fd, bool strict);
     357REGFI_CELL_LIST* regfi_get_unallocated_cells(REGF_FILE* file);
     358REGF_HBIN* regfi_parse_hbin(REGF_FILE* file, uint32 offset,
     359                            bool strict, bool save_unalloc);
     360REGF_NK_REC* regfi_parse_nk(REGF_FILE* f, uint32);
     361uint32 regfi_read(int fd, uint8* buf, uint32* length);
     362
    318363#endif  /* _REGFI_H */
Note: See TracChangeset for help on using the changeset viewer.