summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binary-int.h4
-rw-r--r--src/analysis/binary.c315
-rw-r--r--src/analysis/binary.h7
-rw-r--r--src/analysis/disass/disassembler.c16
-rw-r--r--src/analysis/disass/disassembler.h3
-rw-r--r--src/analysis/disass/macro.c1
6 files changed, 7 insertions, 339 deletions
diff --git a/src/analysis/binary-int.h b/src/analysis/binary-int.h
index fa06a25..ec98bf9 100644
--- a/src/analysis/binary-int.h
+++ b/src/analysis/binary-int.h
@@ -67,10 +67,6 @@ struct _GLoadedBinary
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 */
-
GArchInstruction *instrs; /* Instructions d'assemblage */
GCodeBuffer *disass_buffer; /* Instructions lisibles */
GCodeBuffer **dec_buffers; /* Sources sous forme de texte */
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 0c7a71c..35f7acd 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -62,12 +62,6 @@ static void g_loaded_binary_dispose(GLoadedBinary *);
/* Procède à la libération totale de la mémoire. */
static void g_loaded_binary_finalize(GLoadedBinary *);
-/* Charge les parties intéressantes du binaire à partir d'XML. */
-static bool g_loaded_binary_load_parts_from_xml(GLoadedBinary *, xmlXPathContextPtr, const char *);
-
-/* Ecrit les parties de valeur du binaire dans un fichier XML. */
-static bool g_loaded_binary_save_parts(const GLoadedBinary *, xmlDocPtr, xmlXPathContextPtr, const char *);
-
/* Acquitte la fin d'un désasemblage différé et complet. */
static void ack_completed_disassembly(GDelayedDisassembly *, GLoadedBinary *);
@@ -281,11 +275,6 @@ GLoadedBinary *g_loaded_binary_new_from_xml(xmlXPathContextPtr context, const ch
- /*
- if (!g_loaded_binary_load_parts_from_xml(result, context, path))
- goto glbnfx_error;
- */
-
printf("data :: %p length :: %d\n", result->bin_data, result->bin_length);
@@ -405,229 +394,6 @@ bool g_loaded_binary_save(const GLoadedBinary *binary, xmlDocPtr xdoc, xmlXPathC
result = g_loaded_binary_save_storage(binary, xdoc, context, path);
- /* Parties à désassembler */
-
- result = g_loaded_binary_save_parts(binary, xdoc, context, path);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : context = contexte pour les recherches XPath. *
-* path = chemin d'accès au noeud XML à lire. *
-* *
-* Description : Charge les parties intéressantes du binaire à partir d'XML. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_loaded_binary_load_parts_from_xml(GLoadedBinary *binary, xmlXPathContextPtr context, const char *path)
-{
- bool result; /* Bilan à retourner */
- char *access; /* Chemin pour une sous-config.*/
- xmlXPathObjectPtr xobjects; /* Cible d'une recherche */
- int i; /* Boucle de parcours */
- GBinPart *part; /* Partie binaire à traiter */
- off_t offset; /* Position de cette partie */
- vmpa_t addr; /* Adresse correspondante */
-
- result = NULL;
-
- /* Parties à désassembler : default */
-
- access = strdup(path);
- access = stradd(access, "/BinParts/Default/Part");
-
- xobjects = get_node_xpath_object(context, access);
-
- for (i = 0; i < XPATH_OBJ_NODES_COUNT(xobjects); i++)
- {
- part = g_binary_part_load_from_xml(NODE_FROM_PATH_OBJ(xobjects, i));
-
- if (part != NULL)
- {
- g_binary_part_get_values(part, &offset, NULL, NULL);
-
- if (!g_exe_format_translate_offset_into_address(G_EXE_FORMAT(binary->format), offset, &addr))
- {
- g_object_unref(G_OBJECT(part));
- continue;
- }
-
- binary->parts_count[BPM_DEFAULT]++;
- binary->parts[BPM_DEFAULT] = (GBinPart **)realloc(binary->parts[BPM_DEFAULT],
- binary->parts_count[BPM_DEFAULT] * sizeof(GBinPart *));
-
- binary->parts[BPM_DEFAULT][binary->parts_count[BPM_DEFAULT] - 1] = part;
-
- }
-
- }
-
- if(xobjects != NULL)
- xmlXPathFreeObject(xobjects);
-
- free(access);
-
- qsort(binary->parts[BPM_DEFAULT], binary->parts_count[BPM_DEFAULT],
- sizeof(GBinPart *), (__compar_fn_t)g_binary_part_compare);
-
- /* Parties à désassembler : routines */
-
- access = strdup(path);
- access = stradd(access, "/BinParts/Routines/Part");
-
- xobjects = get_node_xpath_object(context, access);
-
- for (i = 0; i < XPATH_OBJ_NODES_COUNT(xobjects); i++)
- {
- part = g_binary_part_load_from_xml(NODE_FROM_PATH_OBJ(xobjects, i));
-
- if (part != NULL)
- {
- g_binary_part_get_values(part, &offset, NULL, NULL);
-
- if (!g_exe_format_translate_offset_into_address(G_EXE_FORMAT(binary->format), offset, &addr))
- {
- g_object_unref(G_OBJECT(part));
- continue;
- }
- else g_binary_part_set_address(part, addr);
-
- binary->parts_count[BPM_ROUTINES]++;
- binary->parts[BPM_ROUTINES] = (GBinPart **)realloc(binary->parts[BPM_ROUTINES],
- binary->parts_count[BPM_ROUTINES] * sizeof(GBinPart *));
-
- binary->parts[BPM_ROUTINES][binary->parts_count[BPM_ROUTINES] - 1] = part;
-
- }
-
- }
-
- if(xobjects != NULL)
- xmlXPathFreeObject(xobjects);
-
- free(access);
-
- qsort(binary->parts[BPM_ROUTINES], binary->parts_count[BPM_ROUTINES],
- sizeof(GBinPart *), (__compar_fn_t)g_binary_part_compare);
-
- /* Parties à désassembler : utilisateur */
-
- access = strdup(path);
- access = stradd(access, "/BinParts/User/Part");
-
- xobjects = get_node_xpath_object(context, access);
-
- for (i = 0; i < XPATH_OBJ_NODES_COUNT(xobjects); i++)
- {
- part = g_binary_part_load_from_xml(NODE_FROM_PATH_OBJ(xobjects, i));
-
- if (part != NULL)
- {
- g_binary_part_get_values(part, &offset, NULL, NULL);
-
- if (!g_exe_format_translate_offset_into_address(G_EXE_FORMAT(binary->format), offset, &addr))
- {
- g_object_unref(G_OBJECT(part));
- continue;
- }
-
- binary->parts_count[BPM_USER]++;
- binary->parts[BPM_USER] = (GBinPart **)realloc(binary->parts[BPM_USER],
- binary->parts_count[BPM_USER] * sizeof(GBinPart *));
-
- binary->parts[BPM_USER][binary->parts_count[BPM_USER] - 1] = part;
-
- }
-
- }
-
- if(xobjects != NULL)
- xmlXPathFreeObject(xobjects);
-
- free(access);
-
- qsort(binary->parts[BPM_USER], binary->parts_count[BPM_USER],
- sizeof(GBinPart *), (__compar_fn_t)g_binary_part_compare);
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : binary = élément binaire à traiter. *
-* xdoc = structure XML en cours d'édition. *
-* context = contexte à utiliser pour les recherches. *
-* path = chemin d'accès réservé au binaire. *
-* *
-* Description : Ecrit les parties de valeur du binaire dans un fichier XML. *
-* *
-* Retour : true si l'opération a bien tourné, false sinon. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool g_loaded_binary_save_parts(const GLoadedBinary *binary, xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path)
-{
- bool result; /* Bilan à faire remonter */
- char *access; /* Chemin d'accès à un élément */
- xmlNodePtr node; /* Point d'insertion XML */
- size_t i; /* Boucle de parcours */
-
- result = true;
-
- if (binary->parts_count[BPM_DEFAULT] > 0)
- {
- access = strdup(path);
- access = stradd(access, "/BinParts/Default");
-
- node = ensure_node_exist(xdoc, context, access);
-
- free(access);
-
- for (i = 0; i < binary->parts_count[BPM_DEFAULT] && result; i++)
- result &= g_binary_part_save_to_xml(binary->parts[BPM_DEFAULT][i], xdoc, node);
-
- }
-
- if (binary->parts_count[BPM_ROUTINES] > 0)
- {
- access = strdup(path);
- access = stradd(access, "/BinParts/Routines");
-
- node = ensure_node_exist(xdoc, context, access);
-
- free(access);
-
- for (i = 0; i < binary->parts_count[BPM_ROUTINES] && result; i++)
- result &= g_binary_part_save_to_xml(binary->parts[BPM_ROUTINES][i], xdoc, node);
-
- }
-
- if (binary->parts_count[BPM_USER] > 0)
- {
- access = strdup(path);
- access = stradd(access, "/BinParts/User");
-
- node = ensure_node_exist(xdoc, context, access);
-
- free(access);
-
- for (i = 0; i < binary->parts_count[BPM_USER] && result; i++)
- result &= g_binary_part_save_to_xml(binary->parts[BPM_USER][i], xdoc, node);
-
- }
-
return result;
}
@@ -1085,56 +851,6 @@ bool g_loaded_binary_add_to_collection(GLoadedBinary *binary, DBFeatures feature
-
-/******************************************************************************
-* *
-* 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_loaded_binary_set_parts(GLoadedBinary *binary, BinaryPartModel model, GBinPart **parts, size_t count)
-{
- qsort(parts, count, sizeof(GBinPart *), (__compar_fn_t)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_loaded_binary_get_parts(const GLoadedBinary *binary, BinaryPartModel *model, size_t **count)
-{
- *model = binary->model;
- *count = binary->parts_count;
-
- return binary->parts;
-
-}
-
-
/******************************************************************************
* *
* Paramètres : binary = élément binaire à traiter. *
@@ -1149,9 +865,6 @@ GBinPart ***g_loaded_binary_get_parts(const GLoadedBinary *binary, BinaryPartMod
void g_loaded_binary_analyse(GLoadedBinary *binary)
{
- GBinPart **parts; /* Parties d'élément binaire */
- size_t parts_count; /* Nombre de ces parties */
-
/* Détermination de l'identifiant */
/* déplacé
@@ -1165,33 +878,7 @@ void g_loaded_binary_analyse(GLoadedBinary *binary)
-
- if (binary->parts_count[BPM_ROUTINES] > 0)
- binary->model = BPM_ROUTINES;
-
-
- 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 *), (__compar_fn_t)g_binary_part_compare);
- }
- }
-
- disassemble_binary(binary, parts, parts_count,
- &binary->instrs, &binary->disass_buffer,
- ack_completed_disassembly);
+ disassemble_binary(binary, &binary->instrs, &binary->disass_buffer, ack_completed_disassembly);
/* TODO : remme ! */
//ack_completed_disassembly(NULL, binary);
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 8574f28..8ce64cb 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -141,13 +141,6 @@ bool g_loaded_binary_add_to_collection(GLoadedBinary *, DBFeatures, GDbItem *);
-/* Définit les parties de binaire à analyser. */
-
-void g_loaded_binary_set_parts(GLoadedBinary *, BinaryPartModel, GBinPart **, size_t);
-
-/* Fournit les parties de binaire analysées. */
-GBinPart ***g_loaded_binary_get_parts(const GLoadedBinary *, BinaryPartModel *, size_t **);
-
/* Lance l'analyse d'un élément binaire chargé. */
void g_loaded_binary_analyse(GLoadedBinary *);
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 126c116..ac6eb5b 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -58,9 +58,6 @@ struct _GDelayedDisassembly
GLoadedBinary *binary; /* Destinataire final */
GExeFormat *format; /* Format du binaire représenté*/
- GBinPart **parts; /* Parties binaires à traiter */
- size_t count; /* Nombre de ces parties */
-
GArchInstruction **instrs; /* Instructions résultantes */
GCodeBuffer *buffer; /* Tampon pour le rendu */
@@ -81,7 +78,7 @@ static void g_delayed_disassembly_class_init(GDelayedDisassemblyClass *);
static void g_delayed_disassembly_init(GDelayedDisassembly *);
/* Crée une tâche de désassemblage différé. */
-static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *, GBinPart **, size_t, GArchInstruction **, GCodeBuffer *);
+static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *, GArchInstruction **, GCodeBuffer *);
/* Assure le désassemblage en différé. */
static void g_delayed_disassembly_process(GDelayedDisassembly *, GtkExtStatusBar *);
@@ -146,8 +143,6 @@ static void g_delayed_disassembly_init(GDelayedDisassembly *disass)
* *
* Paramètres : binary = binaire chargé en attente des résultats. *
* format = format du binaire représenté. *
-* parts = parties binaires à désassembler. *
-* count = nombre de parties à traiter. *
* instrs = emplacement pour la liste d'instructions. *
* buffer = tampon de sortie pour les instructions. *
* *
@@ -159,7 +154,7 @@ static void g_delayed_disassembly_init(GDelayedDisassembly *disass)
* *
******************************************************************************/
-static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GBinPart **parts, size_t count, GArchInstruction **instrs, GCodeBuffer *buffer)
+static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GArchInstruction **instrs, GCodeBuffer *buffer)
{
GDelayedDisassembly *result; /* Tâche à retourner */
@@ -168,9 +163,6 @@ static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GBi
result->binary = binary;
result->format = g_loaded_binary_get_format(binary);
- result->parts = parts;
- result->count = count;
-
result->instrs = instrs;
result->buffer = buffer;
@@ -538,7 +530,7 @@ static void build_disass_prologue(GCodeBuffer *buffer, const char *filename, con
* *
******************************************************************************/
-void disassemble_binary(GLoadedBinary *binary, GBinPart **parts, size_t parts_count, GArchInstruction **instrs, GCodeBuffer **buffer, disassembly_ack_fc ack)
+void disassemble_binary(GLoadedBinary *binary, GArchInstruction **instrs, GCodeBuffer **buffer, disassembly_ack_fc ack)
{
const uint8_t *data; /* Données binaires brutes */
off_t length; /* Quantité de ces données */
@@ -550,7 +542,7 @@ void disassemble_binary(GLoadedBinary *binary, GBinPart **parts, size_t parts_co
data = g_loaded_binary_get_data(binary, &length);
build_disass_prologue(*buffer, g_loaded_binary_get_name(binary, true), data, length);
- disass = g_delayed_disassembly_new(binary, parts, parts_count, instrs, *buffer);
+ disass = g_delayed_disassembly_new(binary, instrs, *buffer);
g_signal_connect(disass, "work-completed", G_CALLBACK(ack), binary);
queue = get_work_queue();
diff --git a/src/analysis/disass/disassembler.h b/src/analysis/disass/disassembler.h
index 46bd3cc..4e459a1 100644
--- a/src/analysis/disass/disassembler.h
+++ b/src/analysis/disass/disassembler.h
@@ -26,7 +26,6 @@
#include "../binary.h"
-#include "../../format/part.h"
@@ -60,7 +59,7 @@ GType g_delayed_disassembly_get_type(void);
typedef void (* disassembly_ack_fc) (GDelayedDisassembly *, GLoadedBinary *);
/* Procède à la décompilation des routines d'un fichier donné. */
-void disassemble_binary(GLoadedBinary *, GBinPart **parts, size_t parts_count, GArchInstruction **, GCodeBuffer **, disassembly_ack_fc);
+void disassemble_binary(GLoadedBinary *, GArchInstruction **, GCodeBuffer **, disassembly_ack_fc);
diff --git a/src/analysis/disass/macro.c b/src/analysis/disass/macro.c
index 9addf1e..3745f25 100644
--- a/src/analysis/disass/macro.c
+++ b/src/analysis/disass/macro.c
@@ -25,6 +25,7 @@
#include <malloc.h>
+#include <stdlib.h>
#include <string.h>