summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-04-25 16:51:41 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-04-25 16:51:41 (GMT)
commitb9977e00ff9eb6e025e86a15c858183f3f314cf5 (patch)
treeeedacb236b90228d2b4c603fa9875ecaad05ee29 /src
parent216a3d0121fabd678e50ea6b4fa2447ae9b921f0 (diff)
Saved the current work on plugins.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@59 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am37
-rwxr-xr-xsrc/analysis/Makefile.am11
-rw-r--r--src/analysis/binary.c (renamed from src/binary.c)19
-rw-r--r--src/analysis/binary.h (renamed from src/binary.h)4
-rw-r--r--src/analysis/line.c13
-rw-r--r--src/arch/Makefile.am9
-rw-r--r--src/arch/processor.c64
-rw-r--r--src/arch/processor.h4
-rw-r--r--src/arch/x86/processor.c3
-rwxr-xr-xsrc/common/Makefile.am6
-rw-r--r--src/common/extstr.c55
-rw-r--r--src/common/extstr.h3
-rw-r--r--src/debug/debuggers.h2
-rw-r--r--src/debug/ptrace/options.h2
-rw-r--r--src/dlg_sections.c2
-rw-r--r--src/editor.c24
-rw-r--r--src/format/Makefile.am11
-rw-r--r--src/format/dwarf/Makefile.am6
-rw-r--r--src/format/elf/Makefile.am8
-rw-r--r--src/format/elf/e_elf.c6
-rwxr-xr-xsrc/format/java/Makefile.am6
-rw-r--r--src/format/mangling/Makefile.am6
-rwxr-xr-xsrc/format/pe/Makefile.am6
-rw-r--r--src/gtkext/Makefile.am11
-rw-r--r--src/gtkext/easygtk.c (renamed from src/easygtk.c)22
-rw-r--r--src/gtkext/easygtk.h (renamed from src/easygtk.h)0
-rw-r--r--src/gtkext/gtkdockpanel.c6
-rw-r--r--src/gtkext/gtksnippet.c26
-rw-r--r--src/gtkext/support.c (renamed from src/support.c)0
-rw-r--r--src/gtkext/support.h (renamed from src/support.h)0
-rwxr-xr-xsrc/panel/Makefile.am7
-rw-r--r--src/panel/log.c10
-rw-r--r--src/panel/registers.c2
-rw-r--r--src/plugins/Makefile.am17
-rw-r--r--src/plugins/pglist.c73
-rw-r--r--src/plugins/pglist.h39
-rw-r--r--src/plugins/plugin.c144
-rw-r--r--src/plugins/plugin.h56
-rw-r--r--src/plugins/pyoida/Makefile.am20
-rwxr-xr-xsrc/plugins/pyoida/linsyscalls/oidapgi.py28
-rw-r--r--src/plugins/pyoida/py_binary.c358
-rw-r--r--src/plugins/pyoida/py_binary.h45
-rw-r--r--src/plugins/pyoida/py_line.c802
-rw-r--r--src/plugins/pyoida/py_line.h45
-rw-r--r--src/plugins/pyoida/py_log.c341
-rw-r--r--src/plugins/pyoida/py_log.h39
-rw-r--r--src/plugins/pyoida/pyoida.c131
-rw-r--r--src/plugins/pyoida/pyoida.h38
-rw-r--r--src/project.c2
-rw-r--r--src/project.h2
-rw-r--r--src/shell.c330
-rw-r--r--src/shell.h38
52 files changed, 2761 insertions, 178 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index da52127..fa63b43 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,43 +2,46 @@
bin_PROGRAMS=openida
openida_SOURCES = \
- binary.h binary.c \
dlg_sections.h dlg_sections.c \
- easygtk.h easygtk.c \
editor.c \
pan_strings.h pan_strings.c \
pan_symbols.h pan_symbols.c \
project.h project.c \
- support.h support.c \
+ shell.h shell.c \
xdg.h xdg.c \
xml.h xml.c
-INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/intl $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) `pkg-config --cflags gthread-2.0`
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/intl $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) `pkg-config --cflags gthread-2.0` $(LIBPYTHON_CFLAGS) $(LIBVTE_CFLAGS)
AM_CPPFLAGS =
AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
-openida_LDFLAGS = $(LIBGTK_LIBS) -L/usr/X11R6/lib -ldl -lm $(LIBXML_LIBS) `pkg-config --libs gthread-2.0`
+openida_LDFLAGS = $(LIBGTK_LIBS) -L/usr/X11R6/lib -ldl -lm $(LIBXML_LIBS) `pkg-config --libs gthread-2.0` $(LIBPYTHON_LIBS) $(LIBVTE_LIBS) \
+ -Larch/.libs -larch \
+ -Lcommon/.libs -lcommon \
+ -Lpanel/.libs -lpanel \
+ -Lgtkext/.libs -lgtkext \
+ -Lanalysis/.libs -lanalysis \
+ -Lformat/.libs -lformat \
+ -Lformat/dwarf/.libs -lformatdwarf \
+ -Lformat/elf/.libs -lformatelf \
+ -Lformat/java/.libs -lformatjava \
+ -Lformat/mangling/.libs -lformatmangling \
+ -Lformat/pe/.libs -lformatpe
openida_LDADD = $(LIBINTL) \
- arch/libarch.a \
- arch/x86/libarchx86.a \
debug/libdebug.a \
debug/ptrace/libdebugptrace.a \
- format/libformat.a \
- format/dwarf/libformatdwarf.a \
- format/elf/libformatelf.a \
- format/java/libformatjava.a \
- format/mangling/libformatmangling.a \
- format/pe/libformatpe.a \
- gtkext/libgtkext.a \
- panel/libpanel.a \
- analysis/libanalysis.a \
+ plugins/libplugins.a \
+ plugins/pyoida/libpyoida.a \
common/libcommon.a
-SUBDIRS = analysis arch common debug format gtkext panel
+# gtkext doit être traité en premier, à cause des marshals GLib
+# common doit être passé avant analysis
+
+SUBDIRS = arch format common analysis debug gtkext panel plugins
diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am
index e5f7689..8d986a1 100755
--- a/src/analysis/Makefile.am
+++ b/src/analysis/Makefile.am
@@ -1,7 +1,8 @@
-lib_LIBRARIES = libanalysis.a
+lib_LTLIBRARIES = libanalysis.la
-libanalysis_a_SOURCES = \
+libanalysis_la_SOURCES = \
+ binary.h binary.c \
line.h line.c \
line-int.h \
line_code.h line_code.c \
@@ -10,10 +11,12 @@ libanalysis_a_SOURCES = \
prototype.h prototype.c \
variable.h variable.c
-libanalysis_a_CFLAGS = $(AM_CFLAGS)
+libanalysis_la_LDFLAGS = $(LIBGTK_LIBS) $(LIBXML_LIBS) \
+ -L../common/.libs -lcommon \
+ -L../format/.libs -lformat
-INCLUDES = $(LIBGTK_CFLAGS)
+INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
AM_CPPFLAGS =
diff --git a/src/binary.c b/src/analysis/binary.c
index 85196d9..95b24b1 100644
--- a/src/binary.c
+++ b/src/analysis/binary.c
@@ -35,15 +35,15 @@
#include <sys/types.h>
-#include "analysis/line_code.h"
-#include "analysis/line_comment.h"
-#include "analysis/line_prologue.h"
-#include "analysis/prototype.h"
-#include "arch/processor.h"
+#include "line_code.h"
+#include "line_comment.h"
+#include "line_prologue.h"
+#include "prototype.h"
+#include "../arch/processor.h"
-#include "format/dbg_format.h"
-#include "format/exe_format.h"
+#include "../format/dbg_format.h"
+#include "../format/exe_format.h"
@@ -117,7 +117,7 @@ openida_binary *load_binary_file(const char *filename)
if (result->format == NULL) goto lbf_error;
- result->proc = create_x86_processor();
+ result->proc = create_processor();
result->options.show_address = true;
@@ -529,9 +529,6 @@ void disassemble_openida_binary(openida_binary *binary)
binary->lines = build_binary_prologue(binary->filename, binary->bin_data, binary->bin_length);
-
-
-
routines = get_all_exe_routines(binary->format, &routines_count);
diff --git a/src/binary.h b/src/analysis/binary.h
index ed3522d..69da2a7 100644
--- a/src/binary.h
+++ b/src/analysis/binary.h
@@ -26,10 +26,10 @@
#include <stdbool.h>
-#include "xml.h"
-#include "analysis/line.h"
+#include "line.h"
+#include "../xml.h"
diff --git a/src/analysis/line.c b/src/analysis/line.c
index 4fc0ac5..bba601c 100644
--- a/src/analysis/line.c
+++ b/src/analysis/line.c
@@ -39,7 +39,7 @@
/* FIXME */
-extern GtkWidget *mywid;
+//extern GtkWidget *mywid;
@@ -96,9 +96,15 @@ static void g_rendering_line_class_init(GRenderingLineClass *klass)
static void g_rendering_line_init(GRenderingLine *line)
{
+ GdkScreen *screen;
+ PangoContext *context;
+
DL_LIST_ITEM_INIT(&line->link);
- line->layout = gtk_widget_create_pango_layout(mywid, NULL);
+ screen = gdk_screen_get_default();
+ context = gdk_pango_context_get_for_screen(screen);
+
+ line->layout = pango_layout_new(context);
line->get_bin_len = NULL;
line->refresh_markup = NULL;
@@ -230,6 +236,7 @@ RenderingLineFlag g_rendering_line_get_flags(const GRenderingLine *line)
void g_rendering_line_draw(GRenderingLine *line, GdkDrawable *drawable, GdkGC *gc, gint x0, gint x1, gint y, gint h)
{
+#if 0
GdkPixbuf *pixbuf; /* Données utiles au dessin */
gdk_draw_layout(drawable, gc, x1, y, line->layout);
@@ -268,7 +275,7 @@ void g_rendering_line_draw(GRenderingLine *line, GdkDrawable *drawable, GdkGC *g
g_object_unref(pixbuf);
}
-
+#endif
}
diff --git a/src/arch/Makefile.am b/src/arch/Makefile.am
index 2f7f072..ad5e3c6 100644
--- a/src/arch/Makefile.am
+++ b/src/arch/Makefile.am
@@ -1,7 +1,7 @@
-lib_LIBRARIES = libarch.a
+lib_LTLIBRARIES = libarch.la
-libarch_a_SOURCES = \
+libarch_la_SOURCES = \
instruction-int.h \
instruction.h instruction.c \
operand-int.h \
@@ -9,7 +9,10 @@ libarch_a_SOURCES = \
processor-int.h \
processor.h processor.c
-libarch_a_CFLAGS = $(AM_CFLAGS)
+libarch_la_LIBADD = \
+ x86/libarchx86.a
+
+libarch_la_LDFLAGS =
INCLUDES = $(LIBGTK_CFLAGS)
diff --git a/src/arch/processor.c b/src/arch/processor.c
index d367949..a67986d 100644
--- a/src/arch/processor.c
+++ b/src/arch/processor.c
@@ -24,16 +24,21 @@
#include "processor.h"
-#include <regex.h>
-#include <string.h>
#include "instruction-int.h"
#include "processor-int.h"
+#include "x86/processor.h"
+asm_processor *create_processor(void)
+{
+ return create_x86_processor();
+
+}
+
/******************************************************************************
@@ -72,7 +77,7 @@ asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, of
{
*pos = old_pos;
- printf("err while decoding opcode 0x%02hhx at 0x%08llx\n", data[*pos], offset);
+ //printf("err while decoding opcode 0x%02hhx at 0x%08llx\n", data[*pos], offset);
result = create_db_instruction(data, pos, len);
}
@@ -88,59 +93,6 @@ asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, of
}
-/******************************************************************************
-* *
-* Paramètres : input = chaîne de caractères à traiter. *
-* *
-* Description : S'assure qu'une chaîne de caractère tient sur une ligne. *
-* *
-* Retour : Adresse de la chaîne de caractères modifiée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-char *escape_crlf_bin_string(char *input)
-{
- size_t inlen;
- regex_t preg;
- int ret;
- size_t curpos;
- regmatch_t pmatch[2];
-
- inlen = strlen(input);
-
- ret = regcomp(&preg, "(\t|\n|\r)", REG_EXTENDED | REG_ICASE);
- /* TODO: ret */
-
- for (curpos = 0; regexec(&preg, &input[curpos], 2, pmatch, 0) != REG_NOMATCH; )
- {
- inlen += 1 + 1;
- input = (char *)realloc(input, inlen * sizeof(char *));
-
- memmove(&input[curpos + pmatch[1].rm_eo + 1], &input[curpos + pmatch[1].rm_eo], inlen - 1 - curpos - pmatch[1].rm_eo);
-
- switch (input[curpos + pmatch[1].rm_so])
- {
- case '\t':
- memcpy(&input[curpos + pmatch[1].rm_so], "\\t", 2);
- break;
- case '\n':
- memcpy(&input[curpos + pmatch[1].rm_so], "\\n", 2);
- break;
- case '\r':
- memcpy(&input[curpos + pmatch[1].rm_so], "\\r", 2);
- break;
- }
-
- curpos += pmatch[1].rm_eo + 1;
-
- }
-
- return input;
-
-}
-
/******************************************************************************
* *
diff --git a/src/arch/processor.h b/src/arch/processor.h
index 343a98c..6c65e95 100644
--- a/src/arch/processor.h
+++ b/src/arch/processor.h
@@ -53,6 +53,10 @@ typedef struct _asm_processor asm_processor;
+asm_processor *create_processor(void);
+
+
+
/* Décode une instruction dans un flux de données. */
asm_instr *decode_instruction(const asm_processor *, const uint8_t *, off_t *, off_t, off_t, uint64_t);
diff --git a/src/arch/x86/processor.c b/src/arch/x86/processor.c
index 15d26a4..b6f5c30 100644
--- a/src/arch/x86/processor.c
+++ b/src/arch/x86/processor.c
@@ -32,6 +32,7 @@
#include "instruction.h"
#include "opcodes.h"
#include "operand.h"
+#include "../../common/extstr.h"
@@ -517,7 +518,7 @@ void x86_print_instruction(const asm_x86_processor *proc, const exe_format *form
break;
case STP_STRING:
- label = escape_crlf_bin_string(label);
+ label = escape_crlf(label);
snprintf(&opbuffer[i][oplen], 256 - oplen, " \"%s\"", label);
break;
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index f23941b..1bb66d9 100755
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -1,13 +1,13 @@
-lib_LIBRARIES = libcommon.a
+lib_LTLIBRARIES = libcommon.la
-libcommon_a_SOURCES = \
+libcommon_la_SOURCES = \
dllist.h dllist.c \
endianness.h endianness.c \
extstr.h extstr.c \
macros.h
-libcommon_a_CFLAGS = $(AM_CFLAGS)
+libcommon_la_LDFLAGS =
INCLUDES =
diff --git a/src/common/extstr.c b/src/common/extstr.c
index aba9830..deffbd4 100644
--- a/src/common/extstr.c
+++ b/src/common/extstr.c
@@ -25,6 +25,7 @@
#include <malloc.h>
+#include <regex.h>
#include <string.h>
@@ -83,3 +84,57 @@ char *strprep(char *str1, const char *str2)
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : input = chaîne de caractères à traiter. *
+* *
+* Description : S'assure qu'une chaîne de caractère tient sur une ligne. *
+* *
+* Retour : Adresse de la chaîne de caractères modifiée. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+char *escape_crlf(char *input)
+{
+ size_t inlen;
+ regex_t preg;
+ int ret;
+ size_t curpos;
+ regmatch_t pmatch[2];
+
+ inlen = strlen(input);
+
+ ret = regcomp(&preg, "(\t|\n|\r)", REG_EXTENDED | REG_ICASE);
+ /* TODO: ret */
+
+ for (curpos = 0; regexec(&preg, &input[curpos], 2, pmatch, 0) != REG_NOMATCH; )
+ {
+ inlen += 1 + 1;
+ input = (char *)realloc(input, inlen * sizeof(char *));
+
+ memmove(&input[curpos + pmatch[1].rm_eo + 1], &input[curpos + pmatch[1].rm_eo], inlen - 1 - curpos - pmatch[1].rm_eo);
+
+ switch (input[curpos + pmatch[1].rm_so])
+ {
+ case '\t':
+ memcpy(&input[curpos + pmatch[1].rm_so], "\\t", 2);
+ break;
+ case '\n':
+ memcpy(&input[curpos + pmatch[1].rm_so], "\\n", 2);
+ break;
+ case '\r':
+ memcpy(&input[curpos + pmatch[1].rm_so], "\\r", 2);
+ break;
+ }
+
+ curpos += pmatch[1].rm_eo + 1;
+
+ }
+
+ return input;
+
+}
diff --git a/src/common/extstr.h b/src/common/extstr.h
index 8975000..8baa2e2 100644
--- a/src/common/extstr.h
+++ b/src/common/extstr.h
@@ -32,6 +32,9 @@ char *stradd(char *str1, const char *str2);
/* Fait précéder une chaîne de caractères par une autre. */
char *strprep(char *, const char *);
+/* S'assure qu'une chaîne de caractère tient sur une ligne. */
+char *escape_crlf(char *);
+
#endif /* _COMMON_EXTSTR_H */
diff --git a/src/debug/debuggers.h b/src/debug/debuggers.h
index 96e0c47..03c3164 100644
--- a/src/debug/debuggers.h
+++ b/src/debug/debuggers.h
@@ -30,7 +30,7 @@
#include <sys/types.h>
-#include "../binary.h"
+#include "../analysis/binary.h"
diff --git a/src/debug/ptrace/options.h b/src/debug/ptrace/options.h
index e49f87c..bc25abf 100644
--- a/src/debug/ptrace/options.h
+++ b/src/debug/ptrace/options.h
@@ -28,7 +28,7 @@
#include <stdbool.h>
-#include "../../binary.h"
+#include "../../analysis/binary.h"
diff --git a/src/dlg_sections.c b/src/dlg_sections.c
index 2aae552..44a00a7 100644
--- a/src/dlg_sections.c
+++ b/src/dlg_sections.c
@@ -24,7 +24,7 @@
#include "dlg_sections.h"
-#include "easygtk.h"
+#include "gtkext/easygtk.h"
diff --git a/src/editor.c b/src/editor.c
index 888f1af..4e0b8c2 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -41,21 +41,27 @@
-#include "binary.h"
#include "dlg_sections.h"
-#include "easygtk.h"
#include "pan_strings.h"
#include "pan_symbols.h"
+#include "analysis/binary.h"
+#include "gtkext/easygtk.h"
#include "gtkext/gtkbinview.h"
#include "gtkext/gtkdockpanel.h"
#include "gtkext/gtksnippet.h"
#include "format/exe_format.h"
#include "format/mangling/demangler.h"
+#include "plugins/pglist.h"
#include "debug/debuggers.h"
#include "panel/panels.h"
+
+#include "shell.h" /* TODO : à virer -> plugin */
+
+
+
#define _(str) str
@@ -180,6 +186,7 @@ int main(int argc, char **argv)
editor = create_editor();
gtk_widget_show(editor);
+ init_all_plugins(G_OBJECT(editor));
gdk_threads_enter();
gtk_main();
@@ -396,10 +403,16 @@ GtkWidget *create_editor(void)
submenuitem = qck_create_menu_separator();
gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
+
+
update_debug_menu_items(ref, FALSE);
+ menuitem = gtk_menu_item_new_with_mnemonic(_("_Plugins"));
+ gtk_widget_show(menuitem);
+ gtk_container_add(GTK_CONTAINER(menuboard), menuitem);
+
@@ -523,6 +536,13 @@ GtkWidget *create_editor(void)
+ panel = build_shell_panel(G_OBJECT(result));
+
+ ditem = gtk_dock_item_new(_("Shell"), panel);
+ gtk_dock_panel_add_item(dpanel, ditem);
+
+
+
/*
notebook = qck_create_notebook(NULL, NULL);
diff --git a/src/format/Makefile.am b/src/format/Makefile.am
index baf11de..41d7120 100644
--- a/src/format/Makefile.am
+++ b/src/format/Makefile.am
@@ -1,13 +1,18 @@
-lib_LIBRARIES = libformat.a
+lib_LTLIBRARIES = libformat.la
-libformat_a_SOURCES = \
+libformat_la_SOURCES = \
exe_format.h exe_format.c \
exe_format-int.h \
dbg_format.h dbg_format.c \
dbg_format-int.h
-libformat_a_CFLAGS = $(AM_CFLAGS)
+libformat_la_LDFLAGS = $(LIBGTK_LIBS) \
+ -Ldwarf/.libs -lformatdwarf \
+ -Lelf/.libs -lformatelf \
+ -Ljava/.libs -lformatjava \
+ -Lmangling/.libs -lformatmangling \
+ -Lpe/.libs -lformatpe
INCLUDES = $(LIBGTK_CFLAGS)
diff --git a/src/format/dwarf/Makefile.am b/src/format/dwarf/Makefile.am
index 0c36205..d5853c3 100644
--- a/src/format/dwarf/Makefile.am
+++ b/src/format/dwarf/Makefile.am
@@ -1,14 +1,14 @@
-lib_LIBRARIES = libformatdwarf.a
+lib_LTLIBRARIES = libformatdwarf.la
-libformatdwarf_a_SOURCES = \
+libformatdwarf_la_SOURCES = \
abbrev.h abbrev.c \
d_dwarf.h d_dwarf.c \
dwarf_def.h \
info.h info.c \
utils.h utils.c
-libformatdwarf_a_CFLAGS = $(AM_CFLAGS)
+libformatdwarf_la_LDFLAGS = $(LIBGTK_LIBS)
INCLUDES =
diff --git a/src/format/elf/Makefile.am b/src/format/elf/Makefile.am
index 663194e..c64fc5c 100644
--- a/src/format/elf/Makefile.am
+++ b/src/format/elf/Makefile.am
@@ -1,14 +1,16 @@
-lib_LIBRARIES = libformatelf.a
+lib_LTLIBRARIES = libformatelf.la
-libformatelf_a_SOURCES = \
+libformatelf_la_SOURCES = \
e_elf.h e_elf.c \
elf-int.h \
section.h section.c \
strings.h strings.c \
symbol.h symbol.c
-libformatelf_a_CFLAGS = $(AM_CFLAGS)
+libformatelf_la_LDFLAGS = $(LIBGTK_LIBS) \
+ -L../../common/.libs -common \
+ -L../../arch/.libs -larch
INCLUDES = $(LIBGTK_CFLAGS)
diff --git a/src/format/elf/e_elf.c b/src/format/elf/e_elf.c
index 1a1fe8d..c52a304 100644
--- a/src/format/elf/e_elf.c
+++ b/src/format/elf/e_elf.c
@@ -33,6 +33,7 @@
#include "strings.h"
#include "symbol.h"
#include "../../panel/log.h"
+#include "../../common/extstr.h"
@@ -47,9 +48,6 @@ uint64_t get_elf_entry_point(const elf_format *);
-/* S'assure qu'une chaîne de caractère tient sur une ligne. */
-extern char *escape_crlf_bin_string(char *);
-
/* Récupère tous les éléments identifiées dans le binaire. */
size_t get_elf_resolved_items(const elf_format *, char ***, ResolvedType **, uint64_t **);
@@ -462,7 +460,7 @@ size_t get_elf_resolved_items(const elf_format *format, char ***labels, Resolved
(*types)[start + i] = RTP_STRING;
(*offsets)[start + i] = format->strings[i].vaddress;
- (*labels)[start + i] = escape_crlf_bin_string((*labels)[start + i]);
+ (*labels)[start + i] = escape_crlf((*labels)[start + i]);
}
diff --git a/src/format/java/Makefile.am b/src/format/java/Makefile.am
index f94466d..9f59f61 100755
--- a/src/format/java/Makefile.am
+++ b/src/format/java/Makefile.am
@@ -1,7 +1,7 @@
-lib_LIBRARIES = libformatjava.a
+lib_LTLIBRARIES = libformatjava.la
-libformatjava_a_SOURCES = \
+libformatjava_la_SOURCES = \
attribute.h attribute.c \
e_java.h e_java.c \
field.h field.c \
@@ -9,7 +9,7 @@ libformatjava_a_SOURCES = \
method.h method.c \
pool.h pool.c
-libformatjava_a_CFLAGS = $(AM_CFLAGS)
+libformatjava_la_LDFLAGS = $(LIBGTK_LIBS)
INCLUDES = $(LIBGTK_CFLAGS)
diff --git a/src/format/mangling/Makefile.am b/src/format/mangling/Makefile.am
index 3f7acc5..0823ffc 100644
--- a/src/format/mangling/Makefile.am
+++ b/src/format/mangling/Makefile.am
@@ -3,15 +3,15 @@ BUILT_SOURCES = itanium_gram.h
AM_YFLAGS = -d
-lib_LIBRARIES = libformatmangling.a
+lib_LTLIBRARIES = libformatmangling.la
-libformatmangling_a_SOURCES = \
+libformatmangling_la_SOURCES = \
demangler.h demangler.c \
itanium.h \
itanium_gram.y \
itanium_tok.l
-libformatmangling_a_CFLAGS = $(AM_CFLAGS)
+libformatmangling_la_LDFLAGS = $(LIBGTK_LIBS)
INCLUDES = $(LIBGTK_CFLAGS)
diff --git a/src/format/pe/Makefile.am b/src/format/pe/Makefile.am
index cf47c4e..9167577 100755
--- a/src/format/pe/Makefile.am
+++ b/src/format/pe/Makefile.am
@@ -1,11 +1,11 @@
-lib_LIBRARIES = libformatpe.a
+lib_LTLIBRARIES = libformatpe.la
-libformatpe_a_SOURCES = \
+libformatpe_la_SOURCES = \
e_pe.h e_pe.c \
pe-int.h
-libformatpe_a_CFLAGS = $(AM_CFLAGS)
+libformatpe_la_LDFLAGS = $(LIBGTK_LIBS)
INCLUDES =
diff --git a/src/gtkext/Makefile.am b/src/gtkext/Makefile.am
index aa14cf5..dbf1fbc 100644
--- a/src/gtkext/Makefile.am
+++ b/src/gtkext/Makefile.am
@@ -1,17 +1,20 @@
BUILT_SOURCES = iodamarshal.h iodamarshal.c
-lib_LIBRARIES = libgtkext.a
+lib_LTLIBRARIES = libgtkext.la
-libgtkext_a_SOURCES = \
+libgtkext_la_SOURCES = \
+ easygtk.h easygtk.c \
gtkbinview.h gtkbinview.c \
gtkdockitem.h gtkdockitem.c \
gtkdockpanel.h gtkdockpanel.c \
gtkdropwindow.h gtkdropwindow.c \
gtksnippet.h gtksnippet.c \
- iodamarshal.h iodamarshal.c
+ iodamarshal.h iodamarshal.c \
+ support.h support.c
-libgtkext_a_CFLAGS = $(AM_CFLAGS)
+libgtkext_la_LDFLAGS = $(LIBGTK_LIBS) \
+ -L../analysis/.libs -lanalysis
INCLUDES = $(LIBGTK_CFLAGS)
diff --git a/src/easygtk.c b/src/gtkext/easygtk.c
index d6f8dc4..f596404 100644
--- a/src/easygtk.c
+++ b/src/gtkext/easygtk.c
@@ -115,7 +115,7 @@ GtkWidget *qck_create_notebook(GObject *object, const char *name)
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -155,7 +155,7 @@ GtkWidget *qck_create_image(GObject *object, const char *name, gchar *filename)
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -188,7 +188,7 @@ GtkWidget *qck_create_label(GObject *object, const char *name, const char *capti
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -222,7 +222,7 @@ GtkWidget *qck_create_entry(GObject *object, const char *name, const char *text)
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -261,7 +261,7 @@ GtkWidget *qck_create_button(GObject *object, const char *name, const char *capt
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -300,7 +300,7 @@ GtkWidget *qck_create_button_from_stock(GObject *object, const char *name, const
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -344,7 +344,7 @@ GtkWidget *qck_create_button_with_img(GObject *object, const char *name, const c
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -381,7 +381,7 @@ GtkWidget *qck_create_combobox(GObject *object, const char *name, GCallback hand
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -424,7 +424,7 @@ GtkWidget *qck_create_menu_item(GObject *object, const char *name, const char *c
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -462,7 +462,7 @@ GtkWidget *qck_create_check_menu_item(GObject *object, const char *name, const c
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
@@ -501,7 +501,7 @@ GtkWidget *qck_create_radio_menu_item(GObject *object, const char *name, GSList
if (G_IS_OBJECT(object) && name != NULL)
{
gtk_widget_ref(result);
- g_object_set_data_full(object, name, result, (GtkDestroyNotify)gtk_widget_unref);
+ g_object_set_data_full(object, name, result, (GtkDestroyNotify)g_object_unref);
}
gtk_widget_show(result);
diff --git a/src/easygtk.h b/src/gtkext/easygtk.h
index 41b24e0..41b24e0 100644
--- a/src/easygtk.h
+++ b/src/gtkext/easygtk.h
diff --git a/src/gtkext/gtkdockpanel.c b/src/gtkext/gtkdockpanel.c
index f48f31a..e7bd14b 100644
--- a/src/gtkext/gtkdockpanel.c
+++ b/src/gtkext/gtkdockpanel.c
@@ -624,13 +624,13 @@ static gboolean gtk_dock_panel_update_title(GtkNotebook *notebook, GtkNotebookPa
char *str; /* Valeur finale reconstituée */
- printf("[%p] list len :: %u / %u\n", data, index, g_list_length(GTK_DOCK_PANEL(data)->ditems));
+ //printf("[%p] list len :: %u / %u\n", data, index, g_list_length(GTK_DOCK_PANEL(data)->ditems));
if (index >= g_list_length(GTK_DOCK_PANEL(data)->ditems)) return FALSE;
- printf(" >> ditem = %p\n", g_list_nth_data(GTK_DOCK_PANEL(data)->ditems, index));
+ //printf(" >> ditem = %p\n", g_list_nth_data(GTK_DOCK_PANEL(data)->ditems, index));
- printf(" >> index :: %u vs %d\n", index, gtk_notebook_get_current_page(GTK_DOCK_PANEL(data)->notebook));
+ //printf(" >> index :: %u vs %d\n", index, gtk_notebook_get_current_page(GTK_DOCK_PANEL(data)->notebook));
ditem = GTK_DOCK_ITEM(g_list_nth_data(GTK_DOCK_PANEL(data)->ditems, index));
diff --git a/src/gtkext/gtksnippet.c b/src/gtkext/gtksnippet.c
index a48baf2..39d2949 100644
--- a/src/gtkext/gtksnippet.c
+++ b/src/gtkext/gtksnippet.c
@@ -156,29 +156,10 @@ static void gtk_snippet_paint(GtkSnippet *snippet);
static void gtk_snippet_destroy(GtkObject *object);
-GtkType
-gtk_snippet_get_type(void)
-{
- static GtkType gtk_snippet_type = 0;
-
-
- if (!gtk_snippet_type) {
- static const GtkTypeInfo gtk_snippet_info = {
- "GtkSnippet",
- sizeof(GtkSnippet),
- sizeof(GtkSnippetClass),
- (GtkClassInitFunc) gtk_snippet_class_init,
- (GtkObjectInitFunc) gtk_snippet_init,
- NULL,
- NULL,
- (GtkClassInitFunc) NULL
- };
- gtk_snippet_type = gtk_type_unique(GTK_TYPE_WIDGET, &gtk_snippet_info);
- }
+
+G_DEFINE_TYPE(GtkSnippet, gtk_snippet, GTK_TYPE_WIDGET)
- return gtk_snippet_type;
-}
GtkWidget * gtk_snippet_new(void)
@@ -688,6 +669,7 @@ void gtk_snippet_add_line(GtkSnippet *snippet, const code_line_info *line)
void gtk_snippet_build_content(GtkSnippet *snippet)
{
+#if 0
const uint8_t *exe_content; /* Contenu binaire global */
off_t max_bin_len; /* Taille max du code brut */
unsigned int i; /* Boucle de traitement */
@@ -854,7 +836,7 @@ void gtk_snippet_build_content(GtkSnippet *snippet)
pango_layout_iter_free(iter);
//gtk_widget_set_size_request(GTK_WIDGET(snippet), width + 2 * MARGIN_SPACE + snippet->line_height, height);
-
+#endif
}
diff --git a/src/support.c b/src/gtkext/support.c
index 67e7605..67e7605 100644
--- a/src/support.c
+++ b/src/gtkext/support.c
diff --git a/src/support.h b/src/gtkext/support.h
index 9d3373b..9d3373b 100644
--- a/src/support.h
+++ b/src/gtkext/support.h
diff --git a/src/panel/Makefile.am b/src/panel/Makefile.am
index a74cfa0..c69e2ca 100755
--- a/src/panel/Makefile.am
+++ b/src/panel/Makefile.am
@@ -1,12 +1,13 @@
-lib_LIBRARIES = libpanel.a
+lib_LTLIBRARIES = libpanel.la
-libpanel_a_SOURCES = \
+libpanel_la_SOURCES = \
log.h log.c \
panels.h panels.c \
registers.h registers.c
-libpanel_a_CFLAGS = $(AM_CFLAGS)
+libpanel_la_LDFLAGS = $(LIBGTK_LIBS) $(LIBPYTHON_LIBS) \
+ -L../gtkext/.libs -lgtkext
INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
diff --git a/src/panel/log.c b/src/panel/log.c
index 94bb8a4..812d470 100644
--- a/src/panel/log.c
+++ b/src/panel/log.c
@@ -109,8 +109,8 @@ GtkWidget *build_log_panel(void)
/******************************************************************************
* *
-* Paramètres : panel = panneau à mettre à jour. *
-* msg = message à faire apparaître à l'écran. *
+* Paramètres : type = espèce du message à ajouter. *
+* msg = message à faire apparaître à l'écran. *
* *
* Description : Affiche un message dans le journal des messages système. *
* *
@@ -161,9 +161,9 @@ void log_simple_message(LogMessageType type, const char *msg)
/******************************************************************************
* *
-* Paramètres : panel = panneau à mettre à jour. *
-* fmt = format du message à faire apparaître à l'écran. *
-* ... = éventuels arguments venant compléter le message. *
+* Paramètres : type = espèce du message à ajouter. *
+* fmt = format du message à faire apparaître à l'écran. *
+* ... = éventuels arguments venant compléter le message. *
* *
* Description : Affiche un message dans le journal des messages système. *
* *
diff --git a/src/panel/registers.c b/src/panel/registers.c
index ce27a71..1f9c8e5 100644
--- a/src/panel/registers.c
+++ b/src/panel/registers.c
@@ -25,7 +25,7 @@
#include "registers.h"
-#include "../easygtk.h"
+#include "../gtkext/easygtk.h"
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
new file mode 100644
index 0000000..2d480bb
--- /dev/null
+++ b/src/plugins/Makefile.am
@@ -0,0 +1,17 @@
+
+lib_LIBRARIES = libplugins.a
+
+libplugins_a_SOURCES = \
+ pglist.h pglist.c \
+ plugin.h plugin.c
+
+libplugins_a_CFLAGS = $(AM_CFLAGS)
+
+
+INCLUDES = $(LIBGTK_CFLAGS)
+
+AM_CPPFLAGS =
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS = pyoida
diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c
new file mode 100644
index 0000000..8301eb3
--- /dev/null
+++ b/src/plugins/pglist.c
@@ -0,0 +1,73 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * pglist.c - gestion de l'ensemble des greffons
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "pglist.h"
+
+
+#include "plugin.h"
+
+
+
+/* Propriétés de l'ensemble des greffons */
+typedef struct _plugins_list
+{
+ GObject *ref; /* Référencement global */
+
+
+
+
+} plugins_list;
+
+
+/* Liste de l'ensemble des greffons */
+static plugins_list list;
+
+
+
+/******************************************************************************
+* *
+* Paramètres : ref = espace de référencement global. *
+* *
+* Description : Procède au chargement des différents greffons trouvés. *
+* *
+* Retour : Toujours true (même s'il y a des erreurs de chargemet). *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool init_all_plugins(GObject *ref)
+{
+ GPluginModule *pg;
+
+ list.ref = ref;
+
+
+ pg = g_plugin_module_new("/home/ocb/prog/openida.pg/src/plugins/pyoida/pyoidamodule.so", list.ref);
+
+ printf("plug ? %p\n", pg);
+
+ return true;
+
+}
diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h
new file mode 100644
index 0000000..89abd51
--- /dev/null
+++ b/src/plugins/pglist.h
@@ -0,0 +1,39 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * pglist.h - prototypes pour la gestion de l'ensemble des greffons
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PGLIST_H
+#define _PLUGINS_PGLIST_H
+
+
+#include <stdbool.h>
+#include <gtk/gtk.h>
+
+
+
+/* Procède au chargement des différents greffons trouvés. */
+bool init_all_plugins(GObject *);
+
+
+
+#endif /* _PLUGINS_PGLIST_H */
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
new file mode 100644
index 0000000..f21ac02
--- /dev/null
+++ b/src/plugins/plugin.c
@@ -0,0 +1,144 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * plugin.h - interactions avec un greffon donné
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "plugin.h"
+
+
+#include <gmodule.h>
+#include <stdbool.h>
+
+
+
+/* Procède à l'initialisation du greffon */
+typedef bool (* init_plugin_fc) (GObject *);
+
+
+
+/* Greffon pour OpenIDA (instance) */
+struct _GPluginModule
+{
+ GObject parent; /* A laisser en premier */
+
+ GModule *module; /* Abstration de manipulation */
+
+ init_plugin_fc init; /* Procédure d'initialisation */
+
+};
+
+
+/* Greffon pour OpenIDA (classe) */
+struct _GPluginModuleClass
+{
+ GObjectClass parent; /* A laisser en premier */
+
+};
+
+
+/* Initialise la classe des greffons. */
+static void g_plugin_module_class_init(GPluginModuleClass *);
+
+/* Initialise une instance de greffon. */
+static void g_plugin_module_init(GPluginModule *);
+
+
+
+/* Indique le type définit pour un greffon. */
+G_DEFINE_TYPE(GPluginModule, g_plugin_module, G_TYPE_OBJECT);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des greffons. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_plugin_module_class_init(GPluginModuleClass *klass)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : line = instance à initialiser. *
+* *
+* Description : Initialise une instance de greffon. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_plugin_module_init(GPluginModule *line)
+{
+
+}
+
+
+
+/******************************************************************************
+* *
+* Paramètres : filename = nom du fichier à charger. *
+* ref = espace de référencement global. *
+* *
+* Description : Crée un module pour un greffon donné. *
+* *
+* Retour : Adresse de la structure mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GPluginModule *g_plugin_module_new(const gchar *filename, GObject *ref)
+{
+ GPluginModule *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_PLUGIN_MODULE, NULL);
+
+
+ result->module = g_module_open(filename, G_MODULE_BIND_LAZY);
+
+
+ if (!g_module_symbol(result->module, "init_plugin", (gpointer *)&result->init))
+ {
+ printf("Err plugin init sym\n");
+ /* TODO */
+ }
+
+
+
+ if (!result->init(ref))
+ printf("Err loading pg\n");
+
+ return result;
+
+}
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h
new file mode 100644
index 0000000..6013e21
--- /dev/null
+++ b/src/plugins/plugin.h
@@ -0,0 +1,56 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * plugin.h - prototypes pour les interactions avec un greffon donné
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PLUGIN_H
+#define _PLUGINS_PLUGIN_H
+
+
+#include <glib-object.h>
+
+
+
+/* Greffon pour OpenIDA (instance) */
+typedef struct _GPluginModule GPluginModule;
+
+/* Greffon pour OpenIDA (classe) */
+typedef struct _GPluginModuleClass GPluginModuleClass;
+
+
+#define G_TYPE_PLUGIN_MODULE (g_plugin_module_get_type())
+#define G_PLUGIN_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_PLUGIN_MODULE, GPluginModule))
+#define G_IS_PLUGIN_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_PLUGIN_MODULE))
+#define G_PLUGIN_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_PLUGIN_MODULE, GPluginModuleClass))
+#define G_IS_PLUGIN_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_PLUGIN_MODULE))
+#define G_PLUGIN_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_PLUGIN_MODULE, GPluginModuleClass))
+
+
+/* Indique le type définit pour un greffon. */
+GType g_plugin_module_get_type(void);
+
+/* Crée un module pour un greffon donné. */
+GPluginModule *g_plugin_module_new(const gchar *, GObject *);
+
+
+
+#endif /* _PLUGINS_PLUGIN_H */
diff --git a/src/plugins/pyoida/Makefile.am b/src/plugins/pyoida/Makefile.am
new file mode 100644
index 0000000..4df2820
--- /dev/null
+++ b/src/plugins/pyoida/Makefile.am
@@ -0,0 +1,20 @@
+
+lib_LTLIBRARIES = libpyoida.la
+
+libpyoida_la_SOURCES = \
+ py_binary.h py_binary.c \
+ py_line.h py_line.c \
+ py_log.h py_log.c \
+ pyoida.h pyoida.c
+
+libpyoida_la_LDFLAGS = $(LIBGTK_LIBS) $(LIBXML_LIBS) $(LIBPYTHON_LIBS) \
+ -L../../panel/.libs -lpanel
+
+
+INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS)
+
+AM_CPPFLAGS =
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS =
diff --git a/src/plugins/pyoida/linsyscalls/oidapgi.py b/src/plugins/pyoida/linsyscalls/oidapgi.py
new file mode 100755
index 0000000..dd4e010
--- /dev/null
+++ b/src/plugins/pyoida/linsyscalls/oidapgi.py
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+
+import pyoida
+#import oidaline
+from pyoida import Noddy
+
+
+class OpenIDAPlugin:
+ """A simple example class"""
+
+
+
+
+
+if __name__ == "__main__":
+ print "OpenIDA PlugIn"
+
+
+ print "Hello World\n",
+
+ pyoida.system("ls -lh")
+
+ test = Noddy("first", "last")
+
+ print test.name()
+
+ #oidaline.echo()
+
diff --git a/src/plugins/pyoida/py_binary.c b/src/plugins/pyoida/py_binary.c
new file mode 100644
index 0000000..eb2a73d
--- /dev/null
+++ b/src/plugins/pyoida/py_binary.c
@@ -0,0 +1,358 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * py_binary.c - intermédiaire des binaires pour Python
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "py_binary.h"
+
+#include <structmember.h>
+
+
+
+#include "py_line.h"
+
+
+
+typedef struct {
+ PyObject_HEAD
+
+ openida_binary *binary; /* Instance réelle rattachée */
+
+} pybinary;
+
+
+#define _(str) str
+
+
+
+
+
+/* Fournit la description du type 'binary' pour Python. */
+PyTypeObject *pybinary_get_type(void);
+
+
+
+
+/* Fournit les lignes de rendu associé pour Python. */
+static PyObject *pybinary_get_lines(pybinary *);
+
+
+
+
+
+
+
+static void
+pybinary_dealloc(pybinary* self)
+{
+#if 0
+ Py_XDECREF(self->first);
+ Py_XDECREF(self->last);
+#endif
+
+ //printf("dealloc\n");
+
+ self->ob_type->tp_free((PyObject*)self);
+ //Py_TYPE(self)->tp_free((PyObject*)self);
+
+ //printf("dealloc::end\n");
+
+}
+
+static PyObject *
+pybinary_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ pybinary *self;
+
+
+ printf("creating a new binary\n");
+
+ self = (pybinary *)type->tp_alloc(type, 0);
+ if (self != NULL) {
+#if 0
+ self->first = PyString_FromString("");//PyUnicode_FromString("");
+ if (self->first == NULL)
+ {
+ Py_DECREF(self);
+ return NULL;
+ }
+
+ self->last = PyString_FromString("");//PyUnicode_FromString("");
+ if (self->last == NULL)
+ {
+ Py_DECREF(self);
+ return NULL;
+ }
+
+ self->number = 0;
+#endif
+ }
+
+ return (PyObject *)self;
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : binary = modèle à représenter en Python. *
+* *
+* Description : Initialise le greffon permettant l'usage de Python. *
+* *
+* Retour : Nouvelle instance d'objet Python ou NULL en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *pybinary_new_from_existing(openida_binary *binary)
+{
+ pybinary *result; /* Nouvelle instance à renvoyer*/
+ PyTypeObject *type; /* Type d'objet à créer */
+
+ type = pybinary_get_type();
+
+ result = (pybinary *)type->tp_alloc(type, 0);
+
+ if (result != NULL)
+ result->binary = binary;
+
+ return (PyObject *)result;
+
+}
+
+
+
+
+static int
+pybinary_init(pybinary *self, PyObject *args, PyObject *kwds)
+{
+#if 0
+ PyObject *first=NULL, *last=NULL, *tmp;
+
+ static char *kwlist[] = {"first", "last", "number", NULL};
+
+ printf("pybinary_init\n");
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "|SSi", kwlist,
+ &first, &last,
+ &self->number))
+ return -1;
+
+ if (first) {
+ tmp = self->first;
+ Py_INCREF(first);
+ self->first = first;
+ Py_DECREF(tmp);
+ }
+
+ if (last) {
+ tmp = self->last;
+ Py_INCREF(last);
+ self->last = last;
+ Py_DECREF(tmp);
+ }
+#endif
+ return 0;
+}
+
+
+
+
+
+
+
+static PyMemberDef pybinary_members[] = {
+#if 0
+ {"number", T_INT, offsetof(pybinary, number), 0,
+ "noddy number"},
+#endif
+ {NULL} /* Sentinel */
+};
+
+
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = instance manipulée à traiter. *
+* *
+* Description : Fournit les lignes de rendu associé pour Python. *
+* *
+* Retour : Nouvelle instance d'objet Python ou NULL en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *pybinary_get_lines(pybinary *self)
+{
+ PyObject *result; /* Liste à retourner */
+ GRenderingLine *lines; /* Liste récupérée à convertir */
+
+ lines = get_openida_binary_lines(self->binary);
+
+ result = pyline_new_from_existing(lines, lines);
+
+ return result;
+
+}
+
+
+
+
+#if 0
+static PyObject *
+pybinary_name(pybinary* self)
+{
+ static PyObject *format = NULL;
+ PyObject *args, *result;
+
+ if (format == NULL) {
+ format = PyString_FromString("%s %s");//PyUnicode_FromString("%s %s");
+ if (format == NULL)
+ return NULL;
+ }
+
+ args = Py_BuildValue("OO", self->first, self->last);
+ if (args == NULL)
+ return NULL;
+
+ result = PyUnicode_Format(format, args);
+ Py_DECREF(args);
+
+ return result;
+}
+#endif
+
+static PyMethodDef pybinary_methods[] = {
+#if 0
+ {"name", (PyCFunction)pybinary_name, METH_NOARGS,
+ "Return the name, combining the first and last name"
+ },
+#endif
+ { "lines", (PyCFunction)pybinary_get_lines, METH_NOARGS,
+ "Provide a list of associated rendering lines."
+ },
+ {NULL} /* Sentinel */
+};
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit la description du type 'binary' pour Python. *
+* *
+* Retour : Adresse de la description du type 'binary'. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *pybinary_get_type(void)
+{
+ static PyTypeObject result = {
+
+ PyObject_HEAD_INIT(NULL)
+
+#if PY_VERSION_HEX < 0x03000000
+ 0, /*ob_size*/
+#endif
+
+ "noddy.pybinary", /* tp_name */
+ sizeof(pybinary), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)pybinary_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved / tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "pybinary objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ pybinary_methods, /* tp_methods */
+ pybinary_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)pybinary_init, /* tp_init */
+ 0, /* tp_alloc */
+ pybinary_new, /* tp_new */
+ };
+
+ return &result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Ajoute l'objet 'binary' au module Python. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_binary_to_python_module(PyObject *module)
+{
+ int ret; /* Bilan d'un appel */
+
+ if (PyType_Ready(pybinary_get_type()) < 0)
+ return false;
+
+ printf("Adding binary type\n");
+
+
+
+ Py_INCREF(pybinary_get_type());
+ PyModule_AddObject(module, "binary", (PyObject *)pybinary_get_type());
+
+
+ return true; /* FIXME */
+
+
+}
diff --git a/src/plugins/pyoida/py_binary.h b/src/plugins/pyoida/py_binary.h
new file mode 100644
index 0000000..1b9fda4
--- /dev/null
+++ b/src/plugins/pyoida/py_binary.h
@@ -0,0 +1,45 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * py_binary.h - prototypes pour l'intermédiaire des binaires pour Python
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYOIDA_PY_BINARY_H
+#define _PLUGINS_PYOIDA_PY_BINARY_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+#include "../../analysis/binary.h"
+
+
+
+/* Initialise le greffon permettant l'usage de Python. */
+PyObject *pybinary_new_from_existing(openida_binary *);
+
+/* Ajoute l'objet 'binary' au module Python. */
+bool add_binary_to_python_module(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYOIDA_PY_BINARY_H */
diff --git a/src/plugins/pyoida/py_line.c b/src/plugins/pyoida/py_line.c
new file mode 100644
index 0000000..303d155
--- /dev/null
+++ b/src/plugins/pyoida/py_line.c
@@ -0,0 +1,802 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * py_line.c - intermédiaire des lignes de représentation pour Python
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "py_line.h"
+
+#include <structmember.h>
+
+
+
+#include "../../analysis/line_code.h"
+
+
+
+
+typedef struct {
+ PyObject_HEAD
+
+ GRenderingLine *head;
+
+ GRenderingLine *line; /* Instance réelle rattachée */
+
+} pyline;
+
+
+#define _(str) str
+
+
+
+
+
+/* Fournit la description du type 'line' pour Python. */
+PyTypeObject *pyline_get_type(void);
+
+
+
+
+/* Prépare un parcours de lignes. */
+static PyObject *pyline_get_iter(pyline *);
+
+
+
+
+/* ---------------------- ITERATEUR POUR LE PARCOURS DE LIGNES ---------------------- */
+
+
+/* Itérateur pour lignes de rendu */
+typedef struct _PyLineIter
+{
+ PyObject_HEAD /* A laisser en premier */
+
+ GRenderingLine *head; /* Liste à parcourir */
+ GRenderingLine *cur; /* Point de parcours courant */
+
+} PyLineIter;
+
+
+/* Fournit la description de l'itérateur 'PyLine' pour Python. */
+static PyTypeObject *pylineiter_get_type(void);
+
+/* Prépare l'itérateur pour un parcours de lignes de rendu. */
+static PyObject *pylineiter_new(GRenderingLine *);
+
+/* Libère la mémoire occupée par un itérateur de 'PyLine'. */
+static void pylineiter_dealloc(PyLineIter *);
+
+/* Fournit l'élément suivant dans un parcours de lignes. */
+static PyObject *pylineiter_get_next(PyLineIter *);
+
+
+
+
+/* ---------------------- EQUIVALENT PYTHON DES LIGNES DE CODE ---------------------- */
+
+
+/* Représentation Python d'une ligne de code */
+typedef struct _PyCodeLine
+{
+ pyline base; /* A laisser en premier */
+
+} PyCodeLine;
+
+
+/* Fournit la description du type 'PyCodeLine' pour Python. */
+PyTypeObject *pycodeline_get_type(void);
+
+
+
+static int
+pycodeline_init(pyline *self, PyObject *args, PyObject *kwds);
+
+static PyObject *
+pycodeline_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+
+
+
+PyObject *pycodeline_new_from_existing(GRenderingLine *head, GRenderingLine *line);
+
+
+
+
+
+
+
+
+static void
+pyline_dealloc(pyline* self)
+{
+#if 0
+ Py_XDECREF(self->first);
+ Py_XDECREF(self->last);
+#endif
+
+ //printf("dealloc\n");
+
+
+ g_object_set_data(G_OBJECT(self->line), "pyline", NULL);
+
+
+ self->ob_type->tp_free((PyObject*)self);
+ //Py_TYPE(self)->tp_free((PyObject*)self);
+
+ //printf("dealloc::end\n");
+
+}
+
+static PyObject *
+pyline_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ pyline *self;
+
+
+ printf("creating a new line\n");
+
+ self = (pyline *)type->tp_alloc(type, 0);
+ if (self != NULL) {
+#if 0
+ self->first = PyString_FromString("");//PyUnicode_FromString("");
+ if (self->first == NULL)
+ {
+ Py_DECREF(self);
+ return NULL;
+ }
+
+ self->last = PyString_FromString("");//PyUnicode_FromString("");
+ if (self->last == NULL)
+ {
+ Py_DECREF(self);
+ return NULL;
+ }
+
+ self->number = 0;
+#endif
+ }
+
+ return (PyObject *)self;
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : head = ???? *
+* line = modèle à représenter en Python. *
+* *
+* Description : Initialise le greffon permettant l'usage de Python. *
+* *
+* Retour : Nouvelle instance d'objet Python ou NULL en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *pyline_new_from_existing(GRenderingLine *head, GRenderingLine *line)
+{
+ pyline *result; /* Nouvelle instance à renvoyer*/
+ PyTypeObject *type; /* Type d'objet à créer */
+
+ result = (pyline *)g_object_get_data(G_OBJECT(line), "pyline");
+
+ if (result == NULL)
+ {
+ if (G_IS_CODE_LINE(line))
+ result = pycodeline_new_from_existing(head, line);
+
+ else
+ {
+ type = pyline_get_type();
+
+ result = (pyline *)type->tp_alloc(type, 0);
+
+ if (result != NULL)
+ {
+ result->head = head;
+ result->line = line;
+
+ g_object_set_data(G_OBJECT(line), "pyline", result);
+
+ }
+
+ }
+
+ }
+
+ return (PyObject *)result;
+
+}
+
+
+
+
+static int
+pyline_init(pyline *self, PyObject *args, PyObject *kwds)
+{
+#if 0
+ PyObject *first=NULL, *last=NULL, *tmp;
+
+ static char *kwlist[] = {"first", "last", "number", NULL};
+
+ printf("pyline_init\n");
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "|SSi", kwlist,
+ &first, &last,
+ &self->number))
+ return -1;
+
+ if (first) {
+ tmp = self->first;
+ Py_INCREF(first);
+ self->first = first;
+ Py_DECREF(tmp);
+ }
+
+ if (last) {
+ tmp = self->last;
+ Py_INCREF(last);
+ self->last = last;
+ Py_DECREF(tmp);
+ }
+#endif
+ return 0;
+}
+
+
+
+
+
+
+
+static PyMemberDef pyline_members[] = {
+#if 0
+ {"number", T_INT, offsetof(pyline, number), 0,
+ "noddy number"},
+#endif
+ {NULL} /* Sentinel */
+};
+
+
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = instance manipulée à traiter. *
+* *
+* Description : Prépare un parcours de lignes. *
+* *
+* Retour : Point de départ d'un parcours. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *pyline_get_iter(pyline *self)
+{
+ printf(" get iter -- %p\n", self->line);
+
+ return (PyObject *)pylineiter_new(self->head);
+
+}
+
+
+
+
+
+
+#if 0
+static PyObject *
+pyline_name(pyline* self)
+{
+ static PyObject *format = NULL;
+ PyObject *args, *result;
+
+ if (format == NULL) {
+ format = PyString_FromString("%s %s");//PyUnicode_FromString("%s %s");
+ if (format == NULL)
+ return NULL;
+ }
+
+ args = Py_BuildValue("OO", self->first, self->last);
+ if (args == NULL)
+ return NULL;
+
+ result = PyUnicode_Format(format, args);
+ Py_DECREF(args);
+
+ return result;
+}
+#endif
+
+static PyMethodDef pyline_methods[] = {
+#if 0
+ {"name", (PyCFunction)pyline_name, METH_NOARGS,
+ "Return the name, combining the first and last name"
+ },
+#endif
+ {NULL} /* Sentinel */
+};
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit la description du type 'line' pour Python. *
+* *
+* Retour : Adresse de la description du type 'line'. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *pyline_get_type(void)
+{
+ static PyTypeObject result = {
+
+ PyObject_HEAD_INIT(NULL)
+
+#if PY_VERSION_HEX < 0x03000000
+ 0, /*ob_size*/
+#endif
+
+ "noddy.pyline", /* tp_name */
+ sizeof(pyline), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)pyline_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved / tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "pyline objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ (getiterfunc)pyline_get_iter, /* tp_iter */
+ 0, /* tp_iternext */
+ pyline_methods, /* tp_methods */
+ pyline_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)pyline_init, /* tp_init */
+ 0, /* tp_alloc */
+ pyline_new, /* tp_new */
+ };
+
+ return &result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Ajoute l'objet 'line' au module Python. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_line_to_python_module(PyObject *module)
+{
+ int ret; /* Bilan d'un appel */
+
+ if (PyType_Ready(pyline_get_type()) < 0)
+ return false;
+
+ if (PyType_Ready(pylineiter_get_type()) < 0)
+ return false;
+
+ pycodeline_get_type()->tp_base = pyline_get_type();
+ if (PyType_Ready(pycodeline_get_type()) < 0)
+ return false;
+
+
+
+
+ printf("Adding line type\n");
+
+
+
+ Py_INCREF(pyline_get_type());
+ PyModule_AddObject(module, "line", (PyObject *)pyline_get_type());
+
+ Py_INCREF(pylineiter_get_type());
+ PyModule_AddObject(module, "lineiter", (PyObject *)pylineiter_get_type());
+
+ Py_INCREF(pycodeline_get_type());
+ PyModule_AddObject(module, "codeline", (PyObject *)pycodeline_get_type());
+
+
+ return true; /* FIXME */
+
+
+}
+
+
+
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* ITERATEUR POUR LE PARCOURS DE LIGNES */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit la description de l'itérateur 'PyLine' pour Python. *
+* *
+* Retour : Adresse de la description du type 'PyLineIter'. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyTypeObject *pylineiter_get_type(void)
+{
+ static PyTypeObject result = {
+
+ PyObject_HEAD_INIT(NULL)
+
+#if PY_VERSION_HEX < 0x03000000
+ 0, /* ob_size */
+#endif
+
+ "PyOIDA.PyLineIter", /* tp_name */
+ sizeof(PyLineIter), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)pylineiter_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved / tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ "Pylineiter objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ PyObject_SelfIter, /* tp_iter */
+ (iternextfunc)pylineiter_get_next, /* tp_iternext */
+ 0, /* tp_methods */
+ };
+
+ return &result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : head = liste à parcourir. *
+* *
+* Description : Prépare l'itérateur pour un parcours de lignes de rendu. *
+* *
+* Retour : Instance d'itérateur prête à emploi. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *pylineiter_new(GRenderingLine *head)
+{
+ PyLineIter *result; /* Nouvelle instance à renvoyer*/
+ PyTypeObject *type; /* Type d'objet à créer */
+
+ type = pylineiter_get_type();
+
+ result = (PyLineIter *)type->tp_alloc(type, 0);
+
+ if (result != NULL)
+ {
+ result->head = head;
+ result->cur = NULL;
+ }
+
+ return (PyObject *)result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = instance d'objet à supprimer. *
+* *
+* Description : Libère la mémoire occupée par un itérateur de 'PyLine'. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void pylineiter_dealloc(PyLineIter *self)
+{
+ self->ob_type->tp_free((PyObject *)self);
+ //Py_TYPE(self)->tp_free((PyObject *)self);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = instance manipulée à traiter. *
+* *
+* Description : Fournit l'élément suivant dans un parcours de lignes. *
+* *
+* Retour : Point suivant du parcours ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *pylineiter_get_next(PyLineIter *self)
+{
+ PyObject *result; /* Elément à retourner */
+ GRenderingLine *next; /* Elément réel suivant */
+
+ if (self->cur == NULL) next = self->head;
+ else next = g_rendering_line_get_next_iter(self->head, self->cur);
+
+ printf(" next for %p is :: %p\n", self->cur, next);
+
+ if (next != NULL)
+ {
+ self->cur = next;
+ result = pyline_new_from_existing(self->head, next);
+ }
+
+ else result = NULL;
+
+ return (PyObject *)result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* EQUIVALENT PYTHON DES LIGNES DE CODE */
+/* ---------------------------------------------------------------------------------- */
+
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit la description du type 'PyCodeLine' pour Python. *
+* *
+* Retour : Adresse de la description du type 'PyCodeLine'. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *pycodeline_get_type(void)
+{
+ static PyMethodDef pycodeline_methods[] = {
+#if 0
+ {"name", (PyCFunction)pyline_name, METH_NOARGS,
+ "Return the name, combining the first and last name"
+ },
+#endif
+ {NULL} /* Sentinel */
+};
+
+ static PyTypeObject result = {
+
+ PyObject_HEAD_INIT(NULL)
+
+#if PY_VERSION_HEX < 0x03000000
+ 0, /*ob_size*/
+#endif
+
+ "PyOIDA.PyCodeLine", /* tp_name */
+ sizeof(PyCodeLine), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved / tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "pycodeline objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ pycodeline_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)pycodeline_init, /* tp_init */
+ 0, /* tp_alloc */
+ pycodeline_new, /* tp_new */
+ };
+
+ return &result;
+
+}
+
+
+
+
+
+static int
+pycodeline_init(pyline *self, PyObject *args, PyObject *kwds)
+{
+#if 0
+ PyObject *first=NULL, *last=NULL, *tmp;
+
+ static char *kwlist[] = {"first", "last", "number", NULL};
+
+ printf("pyline_init\n");
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "|SSi", kwlist,
+ &first, &last,
+ &self->number))
+ return -1;
+
+ if (first) {
+ tmp = self->first;
+ Py_INCREF(first);
+ self->first = first;
+ Py_DECREF(tmp);
+ }
+
+ if (last) {
+ tmp = self->last;
+ Py_INCREF(last);
+ self->last = last;
+ Py_DECREF(tmp);
+ }
+#endif
+ return 0;
+}
+
+
+
+
+
+static PyObject *
+pycodeline_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ pyline *self;
+
+
+ printf("creating a new line\n");
+
+ self = (pyline *)type->tp_alloc(type, 0);
+ if (self != NULL) {
+#if 0
+ self->first = PyString_FromString("");//PyUnicode_FromString("");
+ if (self->first == NULL)
+ {
+ Py_DECREF(self);
+ return NULL;
+ }
+
+ self->last = PyString_FromString("");//PyUnicode_FromString("");
+ if (self->last == NULL)
+ {
+ Py_DECREF(self);
+ return NULL;
+ }
+
+ self->number = 0;
+#endif
+ }
+
+ return (PyObject *)self;
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : head = ???? *
+* line = modèle à représenter en Python. *
+* *
+* Description : Initialise le greffon permettant l'usage de Python. *
+* *
+* Retour : Nouvelle instance d'objet Python ou NULL en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *pycodeline_new_from_existing(GRenderingLine *head, GRenderingLine *line)
+{
+ pyline *result; /* Nouvelle instance à renvoyer*/
+ PyTypeObject *type; /* Type d'objet à créer */
+
+ result = (pyline *)g_object_get_data(G_OBJECT(line), "pyline");
+
+ if (result == NULL)
+ {
+ type = pycodeline_get_type();
+
+ result = (pyline *)type->tp_alloc(type, 0);
+
+ if (result != NULL)
+ {
+ result->head = head;
+ result->line = line;
+
+ g_object_set_data(G_OBJECT(line), "pyline", result);
+
+ }
+
+ }
+
+ return (PyObject *)result;
+
+}
diff --git a/src/plugins/pyoida/py_line.h b/src/plugins/pyoida/py_line.h
new file mode 100644
index 0000000..2270de6
--- /dev/null
+++ b/src/plugins/pyoida/py_line.h
@@ -0,0 +1,45 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * py_line.h - prototypes pour l'intermédiaire des lignes de représentation pour Python
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYOIDA_PY_LINE_H
+#define _PLUGINS_PYOIDA_PY_LINE_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+#include "../../analysis/line.h"
+
+
+
+/* Initialise le greffon permettant l'usage de Python. */
+PyObject *pyline_new_from_existing(GRenderingLine *, GRenderingLine *);
+
+/* Ajoute l'objet 'line' au module Python. */
+bool add_line_to_python_module(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYOIDA_PY_LINE_H */
diff --git a/src/plugins/pyoida/py_log.c b/src/plugins/pyoida/py_log.c
new file mode 100644
index 0000000..94be1f0
--- /dev/null
+++ b/src/plugins/pyoida/py_log.c
@@ -0,0 +1,341 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * py_log.c - intermédiaire du panneau de messages pour Python
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "py_log.h"
+
+#include <structmember.h>
+
+
+#include "../../panel/log.h"
+
+
+typedef struct {
+ PyObject_HEAD
+ PyObject *first;
+ PyObject *last;
+ int number;
+} pylog;
+
+
+#define _(str) str
+
+
+
+
+/* Définit les constantes pour les types de message. */
+bool pylog_define_constants(PyObject *);
+
+/* Affiche un message dans le journal des messages système. */
+PyObject *pylog_simple_message(PyObject *, PyObject *);
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : dict = dictionnaire à compléter. *
+* *
+* Description : Définit les constantes pour les types de message. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool pylog_define_constants(PyObject *dict)
+{
+ int ret; /* Bilan d'un ajout */
+
+ ret = PyDict_SetItemString(dict, "LMT_INFO", PyInt_FromLong(LMT_INFO));
+ if (ret == -1) return false;
+
+ ret = PyDict_SetItemString(dict, "LMT_BAD_BINARY", PyInt_FromLong(LMT_BAD_BINARY));
+ if (ret == -1) return false;
+
+ ret = PyDict_SetItemString(dict, "LMT_PROCESS", PyInt_FromLong(LMT_PROCESS));
+ if (ret == -1) return false;
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe assurant le lien avec l'éditeur de messages. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Affiche un message dans le journal des messages système. *
+* *
+* Retour : Rien en équivalent Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *pylog_simple_message(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ LogMessageType type; /* Espèce du message */
+ const char *msg; /* Contenu du message */
+
+ if (!PyArg_ParseTuple(args, "is", &type, &msg))
+ return NULL;
+
+ switch (type)
+ {
+ case LMT_INFO:
+ case LMT_BAD_BINARY:
+ case LMT_PROCESS:
+ log_simple_message(type, msg);
+ result = Py_None;
+ break;
+
+ default:
+ PyErr_SetString(PyExc_ValueError,
+ _("Invalid type of message"));
+ result = NULL;
+ break;
+
+ }
+
+ return result;
+
+}
+
+
+
+
+
+
+
+
+
+
+static void
+pylog_dealloc(pylog* self)
+{
+ Py_XDECREF(self->first);
+ Py_XDECREF(self->last);
+
+
+ //printf("dealloc\n");
+
+ self->ob_type->tp_free((PyObject*)self);
+ //Py_TYPE(self)->tp_free((PyObject*)self);
+
+ //printf("dealloc::end\n");
+
+}
+
+static PyObject *
+pylog_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ pylog *self;
+
+ self = (pylog *)type->tp_alloc(type, 0);
+ if (self != NULL) {
+ self->first = PyString_FromString("");//PyUnicode_FromString("");
+ if (self->first == NULL)
+ {
+ Py_DECREF(self);
+ return NULL;
+ }
+
+ self->last = PyString_FromString("");//PyUnicode_FromString("");
+ if (self->last == NULL)
+ {
+ Py_DECREF(self);
+ return NULL;
+ }
+
+ self->number = 0;
+ }
+
+ return (PyObject *)self;
+}
+
+static int
+pylog_init(pylog *self, PyObject *args, PyObject *kwds)
+{
+ PyObject *first=NULL, *last=NULL, *tmp;
+
+ static char *kwlist[] = {"first", "last", "number", NULL};
+
+ printf("pylog_init\n");
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "|SSi", kwlist,
+ &first, &last,
+ &self->number))
+ return -1;
+
+ if (first) {
+ tmp = self->first;
+ Py_INCREF(first);
+ self->first = first;
+ Py_DECREF(tmp);
+ }
+
+ if (last) {
+ tmp = self->last;
+ Py_INCREF(last);
+ self->last = last;
+ Py_DECREF(tmp);
+ }
+
+ return 0;
+}
+
+static PyMemberDef pylog_members[] = {
+ {"number", T_INT, offsetof(pylog, number), 0,
+ "noddy number"},
+ {NULL} /* Sentinel */
+};
+
+
+
+
+
+
+
+
+
+
+static PyObject *
+pylog_name(pylog* self)
+{
+ static PyObject *format = NULL;
+ PyObject *args, *result;
+
+ if (format == NULL) {
+ format = PyString_FromString("%s %s");//PyUnicode_FromString("%s %s");
+ if (format == NULL)
+ return NULL;
+ }
+
+ args = Py_BuildValue("OO", self->first, self->last);
+ if (args == NULL)
+ return NULL;
+
+ result = PyUnicode_Format(format, args);
+ Py_DECREF(args);
+
+ return result;
+}
+
+static PyMethodDef pylog_methods[] = {
+ {"name", (PyCFunction)pylog_name, METH_NOARGS,
+ "Return the name, combining the first and last name"
+ },
+ { "log_simple_message", (PyCFunction)pylog_simple_message, METH_VARARGS | METH_STATIC,
+ "Return the name, combining the first and last name"
+ },
+ {NULL} /* Sentinel */
+};
+
+
+static PyTypeObject pylog_type = {
+
+ PyObject_HEAD_INIT(NULL)
+
+#if PY_VERSION_HEX < 0x03000000
+ 0, /*ob_size*/
+#endif
+
+ "noddy.pylog", /* tp_name */
+ sizeof(pylog), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)pylog_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_reserved / tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "pylog objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ pylog_methods, /* tp_methods */
+ pylog_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)pylog_init, /* tp_init */
+ 0, /* tp_alloc */
+ pylog_new, /* tp_new */
+};
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Ajoute l'objet 'log' au module Python. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_log_to_python_module(PyObject *module)
+{
+ int ret; /* Bilan d'un appel */
+
+ if (PyType_Ready(&pylog_type) < 0)
+ return;
+
+ printf("Adding log type\n");
+
+
+ pylog_define_constants(pylog_type.tp_dict);
+
+
+
+
+ Py_INCREF(&pylog_type);
+ PyModule_AddObject(module, "logger", (PyObject *)&pylog_type);
+
+
+ return true; /* FIXME */
+
+
+}
diff --git a/src/plugins/pyoida/py_log.h b/src/plugins/pyoida/py_log.h
new file mode 100644
index 0000000..5274428
--- /dev/null
+++ b/src/plugins/pyoida/py_log.h
@@ -0,0 +1,39 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * py_log.h - prototypes pour l'intermédiaire du panneau de messages pour Python
+ *
+ * Copyright (C) 2009 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYOIDA_PY_LOG_H
+#define _PLUGINS_PYOIDA_PY_LOG_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Ajoute l'objet 'log' au module Python. */
+bool add_log_to_python_module(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYOIDA_PY_LOG_H */
diff --git a/src/plugins/pyoida/pyoida.c b/src/plugins/pyoida/pyoida.c
new file mode 100644
index 0000000..26624b2
--- /dev/null
+++ b/src/plugins/pyoida/pyoida.c
@@ -0,0 +1,131 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * pyoida.c - plugin permettant des extensions en Python
+ *
+ * Copyright (C) 2009 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 "pyoida.h"
+
+
+
+#include <Python.h>
+
+
+#include "py_binary.h"
+#include "py_log.h"
+
+
+static GObject *_ref = NULL;
+
+
+
+static PyObject *pyoida_get_current_binary(PyObject *self, PyObject *args)
+{
+ openida_binary *binary; /* Structure à copier */
+
+ binary = (openida_binary *)g_object_get_data(_ref, "current_binary");
+
+ return pybinary_new_from_existing(binary);
+
+}
+
+static PyMethodDef SpamMethods[] = {
+ {"current_binary", pyoida_get_current_binary, METH_NOARGS,
+ "Give the current analyzed binary."},
+ {NULL, NULL, 0, NULL} /* Sentinel */
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : ref = espace de référencement global. *
+* *
+* Description : Initialise le greffon permettant l'usage de Python. *
+* *
+* Retour : true. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool init_plugin(GObject *ref)
+{
+
+ printf("Init pyoida\n");
+
+ _ref = ref;
+
+ return true;
+
+}
+
+
+#if PY_VERSION_HEX >= 0x03000000
+
+/* Python 3.x code */
+
+static struct PyModuleDef spammodule = {
+ PyModuleDef_HEAD_INIT,
+ "pyoida", /* name of module */
+ "pyoida_doc", /* module documentation, may be NULL */
+ -1, /* size of per-interpreter state of the module,
+ or -1 if the module keeps state in global variables. */
+ SpamMethods
+};
+
+PyMODINIT_FUNC
+PyInit_pyoida(void)
+{
+ printf("Passage 3\n");
+ (void) PyModule_Create(&spammodule);
+}
+
+#else
+
+/* Python 2.x code */
+
+
+PyMODINIT_FUNC
+initpyoida(void)
+{
+ PyObject *module;
+
+
+ printf("Passage 2\n");
+ module = Py_InitModule("pyoida", SpamMethods);
+
+ add_binary_to_python_module(module);
+ add_line_to_python_module(module);
+ add_log_to_python_module(module);
+
+}
+
+#endif
diff --git a/src/plugins/pyoida/pyoida.h b/src/plugins/pyoida/pyoida.h
new file mode 100644
index 0000000..736db8e
--- /dev/null
+++ b/src/plugins/pyoida/pyoida.h
@@ -0,0 +1,38 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * pyoida.h - prototypes pour le plugin permettant des extensions en Python
+ *
+ * Copyright (C) 2009 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 _PLUGINS_PYOIDA_H
+#define _PLUGINS_PYOIDA_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+
+
+
+/* Initialise le greffon permettant l'usage de Python. */
+bool init_plugin(GObject *);
+
+
+
+#endif /* _PLUGINS_PYOIDA_H */
diff --git a/src/project.c b/src/project.c
index 2ec9e09..20ec7c3 100644
--- a/src/project.c
+++ b/src/project.c
@@ -30,9 +30,9 @@
#include <unistd.h>
-#include "easygtk.h"
#include "xdg.h"
#include "xml.h"
+#include "gtkext/easygtk.h"
diff --git a/src/project.h b/src/project.h
index a08039d..64c32bd 100644
--- a/src/project.h
+++ b/src/project.h
@@ -25,7 +25,7 @@
#define _PROJECT_H
-#include "binary.h"
+#include "analysis/binary.h"
diff --git a/src/shell.c b/src/shell.c
new file mode 100644
index 0000000..1f8d28d
--- /dev/null
+++ b/src/shell.c
@@ -0,0 +1,330 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * shell.c - panneau d'affichage du shell Python
+ *
+ * Copyright (C) 2006-2007 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "shell.h"
+
+
+#include <pty.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/epoll.h>
+#include <sys/types.h>
+#include <vte/reaper.h>
+#include <vte/vte.h>
+
+
+#include <config.h>
+
+
+#include <Python.h>
+
+
+static pid_t child = 0;
+
+
+#define _(str) str
+
+
+
+/* Réagit à la terminaison d'un shell Python lancé. */
+static void terminal_child_exited_cb(VteReaper *, GPid, gint, VteTerminal *);
+
+/* Lance un nouveau shell Python dans un terminal donné. */
+static void run_new_shell_in_terminal(VteTerminal *);
+
+/* Réagit aux premières lignes de l'interpréteur Python. */
+void python_started_cb(VteTerminal *, gpointer);
+
+
+
+/* Exécute un shell interprétant du Python. */
+static gpointer python_shell_thread(gpointer);
+
+
+ int amaster;
+ int aslave;
+ char name[64];
+
+
+/******************************************************************************
+* *
+* Paramètres : ref = adresse de l'espace de référencements. *
+* *
+* Description : Construit le panneau d'affichage des symboles. *
+* *
+* Retour : Adresse du panneau mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GtkWidget *build_shell_panel(GObject *ref)
+{
+ GtkWidget *result; /* Panneau à retourner */
+ GtkWidget *term; /* Terminal proprement dit */
+
+
+
+ GError *error; /* Bilan de création de thread */
+
+
+
+ term = vte_terminal_new();
+
+ result = gtk_scrolled_window_new(NULL, GTK_ADJUSTMENT(VTE_TERMINAL(term)->adjustment));
+ gtk_widget_show(result);
+
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(result), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(result), GTK_SHADOW_IN);
+
+ gtk_widget_show(term);
+ gtk_container_add(GTK_CONTAINER(result), term);
+
+
+ vte_terminal_set_cursor_blinks(VTE_TERMINAL(term), TRUE);
+
+
+ //return result;
+
+ openpty(&amaster, &aslave, name, NULL, NULL);
+
+
+ fprintf(stderr, "m = %d, s = %d, n = \"%s\"\n", amaster,
+ aslave, name);
+
+
+ vte_terminal_set_pty(VTE_TERMINAL(term), amaster);
+
+
+ if (!g_thread_create((GThreadFunc)python_shell_thread, term, FALSE, &error))
+ {
+ printf ("Failed to create the thread: %s\n", error->message);
+ }
+
+
+
+
+ /*
+ g_signal_connect(vte_reaper_get(), "child-exited",
+ G_CALLBACK(terminal_child_exited_cb), term);
+
+
+ run_new_shell_in_terminal(VTE_TERMINAL(term));
+ */
+
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : reaper = surveillant des processus exécuté dans le terminal. *
+* pid = identifiant du processus terminé. *
+* status = informations sur la sortie de l'interpréteur. *
+* term = terminal affiché à l'écran. *
+* *
+* Description : Réagit à la terminaison d'un shell Python lancé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void terminal_child_exited_cb(VteReaper *reaper, GPid pid, gint status, VteTerminal *term)
+{
+
+ vte_terminal_feed(term, _("Exit detected ; lauching an new Python shell...\n\r"), -1);
+
+
+ run_new_shell_in_terminal(term);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : term = terminal affiché à l'écran. *
+* *
+* Description : Lance un nouveau shell Python dans un terminal donné. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void run_new_shell_in_terminal(VteTerminal *term)
+{
+ gdouble refval; /* Attente active (bouh !) */
+ size_t len; /* Longueur de chaîne */
+
+ char *args[] = { "python", NULL };
+
+#ifdef DEBUG
+ char *env[] = { NULL, NULL };
+#else
+ char **env = NULL;
+#endif
+
+ refval = gtk_adjustment_get_value(GTK_ADJUSTMENT(term->adjustment));
+
+#ifdef DEBUG
+ len = strlen("PYTHONPATH=") + strlen(PACKAGE_SOURCE_DIR) + strlen("/src/plugins/pyoida");
+
+ env[0] = (char *)calloc(len + 1, sizeof(char));
+
+ strcpy(env[0], "PYTHONPATH=");
+ strcat(env[0], PACKAGE_SOURCE_DIR);
+ strcat(env[0], "/src/plugins/pyoida");
+#endif
+
+ child = vte_terminal_fork_command(VTE_TERMINAL(term), args[0], args,
+ env, NULL, 0, 0, 0);
+
+ vte_reaper_add_child(child);
+
+ printf("ref :: %g\n", refval);
+
+ //while (refval == gtk_adjustment_get_value(GTK_ADJUSTMENT(term->adjustment)));
+
+
+ g_signal_connect(term, "contents-changed",
+ G_CALLBACK(python_started_cb), NULL);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : term = terminal affiché à l'écran. *
+* data = adresse non utilisée ici. *
+* *
+* Description : Réagit aux premières lignes de l'interpréteur Python. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void python_started_cb(VteTerminal *term, gpointer data)
+{
+ static int counter = 0; /* Saut du prologue */
+
+ if (counter++ == 0) return;
+ else counter = 0;
+
+ vte_terminal_feed_child(term, "import pyoida\n", -1);
+
+ vte_terminal_feed_child(term, "from pyoida import *\n", -1);
+
+ g_signal_handlers_disconnect_by_func(term, G_CALLBACK(python_started_cb), NULL);
+
+}
+
+
+
+/******************************************************************************
+* *
+* Paramètres : ????????????????????????????????????????????????? *
+* *
+* Description : Exécute un shell interprétant du Python. *
+* *
+* Retour : ??? *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static gpointer python_shell_thread(gpointer data)
+{
+ FILE *stream;
+
+ printf("==== FE :: '%s'\n", ptsname(aslave));
+
+
+
+
+ //stream = fopen("/dev/pts/21", "w+");
+ stream = fdopen(aslave, "w+");
+ if (stream == NULL)
+ {
+ perror("fdopen");
+ return NULL;
+ }
+
+
+ /* Mise à jour des entrées/sorties */
+ /*
+ close(STDIN_FILENO);
+ close(STDOUT_FILENO);
+ close(STDERR_FILENO);
+ dup(aslave);
+ dup(aslave);
+ dup(aslave);
+ */
+
+
+
+
+ Py_Initialize();
+
+
+ amaster = STDIN_FILENO;
+
+
+ write(amaster, "import pyoida\n", strlen("import pyoida\n"));
+ write(amaster, "from pyoida import *\n", strlen("from pyoida import *\n"));
+
+
+
+
+
+ write(amaster, "logger.log_simple_message(2, 'uhih')\n", strlen("logger.log_simple_message(2, 'uhih')\n"));
+
+
+
+ write(amaster, "for i in pyoida.current_binary().lines():\n", strlen("for i in pyoida.current_binary().lines():\n"));
+ write(amaster, "\tprint i\n", strlen("\tprint i\n"));
+
+
+
+
+ printf("+++++++++++++++++++++++++++looping\n");
+
+ PyRun_AnyFile(stream, NULL);
+
+ printf("===========================looping\n");
+
+
+ Py_Finalize();
+
+
+
+ return NULL;
+
+}
diff --git a/src/shell.h b/src/shell.h
new file mode 100644
index 0000000..c07a368
--- /dev/null
+++ b/src/shell.h
@@ -0,0 +1,38 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * shell.h - prototypes pour le panneau d'affichage du shell Python
+ *
+ * Copyright (C) 2006-2007 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PAN_SHELL_H
+#define _PAN_SHELL_H
+
+
+#include <gtk/gtk.h>
+
+
+
+/* Construit le panneau d'affichage des symboles. */
+GtkWidget *build_shell_panel(GObject *);
+
+
+
+#endif /* _PAN_SHELL_H */