Changeset 162


Ignore:
Timestamp:
12/07/09 15:12:13 (15 years ago)
Author:
tim
Message:

added UTF-16LE support for value names

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/regfi.h

    r161 r162  
    137137
    138138/* Flags for the vk records */
    139 /* XXX: This next flag may be incorrect.  According to Jeffrey Muir,
    140 *       this may actually indicate that the value name is stored in
    141 *       UTF-16LE.
    142 */
    143 #define REGFI_VK_FLAG_NAME_PRESENT 0x0001
     139#define REGFI_VK_FLAG_ASCIINAME    0x0001
    144140#define REGFI_VK_DATA_IN_OFFSET    0x80000000
    145141#define REGFI_VK_MAX_DATA_LENGTH   1024*1024  /* XXX: This is arbitrary */
     
    331327  uint32 type;
    332328  uint8  magic[REGFI_CELL_MAGIC_SIZE];
    333   uint16 flag;
     329  uint16 flags;
    334330  uint16 unknown1;
    335331  bool data_in_offset;
     
    591587                                     bool strict);
    592588REGFI_VK_REC*         regfi_load_value(REGFI_FILE* file, uint32 offset,
     589                                       REGFI_ENCODING output_encoding,
    593590                                       bool strict);
    594591REGFI_SUBKEY_LIST*    regfi_load_subkeylist(REGFI_FILE* file, uint32 offset,
  • trunk/lib/regfi.c

    r161 r162  
    973973/******************************************************************************
    974974 ******************************************************************************/
    975 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset, bool strict)
     975REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset,
     976                               REGFI_ENCODING output_encoding, bool strict)
    976977{
    977978  REGFI_VK_REC* ret_val = NULL;
    978   int32 max_size;
     979  int32 max_size, tmp_size;
     980  REGFI_ENCODING from_encoding;
    979981
    980982  max_size = regfi_calc_maxsize(file, offset);
     
    986988    return NULL;
    987989
    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  }
    9891023
    9901024  return ret_val;
     
    16851719    {
    16861720      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);
    16881723    }
    16891724  }
     
    24672502  ret_val->data = NULL;
    24682503  ret_val->valuename = NULL;
     2504  ret_val->valuename_raw = NULL;
    24692505 
    24702506  if(ret_val->cell_size > max_size)
     
    25022538  ret_val->data_off = IVAL(vk_header, 0x8);
    25032539  ret_val->type = IVAL(vk_header, 0xC);
    2504   ret_val->flag = SVAL(vk_header, 0x10);
     2540  ret_val->flags = SVAL(vk_header, 0x10);
    25052541  ret_val->unknown1 = SVAL(vk_header, 0x12);
    25062542
    2507   if(ret_val->flag & REGFI_VK_FLAG_NAME_PRESENT)
     2543  if(ret_val->name_length > 0)
    25082544  {
    25092545    if(ret_val->name_length + REGFI_VK_MIN_LENGTH + 4 > ret_val->cell_size)
     
    25262562      cell_length+=8;
    25272563
    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)
    25302566    {
    25312567      talloc_free(ret_val);
     
    25342570
    25352571    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)
    25372573       || length != ret_val->name_length)
    25382574    {
     
    25422578      return NULL;
    25432579    }
    2544     ret_val->valuename[ret_val->name_length] = '\0';
    2545 
    25462580  }
    25472581  else
  • trunk/src/reglookup.c

    r161 r162  
    5858  const char* str_type = NULL;
    5959
    60   quoted_name = quote_string(vk->valuename, key_special_chars);
     60  if(vk->valuename == NULL)
     61    quoted_name = quote_buffer(vk->valuename_raw, vk->name_length,
     62                               key_special_chars);
     63  else
     64    quoted_name = quote_string(vk->valuename, key_special_chars);
    6165  if (quoted_name == NULL)
    6266  { /* Value names are NULL when we're looking at the "(default)" value.
Note: See TracChangeset for help on using the changeset viewer.