summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-12-12 18:05:45 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-12-12 18:05:45 (GMT)
commitdcc0438ff24efd5958b8d46940eb395ff2b7ed77 (patch)
treea977fdbd43abd34bbea73f1fd1aef89f364230f2 /plugins
parentb3efd0bbc506e701ea9872f50b8b4db974f35954 (diff)
Applied some code refactoring to remove usages of GBinFormat in favor of GExeFormat.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/libcsem/exit.c3
-rw-r--r--plugins/ropgadgets/finder.c13
-rw-r--r--plugins/ropgadgets/finder.h4
-rw-r--r--plugins/ropgadgets/select.c30
4 files changed, 27 insertions, 23 deletions
diff --git a/plugins/libcsem/exit.c b/plugins/libcsem/exit.c
index b5545b9..cbfec64 100644
--- a/plugins/libcsem/exit.c
+++ b/plugins/libcsem/exit.c
@@ -24,6 +24,9 @@
#include "exit.h"
+#include <format/format.h>
+
+
/* Modifie toutes les instructions appelant exit(). */
static void mark_one_kind_of_exit_as_return(const GLoadedBinary *, const char *);
diff --git a/plugins/ropgadgets/finder.c b/plugins/ropgadgets/finder.c
index 4d48296..6a2283c 100644
--- a/plugins/ropgadgets/finder.c
+++ b/plugins/ropgadgets/finder.c
@@ -28,6 +28,7 @@
#include <core/processors.h>
+#include <format/format.h>
#include <i18n.h>
@@ -40,7 +41,7 @@
/* Données utiles à transmettre */
typedef struct _search_domain
{
- GBinFormat *format; /* Format du fichier binaire */
+ GExeFormat *format; /* Format du fichier binaire */
GBinContent *content; /* Contenu associé récupéré */
GArchProcessor *proc; /* Processeur idéal en place */
GProcContext *ctx; /* Contexte de désassemblage */
@@ -86,7 +87,7 @@ static GArchInstruction *disassemble_instruction_in_domain(const search_domain *
ctx = domain->ctx; /* TODO : copie */
- result = g_arch_processor_disassemble(domain->proc, ctx, domain->content, pos, G_EXE_FORMAT(domain->format));
+ result = g_arch_processor_disassemble(domain->proc, ctx, domain->content, pos, domain->format);
if (result != NULL)
{
@@ -317,7 +318,7 @@ static GArchInstruction **list_all_gadgets_in_domain(const search_domain *domain
* *
******************************************************************************/
-found_rop_list *list_all_gadgets(GBinFormat *format, unsigned int max_depth, update_search_progress_cb update, GObject *data, size_t *count)
+found_rop_list *list_all_gadgets(GExeFormat *format, unsigned int max_depth, update_search_progress_cb update, GObject *data, size_t *count)
{
found_rop_list *result; /* Liste de listes à renvoyer */
const char *target; /* Sous-traitance requise */
@@ -331,12 +332,12 @@ found_rop_list *list_all_gadgets(GBinFormat *format, unsigned int max_depth, upd
g_object_ref(G_OBJECT(format));
domain.format = format;
- domain.content = g_binary_format_get_content(format);
+ domain.content = g_binary_format_get_content(G_BIN_FORMAT(format));
- target = g_exe_format_get_target_machine(G_EXE_FORMAT(format));
+ 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(G_EXE_FORMAT(format), &domain.exe_count);
+ domain.exe_ranges = g_exe_format_get_x_ranges(format, &domain.exe_count);
/* Récupération des différents contextes */
diff --git a/plugins/ropgadgets/finder.h b/plugins/ropgadgets/finder.h
index 2c7d692..6539784 100644
--- a/plugins/ropgadgets/finder.h
+++ b/plugins/ropgadgets/finder.h
@@ -26,7 +26,7 @@
#include <arch/instruction.h>
-#include <format/format.h>
+#include <format/executable.h>
@@ -46,7 +46,7 @@ typedef struct _found_rop_list
/* Etablit une liste de tous les gadgets présents. */
-found_rop_list *list_all_gadgets(GBinFormat *, unsigned int, update_search_progress_cb, GObject *, size_t *);
+found_rop_list *list_all_gadgets(GExeFormat *, unsigned int, update_search_progress_cb, GObject *, size_t *);
diff --git a/plugins/ropgadgets/select.c b/plugins/ropgadgets/select.c
index 8878839..881cd39 100644
--- a/plugins/ropgadgets/select.c
+++ b/plugins/ropgadgets/select.c
@@ -138,7 +138,7 @@ typedef struct _search_step
struct
{
- GBinFormat *format; /* Format binaire chargé */
+ GExeFormat *format; /* Format binaire chargé */
found_rop_list *list; /* Liste de gadgets ROP trouvés*/
size_t count; /* Nombre de gadgets trouvés */
};
@@ -167,13 +167,13 @@ static void push_new_progress_fraction(GObject *, gdouble);
static gboolean register_found_rop_gadgets(search_step *);
/* Lance une conservation des gadgets trouvés. */
-static void push_found_rop_gadgets(GObject *, GBinFormat *, found_rop_list *, size_t);
+static void push_found_rop_gadgets(GObject *, GExeFormat *, found_rop_list *, size_t);
/* Charge un format binaire interne déjà chargé. */
-static GBinFormat *load_internal_format_for_rop_gadgets(GObject *);
+static GExeFormat *load_internal_format_for_rop_gadgets(GObject *);
/* Charge un format binaire externe. */
-static GBinFormat *load_external_format_for_rop_gadgets(GObject *);
+static GExeFormat *load_external_format_for_rop_gadgets(GObject *);
/* Procède à la recherche de gadgets de façon séparée. */
static gpointer look_for_rop_gadgets(GObject *);
@@ -211,7 +211,7 @@ static void on_rop_gadgets_filter_changed(GtkSearchEntry *, GObject *);
static gboolean filter_visible_rop_gadgets(GtkTreeModel *, GtkTreeIter *, GObject *);
/* Ajoute de nouvelles chaînes de gadgets localisées. */
-static void add_new_gadgets_for_category(GBinFormat *, GtkComboBoxText *, GtkTreeStore *, const char *, GArchInstruction **, size_t);
+static void add_new_gadgets_for_category(GExeFormat *, GtkComboBoxText *, GtkTreeStore *, const char *, GArchInstruction **, size_t);
@@ -1233,7 +1233,7 @@ static gboolean register_found_rop_gadgets(search_step *step)
* *
******************************************************************************/
-static void push_found_rop_gadgets(GObject *ref, GBinFormat *format, found_rop_list *list, size_t count)
+static void push_found_rop_gadgets(GObject *ref, GExeFormat *format, found_rop_list *list, size_t count)
{
search_step *step; /* Informations d'étape */
@@ -1262,9 +1262,9 @@ static void push_found_rop_gadgets(GObject *ref, GBinFormat *format, found_rop_l
* *
******************************************************************************/
-static GBinFormat *load_internal_format_for_rop_gadgets(GObject *ref)
+static GExeFormat *load_internal_format_for_rop_gadgets(GObject *ref)
{
- GBinFormat *result; /* Format chargé à retourner */
+ GExeFormat *result; /* Format chargé à retourner */
GtkComboBox *combo; /* Composant de sélection */
GtkTreeIter iter; /* Tête de lecture à placer */
GtkTreeModel *model; /* Modèle de gestion */
@@ -1283,7 +1283,7 @@ static GBinFormat *load_internal_format_for_rop_gadgets(GObject *ref)
push_status_printing_of_rop_search_step(ref, "loading", _("done"), true);
- result = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
+ result = g_loaded_binary_get_format(binary);
push_status_printing_of_rop_search_step(ref, "format", _("already loaded"), true);
@@ -1306,9 +1306,9 @@ static GBinFormat *load_internal_format_for_rop_gadgets(GObject *ref)
* *
******************************************************************************/
-static GBinFormat *load_external_format_for_rop_gadgets(GObject *ref)
+static GExeFormat *load_external_format_for_rop_gadgets(GObject *ref)
{
- GBinFormat *result; /* Format chargé à retourner */
+ GExeFormat *result; /* Format chargé à retourner */
GtkEntry *entry; /* Zone de saisie de texte */
const gchar *filename; /* Nom du fichier à charger */
GBinContent *content; /* Contenu binaire chargé */
@@ -1346,7 +1346,7 @@ static GBinFormat *load_external_format_for_rop_gadgets(GObject *ref)
desc = get_binary_format_name(target);
- result = load_new_named_format(target, content, NULL);
+ result = G_EXE_FORMAT(load_new_named_format(target, content, NULL));
free(target);
@@ -1383,7 +1383,7 @@ static gpointer look_for_rop_gadgets(GObject *ref)
{
GtkToggleButton *internal; /* Bouton de sélection interne */
gboolean state; /* Etat du bouton courant */
- GBinFormat *format; /* Format du binaire à traiter */
+ GExeFormat *format; /* Format du binaire à traiter */
found_rop_list *list; /* Liste de gadgets ROP trouvés*/
size_t count; /* Nombre de ces listes */
size_t found; /* Nombre de gadgets trouvés */
@@ -1744,7 +1744,7 @@ static gboolean filter_visible_rop_gadgets(GtkTreeModel *model, GtkTreeIter *ite
* *
******************************************************************************/
-static void add_new_gadgets_for_category(GBinFormat *format, GtkComboBoxText *combo, GtkTreeStore *store, const char *category, GArchInstruction **gadgets, size_t count)
+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 */
@@ -1764,7 +1764,7 @@ static void add_new_gadgets_for_category(GBinFormat *format, GtkComboBoxText *co
/* Définition de l'écosystème nécessaire */
- target = g_exe_format_get_target_machine(G_EXE_FORMAT(format));
+ target = g_exe_format_get_target_machine(format);
proc = get_arch_processor_for_type(target);
msize = g_arch_processor_get_memory_size(proc);