diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-30 10:38:52 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-30 10:38:52 (GMT) |
commit | 932ea7c83c07d3982fee605c6dd9895fd2753874 (patch) | |
tree | 766ad53bab9e3e3005334c30e823493de8e84168 /plugins/ropgadgets | |
parent | 1b5d39bfbc48c33a0ea0924b60e48448c8b45dd4 (diff) |
Rewritten the line buffers using generators and on-demand building to save memory.
Diffstat (limited to 'plugins/ropgadgets')
-rw-r--r-- | plugins/ropgadgets/select.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/plugins/ropgadgets/select.c b/plugins/ropgadgets/select.c index 881cd39..0fedfb1 100644 --- a/plugins/ropgadgets/select.c +++ b/plugins/ropgadgets/select.c @@ -1746,11 +1746,7 @@ static gboolean filter_visible_rop_gadgets(GtkTreeModel *model, GtkTreeIter *ite static void add_new_gadgets_for_category(GExeFormat *format, GtkComboBoxText *combo, GtkTreeStore *store, const char *category, GArchInstruction **gadgets, size_t count) { - const char *target; /* Sous-traitance requise */ - GArchProcessor *proc; /* Architecture du binaire */ - MemoryDataSize msize; /* Taille du bus d'adresses */ const GBinContent *content; /* Contenu binaire global */ - GCodeBuffer *buffer; /* Tampon de rassemblement */ size_t i; /* Boucle de parcours */ GArchInstruction *instr; /* Elément de liste de gadgets */ GBufferLine *line; /* Ligne présente à l'adresse */ @@ -1762,21 +1758,10 @@ static void add_new_gadgets_for_category(GExeFormat *format, GtkComboBoxText *co char *content_markup; /* Contenu assemblé de chaîne */ GtkTreeIter iter; /* Point d'insertion */ - /* Définition de l'écosystème nécessaire */ - - target = g_exe_format_get_target_machine(format); - proc = get_arch_processor_for_type(target); - - msize = g_arch_processor_get_memory_size(proc); - - g_object_unref(G_OBJECT(proc)); - content = g_binary_format_get_content(G_BIN_FORMAT(format)); /* Conversion en contenu textuel */ - buffer = g_code_buffer_new(BLC_ASSEMBLY); - for (i = 0; i < count; i++) { /* Parcours des différentes lignes */ @@ -1788,8 +1773,8 @@ static void add_new_gadgets_for_category(GExeFormat *format, GtkComboBoxText *co for (instr = gadgets[i]; instr != NULL; instr = g_arch_instruction_get_next_iter(gadgets[i], instr, ~0)) { - line = g_arch_instruction_print(instr, buffer, msize, content, ASX_INTEL); - if (line == NULL) continue; + line = g_buffer_line_new(NULL, BLC_ASSEMBLY); + g_line_generator_print(G_LINE_GENERATOR(instr), line, -1, 0); if (instr == gadgets[i]) { @@ -1800,6 +1785,8 @@ static void add_new_gadgets_for_category(GExeFormat *format, GtkComboBoxText *co partial_raw = g_buffer_line_get_text(line, BLC_ASSEMBLY_HEAD, BLC_COUNT, false); partial_markup = g_buffer_line_get_text(line, BLC_ASSEMBLY_HEAD, BLC_COUNT, true); + g_object_unref(G_OBJECT(line)); + if (content_raw != NULL) content_raw = stradd(content_raw, " ; "); @@ -1836,8 +1823,6 @@ static void add_new_gadgets_for_category(GExeFormat *format, GtkComboBoxText *co } - g_object_unref(G_OBJECT(buffer)); - g_object_unref(G_OBJECT(content)); /* Rajout de la catégorie et filtre au besoin */ |