- Timestamp:
- 09/04/05 21:19:05 (19 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/regfio.h
r53 r54 57 57 #define REG_BINARY 3 58 58 #define REG_DWORD 4 59 #define REG_DWORD_LE 4 60 #define REG_DWORD_BE 5 59 #define REG_DWORD_LE 4 /* DWORD, little endian */ 60 #define REG_DWORD_BE 5 /* DWORD, big endian */ 61 61 #define REG_LINK 6 62 62 #define REG_MULTI_SZ 7 … … 95 95 #define NK_TYPE_ROOTKEY 0x002c 96 96 97 #define HBIN_STORE_REF(x, y) { x->hbin = y; y->ref_count++ }; 98 #define HBIN_REMOVE_REF(x, y) { x->hbin = NULL; y->ref_count-- /* if the count == 0; we can clean up */ }; 97 #define HBIN_STORE_REF(x, y) { x->hbin = y; y->ref_count++ }; 98 /* if the count == 0; we can clean up */ 99 #define HBIN_REMOVE_REF(x, y){ x->hbin = NULL; y->ref_count-- }; 99 100 100 101 … … 107 108 uint32 free_off; /* offset to free space within the hbin record */ 108 109 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) */ 110 int ref_count; /* how many active records are pointing to this 111 * block (not used currently) 112 */ 110 113 111 114 uint8 header[HBIN_HDR_SIZE]; /* "hbin" */ 112 115 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 */ 116 uint32 block_size; /* block size of this block is 117 * usually a multiple of 4096Kb 118 */ 119 prs_struct ps; /* data */ 115 120 bool dirty; /* has this hbin block been modified? */ 116 121 } REGF_HBIN; 117 122 118 123 /* ??? List -- list of key offsets and hashed names for consistency */ 119 120 124 typedef struct { 121 125 uint32 nk_off; … … 124 128 125 129 typedef struct { 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) */ 130 REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing 131 * this nk record 132 */ 133 uint32 hbin_off; /* offset from beginning of this hbin block */ 134 uint32 rec_size; /* ((start_offset - end_offset) & 0xfffffff8) */ 129 135 130 136 uint8 header[REC_HDR_SIZE]; … … 136 142 137 143 typedef struct { 138 REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing this nk record */ 144 REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing 145 * this nk record 146 */ 139 147 uint32 hbin_off; /* offset from beginning of this hbin block */ 140 148 uint32 rec_size; /* ((start_offset - end_offset) & 0xfffffff8) */ 141 uint32 rec_off; 149 uint32 rec_off; /* offset stored in the value list */ 142 150 143 151 uint8 header[REC_HDR_SIZE]; … … 156 164 typedef struct _regf_sk_rec { 157 165 struct _regf_sk_rec *next, *prev; 158 REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing this nk record */ 166 REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing 167 * this nk record 168 */ 159 169 uint32 hbin_off; /* offset from beginning of this hbin block */ 160 170 uint32 rec_size; /* ((start_offset - end_offset) & 0xfffffff8) */ 161 171 162 uint32 sk_off; /* offset parsed from NK record used as a key 163 to lookup reference to this SK record */ 172 uint32 sk_off; /* offset parsed from NK record used as a key 173 * to lookup reference to this SK record 174 */ 164 175 165 176 uint8 header[REC_HDR_SIZE]; … … 174 185 175 186 typedef struct { 176 REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing this nk record */ 187 REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing 188 * this nk record 189 */ 177 190 uint32 hbin_off; /* offset from beginning of this hbin block */ 178 191 uint32 subkey_index; /* index to next subkey record to return */ … … 180 193 181 194 /* header information */ 182 183 195 uint8 header[REC_HDR_SIZE]; 184 196 uint16 key_type; … … 190 202 191 203 /* 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 */ 204 uint32 max_bytes_subkeyname; /* max subkey name * 2 */ 205 uint32 max_bytes_subkeyclassname; /* max subkey classname length (as if) */ 206 uint32 max_bytes_valuename; /* max valuename * 2 */ 207 uint32 max_bytes_value; /* max value data size */ 197 208 198 209 /* unknowns */ 199 200 uint32 unk_index; /* nigel says run time index ? */ 210 uint32 unk_index; /* nigel says run time index ? */ 201 211 202 212 /* children */ 203 204 213 uint32 num_subkeys; 205 214 uint32 subkeys_off; /* hash records that point to NK records */ 206 215 uint32 num_values; 207 216 uint32 values_off; /* value lists which point to VK records */ 208 uint32 sk_off; 217 uint32 sk_off; /* offset to SK record */ 209 218 210 219 /* link in the other records here */ 211 212 220 REGF_LF_REC subkeys; 213 221 REGF_VK_REC *values; … … 220 228 typedef struct { 221 229 /* 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 */ 230 int fd; /* file descriptor */ 231 int open_flags; /* flags passed to the open() call */ 232 void *mem_ctx; /* memory context for run-time file access information */ 233 REGF_HBIN *block_list; /* list of open hbin blocks */ 227 234 228 235 /* file format information */ 229 236 230 237 uint8 header[REGF_HDR_SIZE]; /* "regf" */ 231 uint32 data_offset; /* offset to record in the first (or any?) hbin block */ 238 uint32 data_offset; /* offset to record in the first (or any?) 239 * hbin block 240 */ 232 241 uint32 last_block; /* offset to last hbin block in file */ 233 242 uint32 checksum; /* XOR of bytes 0x0000 - 0x01FB */ 234 243 NTTIME mtime; 235 244 236 REGF_SK_REC *sec_desc_list; /* list of security descriptors referenced by NK records */ 245 REGF_SK_REC *sec_desc_list; /* list of security descriptors referenced 246 * by NK records 247 */ 237 248 238 249 /* unknowns used to simply writing */ 239 240 250 uint32 unknown1; 241 251 uint32 unknown2; … … 247 257 248 258 259 /******************************************************************************/ 249 260 /* Function Declarations */ 250 261 251 262 const char* regfio_type_val2str(unsigned int val); 252 263 int regfio_type_str2val(const char* str); -
trunk/src/reglookup.c
r53 r54 184 184 185 185 /* XXX: this MULTI_SZ parser is pretty inefficient. Should be 186 * redone with fewer malloc and better string concatenation.186 * redone with fewer malloc calls and better string concatenation. 187 187 */ 188 188 case REG_MULTI_SZ: … … 317 317 if (buf == NULL) 318 318 return NULL; 319 buf[0] = '/'; 320 buf[1] = '\0'; 319 buf[0] = '\0'; 321 320 322 321 iter = void_stack_iterator_new(nk_stack); … … 472 471 473 472 474 /* XXX: this function is god-awful. Needs to be re-designed. */473 /* XXX: this function is awful. Needs to be re-designed. */ 475 474 void printKeyTree(REGF_FILE* f, void_stack* nk_stack, char* prefix) 476 475 { … … 479 478 char* path = NULL; 480 479 char* val_path = NULL; 481 482 480 int key_type = regfio_type_str2val("KEY"); 483 481 … … 486 484 cur->subkey_index = 0; 487 485 path = stack2Path(nk_stack); 488 486 487 if(print_verbose) 488 { 489 if(prefix[0] == '\0') 490 fprintf(stderr, "VERBOSE: Printing key tree under path: /\n"); 491 else 492 fprintf(stderr, "VERBOSE: Printing key tree under path: %s\n", 493 prefix); 494 } 489 495 490 496 val_path = (char*)malloc(strlen(prefix)+strlen(path)+1); 491 497 sprintf(val_path, "%s%s", prefix, path); 498 if(val_path[0] == '\0') 499 { 500 val_path[0] = '/'; 501 val_path[1] = '\0'; 502 } 503 492 504 if(!type_filter_enabled || (key_type == type_filter)) 493 505 printKey(cur, val_path); 494 495 506 if(!type_filter_enabled || (key_type != type_filter)) 496 507 printValueList(cur, val_path); … … 527 538 } 528 539 } 540 if(print_verbose) 541 fprintf(stderr, "VERBOSE: Finished printing key tree.\n"); 529 542 } 530 543 … … 559 572 cur = (REGF_NK_REC*)void_stack_cur(nk_stack); 560 573 574 if(print_verbose) 575 fprintf(stderr, "VERBOSE: Beginning retrieval of specified path: %s\n", 576 path_filter); 577 561 578 while(void_stack_size(path_stack) > 1) 562 579 { … … 575 592 } 576 593 } 594 if(print_verbose && !found_cur) 595 fprintf(stderr, "VERBOSE: Could not find KEY '%s' in specified path.\n", 596 cur_str); 597 577 598 free(cur_str); 578 579 599 if(!found_cur) 580 600 return 1; … … 583 603 /* Last round, search value and key records */ 584 604 cur_str = (char*)void_stack_pop(path_stack); 605 606 if(print_verbose) 607 fprintf(stderr, "VERBOSE: Searching values for last component" 608 " of specified path.\n"); 585 609 586 610 for(i=0; (i < cur->num_values); i++) … … 594 618 if(path != NULL) 595 619 free(path); 620 621 if(print_verbose) 622 fprintf(stderr, "VERBOSE: Found final path element as value.\n"); 623 596 624 return 0; 597 625 } 598 626 } 627 628 if(print_verbose) 629 fprintf(stderr, "VERBOSE: Searching keys for last component" 630 " of specified path.\n"); 599 631 600 632 while((sub = regfio_fetch_subkey(f, cur)) != NULL) … … 611 643 strcat(prefix, "/"); 612 644 strcat(prefix, sub->keyname); 645 646 if(print_verbose) 647 fprintf(stderr, "VERBOSE: Found final path element as key.\n"); 648 613 649 printKeyTree(f, sub_nk_stack, prefix); 650 614 651 return 0; 615 652 } 616 653 } 654 655 if(print_verbose) 656 fprintf(stderr, "VERBOSE: Could not find last element of path.\n"); 617 657 618 658 return 1;
Note: See TracChangeset
for help on using the changeset viewer.