summaryrefslogtreecommitdiff
path: root/src/analysis/binary.c
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/binary.c
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/binary.c')
-rw-r--r--src/analysis/binary.c143
1 files changed, 114 insertions, 29 deletions
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);