- Timestamp:
- 12/07/09 15:12:13 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/regfi.c
r161 r162 973 973 /****************************************************************************** 974 974 ******************************************************************************/ 975 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset, bool strict) 975 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset, 976 REGFI_ENCODING output_encoding, bool strict) 976 977 { 977 978 REGFI_VK_REC* ret_val = NULL; 978 int32 max_size; 979 int32 max_size, tmp_size; 980 REGFI_ENCODING from_encoding; 979 981 980 982 max_size = regfi_calc_maxsize(file, offset); … … 986 988 return NULL; 987 989 988 /* XXX: convert valuename to proper encoding if necessary */ 990 from_encoding = (ret_val->flags & REGFI_VK_FLAG_ASCIINAME) 991 ? REGFI_ENCODING_ASCII : REGFI_ENCODING_UTF16LE; 992 993 if(from_encoding == output_encoding) 994 { 995 ret_val->valuename_raw = talloc_realloc(ret_val, ret_val->valuename_raw, 996 uint8, ret_val->name_length+1); 997 ret_val->valuename_raw[ret_val->name_length] = '\0'; 998 ret_val->valuename = (char*)ret_val->valuename_raw; 999 } 1000 else 1001 { 1002 ret_val->valuename = talloc_array(ret_val, char, ret_val->name_length+1); 1003 if(ret_val->valuename == NULL) 1004 { 1005 regfi_free_value(ret_val); 1006 return NULL; 1007 } 1008 1009 tmp_size = regfi_conv_charset(regfi_encoding_int2str(from_encoding), 1010 regfi_encoding_int2str(output_encoding), 1011 ret_val->valuename_raw, ret_val->valuename, 1012 ret_val->name_length, ret_val->name_length+1); 1013 if(tmp_size < 0) 1014 { 1015 regfi_add_message(file, REGFI_MSG_WARN, "Error occurred while converting" 1016 " valuename to encoding %s. Error message: %s", 1017 regfi_encoding_int2str(output_encoding), 1018 strerror(-tmp_size)); 1019 talloc_free(ret_val->valuename); 1020 ret_val->valuename = NULL; 1021 } 1022 } 989 1023 990 1024 return ret_val; … … 1685 1719 { 1686 1720 voffset = i->cur_key->values->elements[i->cur_value]; 1687 ret_val = regfi_load_value(i->f, voffset+REGFI_REGF_SIZE, true); 1721 ret_val = regfi_load_value(i->f, voffset+REGFI_REGF_SIZE, 1722 i->string_encoding, true); 1688 1723 } 1689 1724 } … … 2467 2502 ret_val->data = NULL; 2468 2503 ret_val->valuename = NULL; 2504 ret_val->valuename_raw = NULL; 2469 2505 2470 2506 if(ret_val->cell_size > max_size) … … 2502 2538 ret_val->data_off = IVAL(vk_header, 0x8); 2503 2539 ret_val->type = IVAL(vk_header, 0xC); 2504 ret_val->flag = SVAL(vk_header, 0x10);2540 ret_val->flags = SVAL(vk_header, 0x10); 2505 2541 ret_val->unknown1 = SVAL(vk_header, 0x12); 2506 2542 2507 if(ret_val-> flag & REGFI_VK_FLAG_NAME_PRESENT)2543 if(ret_val->name_length > 0) 2508 2544 { 2509 2545 if(ret_val->name_length + REGFI_VK_MIN_LENGTH + 4 > ret_val->cell_size) … … 2526 2562 cell_length+=8; 2527 2563 2528 ret_val->valuename = talloc_array(ret_val, char, ret_val->name_length+1);2529 if(ret_val->valuename == NULL)2564 ret_val->valuename_raw = talloc_array(ret_val, uint8, ret_val->name_length); 2565 if(ret_val->valuename_raw == NULL) 2530 2566 { 2531 2567 talloc_free(ret_val); … … 2534 2570 2535 2571 length = ret_val->name_length; 2536 if((regfi_read(file->fd, (uint8*)ret_val->valuename , &length) != 0)2572 if((regfi_read(file->fd, (uint8*)ret_val->valuename_raw, &length) != 0) 2537 2573 || length != ret_val->name_length) 2538 2574 { … … 2542 2578 return NULL; 2543 2579 } 2544 ret_val->valuename[ret_val->name_length] = '\0';2545 2546 2580 } 2547 2581 else
Note: See TracChangeset
for help on using the changeset viewer.