summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-12-31 16:16:20 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-12-31 16:16:20 (GMT)
commit8599cd772627ed8f7c923615fe991808d3f5c882 (patch)
tree95f266197c63c51c4f6513e5575f935a63af6fa0
parente0ab9498f78ee6b4fbbba25400d78436db682899 (diff)
Updated the ROP gadgets finder.
-rw-r--r--ChangeLog16
-rw-r--r--plugins/ropgadgets/select.c42
-rw-r--r--src/analysis/loading.c7
-rw-r--r--src/core/global.c4
-rw-r--r--src/gui/editor.c8
-rw-r--r--src/gui/menus/file.c6
-rw-r--r--src/gui/menus/project.c11
7 files changed, 70 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 41fb56a..63cedf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
17-12-31 Cyrille Bagard <nocbos@gmail.com>
+ * plugins/ropgadgets/select.c:
+ Update the ROP gadgets finder.
+
+ * src/analysis/loading.c:
+ Update code.
+
+ * src/core/global.c:
+ Increase the reference counter when providing the current project.
+
+ * src/gui/editor.c:
+ * src/gui/menus/file.c:
+ * src/gui/menus/project.c:
+ Update code.
+
+17-12-31 Cyrille Bagard <nocbos@gmail.com>
+
* plugins/elf/elf_def.h:
Typo.
diff --git a/plugins/ropgadgets/select.c b/plugins/ropgadgets/select.c
index 2294a9c..021a2fa 100644
--- a/plugins/ropgadgets/select.c
+++ b/plugins/ropgadgets/select.c
@@ -35,8 +35,8 @@
#include <i18n.h>
-#include <analysis/project.h>
#include <analysis/contents/file.h>
+#include <core/global.h>
#include <common/cpp.h>
#include <common/extstr.h>
#include <core/formats.h>
@@ -502,16 +502,20 @@ static void register_input_output_panel(GtkAssistant *assistant, GObject *ref)
static GtkWidget *load_and_populate_current_project_binaries(GObject *ref)
{
GtkWidget *result; /* Composant à retourner */
+ GStudyProject *project; /* Projet courant */
GLoadedBinary *current; /* Binaire actif courant */
gint selected; /* Indice à sélectionner */
GtkListStore *store; /* Modèle de gestion en liste */
- GLoadedBinary **binaries; /* Liste de binaires */
+ GLoadedContent **contents; /* Liste de contenus chargés */
size_t count; /* Taille de cette liste */
size_t i; /* Boucle de parcours */
+ GLoadedBinary *binary; /* Contenu de code binaire */
GtkTreeIter iter; /* Point d'insertion */
GtkCellRenderer *renderer; /* Moteur de rendu de colonne */
- /* Récupération du binaire courant */
+ /* Récupération des éléments courants */
+
+ project = get_current_project();
current = get_current_binary();
@@ -521,26 +525,32 @@ static GtkWidget *load_and_populate_current_project_binaries(GObject *ref)
store = gtk_list_store_new(CPB_COUNT, G_TYPE_OBJECT, G_TYPE_STRING);
- binaries = g_study_project_get_binaries(get_current_project(), &count);
+ contents = g_study_project_get_contents(project, &count);
- if (binaries != NULL)
+ if (contents != NULL)
{
for (i = 0; i < count; i++)
{
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- CPB_BINARY, binaries[i],
- CPB_FILENAME, g_loaded_binary_get_name(binaries[i], true),
- -1);
+ if (G_IS_LOADED_BINARY(contents[i]))
+ {
+ binary = G_LOADED_BINARY(contents[i]);
- if (binaries[i] == current)
- selected = i;
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ CPB_BINARY, binary,
+ CPB_FILENAME, g_loaded_binary_get_name(binary, true),
+ -1);
- g_object_unref(G_OBJECT(binaries[i]));
+ if (binary == current)
+ selected = i;
+
+ }
+
+ g_object_unref(G_OBJECT(contents[i]));
}
- free(binaries);
+ free(contents);
}
@@ -563,8 +573,12 @@ static GtkWidget *load_and_populate_current_project_binaries(GObject *ref)
g_object_unref(G_OBJECT(store));
+ /* Sortie propre */
+
g_object_unref(G_OBJECT(current));
+ g_object_unref(G_OBJECT(project));
+
return result;
}
diff --git a/src/analysis/loading.c b/src/analysis/loading.c
index 700a03f..f8dc2c3 100644
--- a/src/analysis/loading.c
+++ b/src/analysis/loading.c
@@ -368,9 +368,14 @@ void g_delayed_study_preload_only(GDelayedStudy *dstudy)
void qck_study_new_content(GBinContent *content, ProjectContentState state)
{
+ GStudyProject *project; /* Projet courant */
GDelayedStudy *dstudy; /* Etude à conduire */
- dstudy = g_delayed_study_new(get_current_project(), content, state);
+ project = get_current_project();
+
+ dstudy = g_delayed_study_new(project, content, state);
+
+ g_object_unref(G_OBJECT(project));
study_new_content(dstudy);
diff --git a/src/core/global.c b/src/core/global.c
index c5f25c1..2185c3a 100644
--- a/src/core/global.c
+++ b/src/core/global.c
@@ -121,6 +121,10 @@ void set_current_project(GStudyProject *project)
GStudyProject *get_current_project(void)
{
+ assert(_project != NULL);
+
+ g_object_ref(G_OBJECT(_project));
+
return _project;
}
diff --git a/src/gui/editor.c b/src/gui/editor.c
index d1f90d5..11c7f06 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -421,7 +421,6 @@ static gboolean on_delete_editor(GtkWidget *widget, GdkEvent *event, gpointer da
result = FALSE;
project = get_current_project();
- if (project == NULL) goto ode_no_project;
if (g_study_project_get_filename(project) == NULL)
{
@@ -454,7 +453,7 @@ static gboolean on_delete_editor(GtkWidget *widget, GdkEvent *event, gpointer da
}
- ode_no_project:
+ g_object_unref(G_OBJECT(project));
return result;
@@ -476,11 +475,6 @@ static gboolean on_delete_editor(GtkWidget *widget, GdkEvent *event, gpointer da
static void on_destroy_editor(GtkWidget *widget, GObject *ref)
{
- GStudyProject *project; /* Projet courant */
-
- project = get_current_project();
- if (project != NULL) g_object_unref(G_OBJECT(project));
-
/* Fermeture propre */
/* ... */
diff --git a/src/gui/menus/file.c b/src/gui/menus/file.c
index c0c031c..9c0b218 100644
--- a/src/gui/menus/file.c
+++ b/src/gui/menus/file.c
@@ -185,6 +185,8 @@ static void mcb_file_open_project(GtkMenuItem *menuitem, gpointer unused)
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
g_study_project_get_filename(project));
+ g_object_unref(G_OBJECT(project));
+
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
{
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
@@ -235,6 +237,8 @@ static void mcb_file_save_project(GtkMenuItem *menuitem, gpointer unused)
else
mcb_file_save_project_as(menuitem, NULL);
+ g_object_unref(G_OBJECT(project));
+
}
@@ -280,6 +284,8 @@ static void mcb_file_save_project_as(GtkMenuItem *menuitem, gpointer unused)
}
+ g_object_unref(G_OBJECT(project));
+
gtk_widget_destroy(dialog);
}
diff --git a/src/gui/menus/project.c b/src/gui/menus/project.c
index 5d027a0..424a506 100644
--- a/src/gui/menus/project.c
+++ b/src/gui/menus/project.c
@@ -202,6 +202,8 @@ static void mcb_project_add_shellcode(GtkMenuItem *menuitem, GMenuBar *bar)
}
+ g_object_unref(G_OBJECT(project));
+
#if 0
GtkWidget *dialog; /* Boîte à afficher */
char *dir; /* Répertoire courant */
@@ -262,6 +264,7 @@ static void mcb_project_add_shellcode(GtkMenuItem *menuitem, GMenuBar *bar)
static void mcb_project_add_binary_file(GtkMenuItem *menuitem, GMenuBar *bar)
{
GtkWidget *dialog; /* Boîte à afficher */
+ GStudyProject *project; /* Projet courant */
char *dir; /* Répertoire courant */
gchar *filename; /* Nom du fichier à intégrer */
GBinContent *content; /* Contenu binaire à charger */
@@ -273,14 +276,18 @@ static void mcb_project_add_binary_file(GtkMenuItem *menuitem, GMenuBar *bar)
_("_Open"), GTK_RESPONSE_ACCEPT,
NULL);
- if (g_study_project_get_filename(get_current_project()) != NULL)
+ project = get_current_project();
+
+ if (g_study_project_get_filename(project) != NULL)
{
- dir = strdup(g_study_project_get_filename(get_current_project()));
+ dir = strdup(g_study_project_get_filename(project));
dir = dirname(dir);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir);
free(dir);
}
+ g_object_unref(G_OBJECT(project));
+
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
{
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));