summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dialogs/gotox.c26
-rw-r--r--src/gui/panels/strings.c31
-rw-r--r--src/gui/panels/symbols.c65
3 files changed, 77 insertions, 45 deletions
diff --git a/src/gui/dialogs/gotox.c b/src/gui/dialogs/gotox.c
index 00ad356..31123ff 100644
--- a/src/gui/dialogs/gotox.c
+++ b/src/gui/dialogs/gotox.c
@@ -32,6 +32,7 @@
#include "../../format/format.h"
+#include "../../format/symiter.h"
#include "../../gtkext/easygtk.h"
#include "../../gtkext/support.h"
@@ -213,10 +214,9 @@ GtkWidget *create_gotox_dialog_for_entry_points(GtkWindow *parent, GLoadedBinary
GtkWidget *result; /* Fenêtre à renvoyer */
GtkTreeStore *store; /* Modèle de gestion */
GBinFormat *format; /* Format associé au binaire */
- GBinSymbol **symbols; /* Symboles à représenter */
- size_t sym_count; /* Qté de symboles présents */
+ sym_iter_t *siter; /* Parcours des symboles */
+ GBinSymbol *symbol; /* Symbole manipulé */
bool has_entry_points; /* Présences d'insertions ? */
- size_t i; /* Boucle de parcours */
vmpa2t addr; /* Localisation de symbole */
/* Mise en place de la boîte de dialogue */
@@ -229,23 +229,31 @@ GtkWidget *create_gotox_dialog_for_entry_points(GtkWindow *parent, GLoadedBinary
format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
- symbols = g_binary_format_get_symbols(format, &sym_count);
+ siter = create_symbol_iterator(format, 0);
has_entry_points = false;
- for (i = 0; i < sym_count; i++)
+ for (symbol = get_symbol_iterator_current(siter);
+ symbol != NULL;
+ symbol = get_symbol_iterator_next(siter))
{
- if (g_binary_symbol_get_target_type(symbols[i]) != STP_ENTRY_POINT)
- continue;
+ if (g_binary_symbol_get_target_type(symbol) != STP_ENTRY_POINT)
+ goto cgdfep_next;
- copy_vmpa(&addr, get_mrange_addr(g_binary_symbol_get_range(symbols[i])));
+ copy_vmpa(&addr, get_mrange_addr(g_binary_symbol_get_range(symbol)));
- add_new_location_to_list(store, binary, &addr, symbols[i]);
+ add_new_location_to_list(store, binary, &addr, symbol);
has_entry_points = true;
+ cgdfep_next:
+
+ g_object_unref(G_OBJECT(symbol));
+
}
+ delete_symbol_iterator(siter);
+
g_object_unref(G_OBJECT(format));
g_object_unref(G_OBJECT(store));
diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c
index 23383a1..5942d03 100644
--- a/src/gui/panels/strings.c
+++ b/src/gui/panels/strings.c
@@ -35,6 +35,7 @@
#include "../../common/extstr.h"
#include "../../core/params.h"
#include "../../format/format.h"
+#include "../../format/symiter.h"
#include "../../gtkext/easygtk.h"
#include "../../gtkext/gtkdockable-int.h"
@@ -468,9 +469,8 @@ static void change_strings_panel_current_binary(GStringsPanel *panel, GLoadedBin
GExeFormat *format; /* Format de travail */
GBinPortion *portions; /* Couche première de portions */
GBinContent *content; /* Contenu binaire en mémoire */
- size_t count; /* Nombre des chaînes */
- GBinSymbol **symbols; /* Liste des chaînes trouvées */
- size_t i; /* Boucle de parcours */
+ sym_iter_t *siter; /* Parcours des symboles */
+ GBinSymbol *symbol; /* Symbole manipulé */
const mrange_t *range; /* Couverture mémoire */
const vmpa2t *addr; /* Adressse liée à la chaîne */
VMPA_BUFFER(phys); /* Position physique */
@@ -509,13 +509,16 @@ static void change_strings_panel_current_binary(GStringsPanel *panel, GLoadedBin
portions = g_exe_format_get_portions(format);
content = g_binary_format_get_content(G_BIN_FORMAT(format));
- symbols = g_binary_format_get_symbols(G_BIN_FORMAT(format), &count);
+ siter = create_symbol_iterator(G_BIN_FORMAT(format), 0);
- for (i = 0; i < count; i++)
+ for (symbol = get_symbol_iterator_current(siter);
+ symbol != NULL;
+ symbol = get_symbol_iterator_next(siter))
{
- if (g_binary_symbol_get_target_type(symbols[i]) != STP_RO_STRING) continue;
+ if (g_binary_symbol_get_target_type(symbol) != STP_RO_STRING)
+ goto cspcb_next;
- range = g_binary_symbol_get_range(symbols[i]);
+ range = g_binary_symbol_get_range(symbol);
addr = get_mrange_addr(range);
vmpa2_phys_to_string(addr, msize, phys, NULL);
@@ -525,7 +528,7 @@ static void change_strings_panel_current_binary(GStringsPanel *panel, GLoadedBin
area = g_binary_portion_get_desc(portion);
g_object_unref(G_OBJECT(portion));
- label = g_binary_symbol_get_label(symbols[i]);
+ label = g_binary_symbol_get_label(symbol);
text = (char *)calloc(get_mrange_length(range) + 1, sizeof(char));
@@ -534,13 +537,13 @@ static void change_strings_panel_current_binary(GStringsPanel *panel, GLoadedBin
if (!g_binary_content_read_raw(content, &pos, get_mrange_length(range), (uint8_t *)text))
{
free(text);
- continue;
+ goto cspcb_next;
}
if (is_string_filtered(panel, label, text))
{
free(text);
- continue;
+ goto cspcb_next;
}
text = strrpl(text, "&", "&amp;");
@@ -551,7 +554,7 @@ static void change_strings_panel_current_binary(GStringsPanel *panel, GLoadedBin
gtk_tree_store_append(store, &iter, NULL);
gtk_tree_store_set(store, &iter,
- STC_STRING, symbols[i],
+ STC_STRING, symbol,
STC_PHYSICAL, phys,
STC_VIRTUAL, virt,
STC_AREA, area,
@@ -561,8 +564,14 @@ static void change_strings_panel_current_binary(GStringsPanel *panel, GLoadedBin
free(text);
+ cspcb_next:
+
+ g_object_unref(G_OBJECT(symbol));
+
}
+ delete_symbol_iterator(siter);
+
g_object_unref(G_OBJECT(content));
g_object_unref(G_OBJECT(portions));
g_object_unref(G_OBJECT(format));
diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c
index f64f087..dee03b5 100644
--- a/src/gui/panels/symbols.c
+++ b/src/gui/panels/symbols.c
@@ -39,6 +39,7 @@
#include "panel-int.h"
#include "../core/global.h"
#include "../../format/format.h"
+#include "../../format/symiter.h"
#include "../../gtkext/easygtk.h"
#include "../../gtkext/support.h"
#include "../../gtkext/tmgt.h"
@@ -649,11 +650,10 @@ static void change_symbols_panel_current_binary(GSymbolsPanel *panel, GLoadedBin
static void reload_symbols_for_new_list_view(GSymbolsPanel *panel)
{
GExeFormat *format; /* Format associé au binaire */
- GBinSymbol **symbols; /* Symboles à représenter */
- size_t sym_count; /* Qté de symboles présents */
GArchProcessor *proc; /* Architecture utilisée */
MemoryDataSize size; /* Taille des localisations */
- size_t i; /* Boucle de parcours */
+ sym_iter_t *siter; /* Parcours des symboles */
+ GBinSymbol *symbol; /* Symbole manipulé */
regmatch_t match; /* Récupération des trouvailles*/
cairo_surface_t *icon; /* Image associée au symbole */
const char *original; /* Etiquette brute d'origine */
@@ -664,18 +664,20 @@ static void reload_symbols_for_new_list_view(GSymbolsPanel *panel)
format = g_loaded_binary_get_format(panel->binary);
- symbols = g_binary_format_get_symbols(G_BIN_FORMAT(format), &sym_count);
-
proc = g_loaded_binary_get_processor(panel->binary);
size = g_arch_processor_get_memory_size(proc);
g_object_unref(G_OBJECT(proc));
- for (i = 0; i < sym_count; i++)
+ siter = create_symbol_iterator(G_BIN_FORMAT(format), 0);
+
+ for (symbol = get_symbol_iterator_current(siter);
+ symbol != NULL;
+ symbol = get_symbol_iterator_next(siter))
{
- if (!is_symbol_matching(panel, symbols[i], &match))
- continue;
+ if (!is_symbol_matching(panel, symbol, &match))
+ goto rsfnlv_next;
- switch (g_binary_symbol_get_target_type(symbols[i]))
+ switch (g_binary_symbol_get_target_type(symbol))
{
case STP_ROUTINE:
case STP_ENTRY_POINT:
@@ -689,15 +691,15 @@ static void reload_symbols_for_new_list_view(GSymbolsPanel *panel)
break;
}
- original = g_binary_symbol_get_label(symbols[i]);
+ original = g_binary_symbol_get_label(symbol);
name = build_highlighted_name(original, &match, 0);
- addr = get_mrange_addr(g_binary_symbol_get_range(symbols[i]));
+ addr = get_mrange_addr(g_binary_symbol_get_range(symbol));
vmpa2_virt_to_string(addr, size, virt, NULL);
gtk_tree_store_append(panel->store, &iter, NULL);
gtk_tree_store_set(panel->store, &iter,
- SBC_SYMBOL, symbols[i],
+ SBC_SYMBOL, symbol,
SBC_PICTURE, icon,
SBC_NAME, name,
SBC_ORIGINAL, original,
@@ -706,8 +708,14 @@ static void reload_symbols_for_new_list_view(GSymbolsPanel *panel)
free(name);
+ rsfnlv_next:
+
+ g_object_unref(G_OBJECT(symbol));
+
}
+ delete_symbol_iterator(siter);
+
g_object_unref(G_OBJECT(format));
}
@@ -849,11 +857,10 @@ static bool find_parent_for_symbol(GSymbolsPanel *panel, const GBinSymbol *symbo
static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel)
{
GExeFormat *format; /* Format associé au binaire */
- GBinSymbol **symbols; /* Symboles à représenter */
- size_t sym_count; /* Qté de symboles présents */
GArchProcessor *proc; /* Architecture utilisée */
MemoryDataSize size; /* Taille des localisations */
- size_t i; /* Boucle de parcours */
+ sym_iter_t *siter; /* Parcours des symboles */
+ GBinSymbol *symbol; /* Symbole manipulé */
regmatch_t match; /* Récupération des trouvailles*/
GtkTreeIter parent; /* Point d'insertion parent */
size_t last; /* Position du dernier élément */
@@ -866,18 +873,20 @@ static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel)
format = g_loaded_binary_get_format(panel->binary);
- symbols = g_binary_format_get_symbols(G_BIN_FORMAT(format), &sym_count);
-
proc = g_loaded_binary_get_processor(panel->binary);
size = g_arch_processor_get_memory_size(proc);
g_object_unref(G_OBJECT(proc));
- for (i = 0; i < sym_count; i++)
+ siter = create_symbol_iterator(G_BIN_FORMAT(format), 0);
+
+ for (symbol = get_symbol_iterator_current(siter);
+ symbol != NULL;
+ symbol = get_symbol_iterator_next(siter))
{
- if (!is_symbol_matching(panel, symbols[i], &match))
- continue;
+ if (!is_symbol_matching(panel, symbol, &match))
+ goto rsfntv_next;
- if (find_parent_for_symbol(panel, symbols[i], &parent, &match, &last))
+ if (find_parent_for_symbol(panel, symbol, &parent, &match, &last))
{
gtk_tree_store_set(panel->store, &parent,
SBC_PICTURE, G_SYMBOLS_PANEL_GET_CLASS(panel)->class_img,
@@ -890,7 +899,7 @@ static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel)
else
gtk_tree_store_append(panel->store, &iter, NULL);
- switch (g_binary_symbol_get_target_type(symbols[i]))
+ switch (g_binary_symbol_get_target_type(symbol))
{
case STP_ROUTINE:
case STP_ENTRY_POINT:
@@ -904,14 +913,14 @@ static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel)
break;
}
- original = g_binary_symbol_get_label(symbols[i]);
+ original = g_binary_symbol_get_label(symbol);
name = build_highlighted_name(original + last, &match, last);
- addr = get_mrange_addr(g_binary_symbol_get_range(symbols[i]));
+ addr = get_mrange_addr(g_binary_symbol_get_range(symbol));
vmpa2_virt_to_string(addr, size, virt, NULL);
gtk_tree_store_set(panel->store, &iter,
- SBC_SYMBOL, symbols[i],
+ SBC_SYMBOL, symbol,
SBC_PICTURE, icon,
SBC_NAME, name,
SBC_ORIGINAL, original + last,
@@ -920,8 +929,14 @@ static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel)
free(name);
+ rsfntv_next:
+
+ g_object_unref(G_OBJECT(symbol));
+
}
+ delete_symbol_iterator(siter);
+
g_object_unref(G_OBJECT(format));
}