Commit b8ae9dcc authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winedump: Fix a couple of issues with types table walking.

Align types to DWORD boundaries. Split types dumping functions into two versions (one without offsets table, the second one with offset table).
parent f2ef7cf4
...@@ -190,7 +190,12 @@ static int dump_cv_sst_global_types(const OMFDirEntry* omfde) ...@@ -190,7 +190,12 @@ static int dump_cv_sst_global_types(const OMFDirEntry* omfde)
data = PRD(fileoffset + sizeof(OMFGlobalTypes) + sizeof(DWORD) * types->cTypes, sz); data = PRD(fileoffset + sizeof(OMFGlobalTypes) + sizeof(DWORD) * types->cTypes, sz);
if (!data) {printf("Can't OMF-SymHash details, aborting\n"); return FALSE;} if (!data) {printf("Can't OMF-SymHash details, aborting\n"); return FALSE;}
codeview_dump_types(data, sz); /* doc says:
* - for NB07 & NB08 (that we don't support yet), offsets are from types
* - for NB09, offsets are from data
* For now, we only support the later
*/
codeview_dump_types_from_offsets(data, (const DWORD*)(types + 1), types->cTypes);
return TRUE; return TRUE;
} }
......
...@@ -507,19 +507,12 @@ static void do_field(const unsigned char* start, const unsigned char* end) ...@@ -507,19 +507,12 @@ static void do_field(const unsigned char* start, const unsigned char* end)
} }
} }
int codeview_dump_types(const void* table, unsigned long len) static void codeview_dump_one_type(unsigned curr_type, const union codeview_type* type)
{ {
unsigned int curr_type = 0x1000; const union codeview_reftype* reftype = (const union codeview_reftype*)type;
const unsigned char*ptr = table;
int i, leaf_len, value; int i, leaf_len, value;
const char* str; const char* str;
while (ptr - (const unsigned char*)table < len)
{
const union codeview_type* type = (const union codeview_type*)ptr;
const union codeview_reftype* reftype = (const union codeview_reftype*)ptr;
int retv = TRUE;
switch (type->generic.id) switch (type->generic.id)
{ {
case LF_POINTER_V1: case LF_POINTER_V1:
...@@ -550,7 +543,6 @@ int codeview_dump_types(const void* table, unsigned long len) ...@@ -550,7 +543,6 @@ int codeview_dump_types(const void* table, unsigned long len)
type->array_v3.idxtype, type->array_v3.elemtype); type->array_v3.idxtype, type->array_v3.elemtype);
break; break;
/* a bitfields is a CodeView specific data type which represent a bitfield /* a bitfields is a CodeView specific data type which represent a bitfield
* in a structure or a class. For now, we store it in a SymTag-like type * in a structure or a class. For now, we store it in a SymTag-like type
* (so that the rest of the process is seamless), but check at udt inclusion * (so that the rest of the process is seamless), but check at udt inclusion
...@@ -571,7 +563,7 @@ int codeview_dump_types(const void* table, unsigned long len) ...@@ -571,7 +563,7 @@ int codeview_dump_types(const void* table, unsigned long len)
case LF_FIELDLIST_V1: case LF_FIELDLIST_V1:
case LF_FIELDLIST_V2: case LF_FIELDLIST_V2:
printf("\t%x => Fieldlist\n", curr_type); printf("\t%x => Fieldlist\n", curr_type);
do_field(reftype->fieldlist.list, ptr + reftype->generic.len + 2); do_field(reftype->fieldlist.list, (const BYTE*)type + reftype->generic.len + 2);
break; break;
case LF_STRUCTURE_V1: case LF_STRUCTURE_V1:
...@@ -685,6 +677,7 @@ int codeview_dump_types(const void* table, unsigned long len) ...@@ -685,6 +677,7 @@ int codeview_dump_types(const void* table, unsigned long len)
type->procedure_v1.call, type->procedure_v1.params, type->procedure_v1.call, type->procedure_v1.params,
type->procedure_v1.arglist); type->procedure_v1.arglist);
break; break;
case LF_PROCEDURE_V2: case LF_PROCEDURE_V2:
printf("\t%x => Procedure V2 ret_type:%x unk:%x (#%u args_type:%x)\n", printf("\t%x => Procedure V2 ret_type:%x unk:%x (#%u args_type:%x)\n",
curr_type, type->procedure_v2.rvtype, curr_type, type->procedure_v2.rvtype,
...@@ -709,6 +702,7 @@ int codeview_dump_types(const void* table, unsigned long len) ...@@ -709,6 +702,7 @@ int codeview_dump_types(const void* table, unsigned long len)
printf("\t%x => Modifier V1 type:%x modif:%x\n", printf("\t%x => Modifier V1 type:%x modif:%x\n",
curr_type, type->modifier_v1.type, type->modifier_v1.attribute); curr_type, type->modifier_v1.type, type->modifier_v1.attribute);
break; break;
case LF_MODIFIER_V2: case LF_MODIFIER_V2:
printf("\t%x => Modifier V2 type:%x modif:%x\n", printf("\t%x => Modifier V2 type:%x modif:%x\n",
curr_type, type->modifier_v2.type, type->modifier_v2.attribute); curr_type, type->modifier_v2.type, type->modifier_v2.attribute);
...@@ -786,12 +780,33 @@ int codeview_dump_types(const void* table, unsigned long len) ...@@ -786,12 +780,33 @@ int codeview_dump_types(const void* table, unsigned long len)
dump_data((const void*)type, type->generic.len + 2, ""); dump_data((const void*)type, type->generic.len + 2, "");
break; break;
} }
}
if (!retv) int codeview_dump_types_from_offsets(const void* table, const DWORD* offsets, unsigned num_types)
return FALSE; {
unsigned long i;
for (i = 0; i < num_types; i++)
{
codeview_dump_one_type(0x1000 + i,
(const union codeview_type*)((const char*)table + offsets[i]));
}
return TRUE;
}
int codeview_dump_types_from_block(const void* table, unsigned long len)
{
unsigned int curr_type = 0x1000;
const unsigned char*ptr = table;
while (ptr - (const unsigned char*)table < len)
{
const union codeview_type* type = (const union codeview_type*)ptr;
codeview_dump_one_type(curr_type, type);
curr_type++; curr_type++;
ptr += type->generic.len + 2; ptr += (type->generic.len + 2 + 3) & ~3;
} }
return TRUE; return TRUE;
......
...@@ -458,7 +458,7 @@ static void pdb_dump_types(struct pdb_reader* reader) ...@@ -458,7 +458,7 @@ static void pdb_dump_types(struct pdb_reader* reader)
types->search_len, types->search_len,
types->unknown_offset, types->unknown_offset,
types->unknown_len); types->unknown_len);
codeview_dump_types((const char*)types + types->type_offset, types->type_size); codeview_dump_types_from_block((const char*)types + types->type_offset, types->type_size);
free((char*)types); free((char*)types);
} }
......
...@@ -259,7 +259,8 @@ void emf_dump( void ); ...@@ -259,7 +259,8 @@ void emf_dump( void );
enum FileSig get_kind_pdb(void); enum FileSig get_kind_pdb(void);
void pdb_dump(void); void pdb_dump(void);
int codeview_dump_symbols(const void* root, unsigned long size); int codeview_dump_symbols(const void* root, unsigned long size);
int codeview_dump_types(const void* table, unsigned long len); int codeview_dump_types_from_offsets(const void* table, const DWORD* offsets, unsigned num_types);
int codeview_dump_types_from_block(const void* table, unsigned long len);
void dump_stabs(const void* pv_stabs, unsigned szstabs, const char* stabstr, unsigned szstr); void dump_stabs(const void* pv_stabs, unsigned szstabs, const char* stabstr, unsigned szstr);
void dump_codeview(unsigned long ptr, unsigned long len); void dump_codeview(unsigned long ptr, unsigned long len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment