Changeset 135 for trunk/include
- Timestamp:
- 01/21/09 05:27:32 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/regfi.h
r134 r135 72 72 #define REG_KEY 0x7FFFFFFF 73 73 74 #define REGF_BLOCKSIZE 0x1000 75 #define REGF_ALLOC_BLOCK 0x1000 /* Minimum allocation unit for HBINs */ 76 #define REGF_MAX_DEPTH 512 77 78 /* header sizes for various records */ 79 #define REGF_MAGIC_SIZE 4 80 #define HBIN_MAGIC_SIZE 4 81 #define HBIN_HEADER_REC_SIZE 0x20 82 #define REC_HDR_SIZE 2 83 84 #define REGF_OFFSET_NONE 0xffffffff 74 #define REGFI_REGF_SIZE 0x1000 /* "regf" header block size */ 75 #define REGFI_HBIN_ALLOC 0x1000 /* Minimum allocation unit for HBINs */ 76 #define REGFI_MAX_DEPTH 512 77 #define REGFI_OFFSET_NONE 0xffffffff 78 79 /* Header sizes and magic number lengths for various records */ 80 #define REGFI_REGF_MAGIC_SIZE 4 81 #define REGFI_HBIN_MAGIC_SIZE 4 82 #define REGFI_CELL_MAGIC_SIZE 2 83 #define REGFI_HBIN_HEADER_SIZE 0x20 85 84 #define REGFI_NK_MIN_LENGTH 0x4C 86 85 #define REGFI_VK_MIN_LENGTH 0x14 87 86 #define REGFI_SK_MIN_LENGTH 0x14 88 87 #define REGFI_SUBKEY_LIST_MIN_LEN 0x4 88 89 89 90 90 /* Constants used for validation */ … … 106 106 107 107 /* Flags for the vk records */ 108 #define VK_FLAG_NAME_PRESENT0x0001109 #define VK_DATA_IN_OFFSET0x80000000110 #define VK_MAX_DATA_LENGTH1024*1024108 #define REGFI_VK_FLAG_NAME_PRESENT 0x0001 109 #define REGFI_VK_DATA_IN_OFFSET 0x80000000 110 #define REGFI_VK_MAX_DATA_LENGTH 1024*1024 111 111 112 112 /* NK record types */ 113 #define NK_TYPE_LINKKEY 0x0010 114 #define NK_TYPE_NORMALKEY 0x0020 115 #define NK_TYPE_ROOTKEY1 0x002c 116 #define NK_TYPE_ROOTKEY2 0x00ac 117 /* XXX: Unknown type that shows up in Vista registries */ 118 #define NK_TYPE_UNKNOWN1 0x1020 113 #define REGFI_NK_TYPE_LINKKEY 0x0010 114 #define REGFI_NK_TYPE_NORMALKEY 0x0020 115 /* XXX: Unknown key type that shows up in Vista registries */ 116 #define REGFI_NK_TYPE_UNKNOWN1 0x1020 117 #define REGFI_NK_TYPE_ROOTKEY1 0x002c 118 /* XXX: Unknown root key type that shows up in Vista registries */ 119 #define REGFI_NK_TYPE_ROOTKEY2 0x00ac 119 120 120 121 121 122 /* HBIN block */ 122 typedef struct regf_hbin123 typedef struct _regfi_hbin 123 124 { 124 125 uint32 file_off; /* my offset in the registry file */ … … 135 136 */ 136 137 137 uint8 magic[ HBIN_MAGIC_SIZE]; /* "hbin" */138 } REGF _HBIN;138 uint8 magic[REGFI_HBIN_MAGIC_SIZE]; /* "hbin" */ 139 } REGFI_HBIN; 139 140 140 141 … … 144 145 uint32 nk_off; 145 146 uint32 hash; 146 } REGF _SUBKEY_LIST_ELEM;147 } REGFI_SUBKEY_LIST_ELEM; 147 148 148 149 … … 152 153 uint32 cell_size; /* ((start_offset - end_offset) & 0xfffffff8) */ 153 154 uint32 num_keys; 154 REGF _SUBKEY_LIST_ELEM* elements;155 156 uint8 magic[RE C_HDR_SIZE];157 } REGF _SUBKEY_LIST;155 REGFI_SUBKEY_LIST_ELEM* elements; 156 157 uint8 magic[REGFI_CELL_MAGIC_SIZE]; 158 } REGFI_SUBKEY_LIST; 158 159 159 160 … … 164 165 uint32 cell_size; /* ((start_offset - end_offset) & 0xfffffff8) */ 165 166 166 REGF _HBIN* hbin; /* pointer to HBIN record (in memory) containing167 REGFI_HBIN* hbin; /* pointer to HBIN record (in memory) containing 167 168 * this nk record 168 169 */ … … 175 176 uint32 data_off; /* offset of data cell (virtual) */ 176 177 uint32 type; 177 uint8 magic[RE C_HDR_SIZE];178 uint8 magic[REGFI_CELL_MAGIC_SIZE]; 178 179 uint16 flag; 179 180 uint16 unknown1; 180 181 bool data_in_offset; 181 } REGF _VK_REC;182 } REGFI_VK_REC; 182 183 183 184 184 185 /* Key Security */ 185 struct _regf _sk_rec;186 187 typedef struct _regf _sk_rec186 struct _regfi_sk_rec; 187 188 typedef struct _regfi_sk_rec 188 189 { 189 190 uint32 offset; /* Real file offset of this record */ … … 202 203 uint32 desc_size; /* size of security descriptor */ 203 204 uint16 unknown_tag; 204 uint8 magic[RE C_HDR_SIZE];205 } REGF _SK_REC;205 uint8 magic[REGFI_CELL_MAGIC_SIZE]; 206 } REGFI_SK_REC; 206 207 207 208 … … 215 216 216 217 /* link in the other records here */ 217 REGF _VK_REC** values;218 REGF _SUBKEY_LIST* subkeys;218 REGFI_VK_REC** values; 219 REGFI_SUBKEY_LIST* subkeys; 219 220 220 221 /* header information */ 221 222 uint16 key_type; 222 uint8 magic[RE C_HDR_SIZE];223 uint8 magic[REGFI_CELL_MAGIC_SIZE]; 223 224 NTTIME mtime; 224 225 uint16 name_length; … … 247 248 uint32 values_off; /* value lists which point to VK records */ 248 249 uint32 sk_off; /* offset to SK record */ 249 } REGF _NK_REC;250 } REGFI_NK_REC; 250 251 251 252 … … 254 255 typedef struct 255 256 { 256 /* run time information */ 257 /* Run-time information */ 258 /************************/ 257 259 int fd; /* file descriptor */ 260 261 /* Experimental hbin lists */ 262 range_list* hbins; 263 264 /* Error/warning/info messages returned by lower layer functions */ 265 char* last_message; 266 258 267 /* For sanity checking (not part of the registry header) */ 259 268 uint32 file_length; 260 void* mem_ctx; /* memory context for run-time file access information */ 261 262 /* Experimental hbin lists */ 263 range_list* hbins; 264 265 /* file format information */ 266 uint8 magic[REGF_MAGIC_SIZE];/* "regf" */ 269 270 271 /* Data parsed from file header */ 272 /********************************/ 273 uint8 magic[REGFI_REGF_MAGIC_SIZE];/* "regf" */ 267 274 NTTIME mtime; 268 275 uint32 data_offset; /* offset to record in the first (or any?) … … 284 291 uint32 unknown6; 285 292 uint32 unknown7; 286 } REGF _FILE;287 288 289 290 typedef struct 291 { 292 REGF _FILE* f;293 } REGFI_FILE; 294 295 296 297 typedef struct 298 { 299 REGFI_FILE* f; 293 300 void_stack* key_positions; 294 301 lru_cache* sk_recs; 295 REGF _NK_REC* cur_key;302 REGFI_NK_REC* cur_key; 296 303 uint32 cur_subkey; 297 304 uint32 cur_value; … … 301 308 typedef struct 302 309 { 303 REGF_NK_REC* nk; 310 /* XXX: Should probably eliminate the storage of keys here 311 * once key caching is implemented. 312 */ 313 REGFI_NK_REC* nk; 304 314 uint32 cur_subkey; 305 315 /* We could store a cur_value here as well, but didn't see … … 310 320 311 321 /******************************************************************************/ 312 /* Function Declarations */ 313 /* Main API */ 314 const char* regfi_type_val2str(unsigned int val); 315 int regfi_type_str2val(const char* str); 316 317 char* regfi_get_sacl(WINSEC_DESC* sec_desc); 318 char* regfi_get_dacl(WINSEC_DESC* sec_desc); 319 char* regfi_get_owner(WINSEC_DESC* sec_desc); 320 char* regfi_get_group(WINSEC_DESC* sec_desc); 321 322 REGF_FILE* regfi_open(const char* filename); 323 int regfi_close(REGF_FILE* r); 324 325 REGFI_ITERATOR* regfi_iterator_new(REGF_FILE* fh); 322 /* Main iterator API */ 323 /******************************************************************************/ 324 REGFI_FILE* regfi_open(const char* filename); 325 int regfi_close(REGFI_FILE* r); 326 327 /* regfi_get_message: Get errors, warnings, and/or verbose information 328 * relating to processing of the given registry file. 329 * 330 * Arguments: 331 * file -- the structure for the registry file 332 * 333 * Returns: 334 * A newly allocated char* which must be free()d by the caller. 335 */ 336 char* regfi_get_message(REGFI_FILE* file); 337 338 REGFI_ITERATOR* regfi_iterator_new(REGFI_FILE* fh); 326 339 void regfi_iterator_free(REGFI_ITERATOR* i); 327 340 bool regfi_iterator_down(REGFI_ITERATOR* i); … … 333 346 bool regfi_iterator_walk_path(REGFI_ITERATOR* i, 334 347 const char** path); 335 const REGF _NK_REC*regfi_iterator_cur_key(REGFI_ITERATOR* i);336 const REGF _SK_REC*regfi_iterator_cur_sk(REGFI_ITERATOR* i);337 const REGF _NK_REC*regfi_iterator_first_subkey(REGFI_ITERATOR* i);338 const REGF _NK_REC*regfi_iterator_cur_subkey(REGFI_ITERATOR* i);339 const REGF _NK_REC*regfi_iterator_next_subkey(REGFI_ITERATOR* i);348 const REGFI_NK_REC* regfi_iterator_cur_key(REGFI_ITERATOR* i); 349 const REGFI_SK_REC* regfi_iterator_cur_sk(REGFI_ITERATOR* i); 350 const REGFI_NK_REC* regfi_iterator_first_subkey(REGFI_ITERATOR* i); 351 const REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i); 352 const REGFI_NK_REC* regfi_iterator_next_subkey(REGFI_ITERATOR* i); 340 353 341 354 bool regfi_iterator_find_value(REGFI_ITERATOR* i, 342 355 const char* value_name); 343 const REGF _VK_REC*regfi_iterator_first_value(REGFI_ITERATOR* i);344 const REGF _VK_REC*regfi_iterator_cur_value(REGFI_ITERATOR* i);345 const REGF _VK_REC*regfi_iterator_next_value(REGFI_ITERATOR* i);356 const REGFI_VK_REC* regfi_iterator_first_value(REGFI_ITERATOR* i); 357 const REGFI_VK_REC* regfi_iterator_cur_value(REGFI_ITERATOR* i); 358 const REGFI_VK_REC* regfi_iterator_next_value(REGFI_ITERATOR* i); 346 359 347 360 … … 349 362 /* Middle-layer structure caching, loading, and linking */ 350 363 /********************************************************/ 351 REGF_HBIN* regfi_lookup_hbin(REGF_FILE* file, uint32 offset); 352 353 REGF_NK_REC* regfi_load_key(REGF_FILE* file, uint32 offset, bool strict); 354 355 REGF_SUBKEY_LIST* regfi_load_subkeylist(REGF_FILE* file, uint32 offset, 356 uint32 num_keys, uint32 max_size, 357 bool strict); 358 359 REGF_VK_REC** regfi_load_valuelist(REGF_FILE* file, uint32 offset, 360 uint32 num_values, uint32 max_size, 361 bool strict); 362 363 REGF_SUBKEY_LIST* regfi_merge_subkeylists(uint16 num_lists, 364 REGF_SUBKEY_LIST** lists, 365 bool strict); 364 REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32 offset); 365 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32 offset, 366 bool strict); 367 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32 offset, 368 uint32 num_keys, uint32 max_size, 369 bool strict); 370 REGFI_VK_REC** regfi_load_valuelist(REGFI_FILE* file, uint32 offset, 371 uint32 num_values, uint32 max_size, 372 bool strict); 366 373 367 374 /************************************/ 368 375 /* Low-layer data structure access */ 369 376 /************************************/ 370 REGF _FILE*regfi_parse_regf(int fd, bool strict);371 REGF _HBIN* regfi_parse_hbin(REGF_FILE* file, uint32 offset,377 REGFI_FILE* regfi_parse_regf(int fd, bool strict); 378 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32 offset, 372 379 bool strict); 373 380 … … 384 391 * A newly allocated NK record structure, or NULL on failure. 385 392 */ 386 REGF _NK_REC* regfi_parse_nk(REGF_FILE* file, uint32 offset,393 REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32 offset, 387 394 uint32 max_size, bool strict); 388 395 389 REGF_VK_REC* regfi_parse_vk(REGF_FILE* file, uint32 offset, 390 uint32 max_size, bool strict); 391 392 uint8* regfi_parse_data(REGF_FILE* file, uint32 offset, 393 uint32 length, uint32 max_size, bool strict); 394 395 REGF_SK_REC* regfi_parse_sk(REGF_FILE* file, uint32 offset, uint32 max_size, bool strict); 396 397 range_list* regfi_parse_unalloc_cells(REGF_FILE* file); 398 399 bool regfi_parse_cell(int fd, uint32 offset, uint8* hdr, uint32 hdr_len, 400 uint32* cell_length, bool* unalloc); 401 402 char* regfi_parse_classname(REGF_FILE* file, uint32 offset, 403 uint16* name_length, uint32 max_size, bool strict); 404 405 406 /* Private Functions */ 407 REGF_NK_REC* regfi_rootkey(REGF_FILE* file); 408 void regfi_key_free(REGF_NK_REC* nk); 409 void regfi_subkeylist_free(REGF_SUBKEY_LIST* list); 396 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32 offset, 397 uint32 max_size, bool strict); 398 399 uint8* regfi_parse_data(REGFI_FILE* file, uint32 offset, 400 uint32 length, uint32 max_size, 401 bool strict); 402 403 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, 404 uint32 max_size, bool strict); 405 406 range_list* regfi_parse_unalloc_cells(REGFI_FILE* file); 407 408 bool regfi_parse_cell(int fd, uint32 offset, 409 uint8* hdr, uint32 hdr_len, 410 uint32* cell_length, bool* unalloc); 411 412 char* regfi_parse_classname(REGFI_FILE* file, uint32 offset, 413 uint16* name_length, 414 uint32 max_size, bool strict); 415 416 417 /************************************/ 418 /* Private Functions */ 419 /************************************/ 420 REGFI_NK_REC* regfi_rootkey(REGFI_FILE* file); 421 void regfi_key_free(REGFI_NK_REC* nk); 422 void regfi_subkeylist_free(REGFI_SUBKEY_LIST* list); 410 423 uint32 regfi_read(int fd, uint8* buf, uint32* length); 411 424 412 425 const char* regfi_type_val2str(unsigned int val); 426 int regfi_type_str2val(const char* str); 427 428 char* regfi_get_sacl(WINSEC_DESC* sec_desc); 429 char* regfi_get_dacl(WINSEC_DESC* sec_desc); 430 char* regfi_get_owner(WINSEC_DESC* sec_desc); 431 char* regfi_get_group(WINSEC_DESC* sec_desc); 432 433 REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16 num_lists, 434 REGFI_SUBKEY_LIST** lists, 435 bool strict); 436 void regfi_add_message(REGFI_FILE* file, const char* error); 413 437 #endif /* _REGFI_H */
Note: See TracChangeset
for help on using the changeset viewer.