Changeset 115
- Timestamp:
- 05/27/08 18:04:48 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/reglookup-recover.c
r114 r115 422 422 int32 rm_idx; 423 423 const range_list_element* cur_elem; 424 424 425 425 rm_idx = range_list_find(rl, offset); 426 426 if(rm_idx < 0) … … 474 474 { 475 475 cur_elem = range_list_get(unalloc_cells, i); 476 for(j=0; j <= cur_elem->length; j+=8) 477 { 478 key = regfi_parse_nk(f, cur_elem->offset+j, 479 cur_elem->length-j, false); 476 for(j=0; cur_elem->length > REGFI_NK_MIN_LENGTH 477 && j <= cur_elem->length-REGFI_NK_MIN_LENGTH; j+=8) 478 { 479 key = regfi_parse_nk(f, cur_elem->offset+j, 480 cur_elem->length-j, false); 480 481 if(key != NULL) 481 482 { … … 487 488 } 488 489 489 if(!removeRange(unalloc_cells, key->offset, key->cell_size)) 490 if(removeRange(unalloc_cells, key->offset, key->cell_size)) 491 { 492 /* TODO: This ugly hack is needed because unalloc_cells is changing 493 * underneath us when we find things. Need a better approach 494 * so we can parse things single-pass. 495 */ 496 i=0; 497 break; 498 } 499 else 490 500 return 30; 491 501 } … … 531 541 nk->values = regfi_load_valuelist(f, off, nk->num_values, max_length, 532 542 false); 543 values_length = (nk->num_values+1)*sizeof(uint32); 544 if(values_length != (values_length & 0xFFFFFFF8)) 545 values_length = (values_length & 0xFFFFFFF8) + 8; 533 546 534 547 if(nk->values != NULL) 535 548 { 536 if(!range_list_has_range(unalloc_cells, off, nk->cell_size))549 if(!range_list_has_range(unalloc_cells, off, values_length)) 537 550 { /* We've parsed a values-list which isn't in the unallocated list, 538 551 * so prune it. … … 545 558 free(nk->values[j]->data); 546 559 free(nk->values[j]); 547 free(nk->values);548 nk->values = NULL;549 560 } 550 561 } 562 free(nk->values); 563 nk->values = NULL; 551 564 } 552 565 else … … 554 567 * inspect values. 555 568 */ 556 values_length = (nk->num_values+1)*sizeof(uint32);557 if(values_length != (values_length & 0xFFFFFFF8))558 values_length = (values_length & 0xFFFFFFF8) + 8;559 560 569 if(!removeRange(unalloc_cells, off, values_length)) 561 570 return 20; … … 625 634 const range_list_element* cur_elem; 626 635 REGF_VK_REC* vk; 627 uint32 i, j ;636 uint32 i, j, off; 628 637 629 638 for(i=0; i < range_list_size(unalloc_cells); i++) … … 645 654 if(!removeRange(unalloc_cells, vk->offset, vk->cell_size)) 646 655 return 30; 656 657 if(vk->data != NULL && !vk->data_in_offset) 658 { 659 off = vk->data_off+REGF_BLOCKSIZE; 660 if(!range_list_has_range(unalloc_cells, off, 661 vk->data_size)) 662 { /* We've parsed a data cell which isn't in the unallocated 663 * list, so prune it. 664 */ 665 free(vk->data); 666 vk->data = NULL; 667 } 668 else 669 { /*A data record was recovered. Remove from unalloc_cells.*/ 670 if(!removeRange(unalloc_cells, off, vk->data_size)) 671 return 40; 672 } 673 } 674 675 /* TODO: This ugly hack is needed because unalloc_cells is changing 676 * underneath us when we find things. Need a better approach 677 * so we can parse things single-pass. 678 */ 679 i=0; 680 break; 647 681 } 648 682 } … … 677 711 } 678 712 679 if(!removeRange(unalloc_cells, sk->offset, sk->cell_size)) 713 if(removeRange(unalloc_cells, sk->offset, sk->cell_size)) 714 { 715 /* TODO: This ugly hack is needed because unalloc_cells is changing 716 * underneath us when we find things. Need a better approach 717 * so we can parse things single-pass. 718 */ 719 i = 0; 720 break; 721 } 722 else 680 723 return 30; 681 724 } … … 700 743 REGF_NK_REC* tmp_key; 701 744 REGF_VK_REC* tmp_value; 702 uint32 argi, arge, i, j, ret, num_unalloc_keys;745 uint32 argi, arge, i, j, k, ret, num_unalloc_keys; 703 746 /* uint32 test_offset;*/ 704 747 … … 758 801 } 759 802 803 /*XXX 804 for(i=0,k=0; i < range_list_size(unalloc_cells); i++) 805 { 806 cur_elem = range_list_get(unalloc_cells, i); 807 k+=cur_elem->length; 808 } 809 printf("UNALLOC=%d\n", k); 810 printf("UNALLOC_CELL_COUNT=%d\n", range_list_size(unalloc_cells)); 811 XXX*/ 812 760 813 unalloc_keys = range_list_new(); 761 814 if(unalloc_keys == NULL) … … 858 911 } 859 912 913 /*XXX 914 for(i=0,j=0; i < range_list_size(unalloc_cells); i++) 915 { 916 cur_elem = range_list_get(unalloc_cells, i); 917 j+=cur_elem->length; 918 } 919 printf("PARSED_UNALLOC=%d\n", k-j); 920 XXX*/ 921 860 922 if(print_leftover) 861 923 { … … 863 925 { 864 926 cur_elem = range_list_get(unalloc_cells, i); 865 printf("0x%X,%d,", cur_elem->offset, cur_elem->length);866 867 927 printCell(f, cur_elem->offset); 868 928 }
Note: See TracChangeset
for help on using the changeset viewer.