summaryrefslogtreecommitdiff
path: root/plugins/ropgadgets
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-12-29 10:30:28 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-12-29 10:30:28 (GMT)
commit9f9041e11efa71cb043425cd5e89daea0247e76c (patch)
tree84d8704c291a5efef46af1e14a2aa3544dc29455 /plugins/ropgadgets
parent403a0519ec85a156a7f306b045d9cab619302473 (diff)
Cut binary data into several areas using all the available CPUs and less memory.
Diffstat (limited to 'plugins/ropgadgets')
-rw-r--r--plugins/ropgadgets/finder.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/plugins/ropgadgets/finder.c b/plugins/ropgadgets/finder.c
index 6a2283c..98871b5 100644
--- a/plugins/ropgadgets/finder.c
+++ b/plugins/ropgadgets/finder.c
@@ -323,6 +323,7 @@ found_rop_list *list_all_gadgets(GExeFormat *format, unsigned int max_depth, upd
found_rop_list *result; /* Liste de listes à renvoyer */
const char *target; /* Sous-traitance requise */
search_domain domain; /* Outils pour la recherche */
+ GBinPortion *portions; /* Couche première de portions */
GProcContext **contexts; /* Contextes pour recherches */
char **names; /* Désignations humaines liées */
size_t i; /* Boucle de parcours */
@@ -337,7 +338,35 @@ found_rop_list *list_all_gadgets(GExeFormat *format, unsigned int max_depth, upd
target = g_exe_format_get_target_machine(format);
domain.proc = get_arch_processor_for_type(target);
- domain.exe_ranges = g_exe_format_get_x_ranges(format, &domain.exe_count);
+ bool collect_x_ranges(GBinPortion *portion, GBinPortion *parent, BinaryPortionVisit visit, void *unused)
+ {
+ const mrange_t *range;
+
+ if (visit == BPV_SHOW)
+ {
+ if (g_binary_portion_get_rights(portion) & PAC_EXEC)
+ {
+ range = g_binary_portion_get_range(portion);
+
+ domain.exe_ranges = (mrange_t *)realloc(domain.exe_ranges, ++domain.exe_count * sizeof(mrange_t));
+ copy_mrange(&domain.exe_ranges[domain.exe_count - 1], range);
+
+ }
+
+ }
+
+ return true;
+
+ }
+
+ domain.exe_ranges = NULL;
+ domain.exe_count = 0;
+
+ portions = g_exe_format_get_portions(format);
+
+ g_binary_portion_visit(portions, (visit_portion_fc)collect_x_ranges, NULL);
+
+ g_object_unref(G_OBJECT(portions));
/* Récupération des différents contextes */