summaryrefslogtreecommitdiff
path: root/src/dialogs
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-01-26 23:00:18 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-01-26 23:00:18 (GMT)
commit84790a5b420d0a9ce658013573b180ce059db325 (patch)
tree5000d25a0d5ede63e671364e1e017fbb6674b5f5 /src/dialogs
parentabb191e42e356914bd09176a6d6c5bf89ec50bbf (diff)
Saved the first steps of the migration to GTK+ v3.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@367 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/dialogs')
-rw-r--r--src/dialogs/Makefile.am4
-rw-r--r--src/dialogs/about.c6
-rw-r--r--src/dialogs/binparts.c6
-rw-r--r--src/dialogs/export.c2
-rw-r--r--src/dialogs/export.h2
-rw-r--r--src/dialogs/goto.c4
-rw-r--r--src/dialogs/shellcode.c (renamed from src/dialogs/add_shellcode.c)127
-rw-r--r--src/dialogs/shellcode.h (renamed from src/dialogs/add_shellcode.h)2
8 files changed, 73 insertions, 80 deletions
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index 70642b2..05bd50e 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -3,11 +3,11 @@ noinst_LTLIBRARIES = libdialogs.la
libdialogs_la_SOURCES = \
about.h about.c \
- add_shellcode.h add_shellcode.c \
binparts.h binparts.c \
export.h export.c \
goto.h goto.c \
- plugins.h plugins.c
+ plugins.h plugins.c \
+ shellcode.h shellcode.c
libdialogs_la_LDFLAGS =
diff --git a/src/dialogs/about.c b/src/dialogs/about.c
index 8773e31..1a1b064 100644
--- a/src/dialogs/about.c
+++ b/src/dialogs/about.c
@@ -52,7 +52,7 @@
GtkWidget *create_about_dialog(GtkWindow *parent)
{
GtkWidget *result; /* Fenêtre à renvoyer */
- GtkStyle *style; /* Style associé à la fenêtre */
+ GdkRGBA color; /* Couleur de fond noire */
GtkWidget *fixed; /* Support global */
gchar *filename; /* Chemin d'accès au fichier */
GtkWidget *image; /* Image chargée */
@@ -71,8 +71,8 @@ GtkWidget *create_about_dialog(GtkWindow *parent)
gtk_window_set_default_size(GTK_WINDOW(result), 350, 430);
gtk_window_set_type_hint(GTK_WINDOW(result), GDK_WINDOW_TYPE_HINT_DIALOG);
- style = gtk_widget_get_style(result);
- gtk_widget_modify_bg(result, GTK_STATE_NORMAL, &style->black);
+ gdk_rgba_parse(&color, "black");
+ gtk_widget_override_background_color(GTK_WIDGET(result), GTK_STATE_FLAG_NORMAL, &color);
fixed = gtk_fixed_new();
gtk_widget_show(fixed);
diff --git a/src/dialogs/binparts.c b/src/dialogs/binparts.c
index 14e1422..6df3d0a 100644
--- a/src/dialogs/binparts.c
+++ b/src/dialogs/binparts.c
@@ -279,9 +279,9 @@ GtkWidget *create_sections_dialog(GLoadedBinary *binary, GtkWindow *parent)
g_signal_connect(G_OBJECT(comboboxentry), "changed", G_CALLBACK(on_model_change), ref);
- gtk_combo_box_append_text(GTK_COMBO_BOX(comboboxentry), _("Default"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(comboboxentry), _("Routines"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(comboboxentry), _("User"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboboxentry), _("Default"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboboxentry), _("Routines"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(comboboxentry), _("User"));
load_binary_current_parts(binary, ref);
diff --git a/src/dialogs/export.c b/src/dialogs/export.c
index 317ada4..a7af141 100644
--- a/src/dialogs/export.c
+++ b/src/dialogs/export.c
@@ -298,7 +298,7 @@ static void register_output_panel(GtkAssistant *assistant)
combobox = qck_create_combobox(NULL, NULL, G_CALLBACK(NULL), NULL);
gtk_box_pack_start(GTK_BOX(hbox), combobox, TRUE, TRUE, 0);
- gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("Simple text"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("Simple text"));
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
diff --git a/src/dialogs/export.h b/src/dialogs/export.h
index fc7e1bd..dff409a 100644
--- a/src/dialogs/export.h
+++ b/src/dialogs/export.h
@@ -25,7 +25,7 @@
#define _DIALOGS_EXPORT_H
-#include <gtk/gtkwindow.h>
+#include <gtk/gtk.h>
#include "../analysis/binary.h"
diff --git a/src/dialogs/goto.c b/src/dialogs/goto.c
index 18c364d..8a64e7e 100644
--- a/src/dialogs/goto.c
+++ b/src/dialogs/goto.c
@@ -157,7 +157,7 @@ GtkWidget *create_goto_dialog(GtkWindow *parent)
gtk_window_set_modal(GTK_WINDOW(result), TRUE);
gtk_window_set_type_hint(GTK_WINDOW(result), GDK_WINDOW_TYPE_HINT_DIALOG);
- dlgvbox = GTK_DIALOG(result)->vbox;
+ dlgvbox = gtk_dialog_get_content_area(GTK_DIALOG(result));
gtk_widget_show(dlgvbox);
vbox = gtk_vbox_new(FALSE, 8);
@@ -184,7 +184,7 @@ GtkWidget *create_goto_dialog(GtkWindow *parent)
- dialog_action_area1 = GTK_DIALOG(result)->action_area;
+ dialog_action_area1 = gtk_dialog_get_action_area(GTK_DIALOG(result));
gtk_widget_show(dialog_action_area1);
gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END);
diff --git a/src/dialogs/add_shellcode.c b/src/dialogs/shellcode.c
index ab59b36..bfde921 100644
--- a/src/dialogs/add_shellcode.c
+++ b/src/dialogs/shellcode.c
@@ -21,7 +21,10 @@
*/
-#include "add_shellcode.h"
+#include "shellcode.h"
+
+
+#include <i18n.h>
#include <malloc.h>
@@ -38,9 +41,6 @@
#include "../analysis/roptions.h" // A garder ?
-#ifndef _
-# define _(str) str
-#endif
@@ -120,7 +120,7 @@ static void register_content_panel(GtkAssistant *);
* *
******************************************************************************/
-void run_add_shellcode_assistant(GStudyProject *project, GtkWindow *parent)
+void run_shellcode_assistant(GStudyProject *project, GtkWindow *parent)
{
GtkWidget *assistant; /* Fenêtre à afficher */
GObject *ref; /* Espace de référencement */
@@ -259,10 +259,15 @@ static void register_bincode_panel(GtkAssistant *assistant)
/* Réception du code */
+ label = qck_create_label(NULL, NULL, _("Paste here the raw C code containing the shellcode.\r\n"
+ "All content between quotes will be extracted."));
+ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+
scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_show(scrolledwindow);
gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_SHADOW_IN);
textview = qck_create_textview(G_OBJECT(assistant), "bincode",
@@ -283,16 +288,6 @@ static void register_bincode_panel(GtkAssistant *assistant)
gtk_assistant_set_page_complete(assistant, alignment, TRUE);
- /* Choix par défaut */
- /*
- binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(assistant), "binary"));
- filename = g_loaded_binary_get_filename(binary);
-
- gtk_entry_set_text(GTK_ENTRY(entry), filename);
- gtk_entry_append_text(GTK_ENTRY(entry), ".txt");
-
- g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(on_export_filename_changed), assistant);
- */
}
@@ -330,6 +325,10 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length)
*code = NULL;
*length = 0;
+ /* Détermination des cibles */
+
+ ret = regcomp(&preg, "[^'\"]*(['\"])([^'\"]*)\\1", REG_EXTENDED);
+ if (ret != 0) return false;
/* Constitution du contexte */
@@ -339,52 +338,25 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length)
gtk_text_buffer_get_bounds(buffer, &start, &end);
bincode = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
-
- printf("---- %s ----\n", bincode);
-
-
-
- /* Détermination des cibles */
-
-
-
- ret = regcomp(&preg, "[^'\"]*(['\"])([^'\"]*)\\1", REG_EXTENDED);
-
-
- printf("comp :: %d\n", ret);
-
-
/* Recomposition du code */
-
pos = 0;
-
ret = regexec(&preg, &bincode[pos], 3, pmatch, 0);
while (ret != REG_NOMATCH && result)
{
-
-
bincode[pos + pmatch[2].rm_eo] = '\0';
- printf(" trouvé :: (%d ; %d) <=> %s\n",
- pmatch[2].rm_so, pmatch[2].rm_eo, &bincode[pos + pmatch[2].rm_so]);
-
-
-
for (i = pos + pmatch[2].rm_so; i < (pos + pmatch[2].rm_eo) && result; i++)
{
*code = (bin_t *)realloc(*code, ++(*length) * sizeof(bin_t));
- printf("Trying... %d < %d\n", i, pos + pmatch[2].rm_eo);
-
switch (bincode[i])
{
case '\\':
if (++i >= (pos + pmatch[2].rm_eo))
{
- printf("Exit !\n");
result = false;
break;
}
@@ -393,14 +365,12 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length)
{
if (++i >= (pos + pmatch[2].rm_eo))
{
- printf("Exit2 !\n");
result = false;
break;
}
if ((i + 2) > (pos + pmatch[2].rm_eo))
{
- printf("Exit3 !\n");
result = false;
break;
}
@@ -433,9 +403,6 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length)
}
-
-
-
g_free(bincode);
if (!result && *code != NULL)
@@ -443,16 +410,7 @@ static bool extract_shell_code(GObject *ref, bin_t **code, off_t *length)
*length = 0;
free(*code);
}
- /*
- else if (*code != NULL)
- {
- *code = (bin_t *)realloc(*code, ++(*length) * sizeof(bin_t));
- (*code)[*length - 1] = '\0';
-
- printf(">>> code == '%s' <<<\n", *code);
- }
- */
return result;
}
@@ -478,11 +436,12 @@ static void on_bincode_changed(GtkTextBuffer *textbuffer, GObject *ref)
bool status; /* Bilan de l'extraction */
GtkLabel *label; /* Etiquette à mettre à jour */
char *markup; /* Affichage étendu */
+ GtkAssistant *assistant; /* Assistant en première ligne */
+ gint index; /* Indice de la page courante */
+ GtkWidget *page; /* Cotenu de la page courante */
status = extract_shell_code(ref, &code, &length);
- printf("extracted ! ==> %p %d -> %d\n", code, length, status);
-
label = GTK_LABEL(g_object_get_data(ref, "status"));
if (!status)
@@ -490,18 +449,31 @@ static void on_bincode_changed(GtkTextBuffer *textbuffer, GObject *ref)
else if (length > 0)
{
- markup = g_markup_printf_escaped(_("<span color=\"#00cc00\"><b>Decoding OK (%d %s)</b></span>"),
- length, length > 1 ? _("bytes") : _("byte"));
+ markup = g_markup_printf_escaped(_("<span color=\"#00cc00\"><b>Decoding OK ("
+ OFF_FMT " %s)</b></span>"),
+ OFF_CAST(length), length > 1 ? _("bytes") : _("byte"));
gtk_label_set_markup(label, markup);
g_free(markup);
}
else
+ {
gtk_label_set_markup(label, _("No code"));
+ status = false;
+ }
if (length > 0)
free(code);
+ /* Poursuite des opérations ? */
+
+ assistant = GTK_ASSISTANT(ref);
+
+ index = gtk_assistant_get_current_page(assistant);
+ page = gtk_assistant_get_nth_page(assistant, index);
+
+ gtk_assistant_set_page_complete(assistant, page, status);
+
}
@@ -547,9 +519,9 @@ static void register_archi_panel(GtkAssistant *assistant)
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
combobox = qck_create_combobox(G_OBJECT(assistant), "archi", G_CALLBACK(NULL), NULL);
- gtk_box_pack_start(GTK_BOX(vbox), combobox, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), combobox, TRUE, FALSE, 0);
- gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("x86"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("x86"));
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
@@ -559,10 +531,10 @@ static void register_archi_panel(GtkAssistant *assistant)
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
combobox = qck_create_combobox(G_OBJECT(assistant), "rsize", G_CALLBACK(NULL), NULL);
- gtk_box_pack_start(GTK_BOX(vbox), combobox, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), combobox, TRUE, FALSE, 0);
- gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("32 bits"));
- gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("16 bits"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("32 bits"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("16 bits"));
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
@@ -632,7 +604,7 @@ static void register_output_panel(GtkAssistant *assistant)
combobox = qck_create_combobox(NULL, NULL, G_CALLBACK(NULL), NULL);
gtk_box_pack_start(GTK_BOX(hbox), combobox, TRUE, TRUE, 0);
- gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), _("Simple text"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), _("Simple text"));
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), 0);
@@ -830,3 +802,24 @@ static void register_content_panel(GtkAssistant *assistant)
gtk_assistant_set_page_complete(assistant, alignment, TRUE);
}
+
+
+
+
+
+
+
+
+ /* Choix par défaut */
+ /*
+ binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(assistant), "binary"));
+ filename = g_loaded_binary_get_filename(binary);
+
+ gtk_entry_set_text(GTK_ENTRY(entry), filename);
+ gtk_entry_append_text(GTK_ENTRY(entry), ".txt");
+
+ g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(on_export_filename_changed), assistant);
+ */
+
+
+
diff --git a/src/dialogs/add_shellcode.h b/src/dialogs/shellcode.h
index 115507c..0a3c51a 100644
--- a/src/dialogs/add_shellcode.h
+++ b/src/dialogs/shellcode.h
@@ -30,7 +30,7 @@
/* Crée et affiche un assistant d'ajout de binaire. */
-void run_add_shellcode_assistant(GStudyProject *, GtkWindow *);
+void run_shellcode_assistant(GStudyProject *, GtkWindow *);