Changeset 53 for trunk/include


Ignore:
Timestamp:
09/04/05 17:04:58 (19 years ago)
Author:
tim
Message:

Moved security descriptor parsing functions into regfio.c

Improved malloc() mode of failure.

Eliminated some warnings in regfio.c

Location:
trunk/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/regfio.h

    r41 r53  
    102102struct regf_hbin;
    103103typedef struct regf_hbin {
    104         struct regf_hbin *prev, *next;
    105         uint32 file_off;                /* my offset in the registry file */
    106         uint32 free_off;                /* offset to free space within the hbin record */
    107         uint32 free_size;               /* amount of data left in the block */
    108         int ref_count;                  /* how many active records are pointing to this block (not used currently) */
     104  struct regf_hbin* prev;
     105  struct regf_hbin* next;
     106  uint32 file_off;       /* my offset in the registry file */
     107  uint32 free_off;       /* offset to free space within the hbin record */
     108  uint32 free_size;      /* amount of data left in the block */
     109  int    ref_count;      /* how many active records are pointing to this block (not used currently) */
    109110       
    110         char   header[HBIN_HDR_SIZE];   /* "hbin" */
    111         uint32 first_hbin_off;          /* offset from first hbin block */
    112         uint32 block_size;              /* block size of this blockually a multiple of 4096Kb) */
    113 
    114         prs_struct ps;                  /* data */
    115 
    116         bool dirty;                     /* has this hbin block been modified? */
     111  uint8  header[HBIN_HDR_SIZE]; /* "hbin" */
     112  uint32 first_hbin_off; /* offset from first hbin block */
     113  uint32 block_size;     /* block size of this blockually a multiple of 4096Kb) */
     114  prs_struct ps;               /* data */
     115  bool dirty;            /* has this hbin block been modified? */
    117116} REGF_HBIN;
    118117
     
    120119
    121120typedef struct {
    122         uint32 nk_off;
    123         uint8 keycheck[sizeof(uint32)];
     121  uint32 nk_off;
     122  uint8 keycheck[sizeof(uint32)];
    124123} REGF_HASH_REC;
    125124
    126125typedef struct {
    127         REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
    128         uint32 hbin_off;        /* offset from beginning of this hbin block */
    129         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
    130 
    131         char header[REC_HDR_SIZE];
    132         uint16 num_keys;
    133         REGF_HASH_REC *hashes;
     126  REGF_HBIN *hbin;      /* pointer to HBIN record (in memory) containing this nk record */
     127  uint32 hbin_off;      /* offset from beginning of this hbin block */
     128  uint32 rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     129 
     130  uint8 header[REC_HDR_SIZE];
     131  uint16 num_keys;
     132  REGF_HASH_REC *hashes;
    134133} REGF_LF_REC;
    135134
     
    137136
    138137typedef struct {
    139         REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
    140         uint32 hbin_off;        /* offset from beginning of this hbin block */
    141         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
    142         uint32 rec_off;         /* offset stored in the value list */
    143        
    144         char header[REC_HDR_SIZE];
    145         char *valuename;
    146         uint32 data_size;
    147         uint32 data_off;
    148         uint8  *data;
    149         uint32 type;
    150         uint16 flag;
     138  REGF_HBIN *hbin;      /* pointer to HBIN record (in memory) containing this nk record */
     139  uint32 hbin_off;      /* offset from beginning of this hbin block */
     140  uint32 rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     141  uint32 rec_off;               /* offset stored in the value list */
     142 
     143  uint8 header[REC_HDR_SIZE];
     144  char*  valuename;
     145  uint32 data_size;
     146  uint32 data_off;
     147  uint8* data;
     148  uint32 type;
     149  uint16 flag;
    151150} REGF_VK_REC;
    152151
     
    156155
    157156typedef struct _regf_sk_rec {
    158         struct _regf_sk_rec *next, *prev;
    159         REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
    160         uint32 hbin_off;        /* offset from beginning of this hbin block */
    161         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
    162 
    163         uint32 sk_off;          /* offset parsed from NK record used as a key
     157  struct _regf_sk_rec *next, *prev;
     158  REGF_HBIN *hbin;      /* pointer to HBIN record (in memory) containing this nk record */
     159  uint32 hbin_off;      /* offset from beginning of this hbin block */
     160  uint32 rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     161 
     162  uint32 sk_off;                /* offset parsed from NK record used as a key
    164163                                   to lookup reference to this SK record */
    165 
    166         char header[REC_HDR_SIZE];
    167         uint32 prev_sk_off;
    168         uint32 next_sk_off;
    169         uint32 ref_count;
    170         uint32 size;
    171         SEC_DESC *sec_desc;
     164 
     165  uint8 header[REC_HDR_SIZE];
     166  uint32 prev_sk_off;
     167  uint32 next_sk_off;
     168  uint32 ref_count;
     169  uint32 size;
     170  SEC_DESC *sec_desc;
    172171} REGF_SK_REC;
    173172
     
    175174
    176175typedef struct {
    177         REGF_HBIN *hbin;        /* pointer to HBIN record (in memory) containing this nk record */
    178         uint32 hbin_off;        /* offset from beginning of this hbin block */
    179         uint32 subkey_index;    /* index to next subkey record to return */
    180         uint32 rec_size;        /* ((start_offset - end_offset) & 0xfffffff8) */
    181        
    182         /* header information */
    183        
    184         char header[REC_HDR_SIZE];
    185         uint16 key_type;
    186         NTTIME mtime;
    187         uint32 parent_off;      /* back pointer in registry hive */
    188         uint32 classname_off;   
    189         char *classname;
    190         char *keyname;
    191 
    192         /* max lengths */
    193 
    194         uint32 max_bytes_subkeyname;            /* max subkey name * 2 */
    195         uint32 max_bytes_subkeyclassname;       /* max subkey classname length (as if) */
    196         uint32 max_bytes_valuename;             /* max valuename * 2 */
    197         uint32 max_bytes_value;                 /* max value data size */
    198 
    199         /* unknowns */
    200 
    201         uint32 unk_index;                       /* nigel says run time index ? */
    202        
    203         /* children */
    204        
    205         uint32 num_subkeys;
    206         uint32 subkeys_off;     /* hash records that point to NK records */     
    207         uint32 num_values;
    208         uint32 values_off;      /* value lists which point to VK records */
    209         uint32 sk_off;          /* offset to SK record */
    210        
    211         /* link in the other records here */
    212        
    213         REGF_LF_REC subkeys;
    214         REGF_VK_REC *values;
    215         REGF_SK_REC *sec_desc;
     176  REGF_HBIN *hbin;      /* pointer to HBIN record (in memory) containing this nk record */
     177  uint32 hbin_off;      /* offset from beginning of this hbin block */
     178  uint32 subkey_index;  /* index to next subkey record to return */
     179  uint32 rec_size;      /* ((start_offset - end_offset) & 0xfffffff8) */
     180 
     181  /* header information */
     182 
     183  uint8 header[REC_HDR_SIZE];
     184  uint16 key_type;
     185  NTTIME mtime;
     186  uint32 parent_off;    /* back pointer in registry hive */
     187  uint32 classname_off;
     188  char *classname;
     189  char *keyname;
     190 
     191  /* max lengths */
     192 
     193  uint32 max_bytes_subkeyname;          /* max subkey name * 2 */
     194  uint32 max_bytes_subkeyclassname;     /* max subkey classname length (as if) */
     195  uint32 max_bytes_valuename;           /* max valuename * 2 */
     196  uint32 max_bytes_value;                       /* max value data size */
     197 
     198  /* unknowns */
     199 
     200  uint32 unk_index;                     /* nigel says run time index ? */
     201 
     202  /* children */
     203 
     204  uint32 num_subkeys;
     205  uint32 subkeys_off;   /* hash records that point to NK records */     
     206  uint32 num_values;
     207  uint32 values_off;    /* value lists which point to VK records */
     208  uint32 sk_off;                /* offset to SK record */
     209 
     210  /* link in the other records here */
     211 
     212  REGF_LF_REC subkeys;
     213  REGF_VK_REC *values;
     214  REGF_SK_REC *sec_desc;
    216215       
    217216} REGF_NK_REC;
     
    220219 
    221220typedef struct {
    222         /* run time information */
    223 
    224         int fd;                         /* file descriptor */
    225         int open_flags;                 /* flags passed to the open() call */
    226         void *mem_ctx;          /* memory context for run-time file access information */
    227         REGF_HBIN *block_list;          /* list of open hbin blocks */
    228 
    229         /* file format information */
    230 
    231         char   header[REGF_HDR_SIZE];   /* "regf" */
    232         uint32 data_offset;             /* offset to record in the first (or any?) hbin block */
    233         uint32 last_block;              /* offset to last hbin block in file */
    234         uint32 checksum;                /* XOR of bytes 0x0000 - 0x01FB */
    235         NTTIME mtime;
    236        
    237         REGF_SK_REC *sec_desc_list;     /* list of security descriptors referenced by NK records */
    238 
    239         /* unknowns used to simply writing */
    240        
    241         uint32 unknown1;
    242         uint32 unknown2;
    243         uint32 unknown3;
    244         uint32 unknown4;
    245         uint32 unknown5;
    246         uint32 unknown6;
    247        
     221  /* run time information */
     222 
     223  int fd;                               /* file descriptor */
     224  int open_flags;                       /* flags passed to the open() call */
     225  void *mem_ctx;                /* memory context for run-time file access information */
     226  REGF_HBIN *block_list;                /* list of open hbin blocks */
     227 
     228  /* file format information */
     229 
     230  uint8  header[REGF_HDR_SIZE]; /* "regf" */
     231  uint32 data_offset;           /* offset to record in the first (or any?) hbin block */
     232  uint32 last_block;            /* offset to last hbin block in file */
     233  uint32 checksum;              /* XOR of bytes 0x0000 - 0x01FB */
     234  NTTIME mtime;
     235 
     236  REGF_SK_REC *sec_desc_list;   /* list of security descriptors referenced by NK records */
     237 
     238  /* unknowns used to simply writing */
     239 
     240  uint32 unknown1;
     241  uint32 unknown2;
     242  uint32 unknown3;
     243  uint32 unknown4;
     244  uint32 unknown5;
     245  uint32 unknown6;
    248246} REGF_FILE;
     247
    249248
    250249/* Function Declarations */
     
    253252int           regfio_type_str2val(const char* str);
    254253
     254char*         regfio_get_sacl(SEC_DESC *sec_desc);
     255char*         regfio_get_dacl(SEC_DESC *sec_desc);
     256char*         regfio_get_owner(SEC_DESC *sec_desc);
     257char*         regfio_get_group(SEC_DESC *sec_desc);
     258
    255259REGF_FILE*    regfio_open( const char *filename );
    256260int           regfio_close( REGF_FILE *r );
  • trunk/include/smb_deps.h

    r42 r53  
    184184                     uint16 *data16, uint32 ptr_uint16, uint32 start_offset);
    185185bool prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8);
    186 bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len);
     186bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth,
     187                uint8* data8s, int len);
    187188bool prs_set_offset(prs_struct *ps, uint32 offset);
    188189
Note: See TracChangeset for help on using the changeset viewer.