summaryrefslogtreecommitdiff
path: root/src/format/executable.c
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/executable.c
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/executable.c')
-rw-r--r--src/format/executable.c56
1 files changed, 56 insertions, 0 deletions
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] *
* *