From ea6b7898cc3b7e5b8955cab67564c9e062e287e0 Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 17 Nov 2016 21:39:38 -0500 Subject: reader: pe_read_coff_symbl(): initial integration. --- src/output/pe_output_image_symbols.c | 51 +++++++++--------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/src/output/pe_output_image_symbols.c b/src/output/pe_output_image_symbols.c index f55adff..e645948 100644 --- a/src/output/pe_output_image_symbols.c +++ b/src/output/pe_output_image_symbols.c @@ -17,12 +17,10 @@ int pe_output_image_symbols( const struct pe_image_meta * meta, FILE * fout) { - unsigned i,bias; - uint32_t roffset; - struct pe_coff_symbol * symtbl; - char buf[24]; + unsigned i; char * mark; - const char * name; + struct pe_coff_symbol * symtbl; + struct pe_meta_coff_symbol symrec; const char * dash = ""; if (!fout) @@ -38,42 +36,19 @@ int pe_output_image_symbols( mark = (char *)meta->image.addr; symtbl = (struct pe_coff_symbol *)(mark + meta->coff.ptr_to_sym_tbl); - for (i=0,bias=0; icoff.num_of_syms; i++,bias=0) { - if (symtbl[i].storage_class[0] == PE_IMAGE_SYM_CLASS_FILE) - if (symtbl[i].num_of_aux_symbols[0]) - if (!symtbl[i+1].value[0]) - bias = 1; - - i += bias; - - if (!bias && (symtbl[i].storage_class[0] == PE_IMAGE_SYM_CLASS_FILE) - && symtbl[i].num_of_aux_symbols[0]) { - memset(buf,0,sizeof(buf)); - memcpy(buf,symtbl[i+1].name,sizeof(*symtbl)); - name = buf; + for (i=0; icoff.num_of_syms; i++) { + pe_read_coff_symbol( + &symtbl[i],&symrec, + &meta->coff,meta->image.addr); - } else if (symtbl[i].name[0]) { - memset(buf,0,sizeof(buf)); - memcpy(buf,symtbl[i].name,sizeof(symtbl->name)); - name = buf; - - } else if (!symtbl[i].name[1] && !symtbl[i].name[2] && !symtbl[i].name[3]) { - roffset = pe_read_long(&symtbl[i].name[4]); - name = (roffset < meta->coff.size_of_string_tbl) - ? mark + meta->coff.ptr_to_string_tbl + roffset - : 0; - } else { - name = 0; - } + if (fprintf(fout,"%s%s\n", + dash, + symrec.long_name + ? symrec.long_name + : symrec.name) < 0) + return PERK_FILE_ERROR(dctx); - i -= bias; i += symtbl[i].num_of_aux_symbols[0]; - - - if (name) { - if (fprintf(fout,"%s%s\n",dash,name) < 0) - return PERK_FILE_ERROR(dctx); - } } return 0; -- cgit v1.2.3