winedump: Simplify guid dumping.

This commit is contained in:
Eric Pouech 2007-02-10 09:10:13 +01:00 committed by Alexandre Julliard
parent 72c52d6d9e
commit ae48ede907
5 changed files with 28 additions and 28 deletions

View file

@ -425,11 +425,9 @@ static void dump_codeview_headers(unsigned long base, unsigned long len)
if (memcmp(signature, "RSDS", 4) == 0)
{
const OMFSignatureRSDS* rsds_data;
char guid_str[40];
rsds_data = (const void *)cv_base;
printf(" Guid: %s\n",
guid_to_string(&rsds_data->guid, guid_str, sizeof(guid_str)));
printf(" Guid: %s\n", get_guid_str(&rsds_data->guid));
printf(" Dunno: %08X\n", rsds_data->unknown);
printf(" Filename: %s\n", rsds_data->name);
return;

View file

@ -1,7 +1,7 @@
/*
* File dumping utility
*
* Copyright 2001,2005 Eric Pouech
* Copyright 2001,2007 Eric Pouech
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -96,13 +96,9 @@ const char *get_time_str(unsigned long _t)
const time_t t = (const time_t)_t;
const char *str = ctime(&t);
size_t len;
static char buf[128];
char* buf;
if (!str) /* not valid time */
{
strcpy(buf, "not valid time");
return buf;
}
if (!str) return "not valid time";
len = strlen(str);
/* FIXME: I don't get the same values from MS' pedump running under Wine...
@ -110,8 +106,12 @@ const char *get_time_str(unsigned long _t)
*/
if (len && str[len-1] == '\n') len--;
if (len >= sizeof(buf)) len = sizeof(buf) - 1;
memcpy( buf, str, len );
buf[len] = 0;
buf = dump_want_n(len + 1);
if (buf)
{
memcpy( buf, str, len );
buf[len] = 0;
}
return buf;
}
@ -200,12 +200,16 @@ const char* get_symbol_str(const char* symname)
return ret;
}
char* guid_to_string(const GUID* guid, char* str, size_t sz)
const char* get_guid_str(const GUID* guid)
{
snprintf(str, sz, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
char* str;
str = dump_want_n(39);
if (str)
sprintf(str, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
return str;
}

View file

@ -279,14 +279,14 @@ static int dump_advertise_info(const char *type)
printf("%s = %s\n", type, avt->bufA);
if (avt->magic == 0xa0000006)
{
char prod_str[40], comp_str[40], feat_str[40];
const char *feat, *comp;
char comp_str[40];
const char *feat, *comp, *prod_str, *feat_str;
GUID guid;
if (base85_to_guid(avt->bufA, &guid))
guid_to_string( &guid, prod_str, sizeof(prod_str) );
prod_str = get_guid_str( &guid );
else
strcpy( prod_str, "?" );
prod_str = "?";
comp = &avt->bufA[20];
feat = strchr(comp,'>');
@ -303,9 +303,9 @@ static int dump_advertise_info(const char *type)
}
if (feat && feat[0] == '>' && base85_to_guid( &feat[1], &guid ))
guid_to_string( &guid, feat_str, sizeof(feat_str) );
feat_str = get_guid_str( &guid );
else
feat_str[0] = 0;
feat_str = "";
printf(" product: %s\n", prod_str);
printf(" component: %s\n", comp_str );
@ -332,7 +332,6 @@ enum FileSig get_kind_lnk(void)
void lnk_dump(void)
{
const LINK_HEADER* hdr;
char guid[40];
offset = 0;
hdr = fetch_block();
@ -340,7 +339,7 @@ void lnk_dump(void)
printf("Header\n");
printf("------\n\n");
printf("Size: %04x\n", hdr->dwSize);
printf("GUID: %s\n", guid_to_string(&hdr->MagicGuid, guid, sizeof(guid)));
printf("GUID: %s\n", get_guid_str(&hdr->MagicGuid));
printf("FileAttr: %08x\n", hdr->dwFileAttr);
printf("FileLength: %08x\n", hdr->dwFileLength);

View file

@ -625,7 +625,6 @@ static void pdb_ds_dump(void)
if (root)
{
const char* ptr;
char guid_str[40];
printf("Root:\n"
"\tVersion: %u\n"
@ -636,7 +635,7 @@ static void pdb_ds_dump(void)
root->Version,
root->TimeDateStamp,
root->Age,
guid_to_string(&root->guid, guid_str, sizeof(guid_str)),
get_guid_str(&root->guid),
root->cbNames);
for (ptr = &root->names[0]; ptr < &root->names[0] + root->cbNames; ptr += strlen(ptr) + 1)
printf("\tString: %s\n", ptr);

View file

@ -236,11 +236,11 @@ void dump_data( const unsigned char *ptr, unsigned int size, const ch
const char* get_time_str( unsigned long );
unsigned int strlenW( const unsigned short *str );
void dump_unicode_str( const unsigned short *str, int len );
const char* get_guid_str(const GUID* guid);
const char* get_symbol_str(const char* symname);
void dump_file_header(const IMAGE_FILE_HEADER *);
void dump_optional_header(const IMAGE_OPTIONAL_HEADER32 *, UINT);
void dump_section(const IMAGE_SECTION_HEADER *);
char* guid_to_string(const GUID* guid, char *str, size_t sz);
enum FileSig get_kind_exec(void);
void dos_dump( void );