summaryrefslogtreecommitdiff
path: root/src/analysis/binary.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-02-03 23:21:49 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-02-03 23:21:49 (GMT)
commit425860b441b21e4aca7bf2473be26b0fe1e756e2 (patch)
tree341a0fc8b370d76566f3e332c344ffae5c065916 /src/analysis/binary.c
parent5511e355e7810f06bd610b79bcc94402c88d7ec9 (diff)
Removed all references to binary parts (GBinPart) and updated the code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@465 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r--src/analysis/binary.c315
1 files changed, 1 insertions, 314 deletions
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);