summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-11-29 09:33:00 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-11-29 09:33:00 (GMT)
commit97d1cc10210cf4ec237e1d9a8b23b120ddef47c5 (patch)
treebe02d0c99cd02917ca31541f4ff0aafa9b9903fc /src/format
parentb4d1a25a22371fa67c5d73bc8fcca08e045556f3 (diff)
Displayed segments in the disassembly view.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@429 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format')
-rw-r--r--src/format/elf/elf.c4
-rw-r--r--src/format/executable.c56
-rw-r--r--src/format/executable.h3
3 files changed, 61 insertions, 2 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c
index 64708ee..6d2138a 100644
--- a/src/format/elf/elf.c
+++ b/src/format/elf/elf.c
@@ -345,7 +345,7 @@ static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *
new = g_binary_portion_new(background);
- sprintf(desc, "%s %s",
+ sprintf(desc, "%s \"%s\"",
_("Segment"),
get_elf_program_type_desc(ELF_PHDR(format, phdr, p_type)));
@@ -391,7 +391,7 @@ static void g_elf_format_refine_portions(const GElfFormat *format, GBinPortion *
else name = NULL;
if (name != NULL)
- sprintf(desc, "%s %s", _("Section"), name);
+ sprintf(desc, "%s \"%s\"", _("Section"), name);
else
sprintf(desc, "%s ???", _("Section"));
diff --git a/src/format/executable.c b/src/format/executable.c
index ea1b398..0ae6934 100644
--- a/src/format/executable.c
+++ b/src/format/executable.c
@@ -162,6 +162,62 @@ GBinPortion *g_exe_format_get_portions(GExeFormat *format)
/******************************************************************************
* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* level = étage des portions à considérer ou -1 pour tous. *
+* count = nombre de portions trouvées et renvoyées. [OUT] *
+* *
+* Description : Fournit une liste choisie de portions d'un binaire. *
+* *
+* Retour : Liste de définitins de zones à libérer après usage. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinPortion **g_exe_format_get_portions_at_level(GExeFormat *format, unsigned int level, size_t *count)
+{
+ GBinPortion **result; /* Liste à retourner */
+
+ typedef struct _portions_list
+ {
+ unsigned int required;
+ GBinPortion **portions;
+ size_t length;
+
+ } portions_list;
+
+ portions_list list; /* Sauvegarde de la liste */
+
+ bool visit_for_level(GBinPortion *portion, portions_list *list)
+ {
+ if (list->required == -1 || g_binary_portion_get_level(portion) == list->required)
+ {
+ list->portions = (GBinPortion **)realloc(list->portions, ++list->length * sizeof(GBinPortion *));
+ list->portions[list->length - 1] = portion;
+ }
+
+ return true;
+
+ }
+
+ list.required = level;
+ list.portions = NULL;
+ list.length = 0;
+
+ g_binary_portion_visit(g_exe_format_get_portions(format), (visit_portion_fc)visit_for_level, &list);
+
+ result = list.portions;
+ *count = list.length;
+
+ qsort(result, *count, sizeof(GBinPortion *), (__compar_fn_t)g_binary_portion_compare);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : format = informations chargées à consulter. *
* count = quantité de zones listées. [OUT] *
* *
diff --git a/src/format/executable.h b/src/format/executable.h
index 10bff42..28ac201 100644
--- a/src/format/executable.h
+++ b/src/format/executable.h
@@ -78,6 +78,9 @@ vmpa_t g_exe_format_get_entry_point(const GExeFormat *);
/* Décrit les différentes portions qui composent le binaire. */
GBinPortion *g_exe_format_get_portions(GExeFormat *);
+/* Fournit une liste choisie de portions d'un binaire. */
+GBinPortion **g_exe_format_get_portions_at_level(GExeFormat *, unsigned int, size_t *);
+
/* Fournit les espaces mémoires des portions exécutables. */
mrange_t *g_exe_format_get_x_ranges(GExeFormat *format, size_t *count);