Changeset 99 for trunk/include/regfi.h


Ignore:
Timestamp:
03/03/08 19:38:48 (16 years ago)
Author:
tim
Message:

fixed a range_list bug

replaced NK parsing routine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/regfi.h

    r97 r99  
    4848#include "smb_deps.h"
    4949#include "void_stack.h"
     50#include "range_list.h"
    5051
    5152/******************************************************************************/
     
    8384
    8485#define REGF_OFFSET_NONE        0xffffffff
     86#define REGFI_NK_MIN_LENGTH     0x50
    8587
    8688/* Flags for the vk records */
     
    116118                          * Should be a multiple of 4096 (0x1000)
    117119                          */
    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.
     120  uint32 next_block;     /* relative offset to next block. 
     121                          * NOTE: This value may be unreliable!
    122122                          */
    123123
     
    142142  REGF_HASH_REC* hashes;
    143143  uint32 hbin_off;       /* offset from beginning of this hbin block */
    144   uint32 rec_size;       /* ((start_offset - end_offset) & 0xfffffff8) */
     144  uint32 cell_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
    145145 
    146146  uint8 header[REC_HDR_SIZE];
     
    158158  uint8* data;
    159159  uint32 hbin_off;      /* offset from beginning of this hbin block */
    160   uint32 rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     160  uint32 cell_size;     /* ((start_offset - end_offset) & 0xfffffff8) */
    161161  uint32 rec_off;       /* offset stored in the value list */
    162162 
     
    181181  SEC_DESC* sec_desc;
    182182  uint32 hbin_off;      /* offset from beginning of this hbin block */
    183   uint32 rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     183  uint32 cell_size;     /* ((start_offset - end_offset) & 0xfffffff8) */
    184184 
    185185  uint32 sk_off;        /* offset parsed from NK record used as a key
     
    198198typedef struct
    199199{
    200   uint32 hbin_off;      /* offset from beginning of this hbin block */
    201   uint32 rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
    202   REGF_HBIN *hbin;      /* pointer to HBIN record (in memory) containing
    203                          * this nk record */
     200  uint32 offset;        /* Real offset of this record's cell in the file */
     201  uint32 cell_size;     /* Actual or estimated length of the cell. 
     202                         * Always in multiples of 8.
     203                         */
    204204
    205205  /* link in the other records here */
     
    213213  uint8  header[REC_HDR_SIZE];
    214214  NTTIME mtime;
     215  uint16 name_length;
     216  uint16 classname_length;
    215217  char* classname;
    216218  char* keyname;
     
    225227 
    226228  /* unknowns */
     229  uint32 unknown1;
     230  uint32 unknown2;
     231  uint32 unknown3;
    227232  uint32 unk_index;                 /* nigel says run time index ? */
    228233 
     
    246251  void* mem_ctx;  /* memory context for run-time file access information */
    247252  REGF_HBIN* block_list; /* list of open hbin blocks */
    248  
     253
     254  /* Experimental hbin lists */
     255  range_list* hbins;
     256  range_list* unalloc_cells;
     257
    249258  /* file format information */
    250259  REGF_SK_REC* sec_desc_list;   /* list of security descriptors referenced
     
    298307/******************************************************************************/
    299308/* Function Declarations */
    300 
     309/*  Main API */
    301310const char*           regfi_type_val2str(unsigned int val);
    302311int                   regfi_type_str2val(const char* str);
     
    331340const REGF_VK_REC*    regfi_iterator_next_value(REGFI_ITERATOR* i);
    332341
     342/************************************/
     343/*  Low-layer data structure access */
     344/************************************/
     345REGF_FILE*            regfi_parse_regf(int fd, bool strict);
     346REGF_HBIN*            regfi_parse_hbin(REGF_FILE* file, uint32 offset,
     347                                       bool strict, bool save_unalloc);
     348
     349
     350/* regfi_parse_nk: Parses an NK record.
     351 *
     352 * Arguments:
     353 *   f        -- the registry file structure
     354 *   offset   -- the offset of the cell (not the record) to be parsed.
     355 *   max_size -- the maximum size the NK cell could be. (for validation)
     356 *   strict   -- if true, rejects any malformed records.  Otherwise,
     357 *               tries to minimally validate integrity.
     358 * Returns:
     359 *   A newly allocated NK record structure, or NULL on failure.
     360 */
     361REGF_NK_REC*          regfi_parse_nk(REGF_FILE* file, uint32 offset,
     362                                     uint32 max_size, bool strict);
     363
    333364
    334365/* Private Functions */
    335366REGF_NK_REC*          regfi_rootkey(REGF_FILE* file);
    336367void                  regfi_key_free(REGF_NK_REC* nk);
     368uint32                regfi_read(int fd, uint8* buf, uint32* length);
    337369
    338370
     
    341373/* Experimental */
    342374/****************/
    343 typedef struct
    344 {
    345   uint32 offset;
    346   uint32 size;
    347 } REGFI_CELL_INFO;
    348 
    349 typedef struct
    350 {
    351   uint32 count;
    352   REGFI_CELL_INFO** cells;
    353 } REGFI_CELL_LIST;
    354 
    355 
    356 REGF_FILE* regfi_parse_regf(int fd, bool strict);
    357 REGFI_CELL_LIST* regfi_get_unallocated_cells(REGF_FILE* file);
    358 REGF_HBIN* regfi_parse_hbin(REGF_FILE* file, uint32 offset,
    359                             bool strict, bool save_unalloc);
    360 REGF_NK_REC* regfi_parse_nk(REGF_FILE* f, uint32);
    361 uint32 regfi_read(int fd, uint8* buf, uint32* length);
     375
    362376
    363377#endif  /* _REGFI_H */
Note: See TracChangeset for help on using the changeset viewer.