summaryrefslogtreecommitdiff
path: root/src/analysis/binary.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-11-18 23:20:16 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-11-18 23:20:16 (GMT)
commit783e5e1977c1e4dadf938befa9fce9a311079413 (patch)
tree995423e1069e31db4fe0517fb9a45432dafceb6d /src/analysis/binary.c
parent26d75963fba34d8e5a5b9a6186604110552f3a38 (diff)
Saved the current work on binary parts selection.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@137 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r--src/analysis/binary.c87
1 files changed, 85 insertions, 2 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 97b916e..d2c7f3e 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -136,6 +136,10 @@ struct _GOpenidaBinary
GExeFormat *format; /* Format du binaire */
GArchProcessor *proc; /* Architecture du binaire */
+ BinaryPartModel model; /* Modèle de sélection */
+ GBinPart **parts[BPM_COUNT]; /* Parties binaires à analyser */
+ size_t parts_count[BPM_COUNT]; /* Quantité de ces parties */
+
GRenderingLine *lines; /* Lignes de rendu en place */
GRenderingOptions *options; /* Options de désassemblage */
@@ -549,6 +553,9 @@ static void limit_all_routines(GRenderingLine *lines, GBinRoutine **routines, si
start = g_binary_routine_get_address(routines[i]);
line = g_rendering_line_find_by_address(lines, NULL, start);
+ /* Si le symbole est hors du code analysé (routine de PLT par exemple) */
+ if (line == NULL) continue;
+
last = find_best_ending_address_for_routine(line, i, starts, lengths, count);
line = g_rendering_line_find_by_address(lines, NULL, last);
@@ -821,6 +828,17 @@ bool g_openida_binary_save(const GOpenidaBinary *binary, xmlDocPtr xdoc, xmlXPat
free(access);
+
+
+ access = strdup(path);
+ access = stradd(access, "/Filename2");
+
+ result &= add_content_to_node(xdoc, context, access, binary->filename);
+
+ free(access);
+
+
+
return result;
}
@@ -828,6 +846,55 @@ bool g_openida_binary_save(const GOpenidaBinary *binary, xmlDocPtr xdoc, xmlXPat
/******************************************************************************
* *
+* Paramètres : binary = élément binaire à consulter. *
+* parts = liste des zones binaires à analyser. *
+* model = modèle de sélection des zones. *
+* count = quantité de zones listées. *
+* *
+* Description : Définit les parties de binaire à analyser. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_openida_binary_set_parts(GOpenidaBinary *binary, BinaryPartModel model, GBinPart **parts, size_t count)
+{
+ qsort(parts, count, sizeof(GBinPart *), g_binary_part_compare);
+
+ binary->parts[model] = parts;
+ binary->parts_count[model] = count;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : binary = élément binaire à consulter. *
+* model = modèle de sélection des zones. [OUT] *
+* count = quantité de zones listées. [OUT] *
+* *
+* Description : Fournit les parties de binaire analysées. *
+* *
+* Retour : Zones binaires à analyser. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinPart **g_openida_binary_get_parts(const GOpenidaBinary *binary, BinaryPartModel *model, size_t *count)
+{
+ *model = binary->model;
+ *count = binary->parts_count;
+
+ return binary->parts;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : binary = élément binaire à traiter. *
* *
* Description : Lance l'analyse d'un élément binaire chargé. *
@@ -847,8 +914,24 @@ void g_openida_binary_analyse(GOpenidaBinary *binary)
queue = get_work_queue();
- parts = g_exe_format_get_parts(binary->format, &parts_count);
- qsort(parts, parts_count, sizeof(GBinPart *), g_binary_part_compare);
+ if (binary->parts[binary->model] != NULL)
+ {
+ parts = binary->parts[binary->model];
+ parts_count = binary->parts_count[binary->model];
+ }
+ else
+ {
+ if (binary->parts[BPM_DEFAULT] != NULL)
+ {
+ parts = binary->parts[BPM_DEFAULT];
+ parts_count = binary->parts_count[BPM_DEFAULT];
+ }
+ else
+ {
+ parts = g_exe_format_get_parts(binary->format, &parts_count);
+ qsort(parts, parts_count, sizeof(GBinPart *), g_binary_part_compare);
+ }
+ }
disass = g_delayed_disassembly_new(binary, parts, parts_count);