- Timestamp:
- 03/13/10 12:56:36 (15 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/common.c
r172 r178 38 38 39 39 40 /* Windows is lame */ 41 #ifdef O_BINARY 42 #define REGLOOKUP_OPEN_FLAGS O_RDONLY|O_BINARY 43 #else 44 #define REGLOOKUP_OPEN_FLAGS O_RDONLY 45 #endif 46 47 40 48 void bailOut(int code, char* message) 41 49 { … … 337 345 return ret_val; 338 346 } 347 348 349 int openHive(const char* filename) 350 { 351 int ret_val; 352 353 /* open an existing file */ 354 if ((ret_val = open(filename, REGLOOKUP_OPEN_FLAGS)) == -1) 355 { 356 fprintf(stderr, "ERROR: Failed to open hive. Error returned: %s\n", 357 strerror(errno)); 358 return -1; 359 } 360 361 return ret_val; 362 } 363 364 365 void formatTime(const REGFI_NTTIME* nttime, char* output) 366 { 367 time_t tmp_time[1]; 368 struct tm* tmp_time_s = NULL; 369 370 *tmp_time = regfi_nt2unix_time(nttime); 371 tmp_time_s = gmtime(tmp_time); 372 strftime(output, 373 (4+1+2+1+2)+1+(2+1+2+1+2)+1, 374 "%Y-%m-%d %H:%M:%S", 375 tmp_time_s); 376 } -
trunk/src/reglookup-recover.c
r173 r178 40 40 41 41 42 char* getQuotedData( int fd, uint32_t offset, uint32_t length)42 char* getQuotedData(REGFI_RAW_FILE* file_cb, uint32_t offset, uint32_t length) 43 43 { 44 44 uint8_t* buf; … … 46 46 uint32_t len; 47 47 48 if(( lseek(fd, offset, SEEK_SET)) == -1)48 if((regfi_seek(file_cb, offset, SEEK_SET)) == -1) 49 49 return NULL; 50 50 … … 54 54 55 55 len = length; 56 if((regfi_read(f d, buf, &length) != 0) || length != len)56 if((regfi_read(file_cb, buf, &length) != 0) || length != len) 57 57 { 58 58 free(buf); … … 69 69 void printKey(REGFI_FILE* f, REGFI_NK_REC* nk, const char* prefix) 70 70 { 71 char mtime[20]; 72 time_t tmp_time[1]; 73 struct tm* tmp_time_s = NULL; 71 char mtime[24]; 74 72 char* quoted_name = NULL; 75 73 char* quoted_raw = ""; 76 74 77 *tmp_time = regfi_nt2unix_time(&nk->mtime); 78 tmp_time_s = gmtime(tmp_time); 79 strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s); 80 75 formatTime(&nk->mtime, mtime); 76 81 77 /* XXX: Add command line option to choose output encoding */ 82 78 regfi_interpret_keyname(f, nk, REGFI_ENCODING_ASCII, true); … … 96 92 97 93 if(print_parsedraw) 98 quoted_raw = getQuotedData(f-> fd, nk->offset, nk->cell_size);94 quoted_raw = getQuotedData(f->cb, nk->offset, nk->cell_size); 99 95 100 96 printf("%.8X,%.8X,KEY,%s,%s,%s,%d,,,,,,,,%s\n", nk->offset, nk->cell_size, … … 162 158 163 159 if(print_parsedraw) 164 quoted_raw = getQuotedData(f-> fd, vk->offset, vk->cell_size);160 quoted_raw = getQuotedData(f->cb, vk->offset, vk->cell_size); 165 161 166 162 str_type = regfi_type_val2str(vk->type); … … 195 191 196 192 if(print_parsedraw) 197 quoted_raw = getQuotedData(f-> fd, sk->offset, sk->cell_size);193 quoted_raw = getQuotedData(f->cb, sk->offset, sk->cell_size); 198 194 199 195 if(owner == NULL) … … 229 225 bool unalloc; 230 226 231 if(!regfi_parse_cell(f-> fd, offset, NULL, 0, &cell_length, &unalloc))227 if(!regfi_parse_cell(f->cb, offset, NULL, 0, &cell_length, &unalloc)) 232 228 return 1; 233 229 234 quoted_buf = getQuotedData(f-> fd, offset, cell_length);230 quoted_buf = getQuotedData(f->cb, offset, cell_length); 235 231 if(quoted_buf == NULL) 236 232 return 2; … … 490 486 max_size = regfi_calc_maxsize(file, offset); 491 487 if(max_size >= 0 492 && regfi_parse_cell(file-> fd, offset, NULL, 0,488 && regfi_parse_cell(file->cb, offset, NULL, 0, 493 489 &cell_length, &unalloc) 494 490 && (cell_length & 0x00000007) == 0 … … 789 785 REGFI_VK_REC* tmp_value; 790 786 uint32_t argi, arge, i, j, ret, num_unalloc_keys; 791 787 int fd; 788 792 789 /* Process command line arguments */ 793 790 if(argc < 2) … … 826 823 bailOut(REGLOOKUP_EXIT_OSERR, "ERROR: Memory allocation problem.\n"); 827 824 828 f = regfi_open(registry_file);829 if(f == NULL)825 fd = openHive(registry_file); 826 if(fd < 0) 830 827 { 831 828 fprintf(stderr, "ERROR: Couldn't open registry file: %s\n", registry_file); 832 829 bailOut(REGLOOKUP_EXIT_NOINPUT, ""); 833 830 } 831 832 f = regfi_alloc(fd); 833 if(f == NULL) 834 { 835 close(fd); 836 bailOut(REGLOOKUP_EXIT_NOINPUT, "ERROR: Failed to create REGFI_FILE structure.\n"); 837 } 838 834 839 if(print_verbose) 835 840 regfi_set_message_mask(f, REGFI_MSG_ERROR|REGFI_MSG_WARN|REGFI_MSG_INFO); … … 991 996 range_list_free(unalloc_sks); 992 997 998 regfi_free(f); 999 close(fd); 1000 993 1001 return 0; 994 1002 } -
trunk/src/reglookup.c
r172 r178 296 296 char* sacl = NULL; 297 297 char* dacl = NULL; 298 char mtime[24]; 298 299 char* quoted_classname; 299 char mtime[20];300 time_t tmp_time[1];301 struct tm* tmp_time_s = NULL;302 300 const REGFI_SK_REC* sk; 303 301 const REGFI_NK_REC* k = regfi_iterator_cur_key(iter); 304 302 REGFI_CLASSNAME* classname; 305 303 306 *tmp_time = regfi_nt2unix_time(&k->mtime); 307 tmp_time_s = gmtime(tmp_time); 308 strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s); 304 formatTime(&k->mtime, mtime); 309 305 310 306 if(print_security && (sk=regfi_iterator_cur_sk(iter))) … … 563 559 char** path = NULL; 564 560 REGFI_ITERATOR* iter; 565 int retr_path_ret ;561 int retr_path_ret, fd; 566 562 uint32_t argi, arge; 567 563 … … 624 620 bailOut(REGLOOKUP_EXIT_OSERR, "ERROR: Memory allocation problem.\n"); 625 621 626 f = regfi_open(registry_file);627 if(f == NULL)622 fd = openHive(registry_file); 623 if(fd < 0) 628 624 { 629 625 fprintf(stderr, "ERROR: Couldn't open registry file: %s\n", registry_file); 630 626 bailOut(REGLOOKUP_EXIT_NOINPUT, ""); 627 } 628 629 f = regfi_alloc(fd); 630 if(f == NULL) 631 { 632 close(fd); 633 bailOut(REGLOOKUP_EXIT_NOINPUT, "ERROR: Failed to create REGFI_FILE structure.\n"); 631 634 } 632 635 … … 675 678 676 679 regfi_iterator_free(iter); 677 regfi_close(f); 680 regfi_free(f); 681 close(fd); 678 682 679 683 return 0;
Note: See TracChangeset
for help on using the changeset viewer.