summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-04-29 17:13:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-04-29 17:13:36 (GMT)
commite2f87e6e92a361cdd66b6867f51dda2abb1ed1b3 (patch)
tree2c3b5473c6042f64c145eb25cf923be8935ae793 /src/analysis
parent1e9b23fb37755fef5992f65cb9862fab271e13d9 (diff)
Saved the current work on the overjump plugin.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@61 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rwxr-xr-xsrc/analysis/Makefile.am3
-rw-r--r--src/analysis/binary.c143
-rw-r--r--src/analysis/binary.h14
-rw-r--r--src/analysis/line.c18
4 files changed, 143 insertions, 35 deletions
diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am
index 8d986a1..cc7675b 100755
--- a/src/analysis/Makefile.am
+++ b/src/analysis/Makefile.am
@@ -13,7 +13,8 @@ libanalysis_la_SOURCES = \
libanalysis_la_LDFLAGS = $(LIBGTK_LIBS) $(LIBXML_LIBS) \
-L../common/.libs -lcommon \
- -L../format/.libs -lformat
+ -L../format/.libs -lformat \
+ -L../plugins/.libs -lplugins
INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 95b24b1..b606752 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -39,11 +39,11 @@
#include "line_comment.h"
#include "line_prologue.h"
#include "prototype.h"
-#include "../arch/processor.h"
+#include "../plugins/pglist.h"
#include "../format/dbg_format.h"
-#include "../format/exe_format.h"
+
@@ -230,6 +230,83 @@ const char *openida_binary_to_string(const openida_binary *binary)
}
+/******************************************************************************
+* *
+* Paramètres : binary = élément binaire à consulter. *
+* length = taille en octets des données chargées. [OUT] *
+* *
+* Description : Fournit les détails du contenu binaire chargé en mémoire. *
+* *
+* Retour : Pointeur vers le début des données. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint8_t *get_openida_binary_data(const openida_binary *binary, off_t *length)
+{
+ *length = binary->bin_length;
+
+ return binary->bin_data;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : binary = élément binaire à consulter. *
+* *
+* Description : Fournit le format de fichier reconnu dans le contenu binaire.*
+* *
+* Retour : Adresse du format reconnu. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+exe_format *get_openida_binary_format(const openida_binary *binary)
+{
+ return binary->format;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : binary = élément binaire à consulter. *
+* *
+* Description : Fournit le processeur exécutant le contenu binaire. *
+* *
+* Retour : Adresse du processeur associé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+asm_processor *get_openida_binary_processor(const openida_binary *binary)
+{
+ return binary->proc;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : binary = élément binaire à consulter. *
+* *
+* Description : Fournit les options d'affichage définies pour le binaire. *
+* *
+* Retour : Adresse des options d'affichage. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+disass_options *get_openida_binary_options(const openida_binary *binary)
+{
+ return &binary->options;
+
+}
/******************************************************************************
@@ -525,6 +602,8 @@ void disassemble_openida_binary(openida_binary *binary)
+ GPluginModule *disass; /* Eventuel greffon de désass. */
+
binary->lines = build_binary_prologue(binary->filename, binary->bin_data, binary->bin_length);
@@ -532,60 +611,66 @@ void disassemble_openida_binary(openida_binary *binary)
routines = get_all_exe_routines(binary->format, &routines_count);
- parts = get_elf_default_code_parts(binary->format, &parts_count);
- qsort(parts, parts_count, sizeof(bin_part *), compare_bin_parts);
+ disass = get_one_plugin_for_action(PGA_DISASSEMBLE);
- for (i = 0; i < parts_count; i++)
- {
- get_bin_part_values(parts[i], &pos, &len, &base);
-
- /* Décodage des instructions */
+ if (disass != NULL)
+ binary->lines = g_plugin_module_disassemble_binary_parts(disass, binary);
- start = pos;
- pos = 0;
+ else
+ {
+ parts = get_elf_default_code_parts(binary->format, &parts_count);
+ qsort(parts, parts_count, sizeof(bin_part *), compare_bin_parts);
- while (pos < len)
+ for (i = 0; i < parts_count; i++)
{
- offset = base + pos;
+ get_bin_part_values(parts[i], &pos, &len, &base);
+ /* Décodage des instructions */
- instr = decode_instruction(binary->proc, &binary->bin_data[start], &pos, len, start, offset);
+ start = pos;
+ pos = 0;
+ while (pos < len)
+ {
+ offset = base + pos;
- line = g_code_line_new(offset, instr, &binary->options);
- g_rendering_line_add_to_lines(&binary->lines, line);
- }
+ instr = decode_instruction(binary->proc, &binary->bin_data[start], &pos, len, start, offset);
- /* Ajout des prototypes de fonctions */
- for (k = 0; k < routines_count; k++)
- {
- routine_offset = get_binary_routine_offset(routines[k]);
+ line = g_code_line_new(offset, instr, &binary->options);
+ g_rendering_line_add_to_lines(&binary->lines, line);
- if (!(base <= routine_offset && routine_offset < (base + len))) continue;
+ }
- routine_desc = routine_to_string(routines[k]);
+ /* Ajout des prototypes de fonctions */
- line = g_comment_line_new(routine_offset, routine_desc, &binary->options);
- g_rendering_line_insert_into_lines(&binary->lines, line, true);
+ for (k = 0; k < routines_count; k++)
+ {
+ routine_offset = get_binary_routine_offset(routines[k]);
- free(routine_desc);
+ if (!(base <= routine_offset && routine_offset < (base + len))) continue;
- }
+ routine_desc = routine_to_string(routines[k]);
- }
+ line = g_comment_line_new(routine_offset, routine_desc, &binary->options);
+ g_rendering_line_insert_into_lines(&binary->lines, line, true);
+
+ free(routine_desc);
+ }
+ }
+ }
line = g_rendering_line_find_by_offset(binary->lines, get_exe_entry_point(binary->format));
- g_rendering_line_add_flag(line, RLF_ENTRY_POINT);
+ if (line != NULL) g_rendering_line_add_flag(line, RLF_ENTRY_POINT);
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 69da2a7..813e0ec 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -29,6 +29,8 @@
#include "line.h"
+#include "../arch/processor.h"
+#include "../format/exe_format.h"
#include "../xml.h"
@@ -49,6 +51,18 @@ const char *openida_binary_to_string(const openida_binary *);
/* Fournit le fichier correspondant à l'élément binaire. */
const char *openida_binary_get_filename(const openida_binary *);
+/* Fournit les détails du contenu binaire chargé en mémoire. */
+uint8_t *get_openida_binary_data(const openida_binary *, off_t *);
+
+/* Fournit le format de fichier reconnu dans le contenu binaire. */
+exe_format *get_openida_binary_format(const openida_binary *);
+
+/* Fournit le processeur exécutant le contenu binaire. */
+asm_processor *get_openida_binary_processor(const openida_binary *);
+
+/* Fournit les options d'affichage définies pour le binaire. */
+disass_options *get_openida_binary_options(const openida_binary *);
+
/* Fournit les lignes de rendu issues du désassemblage. */
GRenderingLine *get_openida_binary_lines(const openida_binary *);
diff --git a/src/analysis/line.c b/src/analysis/line.c
index bba601c..fb8295e 100644
--- a/src/analysis/line.c
+++ b/src/analysis/line.c
@@ -96,13 +96,21 @@ static void g_rendering_line_class_init(GRenderingLineClass *klass)
static void g_rendering_line_init(GRenderingLine *line)
{
- GdkScreen *screen;
- PangoContext *context;
+ GdkScreen *screen; /* Ecran d'application */
+ PangoFontDescription *desc; /* Description de la police */
+ static PangoContext *context = NULL; /* Contexte graphique Pango */
DL_LIST_ITEM_INIT(&line->link);
- screen = gdk_screen_get_default();
- context = gdk_pango_context_get_for_screen(screen);
+ if (context == NULL)
+ {
+ screen = gdk_screen_get_default();
+ desc = pango_font_description_from_string("mono 10");
+
+ context = gdk_pango_context_get_for_screen(screen);
+ pango_context_set_font_description(context, desc);
+
+ }
line->layout = pango_layout_new(context);
@@ -236,11 +244,11 @@ 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);
+#if 0
if (line->flags & RLF_BREAK_POINT)
pixbuf = gtk_widget_render_icon(mywid, "gtk-yes", GTK_ICON_SIZE_MENU, NULL);