Changeset 58 for trunk/src/reglookup.c


Ignore:
Timestamp:
10/01/05 20:51:46 (19 years ago)
Author:
tim
Message:

fixed DWORD output bugs

added support for DWORD_BE (big endian)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/reglookup.c

    r56 r58  
    171171
    172172  case REG_DWORD:
    173     ascii_max = sizeof(char)*10;
    174     ascii = malloc(ascii_max+1);
     173    ascii_max = sizeof(char)*11;
     174    ascii = malloc(ascii_max);
    175175    if(ascii == NULL)
    176176      return NULL;
    177177
    178     if (*(int *)datap == 0)
    179       snprintf((char*)ascii, ascii_max, "0");
    180     else
    181       snprintf((char*)ascii, ascii_max, "0x%x", *(int *)datap);
     178    snprintf((char*)ascii, ascii_max, "0x%.2X%.2X%.2X%.2X",
     179             datap[0], datap[1], datap[2], datap[3]);
     180    return ascii;
     181    break;
     182
     183  case REG_DWORD_BE:
     184    ascii_max = sizeof(char)*11;
     185    ascii = malloc(ascii_max);
     186    if(ascii == NULL)
     187      return NULL;
     188
     189    snprintf((char*)ascii, ascii_max, "0x%.2X%.2X%.2X%.2X",
     190             datap[3], datap[2], datap[1], datap[0]);
    182191    return ascii;
    183192    break;
Note: See TracChangeset for help on using the changeset viewer.