summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-04-24 10:16:17 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-04-24 10:16:17 (GMT)
commite56b4db3aae87f0458319019635dea4968a5c529 (patch)
treebbbbbca3921dca2add25f74d73096900254fe301
parentfb12cfc1727ba949b70a48ee042a2aec9ebbb407 (diff)
Updated a little bit the Java part (welcome back).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@154 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
-rw-r--r--ChangeLog41
-rw-r--r--src/arch/jvm/operand.c2
-rw-r--r--src/dialogs/Makefile.am3
-rw-r--r--src/dialogs/binparts.c4
-rw-r--r--src/dialogs/binparts.h12
-rw-r--r--src/dialogs/plugins.c333
-rw-r--r--src/dialogs/plugins.h40
-rw-r--r--src/editor.c33
-rw-r--r--src/format/Makefile.am11
-rw-r--r--src/format/format.c2
-rw-r--r--src/format/format.h1
-rwxr-xr-xsrc/format/java/Makefile.am17
-rw-r--r--src/format/java/java-int.c90
-rwxr-xr-xsrc/format/java/java-int.h379
-rwxr-xr-xsrc/format/java/java.c615
-rwxr-xr-xsrc/format/java/java.h62
-rwxr-xr-xsrc/format/java/java_def.h418
-rwxr-xr-xsrc/format/java/pool.c106
-rwxr-xr-xsrc/format/java/pool.h10
-rw-r--r--src/format/pe/pe-int.h4
-rw-r--r--src/format/pe/pe.c12
-rw-r--r--src/format/pe/pe.h6
22 files changed, 1746 insertions, 455 deletions
diff --git a/ChangeLog b/ChangeLog
index a1eb7ab..e2f0e28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,44 @@
+10-04-24 Cyrille Bagard <nocbos@gmail.com>
+
+ * src/arch/jvm/operand.c:
+ Fix included headers.
+
+ * src/dialogs/binparts.c:
+ * src/dialogs/binparts.h:
+ Typo.
+
+ * src/dialogs/Makefile.am:
+ Add the plugins.[ch] files to libdialogs_a_SOURCES.
+
+ * src/dialogs/plugins.c:
+ * src/dialogs/plugins.h:
+ New entries: begin to allow plugins selection.
+
+ * src/editor.c:
+ Add a menu the select plugins for a loaded binary.
+
+ * src/format/format.c:
+ * src/format/format.h:
+ Register the Java format as [quite] valid.
+
+ * src/format/java/java.c:
+ * src/format/java/java_def.h:
+ * src/format/java/java.h:
+ * src/format/java/java-int.c:
+ New entries: follow the usual model of file format.
+
+ * src/format/java/java-int.h:
+ * src/format/java/Makefile.am:
+ * src/format/java/pool.c:
+ * src/format/java/pool.h:
+ * src/format/Makefile.am:
+ Update a little bit the Java part (welcome back).
+
+ * src/format/pe/pe.c:
+ * src/format/pe/pe.h:
+ * src/format/pe/pe-int.h:
+ Typo.
+
10-04-19 Cyrille Bagard <nocbos@gmail.com>
* src/analysis/binary.c:
diff --git a/src/arch/jvm/operand.c b/src/arch/jvm/operand.c
index a485a2b..4e4146d 100644
--- a/src/arch/jvm/operand.c
+++ b/src/arch/jvm/operand.c
@@ -29,6 +29,8 @@
#include "../../format/java/pool.h"
+#include "../../format/exe_format.h" /* FIXME : remme */
+
/* ---------------------- COQUILLE VIDE POUR LES OPERANDES JVM ---------------------- */
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index 22eaeac..2970d0a 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -3,7 +3,8 @@ lib_LIBRARIES = libdialogs.a
libdialogs_a_SOURCES = \
binparts.h binparts.c \
- export.h export.c
+ export.h export.c \
+ plugins.h plugins.c
libdialogs_a_LDFLAGS =
diff --git a/src/dialogs/binparts.c b/src/dialogs/binparts.c
index a88232e..5f11700 100644
--- a/src/dialogs/binparts.c
+++ b/src/dialogs/binparts.c
@@ -1,8 +1,8 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
- * dlg_sections.h - boîte de dialogue permettant une sélection des sections
+ * binparts.h - boîte de dialogue permettant une sélection des sections
*
- * Copyright (C) 2008 Cyrille Bagard
+ * Copyright (C) 2009 Cyrille Bagard
*
* This file is part of OpenIDA.
*
diff --git a/src/dialogs/binparts.h b/src/dialogs/binparts.h
index 8a86bf6..90f4737 100644
--- a/src/dialogs/binparts.h
+++ b/src/dialogs/binparts.h
@@ -1,8 +1,8 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
- * dlg_sections.h - prototypes pour la boîte de dialogue permettant une sélection des sections
+ * binparts.h - prototypes pour la boîte de dialogue permettant une sélection des sections
*
- * Copyright (C) 2008 Cyrille Bagard
+ * Copyright (C) 2009 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -21,8 +21,8 @@
*/
-#ifndef _DLG_SECTIONS_H
-#define _DLG_SECTIONS_H
+#ifndef _DIALOGS_BINPARTS_H
+#define _DIALOGS_BINPARTS_H
#include <gtk/gtk.h>
@@ -37,6 +37,4 @@ GtkWidget *create_sections_dialog(GOpenidaBinary *, GtkWindow *);
-
-
-#endif /* _DLG_SECTIONS_H */
+#endif /* _DIALOGS_BINPARTS_H */
diff --git a/src/dialogs/plugins.c b/src/dialogs/plugins.c
new file mode 100644
index 0000000..b5e045b
--- /dev/null
+++ b/src/dialogs/plugins.c
@@ -0,0 +1,333 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * plugins.c - boîte de dialogue permettant une sélection des greffons
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "plugins.h"
+
+
+
+
+
+
+#define _(str) str
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : binary = informations sur le binaire actuellement ouvert. *
+* parent = fenêtre parente à surpasser. *
+* *
+* Description : Construit la fenêtre de sélection des sections. *
+* *
+* Retour : Adresse de la fenêtre mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *binary, GtkWindow *parent)
+{
+ GtkWidget *result; /* Fenêtre à renvoyer */
+ GObject *ref; /* Espace de référencements */
+
+
+
+
+ GtkWidget *vbox1;
+ GtkWidget *hbox3;
+ GtkWidget *scrolledwindow1;
+ GtkWidget *treeview1;
+ GtkWidget *vbox2;
+ GtkWidget *vbuttonbox1;
+ GtkWidget *button7;
+ GtkWidget *image3;
+ GtkWidget *button8;
+ GtkWidget *image4;
+ GtkWidget *hseparator1;
+ GtkWidget *vbuttonbox2;
+ GtkWidget *button9;
+ GtkWidget *image5;
+ GtkWidget *button10;
+ GtkWidget *image6;
+ GtkWidget *scrolledwindow2;
+ GtkWidget *treeview2;
+ GtkWidget *expander1;
+ GtkWidget *hbox4;
+ GtkWidget *vbox3;
+ GtkWidget *label5;
+ GtkWidget *label8;
+ GtkWidget *label6;
+ GtkWidget *label9;
+ GtkWidget *label7;
+ GtkWidget *label10;
+ GtkWidget *frame1;
+ GtkWidget *alignment3;
+ GtkWidget *label12;
+ GtkWidget *label11;
+ GtkWidget *label3;
+ GtkWidget *hseparator2;
+ GtkWidget *hbuttonbox1;
+ GtkWidget *button1;
+ GtkWidget *alignment1;
+ GtkWidget *hbox1;
+ GtkWidget *image1;
+ GtkWidget *label1;
+ GtkWidget *button2;
+ GtkWidget *alignment2;
+ GtkWidget *hbox2;
+ GtkWidget *image2;
+ GtkWidget *label2;
+
+ result = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_widget_set_size_request(result, 600, 400);
+ gtk_container_set_border_width(GTK_CONTAINER(result), 8);
+ gtk_window_set_title(GTK_WINDOW(result), _("Plugins selection"));
+ gtk_window_set_transient_for(GTK_WINDOW(result), parent);
+ gtk_window_set_default_size(GTK_WINDOW(result), 600, 400);
+ gtk_window_set_type_hint(GTK_WINDOW(result), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+ ref= G_OBJECT(result);
+ g_object_set_data(ref, "binary", binary);
+
+
+
+
+ vbox1 = gtk_vbox_new(FALSE, 8);
+ gtk_widget_show(vbox1);
+ gtk_container_add(GTK_CONTAINER(result), vbox1);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox1), 8);
+
+ hbox3 = gtk_hbox_new(FALSE, 8);
+ gtk_widget_show(hbox3);
+ gtk_box_pack_start(GTK_BOX(vbox1), hbox3, TRUE, TRUE, 0);
+
+ scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
+ gtk_widget_show(scrolledwindow1);
+ gtk_box_pack_start(GTK_BOX(hbox3), scrolledwindow1, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow1), GTK_SHADOW_IN);
+
+ treeview1 = gtk_tree_view_new();
+ gtk_widget_show(treeview1);
+ gtk_container_add(GTK_CONTAINER(scrolledwindow1), treeview1);
+
+ vbox2 = gtk_vbox_new(TRUE, 0);
+ gtk_widget_show(vbox2);
+ gtk_box_pack_start(GTK_BOX(hbox3), vbox2, FALSE, FALSE, 0);
+
+ vbuttonbox1 = gtk_vbutton_box_new();
+ gtk_widget_show(vbuttonbox1);
+ gtk_box_pack_start(GTK_BOX(vbox2), vbuttonbox1, FALSE, FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(vbuttonbox1), 8);
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(vbuttonbox1), GTK_BUTTONBOX_END);
+ gtk_box_set_spacing(GTK_BOX(vbuttonbox1), 8);
+
+ button7 = gtk_button_new();
+ gtk_widget_show(button7);
+ gtk_container_add(GTK_CONTAINER(vbuttonbox1), button7);
+ GTK_WIDGET_SET_FLAGS(button7, GTK_CAN_DEFAULT);
+
+ image3 = gtk_image_new_from_stock("gtk-add", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show(image3);
+ gtk_container_add(GTK_CONTAINER(button7), image3);
+
+ button8 = gtk_button_new();
+ gtk_widget_show(button8);
+ gtk_container_add(GTK_CONTAINER(vbuttonbox1), button8);
+ GTK_WIDGET_SET_FLAGS(button8, GTK_CAN_DEFAULT);
+
+ image4 = gtk_image_new_from_stock("gtk-remove", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show(image4);
+ gtk_container_add(GTK_CONTAINER(button8), image4);
+
+ hseparator1 = gtk_hseparator_new();
+ gtk_widget_show(hseparator1);
+ gtk_box_pack_start(GTK_BOX(vbox2), hseparator1, FALSE, FALSE, 0);
+
+ vbuttonbox2 = gtk_vbutton_box_new();
+ gtk_widget_show(vbuttonbox2);
+ gtk_box_pack_start(GTK_BOX(vbox2), vbuttonbox2, FALSE, FALSE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(vbuttonbox2), 8);
+ gtk_box_set_spacing(GTK_BOX(vbuttonbox2), 8);
+
+ button9 = gtk_button_new();
+ gtk_widget_show(button9);
+ gtk_container_add(GTK_CONTAINER(vbuttonbox2), button9);
+ GTK_WIDGET_SET_FLAGS(button9, GTK_CAN_DEFAULT);
+
+ image5 = gtk_image_new_from_stock("gtk-go-up", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show(image5);
+ gtk_container_add(GTK_CONTAINER(button9), image5);
+
+ button10 = gtk_button_new();
+ gtk_widget_show(button10);
+ gtk_container_add(GTK_CONTAINER(vbuttonbox2), button10);
+ GTK_WIDGET_SET_FLAGS(button10, GTK_CAN_DEFAULT);
+
+ image6 = gtk_image_new_from_stock("gtk-go-down", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show(image6);
+ gtk_container_add(GTK_CONTAINER(button10), image6);
+
+ scrolledwindow2 = gtk_scrolled_window_new(NULL, NULL);
+ gtk_widget_show(scrolledwindow2);
+ gtk_box_pack_start(GTK_BOX(hbox3), scrolledwindow2, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow2), GTK_SHADOW_IN);
+
+ treeview2 = gtk_tree_view_new();
+ gtk_widget_show(treeview2);
+ gtk_container_add(GTK_CONTAINER(scrolledwindow2), treeview2);
+
+ expander1 = gtk_expander_new(NULL);
+ gtk_widget_show(expander1);
+ gtk_box_pack_start(GTK_BOX(vbox1), expander1, FALSE, FALSE, 0);
+ gtk_expander_set_expanded(GTK_EXPANDER(expander1), TRUE);
+
+ hbox4 = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(hbox4);
+ gtk_container_add(GTK_CONTAINER(expander1), hbox4);
+
+ vbox3 = gtk_vbox_new(FALSE, 0);
+ gtk_widget_show(vbox3);
+ gtk_box_pack_start(GTK_BOX(hbox4), vbox3, TRUE, TRUE, 0);
+
+ label5 = gtk_label_new(_("Author:"));
+ gtk_widget_show(label5);
+ gtk_box_pack_start(GTK_BOX(vbox3), label5, FALSE, FALSE, 0);
+ gtk_misc_set_alignment(GTK_MISC(label5), 0, 0.5);
+
+ label8 = gtk_label_new(_("label8"));
+ gtk_widget_show(label8);
+ gtk_box_pack_start(GTK_BOX(vbox3), label8, FALSE, FALSE, 0);
+
+ label6 = gtk_label_new(_("Version:"));
+ gtk_widget_show(label6);
+ gtk_box_pack_start(GTK_BOX(vbox3), label6, FALSE, FALSE, 0);
+ gtk_misc_set_alignment(GTK_MISC(label6), 0, 0.5);
+
+ label9 = gtk_label_new(_("label9"));
+ gtk_widget_show(label9);
+ gtk_box_pack_start(GTK_BOX(vbox3), label9, FALSE, FALSE, 0);
+
+ label7 = gtk_label_new(_("URL:"));
+ gtk_widget_show(label7);
+ gtk_box_pack_start(GTK_BOX(vbox3), label7, FALSE, FALSE, 0);
+ gtk_misc_set_alignment(GTK_MISC(label7), 0, 0.5);
+
+ label10 = gtk_label_new(_("label10"));
+ gtk_widget_show(label10);
+ gtk_box_pack_start(GTK_BOX(vbox3), label10, FALSE, FALSE, 0);
+
+ frame1 = gtk_frame_new(NULL);
+ gtk_widget_show(frame1);
+ gtk_box_pack_start(GTK_BOX(hbox4), frame1, TRUE, TRUE, 0);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame1), GTK_SHADOW_NONE);
+
+ alignment3 = gtk_alignment_new(0.5, 0.5, 1, 1);
+ gtk_widget_show(alignment3);
+ gtk_container_add(GTK_CONTAINER(frame1), alignment3);
+ gtk_alignment_set_padding(GTK_ALIGNMENT(alignment3), 0, 0, 12, 0);
+
+ label12 = gtk_label_new(_("label12"));
+ gtk_widget_show(label12);
+ gtk_container_add(GTK_CONTAINER(alignment3), label12);
+ gtk_misc_set_alignment(GTK_MISC(label12), 0, 0);
+
+ label11 = gtk_label_new(_("<b>Action</b>"));
+ gtk_widget_show(label11);
+ gtk_frame_set_label_widget(GTK_FRAME(frame1), label11);
+ gtk_label_set_use_markup(GTK_LABEL(label11), TRUE);
+
+ label3 = gtk_label_new(_("<b>Details:</b>"));
+ gtk_widget_show(label3);
+ gtk_expander_set_label_widget(GTK_EXPANDER(expander1), label3);
+ gtk_label_set_use_markup(GTK_LABEL(label3), TRUE);
+
+ hseparator2 = gtk_hseparator_new();
+ gtk_widget_show(hseparator2);
+ gtk_box_pack_start(GTK_BOX(vbox1), hseparator2, FALSE, FALSE, 0);
+
+ hbuttonbox1 = gtk_hbutton_box_new();
+ gtk_widget_show(hbuttonbox1);
+ gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox1, FALSE, FALSE, 0);
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1), GTK_BUTTONBOX_END);
+ gtk_box_set_spacing(GTK_BOX(hbuttonbox1), 8);
+
+ button1 = gtk_button_new();
+ gtk_widget_show(button1);
+ gtk_container_add(GTK_CONTAINER(hbuttonbox1), button1);
+ GTK_WIDGET_SET_FLAGS(button1, GTK_CAN_DEFAULT);
+
+ alignment1 = gtk_alignment_new(0.5, 0.5, 0, 0);
+ gtk_widget_show(alignment1);
+ gtk_container_add(GTK_CONTAINER(button1), alignment1);
+
+ hbox1 = gtk_hbox_new(FALSE, 2);
+ gtk_widget_show(hbox1);
+ gtk_container_add(GTK_CONTAINER(alignment1), hbox1);
+
+ image1 = gtk_image_new_from_stock("gtk-apply", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show(image1);
+ gtk_box_pack_start(GTK_BOX(hbox1), image1, FALSE, FALSE, 0);
+
+ label1 = gtk_label_new_with_mnemonic(_("Apply"));
+ gtk_widget_show(label1);
+ gtk_box_pack_start(GTK_BOX(hbox1), label1, FALSE, FALSE, 0);
+
+ button2 = gtk_button_new();
+ gtk_widget_show(button2);
+ gtk_container_add(GTK_CONTAINER(hbuttonbox1), button2);
+ GTK_WIDGET_SET_FLAGS(button2, GTK_CAN_DEFAULT);
+
+ alignment2 = gtk_alignment_new(0.5, 0.5, 0, 0);
+ gtk_widget_show(alignment2);
+ gtk_container_add(GTK_CONTAINER(button2), alignment2);
+
+ hbox2 = gtk_hbox_new(FALSE, 2);
+ gtk_widget_show(hbox2);
+ gtk_container_add(GTK_CONTAINER(alignment2), hbox2);
+
+ image2 = gtk_image_new_from_stock("gtk-cancel", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show(image2);
+ gtk_box_pack_start(GTK_BOX(hbox2), image2, FALSE, FALSE, 0);
+
+ label2 = gtk_label_new_with_mnemonic(_("Cancel"));
+ gtk_widget_show(label2);
+ gtk_box_pack_start(GTK_BOX(hbox2), label2, FALSE, FALSE, 0);
+
+
+
+
+
+
+ return result;
+
+}
+
+
+
+
+
+
+
+
diff --git a/src/dialogs/plugins.h b/src/dialogs/plugins.h
new file mode 100644
index 0000000..5de15ca
--- /dev/null
+++ b/src/dialogs/plugins.h
@@ -0,0 +1,40 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * plugins.h - prototypes pour la boîte de dialogue permettant une sélection des greffons
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _DIALOGS_SECTIONS_H
+#define _DIALOGS_SECTIONS_H
+
+
+#include <gtk/gtk.h>
+
+
+#include "../analysis/binary.h"
+
+
+
+/* Construit la fenêtre de sélection des sections. */
+GtkWidget *create_plugins_selection_dialog(GOpenidaBinary *, GtkWindow *);
+
+
+
+#endif /* _DLG_SECTIONS_H */
diff --git a/src/editor.c b/src/editor.c
index 8f6428d..63be9d1 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -51,6 +51,7 @@
#include "debug/debuggers.h"
#include "dialogs/binparts.h"
#include "dialogs/export.h"
+#include "dialogs/plugins.h"
#include "panels/panel.h"
@@ -117,6 +118,9 @@ void reload_menu_project(GObject *);
/* Réagit avec le menu "Binaire -> Sélectionner les parties...". */
static void mcb_binary_select_parts(GtkMenuItem *, GObject *);
+/* Réagit avec le menu "Binaire -> Sélectionner les greffons...". */
+static void mcb_binary_select_plugins(GtkMenuItem *, GObject *);
+
/* Réagit au menu "Binaire -> Exporter...". */
static void mcb_binary_export(GtkMenuItem *, GObject *);
@@ -328,6 +332,9 @@ GtkWidget *create_editor(void)
submenuitem = qck_create_menu_item(NULL, NULL, _("Select parts..."), G_CALLBACK(mcb_binary_select_parts), ref);
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
+ submenuitem = qck_create_menu_item(NULL, NULL, _("Select plugins..."), G_CALLBACK(mcb_binary_select_plugins), ref);
+ gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
+
submenuitem = qck_create_menu_separator();
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
@@ -1116,6 +1123,32 @@ static void mcb_binary_select_parts(GtkMenuItem *menuitem, GObject *ref)
* Paramètres : menuitem = élément de menu sélectionné. *
* ref = adresse de l'espace de référencement global. *
* *
+* Description : Réagit avec le menu "Binaire -> Sélectionner les greffons..."*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void mcb_binary_select_plugins(GtkMenuItem *menuitem, GObject *ref)
+{
+ GOpenidaBinary *binary; /* Binaire courant à l'écran */
+ GtkWidget *dialog; /* Boîte de dialogue à montrer */
+
+ binary = G_OPENIDA_BINARY(g_object_get_data(ref, "current_binary"));
+
+ dialog = create_plugins_selection_dialog(binary, GTK_WINDOW(ref));
+ gtk_widget_show(dialog);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : menuitem = élément de menu sélectionné. *
+* ref = adresse de l'espace de référencement global. *
+* *
* Description : Réagit au menu "Binaire -> Exporter...". *
* *
* Retour : - *
diff --git a/src/format/Makefile.am b/src/format/Makefile.am
index 82264bb..b080536 100644
--- a/src/format/Makefile.am
+++ b/src/format/Makefile.am
@@ -23,16 +23,10 @@ libformat_la_SOURCES = \
libformat_la_LIBADD = \
dwarf/libformatdwarf.la \
elf/libformatelf.la \
+ java/libformatjava.la \
mangling/libformatmangling.la \
pe/libformatpe.la
-# libformat_la_LIBADD = \
-# dwarf/libformatdwarf.la \
-# elf/libformatelf.la \
-# java/libformatjava.la \
-# mangling/libformatmangling.la \
-# pe/libformatpe.la
-
libformat_la_LDFLAGS =
@@ -42,5 +36,4 @@ AM_CPPFLAGS =
AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
-SUBDIRS = dwarf elf mangling pe
-#SUBDIRS = dwarf elf java mangling pe
+SUBDIRS = dwarf elf java mangling pe
diff --git a/src/format/format.c b/src/format/format.c
index 00c4538..df375fb 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -30,6 +30,7 @@
#include "format-int.h"
#include "dwarf/dwarf.h"
#include "elf/elf.h"
+#include "java/java.h"
#include "pe/pe.h"
#include "../panels/log.h"
@@ -335,6 +336,7 @@ bool init_all_formats(void)
{
register_format(FID_ELF, _("ELF"), FMT_EXEC, elf_is_matching, g_elf_format_new);
register_format(FID_DWARF, _("Dwarf"), FMT_DEBUG, dwarf_is_matching, g_dwarf_format_new);
+ register_format(FID_JAVA, _("Java"), FMT_EXEC, java_is_matching, g_java_format_new);
register_format(FID_PE, _("PE"), FMT_EXEC, pe_is_matching, g_pe_format_new);
return true;
diff --git a/src/format/format.h b/src/format/format.h
index ccd3ee7..05a2af9 100644
--- a/src/format/format.h
+++ b/src/format/format.h
@@ -83,6 +83,7 @@ typedef enum _FormatIdentifier
{
FID_ELF, /* Format ELF */
FID_DWARF, /* Format Dwarf */
+ FID_JAVA, /* Format Java */
FID_PE, /* Format PE */
FID_COUNT
diff --git a/src/format/java/Makefile.am b/src/format/java/Makefile.am
index 1ad2c67..7a5fd9c 100755
--- a/src/format/java/Makefile.am
+++ b/src/format/java/Makefile.am
@@ -2,13 +2,20 @@
noinst_LTLIBRARIES = libformatjava.la
libformatjava_la_SOURCES = \
- attribute.h attribute.c \
- e_java.h e_java.c \
- field.h field.c \
- java-int.h \
- method.h method.c \
+ java-int.h java-int.c \
+ java.h java.c \
+ java_def.h \
pool.h pool.c
+
+# libformatjava_la_SOURCES = \
+# attribute.h attribute.c \
+# e_java.h e_java.c \
+# field.h field.c \
+# java-int.h \
+# method.h method.c \
+# pool.h pool.c
+
libformatjava_la_LDFLAGS =
diff --git a/src/format/java/java-int.c b/src/format/java/java-int.c
new file mode 100644
index 0000000..b742744
--- /dev/null
+++ b/src/format/java/java-int.c
@@ -0,0 +1,90 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * java-int.c - structures internes du format Java
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "java-int.h"
+
+
+#include "pool.h"
+#include "../../common/endianness.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* pos = position de début de lecture. [OUT] *
+* header = structure lue à retourner. [OUT] *
+* *
+* Description : Procède à la lecture d'une en-tête de programme Java. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool read_java_header(const GJavaFormat *format, off_t *pos, java_header *header)
+{
+ bool result; /* Bilan à retourner */
+ const bin_t *content; /* Contenu binaire à lire */
+ off_t length; /* Taille totale du contenu */
+ uint32_t magic; /* Identifiant Java */
+ size_t i; /* Boucle de parcours */
+
+ content = G_BIN_FORMAT(format)->content;
+ length = G_BIN_FORMAT(format)->length;
+
+ result &= read_u32(&magic, content, pos, length, SRE_BIG);
+ printf("magic :: 0x%08x\n", magic);
+ result &= read_u16(&header->minor_version, content, pos, length, SRE_BIG);
+ result &= read_u16(&header->major_version, content, pos, length, SRE_BIG);
+
+ printf("avant :: %d\n", result);
+
+ result &= load_java_pool(format, pos);
+
+ printf("après :: %d\n", result);
+
+ result &= read_u16((uint16_t *)&header->access, content, pos, length, SRE_BIG);
+ result &= read_u16(&header->this_class, content, pos, length, SRE_BIG);
+ result &= read_u16(&header->super_class, content, pos, length, SRE_BIG);
+ result &= read_u16(&header->interfaces_count, content, pos, length, SRE_BIG);
+
+/* for (i = 0; i < header->interfaces_count; i++) */
+/* result &= read_u16(&header->interfaces[i], content, pos, length, SRE_BIG)) */
+/* goto ldj_error; */
+
+/* result &= load_java_fields(result, pos); */
+
+/* result &= load_java_methods(result, pos); */
+
+/* result &= load_java_attributes(result, pos, &header->attributes, &header->attributes_count); */
+
+ return result;
+
+}
+
+
+
+
+
diff --git a/src/format/java/java-int.h b/src/format/java/java-int.h
index 4fe9895..20ddf3c 100755
--- a/src/format/java/java-int.h
+++ b/src/format/java/java-int.h
@@ -21,394 +21,45 @@
*/
-#ifndef _FORMAT_JAVA_E_JAVA_INT_H
-#define _FORMAT_JAVA_E_JAVA_INT_H
+#ifndef _FORMAT_JAVA_JAVA_INT_H
+#define _FORMAT_JAVA_JAVA_INT_H
-#include "../exe_format-int.h"
+#include "java.h"
+#include "java_def.h"
+#include "../executable-int.h"
-/* ----------------------- ELEMENTS DU RESERVOIR A CONSTANTES ----------------------- */
-/* Types de données dans le réservoir (§4.4) */
-typedef enum _ConstantPoolTag
+/* Format d'exécutable Java (instance) */
+struct _GJavaFormat
{
- CONSTANT_EMPTY = 0, /* Non initialisé ou sur 2 */
+ GExeFormat parent; /* A laisser en premier */
- CONSTANT_CLASS = 7, /* Classe ou interface */
- CONSTANT_FIELD_REF = 9, /* Champ ou méthode */
- CONSTANT_METHOD_REF = 10, /* Champ ou méthode */
- CONSTANT_INTERFACE_METHOD_REF = 11, /* Champ ou méthode */
- CONSTANT_STRING = 8, /* Chaîne constante */
- CONSTANT_INTEGER = 3, /* Valeur entière */
- CONSTANT_FLOAT = 4, /* Valeur flottante */
- CONSTANT_LONG = 5, /* Valeur longue */
- CONSTANT_DOUBLE = 6, /* Valeur double */
- CONSTANT_NAME_AND_TYPE = 12, /* Prototype complet */
- CONSTANT_UTF8 = 1 /* Chaîne codée en UTF8 */
-
-} ConstantPoolTag;
-
-
-/* Représentation d'une classe ou d'une interface */
-typedef struct _class_info
-{
- uint16_t name_index; /* Indice pour le nom */
-
-} class_info;
-
-/* Représentation d'un champ ou d'une méthode */
-typedef struct _ref_info
-{
- uint16_t class_index; /* Indice de la classe */
- uint16_t name_and_type_index; /* Prototype associé */
-
-} ref_info;
-
-/* Représentation d'une chaîne constante */
-typedef struct _string_info
-{
- uint16_t string_index; /* Indice de la valeur UTF8 */
-
-} string_info;
-
-/* Représentation d'une valeur 'int' */
-typedef struct _integer_info
-{
- uint32_t val; /* Valeur au format 'int' */
-
-} integer_info;
-
-/* Représentation d'une valeur 'float' */
-typedef struct _float_info
-{
- float val; /* Valeur au format 'float' */
-
-} float_info;
-
-/* Représentation d'une valeur 'long' */
-typedef struct _long_info
-{
- long val; /* Valeur au format 'long' */
-
-} long_info;
-
-/* Représentation d'une valeur 'double' */
-typedef struct _double_info
-{
- double val; /* Valeur au format 'double' */
-
-} double_info;
-
-/* Représentation brève d'un champ ou d'une méthode */
-typedef struct _name_and_type_info
-{
- uint16_t name_index; /* Indice du nom correspondant */
- uint16_t descriptor_index; /* Prototype associé */
-
-} name_and_type_info;
-
-/* Représentation d'une chaîne codée en UTF8 */
-typedef struct _utf8_info
-{
- char *bytes; /* Valeur de la chaîne */
-
-} utf8_info;
-
-
-/* Entrée du réservoir */
-typedef struct _constant_pool_entry
-{
- ConstantPoolTag tag; /* Type d'entrée présente */
-
- union
- {
- class_info class;
- ref_info ref;
- string_info string;
- integer_info int_val;
- float_info float_val;
- long_info long_val;
- double_info double_val;
- name_and_type_info name_type;
- utf8_info utf8;
-
- } info; /* Infos portées par l'entrée */
-
-} constant_pool_entry;
-
-
-
-/* ------------------------ ATTRIBUTS POUR DES ELEMENTS JAVA ------------------------ */
-
-
-/* Types des attributs reconnus */
-typedef enum _JavaAttributeType
-{
- JAT_NONE = 0, /* Attribu non chargé */
-
- JAT_CONSTANT_VALUE, /* Valeur constante */
- JAT_CODE, /* Code exécutable */
- JAT_EXCEPTIONS, /* Exceptions remontables */
- JAT_INNER_CLASSES, /* Classes internes */
- JAT_SYNTHETIC, /* Membre non présent */
- JAT_SOURCE_FILE, /* Fichier source du code */
- JAT_LINE_NUMBER, /* Correspondances de débogage */
- JAT_LOCAL_VARIABLES, /* Variable(s) locale(s) */
- JAT_DEPRECATED /* Elément vieillot à oublier */
-
-} JavaAttributeType;
-
-/* Représentation d'un attribut à valeur constante (§4.7.2) */
-typedef struct _const_value_attrib
-{
- uint16_t const_value_index; /* Indice dans le réservoir */
-
-} const_value_attrib;
-
-/* Représentation d'un attribut de code (§4.7.3) */
-
-typedef struct _code_exception
-{
- uint16_t start_pc; /* Début de la zone couverte */
- uint16_t end_pc; /* Fin de la zone couverte */
- uint16_t handler_pc; /* Début du gestionnaire */
- uint16_t catch_type; /* Indice du type d'exception */
-
-} code_exception;
-
-typedef struct _code_attrib
-{
- uint16_t max_stack; /* Taille maximale de la pile */
- uint16_t max_locals; /* Nombre de variables (!) */
- uint32_t code_length; /* Taille du code référencé */
-
- off_t content; /* Début du code exécutable */
-
- code_exception *exceptions; /* Exceptions gérées */
- uint16_t exceptions_count; /* Nombre de ces exceptions */
-
- java_attribute *attributes; /* Attributs liés au code */
- uint16_t attributes_count; /* Nombre de ces attributs */
-
-} code_attrib;
-
-/* Représentation d'un attribut fixant les exceptions remontables (§4.7.4) */
-
-typedef struct _exceptions_attrib
-{
- uint16_t *throw; /* Exceptions remontées */
- uint16_t throw_count; /* Nombre de ces exceptions */
-
-} exceptions_attrib;
-
-/* Représentation d'un attribut présentant les classes internes (§4.7.5) */
-
-typedef enum _InnerClassAccessFlags
-{
- ICA_PUBLIC = 0x0001, /* Elément public */
- ICA_PRIVATE = 0x0002, /* Elément privé */
- ICA_PROTECTED = 0x0004, /* Elément sous protection */
- ICA_STATIC = 0x0008, /* Elément statique */
- ICA_FINAL = 0x0010, /* Elément défini un seule fois*/
- ICA_INTERFACE = 0x0200, /* Déclaration d'interface */
- ICA_ABSTRACT = 0x0400 /* Déclaré comme abstrait */
-
-} InnerClassAccessFlags;
-
-typedef struct _inner_class
-{
- uint16_t inner_class_info_index; /* Propriétés de la classe */
- uint16_t outer_class_info_index; /* Propriétés de la parente */
- uint16_t inner_name_index; /* Nom de la classe */
- InnerClassAccessFlags access; /* Droits d'accès */
-
-} inner_class;
-
-typedef struct _inner_classes_attrib
-{
- inner_class *classes; /* Classes internes */
- uint16_t classes_count; /* Nombre de ces classe */
-
-} inner_classes_attrib;
-
-/* Représentation d'un fichier source (§4.7.7) */
-typedef struct _source_file_attrib
-{
- uint16_t source_file_index; /* Indice dans le réservoir */
-
-} source_file_attrib;
-
-/* Représentation des correspondances entre lignes et code (§4.7.8) */
-
-typedef struct _pc_and_line
-{
- uint16_t start_pc; /* Début de la zone visée */
- uint16_t number; /* Numéro de ligne du code */
-
-} pc_and_line;
-
-typedef struct _line_number_attrib
-{
- pc_and_line *lines; /* Correspondances code/source */
- uint16_t lines_count; /* Nombre de correspondances */
-
-} line_number_attrib;
-
-/* Représentation des variables locales (§4.7.9) */
-
-typedef struct _local_variable
-{
- uint16_t start_pc; /* Position dans le code */
- uint16_t length; /* Taille de la variable */
- uint16_t name_index; /* Indice nominal de réservoir */
- uint16_t descriptor_index; /* Type de la variable */
- uint16_t index; /* Place dans la liste complète*/
-
-} local_variable;
-
-typedef struct _local_variables_attrib
-{
- local_variable *vars; /* Variables locales */
- uint16_t vars_count; /* Nombre de ces variables */
-
-} local_variables_attrib;
-
-/* Description des attributs Java */
-struct _java_attribute
-{
- JavaAttributeType type; /* Type d'attribut représenté */
-
- union
- {
- const_value_attrib const_value;
- code_attrib code;
- exceptions_attrib exceptions;
- inner_classes_attrib inner_classes;
- source_file_attrib source_file;
- line_number_attrib line_number;
- local_variables_attrib local_vars;
-
- } info; /* Infos portées par l'attribut*/
+ java_header header; /* En-tête du programme */
};
-
-
-/* ---------------------------- CHAMPS POUR CLASSES JAVA ---------------------------- */
-
-
-/* Types d'accès aux champs (§4.5) */
-typedef enum _FieldAccessFlags
+/* Format d'exécutable Java (classe) */
+struct _GJavaFormatClass
{
- FAC_PUBLIC = 0x0001, /* Elément public */
- FAC_PRIVATE = 0x0002, /* Elément privé */
- FAC_PROTECTED = 0x0004, /* Elément sous protection */
- FAC_STATIC = 0x0008, /* Elément statique */
- FAC_FINAL = 0x0010, /* Elément défini un seule fois*/
- FAC_VOLATILE = 0x0040, /* Elément sans cache */
- FAC_TRANSIENT = 0x0080 /* Elément ni lu ni écrit... */
-
-} FieldAccessFlags;
-
-/* Description d'un champ Java */
-typedef struct _java_field
-{
- FieldAccessFlags access; /* Droits d'accès */
-
- uint16_t name_index; /* Nom dans le réservoir */
- uint16_t descriptor_index; /* Prototype au même endroit */
-
- java_attribute *attributes; /* Attributs liés au champ */
- uint16_t attributes_count; /* Nombre de ces attributs */
-
-} java_field;
-
-
-
-/* --------------------------- METHODES POUR CLASSES JAVA --------------------------- */
-
-
-/* Types d'accès aux champs (§4.6) */
-typedef enum _MethodAccessFlags
-{
- MAC_PUBLIC = 0x0001, /* Elément public */
- MAC_PRIVATE = 0x0002, /* Elément privé */
- MAC_PROTECTED = 0x0004, /* Elément sous protection */
- MAC_STATIC = 0x0008, /* Elément statique */
- MAC_FINAL = 0x0010, /* Elément défini un seule fois*/
- MAC_SYNCHRONIZED = 0x0020, /* Elément avec mutex natif */
- MAC_NATIVE = 0x0100, /* Elément conçu sans Java */
- MAC_ABSTRACT = 0x0400, /* Elément sans implantation */
- MAC_STRICT = 0x0800 /* Elément déclaré stricte FP */
-
-} MethodAccessFlags;
-
-/* Description d'une méthode Java */
-typedef struct _java_method
-{
- MethodAccessFlags access; /* Droits d'accès */
-
- uint16_t name_index; /* Nom dans le réservoir */
- uint16_t descriptor_index; /* Prototype au même endroit */
-
- java_attribute *attributes; /* Attributs liés à la méthode */
- uint16_t attributes_count; /* Nombre de ces attributs */
-
-} java_method;
-
-
-
-/* ---------------------------- LISTE DES DROITS D'ACCES ---------------------------- */
-
-
-/* Types d'accès (§4.1) */
-typedef enum _ClassAccessFlags
-{
- CAC_PUBLIC = 0x0001, /* Elément public */
- CAC_FINAL = 0x0010, /* Déclaré comme final */
- CAC_SUPER = 0x0020, /* Traitement spécial */
- CAC_INTERFACE = 0x0200, /* Déclaration d'interface */
- CAC_ABSTRACT = 0x0400 /* Déclaré comme abstrait */
-
-} ClassAccessFlags;
-
-
-
-/* --------------------------- DESCRIPTION DU FORMAT JAVA --------------------------- */
+ GExeFormatClass parent; /* A laisser en premier */
+};
-/* Description du format Java */
-struct _java_format
-{
- exe_format dummy; /* A laisser en premier */
- uint16_t minor_version; /* Numéro de révision mineur */
- uint16_t major_version; /* Numéro de révision majeur */
- constant_pool_entry *pool; /* Réservoir de constantes */
- uint16_t pool_len; /* Quantité de ces éléments */
- ClassAccessFlags access; /* Type de classe/interface */
- uint16_t this_class; /* Infos sur la classe */
- uint16_t super_class; /* Infos sur la classe parente */
+/* Procède à la lecture d'une en-tête de programme Java. */
+bool read_java_header(const GJavaFormat *, off_t *, java_header *);
- uint16_t *interfaces; /* Interfaces intégrées */
- uint16_t interfaces_count; /* Nombre de ces interfaces */
- java_field *fields; /* Champs de la classe */
- uint16_t fields_count; /* Nombre de champs présents */
- java_method *methods; /* Méthodes de la classe */
- uint16_t methods_count; /* Nombre de méthodes listées */
- java_attribute *attributes; /* Attributs liés à la classe */
- uint16_t attributes_count; /* Nombre de ces attributs */
-};
diff --git a/src/format/java/java.c b/src/format/java/java.c
new file mode 100755
index 0000000..d11b56a
--- /dev/null
+++ b/src/format/java/java.c
@@ -0,0 +1,615 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * java.c - support du format Java
+ *
+ * Copyright (C) 2008 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "java.h"
+
+
+#include <string.h>
+
+
+#include "java-int.h"
+
+
+
+
+
+
+
+
+
+
+
+/* Initialise la classe des formats d'exécutables Java. */
+static void g_java_format_class_init(GJavaFormatClass *);
+
+/* Initialise une instance de format d'exécutable Java. */
+static void g_java_format_init(GJavaFormat *);
+
+/* Indique le type d'architecture visée par le format. */
+static FormatTargetMachine g_java_format_get_target_machine(const GJavaFormat *);
+
+/* Fournit l'adresse mémoire du point d'entrée du programme. */
+static vmpa_t g_java_format_get_entry_point(const GJavaFormat *);
+
+/* Fournit les références aux zones binaires à analyser. */
+static GBinPart **g_java_format_get_parts(const GJavaFormat *, size_t *);
+
+/* Fournit la position correspondant à une adresse virtuelle. */
+static bool g_java_format_translate_address_into_offset(const GJavaFormat *, vmpa_t, off_t *);
+
+/* Fournit l'adresse virtuelle correspondant à une position. */
+static bool g_java_format_translate_offset_into_address(const GJavaFormat *, off_t, vmpa_t *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type de format recherché. *
+* content = contenu binaire à parcourir. *
+* length = taille du contenu en question. *
+* *
+* Description : Indique si le format peut être pris en charge ici. *
+* *
+* Retour : true si la réponse est positive, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool java_is_matching(FormatType type, const uint8_t *content, off_t length)
+{
+ bool result; /* Bilan à faire connaître */
+
+ result = false;
+
+ if (length >= 4)
+ result = (strncmp((const char *)content, "\xca\xfe\xba\xbe", 4) == 0);
+
+ return result;
+
+}
+
+
+/* Indique le type défini pour un format d'exécutable Java. */
+G_DEFINE_TYPE(GJavaFormat, g_java_format, G_TYPE_EXE_FORMAT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des formats d'exécutables Java. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_java_format_class_init(GJavaFormatClass *klass)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = instance à initialiser. *
+* *
+* Description : Initialise une instance de format d'exécutable Java. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_java_format_init(GJavaFormat *format)
+{
+ GExeFormat *exe_format; /* Format parent à constituer */
+
+ exe_format = G_EXE_FORMAT(format);
+
+ exe_format->get_machine = (get_target_machine_fc)g_java_format_get_target_machine;
+ exe_format->get_entry_point = (get_entry_point_fc)g_java_format_get_entry_point;
+ exe_format->get_parts = (get_parts_fc)g_java_format_get_parts;
+
+ exe_format->translate_addr = (translate_addr_fc)g_java_format_translate_address_into_offset;
+ exe_format->translate_off = (translate_off_fc)g_java_format_translate_offset_into_address;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : content = contenu binaire à parcourir. *
+* length = taille du contenu en question. *
+* *
+* Description : Prend en charge un nouveau format Java. *
+* *
+* Retour : Adresse de la structure mise en place ou NULL en cas d'échec.*
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinFormat *g_java_format_new(const bin_t *content, off_t length)
+{
+ GJavaFormat *result; /* Structure à retourner */
+ off_t offset; /* Tête de lecture */
+
+ result = g_object_new(G_TYPE_JAVA_FORMAT, NULL);
+
+ g_binary_format_set_content(G_BIN_FORMAT(result), content, length);
+
+
+ offset = 0;
+
+ if (!read_java_header(result, &offset, &result->header))
+ {
+ /* TODO */
+ return NULL;
+ }
+
+
+ return G_BIN_FORMAT(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* *
+* Description : Indique le type d'architecture visée par le format. *
+* *
+* Retour : Identifiant de l'architecture ciblée par le format. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static FormatTargetMachine g_java_format_get_target_machine(const GJavaFormat *format)
+{
+ FormatTargetMachine result; /* Identifiant à retourner */
+
+ result = FTM_386;
+
+ /*
+ switch (format->header.e_machine)
+ {
+ case EM_MIPS:
+ result = FTM_MIPS;
+ break;
+
+ case EM_386:
+ result = FTM_386;
+ break;
+
+ case EM_NONE:
+ default:
+ result = FTM_NONE;
+ break;
+
+ }
+ */
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* *
+* Description : Fournit l'adresse mémoire du point d'entrée du programme. *
+* *
+* Retour : Adresse de mémoire. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static vmpa_t g_java_format_get_entry_point(const GJavaFormat *format)
+{
+ return 0;//(format->is_32b ? format->header.e_entry.addr32 : format->header.e_entry.addr64);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* count = quantité de zones listées. [OUT] *
+* *
+* Description : Fournit les références aux zones binaires à analyser. *
+* *
+* Retour : Zones binaires à analyser. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GBinPart **g_java_format_get_parts(const GJavaFormat *format, size_t *count)
+{
+ GBinPart **result; /* Tableau à retourner */
+ uint16_t i; /* Boucle de parcours */
+ off_t offset; /* Position physique */
+ off_t size; /* Taille de la partie */
+ GBinPart *part; /* Partie à intégrer à la liste*/
+
+ result = NULL;
+ *count = 0;
+ /*
+ for (i = 0; i < format->header.methods_count; i++)
+ if (find_java_method_code_part(&format->header.methods[i], &offset, &size))
+ {
+ part = g_binary_part_new();
+
+ g_binary_part_set_name(part, "name");
+
+ g_binary_part_set_values(part, offset, size, offset);
+
+ result = (GBinPart **)realloc(result, ++(*count) * sizeof(GBinPart *));
+ result[*count - 1] = part;
+
+ }
+
+ }
+ */
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* addr = adresse virtuelle à retrouver. *
+* pos = position correspondante. [OUT] *
+* *
+* Description : Fournit la position correspondant à une adresse virtuelle. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_java_format_translate_address_into_offset(const GJavaFormat *format, vmpa_t addr, off_t *pos)
+{
+ bool result; /* Bilan à retourner */
+
+ result = false;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à consulter. *
+* pos = position dans le flux binaire à retrouver. *
+* addr = adresse virtuelle correspondante. [OUT] *
+* *
+* Description : Fournit l'adresse virtuelle correspondant à une position. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_java_format_translate_offset_into_address(const GJavaFormat *format, off_t pos, vmpa_t *addr)
+{
+ bool result; /* Bilan à retourner */
+
+ result = false;
+
+ return result;
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#if 0
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include "attribute.h"
+#include "field.h"
+#include "java-int.h"
+#include "method.h"
+#include "pool.h"
+#include "../../common/endianness.h"
+
+
+
+
+/* Indique le type d'architecture visée par le format. */
+FormatTargetMachine get_java_target_machine(const java_format *);
+
+
+
+/* Fournit les références aux zones de code à analyser. */
+bin_part **get_java_default_code_parts(const java_format *, size_t *);
+
+
+/* Fournit le prototype de toutes les routines détectées. */
+GBinRoutine **get_all_java_routines(const java_format *, size_t *);
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : content = contenu binaire à parcourir. *
+* length = taille du contenu en question. *
+* *
+* Description : Indique si le format peut être pris en charge ici. *
+* *
+* Retour : true si la réponse est positive, false sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool java_is_matching(const uint8_t *content, off_t length)
+{
+ bool result; /* Bilan à faire connaître */
+
+ result = false;
+
+ if (length >= 4)
+ result = (strncmp((const char *)content, "\xca\xfe\xba\xbe", 4) == 0);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : content = contenu binaire à parcourir. *
+* length = taille du contenu en question. *
+* *
+* Description : Prend en charge une nouvelle classe Java. *
+* *
+* Retour : Adresse de la structure mise en place ou NULL en cas d'échec.*
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+exe_format *load_java(const uint8_t *content, off_t length)
+{
+ java_format *result; /* Adresse à retourner */
+ off_t pos; /* Point d'analyse */
+ uint32_t magic; /* Identifiant Java */
+ uint16_t i; /* Boucle de parcours */
+
+ result = (java_format *)calloc(1, sizeof(java_format));
+
+ EXE_FORMAT(result)->content = content;
+ EXE_FORMAT(result)->length = length;
+
+ EXE_FORMAT(result)->get_target_machine = (get_target_machine_fc)get_java_target_machine;
+ EXE_FORMAT(result)->get_def_parts = (get_def_parts_fc)get_java_default_code_parts;
+ EXE_FORMAT(result)->get_all_routines = (get_all_routines_fc)get_all_java_routines;
+
+ pos = 0;
+
+ if (!read_u32(&magic, content, &pos, length, SRE_BIG))
+ goto ldj_error;
+
+ if (!read_u16(&result->minor_version, content, &pos, length, SRE_BIG))
+ goto ldj_error;
+
+ if (!read_u16(&result->major_version, content, &pos, length, SRE_BIG))
+ goto ldj_error;
+
+ if (!load_java_pool(result, &pos))
+ goto ldj_error;
+
+ if (!read_u16((uint16_t *)&result->access, content, &pos, length, SRE_BIG))
+ goto ldj_error;
+
+ if (!read_u16(&result->this_class, content, &pos, length, SRE_BIG))
+ goto ldj_error;
+
+ if (!read_u16(&result->super_class, content, &pos, length, SRE_BIG))
+ goto ldj_error;
+
+ if (!read_u16(&result->interfaces_count, content, &pos, length, SRE_BIG))
+ goto ldj_error;
+
+ for (i = 0; i < result->interfaces_count; i++)
+ if (!read_u16(&result->interfaces[i], content, &pos, length, SRE_BIG))
+ goto ldj_error;
+
+ if (!load_java_fields(result, &pos))
+ goto ldj_error;
+
+ if (!load_java_methods(result, &pos))
+ goto ldj_error;
+
+ if (!load_java_attributes(result, &pos, &result->attributes, &result->attributes_count))
+ goto ldj_error;
+
+ return EXE_FORMAT(result);
+
+ ldj_error:
+
+ unload_java(result);
+
+ return NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à supprimer. *
+* *
+* Description : Efface la prise en charge une nouvelle classe Java. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void unload_java(java_format *format)
+{
+ if (format->pool_len > 0)
+ unload_java_pool(format);
+
+ if (format->interfaces_count > 0)
+ free(format->interfaces);
+
+ if (format->fields_count > 0)
+ unload_java_fields(format);
+
+ if (format->methods_count > 0)
+ unload_java_methods(format);
+
+ if (format->attributes_count > 0)
+ unload_java_attributes(format, format->attributes, format->attributes_count);
+
+ free(format);
+
+}
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* *
+* Description : Indique le type d'architecture visée par le format. *
+* *
+* Retour : Identifiant de l'architecture ciblée par le format. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+FormatTargetMachine get_java_target_machine(const java_format *format)
+{
+ return FTM_JVM;
+
+}
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* count = quantité de zones listées. [OUT] *
+* *
+* Description : Fournit les références aux zones de code à analyser. *
+* *
+* Retour : Zones de code à analyser. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bin_part **get_java_default_code_parts(const java_format *format, size_t *count)
+{
+ bin_part **result; /* Tableau à retourner */
+ uint16_t i; /* Boucle de parcours */
+ off_t offset; /* Position physique */
+ off_t size; /* Taille de la partie */
+ bin_part *part; /* Partie à intégrer à la liste*/
+
+ result = NULL;
+ *count = 0;
+
+ for (i = 0; i < format->methods_count; i++)
+ if (find_java_method_code_part(&format->methods[i], &offset, &size))
+ {
+ part = create_bin_part();
+
+ set_bin_part_values(part, offset, size, offset);
+
+ result = (bin_part **)realloc(result, ++(*count) * sizeof(bin_part *));
+ result[*count - 1] = part;
+
+ }
+
+ return result;
+
+}
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* count = taille du tableau créé. [OUT] *
+* *
+* Description : Fournit le prototype de toutes les routines détectées. *
+* *
+* Retour : Tableau créé ou NULL si aucun symbole de routine trouvé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinRoutine **get_all_java_routines(const java_format *format, size_t *count)
+{
+ *count = 0;
+
+ return NULL;
+
+}
+
+#endif
diff --git a/src/format/java/java.h b/src/format/java/java.h
new file mode 100755
index 0000000..0c11a62
--- /dev/null
+++ b/src/format/java/java.h
@@ -0,0 +1,62 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * java.h - prototypes pour le support du format Java
+ *
+ * Copyright (C) 2008 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _FORMAT_JAVA_JAVA_H
+#define _FORMAT_JAVA_JAVA_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+#include <sys/types.h>
+
+
+#include "../format.h"
+
+
+
+#define G_TYPE_JAVA_FORMAT g_java_format_get_type()
+#define G_JAVA_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_java_format_get_type(), GJavaFormat))
+#define G_IS_JAVA_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_java_format_get_type()))
+#define G_JAVA_FORMAT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE((inst), g_java_format_get_type(), GJavaFormatIface))
+#define G_JAVA_FORMAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_JAVA_FORMAT, GJavaFormatClass))
+
+
+/* Format d'exécutable Java (instance) */
+typedef struct _GJavaFormat GJavaFormat;
+
+/* Format d'exécutable Java (classe) */
+typedef struct _GJavaFormatClass GJavaFormatClass;
+
+
+/* Indique si le format peut être pris en charge ici. */
+bool java_is_matching(FormatType, const bin_t *, off_t);
+
+/* Indique le type défini pour un format d'exécutable Java. */
+GType g_java_format_get_type(void);
+
+/* Prend en charge un nouveau format Java. */
+GBinFormat *g_java_format_new(const bin_t *, off_t);
+
+
+
+#endif /* _FORMAT_JAVA_JAVA_H */
diff --git a/src/format/java/java_def.h b/src/format/java/java_def.h
new file mode 100755
index 0000000..fb700a0
--- /dev/null
+++ b/src/format/java/java_def.h
@@ -0,0 +1,418 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * java_def.h - liste des structures et constantes utilisées par le format Java
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _FORMAT_JAVA_JAVA_DEF_H
+#define _FORMAT_JAVA_JAVA_DEF_H
+
+
+#include <stdint.h>
+
+
+
+/* Description des attributs Java */
+typedef struct _java_attribute java_attribute;
+
+
+
+/* ----------------------- ELEMENTS DU RESERVOIR A CONSTANTES ----------------------- */
+
+
+/* Types de données dans le réservoir (§4.4) */
+typedef enum _ConstantPoolTag
+{
+ CONSTANT_EMPTY = 0, /* Non initialisé ou sur 2 */
+
+ CONSTANT_CLASS = 7, /* Classe ou interface */
+ CONSTANT_FIELD_REF = 9, /* Champ ou méthode */
+ CONSTANT_METHOD_REF = 10, /* Champ ou méthode */
+ CONSTANT_INTERFACE_METHOD_REF = 11, /* Champ ou méthode */
+ CONSTANT_STRING = 8, /* Chaîne constante */
+ CONSTANT_INTEGER = 3, /* Valeur entière */
+ CONSTANT_FLOAT = 4, /* Valeur flottante */
+ CONSTANT_LONG = 5, /* Valeur longue */
+ CONSTANT_DOUBLE = 6, /* Valeur double */
+ CONSTANT_NAME_AND_TYPE = 12, /* Prototype complet */
+ CONSTANT_UTF8 = 1 /* Chaîne codée en UTF8 */
+
+} ConstantPoolTag;
+
+
+/* Représentation d'une classe ou d'une interface */
+typedef struct _class_info
+{
+ uint16_t name_index; /* Indice pour le nom */
+
+} class_info;
+
+/* Représentation d'un champ ou d'une méthode */
+typedef struct _ref_info
+{
+ uint16_t class_index; /* Indice de la classe */
+ uint16_t name_and_type_index; /* Prototype associé */
+
+} ref_info;
+
+/* Représentation d'une chaîne constante */
+typedef struct _string_info
+{
+ uint16_t string_index; /* Indice de la valeur UTF8 */
+
+} string_info;
+
+/* Représentation d'une valeur 'int' */
+typedef struct _integer_info
+{
+ uint32_t val; /* Valeur au format 'int' */
+
+} integer_info;
+
+/* Représentation d'une valeur 'float' */
+typedef struct _float_info
+{
+ float val; /* Valeur au format 'float' */
+
+} float_info;
+
+/* Représentation d'une valeur 'long' */
+typedef struct _long_info
+{
+ long val; /* Valeur au format 'long' */
+
+} long_info;
+
+/* Représentation d'une valeur 'double' */
+typedef struct _double_info
+{
+ double val; /* Valeur au format 'double' */
+
+} double_info;
+
+/* Représentation brève d'un champ ou d'une méthode */
+typedef struct _name_and_type_info
+{
+ uint16_t name_index; /* Indice du nom correspondant */
+ uint16_t descriptor_index; /* Prototype associé */
+
+} name_and_type_info;
+
+/* Représentation d'une chaîne codée en UTF8 */
+typedef struct _utf8_info
+{
+ char *bytes; /* Valeur de la chaîne */
+
+} utf8_info;
+
+
+/* Entrée du réservoir */
+typedef struct _constant_pool_entry
+{
+ ConstantPoolTag tag; /* Type d'entrée présente */
+
+ union
+ {
+ class_info class;
+ ref_info ref;
+ string_info string;
+ integer_info int_val;
+ float_info float_val;
+ long_info long_val;
+ double_info double_val;
+ name_and_type_info name_type;
+ utf8_info utf8;
+
+ } info; /* Infos portées par l'entrée */
+
+} constant_pool_entry;
+
+
+
+/* ------------------------ ATTRIBUTS POUR DES ELEMENTS JAVA ------------------------ */
+
+
+/* Types des attributs reconnus */
+typedef enum _JavaAttributeType
+{
+ JAT_NONE = 0, /* Attribu non chargé */
+
+ JAT_CONSTANT_VALUE, /* Valeur constante */
+ JAT_CODE, /* Code exécutable */
+ JAT_EXCEPTIONS, /* Exceptions remontables */
+ JAT_INNER_CLASSES, /* Classes internes */
+ JAT_SYNTHETIC, /* Membre non présent */
+ JAT_SOURCE_FILE, /* Fichier source du code */
+ JAT_LINE_NUMBER, /* Correspondances de débogage */
+ JAT_LOCAL_VARIABLES, /* Variable(s) locale(s) */
+ JAT_DEPRECATED /* Elément vieillot à oublier */
+
+} JavaAttributeType;
+
+/* Représentation d'un attribut à valeur constante (§4.7.2) */
+typedef struct _const_value_attrib
+{
+ uint16_t const_value_index; /* Indice dans le réservoir */
+
+} const_value_attrib;
+
+/* Représentation d'un attribut de code (§4.7.3) */
+
+typedef struct _code_exception
+{
+ uint16_t start_pc; /* Début de la zone couverte */
+ uint16_t end_pc; /* Fin de la zone couverte */
+ uint16_t handler_pc; /* Début du gestionnaire */
+ uint16_t catch_type; /* Indice du type d'exception */
+
+} code_exception;
+
+typedef struct _code_attrib
+{
+ uint16_t max_stack; /* Taille maximale de la pile */
+ uint16_t max_locals; /* Nombre de variables (!) */
+ uint32_t code_length; /* Taille du code référencé */
+
+ off_t content; /* Début du code exécutable */
+
+ code_exception *exceptions; /* Exceptions gérées */
+ uint16_t exceptions_count; /* Nombre de ces exceptions */
+
+ java_attribute *attributes; /* Attributs liés au code */
+ uint16_t attributes_count; /* Nombre de ces attributs */
+
+} code_attrib;
+
+/* Représentation d'un attribut fixant les exceptions remontables (§4.7.4) */
+
+typedef struct _exceptions_attrib
+{
+ uint16_t *throw; /* Exceptions remontées */
+ uint16_t throw_count; /* Nombre de ces exceptions */
+
+} exceptions_attrib;
+
+/* Représentation d'un attribut présentant les classes internes (§4.7.5) */
+
+typedef enum _InnerClassAccessFlags
+{
+ ICA_PUBLIC = 0x0001, /* Elément public */
+ ICA_PRIVATE = 0x0002, /* Elément privé */
+ ICA_PROTECTED = 0x0004, /* Elément sous protection */
+ ICA_STATIC = 0x0008, /* Elément statique */
+ ICA_FINAL = 0x0010, /* Elément défini un seule fois*/
+ ICA_INTERFACE = 0x0200, /* Déclaration d'interface */
+ ICA_ABSTRACT = 0x0400 /* Déclaré comme abstrait */
+
+} InnerClassAccessFlags;
+
+typedef struct _inner_class
+{
+ uint16_t inner_class_info_index; /* Propriétés de la classe */
+ uint16_t outer_class_info_index; /* Propriétés de la parente */
+ uint16_t inner_name_index; /* Nom de la classe */
+ InnerClassAccessFlags access; /* Droits d'accès */
+
+} inner_class;
+
+typedef struct _inner_classes_attrib
+{
+ inner_class *classes; /* Classes internes */
+ uint16_t classes_count; /* Nombre de ces classe */
+
+} inner_classes_attrib;
+
+/* Représentation d'un fichier source (§4.7.7) */
+typedef struct _source_file_attrib
+{
+ uint16_t source_file_index; /* Indice dans le réservoir */
+
+} source_file_attrib;
+
+/* Représentation des correspondances entre lignes et code (§4.7.8) */
+
+typedef struct _pc_and_line
+{
+ uint16_t start_pc; /* Début de la zone visée */
+ uint16_t number; /* Numéro de ligne du code */
+
+} pc_and_line;
+
+typedef struct _line_number_attrib
+{
+ pc_and_line *lines; /* Correspondances code/source */
+ uint16_t lines_count; /* Nombre de correspondances */
+
+} line_number_attrib;
+
+/* Représentation des variables locales (§4.7.9) */
+
+typedef struct _local_variable
+{
+ uint16_t start_pc; /* Position dans le code */
+ uint16_t length; /* Taille de la variable */
+ uint16_t name_index; /* Indice nominal de réservoir */
+ uint16_t descriptor_index; /* Type de la variable */
+ uint16_t index; /* Place dans la liste complète*/
+
+} local_variable;
+
+typedef struct _local_variables_attrib
+{
+ local_variable *vars; /* Variables locales */
+ uint16_t vars_count; /* Nombre de ces variables */
+
+} local_variables_attrib;
+
+/* Description des attributs Java */
+struct _java_attribute
+{
+ JavaAttributeType type; /* Type d'attribut représenté */
+
+ union
+ {
+ const_value_attrib const_value;
+ code_attrib code;
+ exceptions_attrib exceptions;
+ inner_classes_attrib inner_classes;
+ source_file_attrib source_file;
+ line_number_attrib line_number;
+ local_variables_attrib local_vars;
+
+ } info; /* Infos portées par l'attribut*/
+
+};
+
+
+
+/* ---------------------------- CHAMPS POUR CLASSES JAVA ---------------------------- */
+
+
+/* Types d'accès aux champs (§4.5) */
+typedef enum _FieldAccessFlags
+{
+ FAC_PUBLIC = 0x0001, /* Elément public */
+ FAC_PRIVATE = 0x0002, /* Elément privé */
+ FAC_PROTECTED = 0x0004, /* Elément sous protection */
+ FAC_STATIC = 0x0008, /* Elément statique */
+ FAC_FINAL = 0x0010, /* Elément défini un seule fois*/
+ FAC_VOLATILE = 0x0040, /* Elément sans cache */
+ FAC_TRANSIENT = 0x0080 /* Elément ni lu ni écrit... */
+
+} FieldAccessFlags;
+
+/* Description d'un champ Java */
+typedef struct _java_field
+{
+ FieldAccessFlags access; /* Droits d'accès */
+
+ uint16_t name_index; /* Nom dans le réservoir */
+ uint16_t descriptor_index; /* Prototype au même endroit */
+
+ java_attribute *attributes; /* Attributs liés au champ */
+ uint16_t attributes_count; /* Nombre de ces attributs */
+
+} java_field;
+
+
+
+/* --------------------------- METHODES POUR CLASSES JAVA --------------------------- */
+
+
+/* Types d'accès aux champs (§4.6) */
+typedef enum _MethodAccessFlags
+{
+ MAC_PUBLIC = 0x0001, /* Elément public */
+ MAC_PRIVATE = 0x0002, /* Elément privé */
+ MAC_PROTECTED = 0x0004, /* Elément sous protection */
+ MAC_STATIC = 0x0008, /* Elément statique */
+ MAC_FINAL = 0x0010, /* Elément défini un seule fois*/
+ MAC_SYNCHRONIZED = 0x0020, /* Elément avec mutex natif */
+ MAC_NATIVE = 0x0100, /* Elément conçu sans Java */
+ MAC_ABSTRACT = 0x0400, /* Elément sans implantation */
+ MAC_STRICT = 0x0800 /* Elément déclaré stricte FP */
+
+} MethodAccessFlags;
+
+/* Description d'une méthode Java */
+typedef struct _java_method
+{
+ MethodAccessFlags access; /* Droits d'accès */
+
+ uint16_t name_index; /* Nom dans le réservoir */
+ uint16_t descriptor_index; /* Prototype au même endroit */
+
+ java_attribute *attributes; /* Attributs liés à la méthode */
+ uint16_t attributes_count; /* Nombre de ces attributs */
+
+} java_method;
+
+
+
+/* ---------------------------- LISTE DES DROITS D'ACCES ---------------------------- */
+
+
+/* Types d'accès (§4.1) */
+typedef enum _ClassAccessFlags
+{
+ CAC_PUBLIC = 0x0001, /* Elément public */
+ CAC_FINAL = 0x0010, /* Déclaré comme final */
+ CAC_SUPER = 0x0020, /* Traitement spécial */
+ CAC_INTERFACE = 0x0200, /* Déclaration d'interface */
+ CAC_ABSTRACT = 0x0400 /* Déclaré comme abstrait */
+
+} ClassAccessFlags;
+
+
+
+/* --------------------------- DESCRIPTION DU FORMAT JAVA --------------------------- */
+
+
+/* En-tête de tout programe Java */
+typedef struct _java_header
+{
+ uint16_t minor_version; /* Numéro de révision mineur */
+ uint16_t major_version; /* Numéro de révision majeur */
+
+ constant_pool_entry *pool; /* Réservoir de constantes */
+ uint16_t pool_len; /* Quantité de ces éléments */
+
+ ClassAccessFlags access; /* Type de classe/interface */
+
+ uint16_t this_class; /* Infos sur la classe */
+ uint16_t super_class; /* Infos sur la classe parente */
+
+ uint16_t *interfaces; /* Interfaces intégrées */
+ uint16_t interfaces_count; /* Nombre de ces interfaces */
+
+ java_field *fields; /* Champs de la classe */
+ uint16_t fields_count; /* Nombre de champs présents */
+
+ java_method *methods; /* Méthodes de la classe */
+ uint16_t methods_count; /* Nombre de méthodes listées */
+
+ java_attribute *attributes; /* Attributs liés à la classe */
+ uint16_t attributes_count; /* Nombre de ces attributs */
+
+} java_header;
+
+
+
+#endif /* _FORMAT_JAVA_JAVA_DEF_H */
diff --git a/src/format/java/pool.c b/src/format/java/pool.c
index eec2918..c05abd5 100755
--- a/src/format/java/pool.c
+++ b/src/format/java/pool.c
@@ -35,10 +35,10 @@
/* Charge les propriétés d'une constante du réservoir. */
-bool load_java_pool_entry(java_format *, constant_pool_entry *, off_t *);
+bool load_java_pool_entry(GJavaFormat *, constant_pool_entry *, off_t *);
/* Fournit une entrée donnée du réservoir de constantes. */
-const constant_pool_entry *get_java_pool_entry(const java_format *, uint16_t, ConstantPoolTag);
+const constant_pool_entry *get_java_pool_entry(const GJavaFormat *, uint16_t, ConstantPoolTag);
@@ -55,35 +55,39 @@ const constant_pool_entry *get_java_pool_entry(const java_format *, uint16_t, Co
* *
******************************************************************************/
-bool load_java_pool(java_format *format, off_t *pos)
+bool load_java_pool(GJavaFormat *format, off_t *pos)
{
bool result; /* Bilan à remonter */
uint16_t count; /* Nombre d'éléments présents */
uint16_t i; /* Boucle de parcours */
- result = read_u16(&count, EXE_FORMAT(format)->content, pos,
- EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u16(&count, G_BIN_FORMAT(format)->content, pos,
+ G_BIN_FORMAT(format)->length, SRE_BIG);
- format->pool_len = count - 1;
- format->pool = (constant_pool_entry *)calloc(count - 1, sizeof(constant_pool_entry));
+ printf("Alloc %hu entries (result=%d)\n", count, result);
+
+ format->header.pool_len = count - 1;
+ format->header.pool = (constant_pool_entry *)calloc(count - 1, sizeof(constant_pool_entry));
for (i = 1; i < count && result; i++)
{
- result = load_java_pool_entry(format, &format->pool[i - 1], pos);
+ result = load_java_pool_entry(format, &format->header.pool[i - 1], pos);
- if (format->pool[i - 1].tag == CONSTANT_LONG
- || format->pool[i - 1].tag == CONSTANT_DOUBLE)
+ if (format->header.pool[i - 1].tag == CONSTANT_LONG
+ || format->header.pool[i - 1].tag == CONSTANT_DOUBLE)
{
i++;
/* On n'est jamais trop prudent */
if (i < count)
- format->pool[i - 1].tag = CONSTANT_EMPTY;
+ format->header.pool[i - 1].tag = CONSTANT_EMPTY;
}
}
+ printf("stop at %hd || pos :: %d - max %d\n", i, *pos, G_BIN_FORMAT(format)->length);
+
return result;
}
@@ -101,12 +105,12 @@ bool load_java_pool(java_format *format, off_t *pos)
* *
******************************************************************************/
-void unload_java_pool(java_format *format)
+void unload_java_pool(GJavaFormat *format)
{
uint16_t i; /* Boucle de parcours */
- for (i = 0; i < format->pool_len; i++)
- switch (format->pool[i].tag)
+ for (i = 0; i < format->header.pool_len; i++)
+ switch (format->header.pool[i].tag)
{
case CONSTANT_EMPTY:
case CONSTANT_CLASS:
@@ -122,12 +126,12 @@ void unload_java_pool(java_format *format)
break;
case CONSTANT_UTF8:
- free(format->pool[i].info.utf8.bytes);
+ free(format->header.pool[i].info.utf8.bytes);
break;
}
- free(format->pool);
+ free(format->header.pool);
}
@@ -146,7 +150,7 @@ void unload_java_pool(java_format *format)
* *
******************************************************************************/
-bool load_java_pool_entry(java_format *format, constant_pool_entry *entry, off_t *pos)
+bool load_java_pool_entry(GJavaFormat *format, constant_pool_entry *entry, off_t *pos)
{
bool result; /* Bilan à retourner */
uint8_t tag; /* Type de l'élément */
@@ -159,43 +163,43 @@ bool load_java_pool_entry(java_format *format, constant_pool_entry *entry, off_t
uint64_t mantissa64; /* Mantisse du nombre lu 64b */
uint16_t length; /* Taille d'une chaîne */
- result = read_u8(&tag, EXE_FORMAT(format)->content, pos,
- EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u8(&tag, G_BIN_FORMAT(format)->content, pos,
+ G_BIN_FORMAT(format)->length, SRE_BIG);
entry->tag = tag;
switch (entry->tag)
{
case CONSTANT_CLASS:
- result = read_u16(&entry->info.class.name_index, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u16(&entry->info.class.name_index, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
break;
case CONSTANT_FIELD_REF:
case CONSTANT_METHOD_REF:
case CONSTANT_INTERFACE_METHOD_REF:
- result = read_u16(&entry->info.ref.class_index, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
- result &= read_u16(&entry->info.ref.name_and_type_index, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u16(&entry->info.ref.class_index, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
+ result &= read_u16(&entry->info.ref.name_and_type_index, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
break;
case CONSTANT_STRING:
- result = read_u16(&entry->info.string.string_index, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u16(&entry->info.string.string_index, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
break;
case CONSTANT_INTEGER:
- result = read_u32(&entry->info.int_val.val, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u32(&entry->info.int_val.val, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
break;
case CONSTANT_FLOAT:
- result = read_u32(&low_bytes, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u32(&low_bytes, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
if (result)
{
@@ -232,10 +236,10 @@ bool load_java_pool_entry(java_format *format, constant_pool_entry *entry, off_t
case CONSTANT_LONG:
- result = read_u32(&high_bytes, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
- result &= read_u32(&low_bytes, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u32(&high_bytes, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
+ result &= read_u32(&low_bytes, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
if (result)
{
@@ -247,10 +251,10 @@ bool load_java_pool_entry(java_format *format, constant_pool_entry *entry, off_t
case CONSTANT_DOUBLE:
- result = read_u32(&high_bytes, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
- result &= read_u32(&low_bytes, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u32(&high_bytes, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
+ result &= read_u32(&low_bytes, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
if (result)
{
@@ -289,22 +293,22 @@ bool load_java_pool_entry(java_format *format, constant_pool_entry *entry, off_t
case CONSTANT_NAME_AND_TYPE:
- result = read_u16(&entry->info.name_type.name_index, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
- result &= read_u16(&entry->info.name_type.descriptor_index, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u16(&entry->info.name_type.name_index, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
+ result &= read_u16(&entry->info.name_type.descriptor_index, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
break;
case CONSTANT_UTF8:
- result = read_u16(&length, EXE_FORMAT(format)->content,
- pos, EXE_FORMAT(format)->length, SRE_BIG);
+ result = read_u16(&length, G_BIN_FORMAT(format)->content,
+ pos, G_BIN_FORMAT(format)->length, SRE_BIG);
if (result)
{
entry->info.utf8.bytes = (char *)calloc(length + 1, sizeof(char));
- memcpy(entry->info.utf8.bytes, &EXE_FORMAT(format)->content[*pos], length);
+ memcpy(entry->info.utf8.bytes, &G_BIN_FORMAT(format)->content[*pos], length);
*pos += length;
}
@@ -335,16 +339,16 @@ bool load_java_pool_entry(java_format *format, constant_pool_entry *entry, off_t
* *
******************************************************************************/
-const constant_pool_entry *get_java_pool_entry(const java_format *format, uint16_t index, ConstantPoolTag expected)
+const constant_pool_entry *get_java_pool_entry(const GJavaFormat *format, uint16_t index, ConstantPoolTag expected)
{
const constant_pool_entry *result; /* Entrée à retourner */
constant_pool_entry *entry; /* Entrée du réservoir visée */
result = NULL;
- if (/*index < 0 && FIXME */index <= format->pool_len);
+ if (/*index < 0 && FIXME */index <= format->header.pool_len);
{
- entry = &format->pool[index - 1];
+ entry = &format->header.pool[index - 1];
if (entry->tag == expected)
result = entry;
@@ -370,7 +374,7 @@ const constant_pool_entry *get_java_pool_entry(const java_format *format, uint16
* *
******************************************************************************/
-char *build_reference_from_java_pool(const java_format *format, uint16_t index, JavaRefType expected)
+char *build_reference_from_java_pool(const GJavaFormat *format, uint16_t index, JavaRefType expected)
{
char *result; /* Chaîne humaine à retourner */
const constant_pool_entry *entry; /* Entrée du réservoir visée 1 */
@@ -455,7 +459,7 @@ char *build_reference_from_java_pool(const java_format *format, uint16_t index,
* *
******************************************************************************/
-bool get_java_pool_ut8_string(const java_format *format, uint16_t index, const char **str)
+bool get_java_pool_ut8_string(const GJavaFormat *format, uint16_t index, const char **str)
{
bool result; /* Bilan à renvoyer */
const constant_pool_entry *entry; /* Entrée du réservoir visée */
diff --git a/src/format/java/pool.h b/src/format/java/pool.h
index 62d8a84..3550511 100755
--- a/src/format/java/pool.h
+++ b/src/format/java/pool.h
@@ -25,7 +25,7 @@
#define _FORMAT_JAVA_POOL_H
-#include "e_java.h"
+#include "java.h"
@@ -40,16 +40,16 @@ typedef enum _JavaRefType
/* Charge le réservoir de constantes d'un binaire Java. xs*/
-bool load_java_pool(java_format *, off_t *);
+bool load_java_pool(GJavaFormat *, off_t *);
/* Décharge le réservoir de constantes d'un binaire Java. */
-void unload_java_pool(java_format *);
+void unload_java_pool(GJavaFormat *);
/* Construit une version humaine de référence. */
-char *build_reference_from_java_pool(const java_format *, uint16_t, JavaRefType);
+char *build_reference_from_java_pool(const GJavaFormat *, uint16_t, JavaRefType);
/* Recherche une chaîne de caractères dans le réservoir. */
-bool get_java_pool_ut8_string(const java_format *, uint16_t, const char **);
+bool get_java_pool_ut8_string(const GJavaFormat *, uint16_t, const char **);
diff --git a/src/format/pe/pe-int.h b/src/format/pe/pe-int.h
index 3322f62..0c8bf45 100644
--- a/src/format/pe/pe-int.h
+++ b/src/format/pe/pe-int.h
@@ -35,7 +35,7 @@
-/* Format d'exécutable générique (instance) */
+/* Format d'exécutable PE (instance) */
struct _GPeFormat
{
GExeFormat parent; /* A laisser en premier */
@@ -47,7 +47,7 @@ struct _GPeFormat
};
-/* Format d'exécutable générique (classe) */
+/* Format d'exécutable PE (classe) */
struct _GPeFormatClass
{
GExeFormatClass parent; /* A laisser en premier */
diff --git a/src/format/pe/pe.c b/src/format/pe/pe.c
index 1d4e6f4..7b2ac25 100644
--- a/src/format/pe/pe.c
+++ b/src/format/pe/pe.c
@@ -338,9 +338,9 @@ static GBinPart **g_pe_format_get_parts(const GPeFormat *format, size_t *count)
/******************************************************************************
* *
-* Paramètres : format = description de l'exécutable à consulter. *
-* addr = adresse virtuelle à retrouver. *
-* pos = position correspondante. [OUT] *
+* Paramètres : format = description de l'exécutable à consulter. *
+* addr = adresse virtuelle à retrouver. *
+* pos = position correspondante. [OUT] *
* *
* Description : Fournit la position correspondant à une adresse virtuelle. *
* *
@@ -363,9 +363,9 @@ static bool g_pe_format_translate_address_into_offset(const GPeFormat *format, v
/******************************************************************************
* *
-* Paramètres : format = description de l'exécutable à consulter. *
-* pos = position dans le flux binaire à retrouver. *
-* addr = adresse virtuelle correspondante. [OUT] *
+* Paramètres : format = description de l'exécutable à consulter. *
+* pos = position dans le flux binaire à retrouver. *
+* addr = adresse virtuelle correspondante. [OUT] *
* *
* Description : Fournit l'adresse virtuelle correspondant à une position. *
* *
diff --git a/src/format/pe/pe.h b/src/format/pe/pe.h
index da1f44d..9789205 100644
--- a/src/format/pe/pe.h
+++ b/src/format/pe/pe.h
@@ -21,8 +21,8 @@
*/
-#ifndef _FORMAT_PE_E_PE_H
-#define _FORMAT_PE_E_PE_H
+#ifndef _FORMAT_PE_PE_H
+#define _FORMAT_PE_PE_H
#include <glib-object.h>
@@ -59,4 +59,4 @@ GBinFormat *g_pe_format_new(const bin_t *, off_t);
-#endif /* _FORMAT_PE_E_PE_H */
+#endif /* _FORMAT_PE_PE_H */