summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis')
-rwxr-xr-xsrc/analysis/Makefile.am3
-rw-r--r--src/analysis/binary.c29
-rw-r--r--src/analysis/binary.h7
-rw-r--r--src/analysis/content.c2
-rw-r--r--src/analysis/db/items/bookmark.c4
-rw-r--r--src/analysis/db/items/comment.c335
-rw-r--r--src/analysis/db/items/comment.h9
-rw-r--r--src/analysis/db/items/move.h2
-rw-r--r--src/analysis/db/items/switcher.c5
-rw-r--r--src/analysis/disass/area.h1
-rw-r--r--src/analysis/disass/disassembler.c127
-rw-r--r--src/analysis/disass/disassembler.h2
-rw-r--r--src/analysis/disass/output.c183
-rw-r--r--src/analysis/disass/output.h8
-rwxr-xr-xsrc/analysis/human/Makefile.am19
-rwxr-xr-xsrc/analysis/human/asm/Makefile.am17
-rw-r--r--src/analysis/human/asm/lang.c221
-rw-r--r--src/analysis/human/asm/lang.h58
-rw-r--r--src/analysis/human/lang-int.h58
-rw-r--r--src/analysis/human/lang.c167
-rw-r--r--src/analysis/human/lang.h58
-rw-r--r--src/analysis/project.c18
22 files changed, 1060 insertions, 273 deletions
diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am
index 8b346f9..a8b1538 100755
--- a/src/analysis/Makefile.am
+++ b/src/analysis/Makefile.am
@@ -20,6 +20,7 @@ libanalysis_la_LIBADD = \
db/libanalysisdb.la \
db/libanalysiskeys.la \
disass/libanalysisdisass.la \
+ human/libanalysishuman.la \
types/libanalysistypes.la
# decomp/libanalysisdecomp.la
@@ -31,4 +32,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS)
AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
-SUBDIRS = blocks contents db disass types
+SUBDIRS = blocks contents db disass human types
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 3af62cf..ac8863e 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -37,7 +37,7 @@
#include "routine.h"
#include "db/client.h"
-#include "decomp/decompiler.h"
+//#include "decomp/decompiler.h"
#include "disass/disassembler.h"
#include "../common/extstr.h"
#include "../common/cpp.h"
@@ -78,8 +78,9 @@ struct _GLoadedBinary
GDbgFormat *debug; /* Informations de débogage */ //// REMME
GArchProcessor *proc; /* Architecture du binaire */
- GCodeBuffer *disass_buffer; /* Instructions lisibles */
- GCodeBuffer **dec_buffers; /* Sources sous forme de texte */
+
+ GBufferCache *disass_cache; /* Instructions lisibles */
+ //GCodeBuffer **dec_buffers; /* Sources sous forme de texte */
size_t decbuf_count; /* Taille des tableaux */
size_t defsrc; /* Fichier source principal */
@@ -220,9 +221,6 @@ static void g_loaded_binary_init(GLoadedBinary *binary)
binary->col_display[BVW_GRAPH][BLC_PHYSICAL] = false;
binary->col_display[BVW_GRAPH][BLC_VIRTUAL] = false;
binary->col_display[BVW_GRAPH][BLC_BINARY] = false;
- binary->col_display[BVW_SOURCE][BLC_PHYSICAL] = false;
- binary->col_display[BVW_SOURCE][BLC_VIRTUAL] = false;
- binary->col_display[BVW_SOURCE][BLC_BINARY] = false;
binary->lines_display = true;
@@ -1377,7 +1375,7 @@ void g_loaded_binary_analyse(GLoadedBinary *binary)
g_loaded_binary_connect_internal(binary);
- disassemble_binary(binary, &binary->disass_buffer, ack_completed_disassembly);
+ disassemble_binary(binary, &binary->disass_cache, ack_completed_disassembly);
@@ -1508,9 +1506,16 @@ GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *binary)
* *
******************************************************************************/
-GCodeBuffer *g_loaded_binary_get_disassembled_buffer(const GLoadedBinary *binary)
+GBufferCache *g_loaded_binary_get_disassembled_cache(const GLoadedBinary *binary)
{
- return binary->disass_buffer;
+ GBufferCache *result; /* Instance à retourner */
+
+ result = binary->disass_cache;
+
+ if (result != NULL)
+ g_object_ref(G_OBJECT(result));
+
+ return result;
}
@@ -1527,7 +1532,7 @@ GCodeBuffer *g_loaded_binary_get_disassembled_buffer(const GLoadedBinary *binary
* Remarques : - *
* *
******************************************************************************/
-
+#if 0
GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *binary, size_t index)
{
GCodeBuffer *result; /* Tampon à retourner */
@@ -1544,6 +1549,7 @@ GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *binary,
return result;
}
+#endif
/******************************************************************************
@@ -1659,6 +1665,7 @@ void ack_completed_disassembly(GDelayedDisassembly *disass, GLoadedBinary *binar
files = g_binary_format_get_source_files(G_BIN_FORMAT(binary->format),
&binary->decbuf_count, &binary->defsrc);
+#if 0
if (binary->decbuf_count > 0)
{
binary->dec_buffers = (GCodeBuffer **)calloc(binary->decbuf_count, sizeof(GCodeBuffer *));
@@ -1668,7 +1675,7 @@ void ack_completed_disassembly(GDelayedDisassembly *disass, GLoadedBinary *binar
binary->dec_buffers[i] = decompile_all_from_file(binary, files[i]);
*/
}
-
+#endif
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 41c7f7a..501ffe6 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -36,7 +36,7 @@
#include "../common/xml.h"
#include "../format/debuggable.h"
#include "../format/executable.h"
-#include "../glibext/gcodebuffer.h"
+#include "../glibext/gbuffercache.h"
@@ -76,7 +76,6 @@ typedef enum _BinaryView
{
BVW_BLOCK, /* Version basique */
BVW_GRAPH, /* Affichage en graphique */
- BVW_SOURCE, /* Code décompilé */
BVW_COUNT
@@ -181,10 +180,10 @@ GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *);
GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *);
/* Fournit le tampon associé au contenu assembleur d'un binaire. */
-GCodeBuffer *g_loaded_binary_get_disassembled_buffer(const GLoadedBinary *);
+GBufferCache *g_loaded_binary_get_disassembled_cache(const GLoadedBinary *);
/* Fournit le tampon associé au contenu d'un fichier source. */
-GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *, size_t);
+//GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *, size_t);
/* Définit si une colonne donnée doit apparaître dans le rendu. */
void g_loaded_binary_set_column_display(GLoadedBinary *, BinaryView, BufferLineColumn, bool);
diff --git a/src/analysis/content.c b/src/analysis/content.c
index 484599f..09f293c 100644
--- a/src/analysis/content.c
+++ b/src/analysis/content.c
@@ -47,7 +47,7 @@ G_DEFINE_INTERFACE(GBinContent, g_binary_content, G_TYPE_OBJECT)
/******************************************************************************
* *
-* Paramètres : iface = interface GTK à initialiser. *
+* Paramètres : iface = interface GLib à initialiser. *
* *
* Description : Procède à l'initialisation de l'interface de rassemblement. *
* *
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c
index 086b9f2..18e4bb5 100644
--- a/src/analysis/db/items/bookmark.c
+++ b/src/analysis/db/items/bookmark.c
@@ -409,6 +409,8 @@ static void g_db_bookmark_build_label(GDbBookmark *bookmark)
static bool g_db_bookmark_run(GDbBookmark *bookmark, GLoadedBinary *binary, bool *prev, bool set)
{
+ return false;
+#if 0
bool result; /* Bilan à faire remonter */
GCodeBuffer *buffer; /* Tampon de lignes à traiter */
GBufferLine *line; /* Ligne de tampon à marquer */
@@ -437,7 +439,7 @@ static bool g_db_bookmark_run(GDbBookmark *bookmark, GLoadedBinary *binary, bool
exit:
return result;
-
+#endif
}
diff --git a/src/analysis/db/items/comment.c b/src/analysis/db/items/comment.c
index 55893d1..3517f38 100644
--- a/src/analysis/db/items/comment.c
+++ b/src/analysis/db/items/comment.c
@@ -35,7 +35,10 @@
#include "../collection-int.h"
#include "../item-int.h"
+#include "../../human/asm/lang.h"
#include "../../../common/io.h"
+#include "../../../common/extstr.h"
+#include "../../../glibext/linegen-int.h"
@@ -52,6 +55,9 @@ struct _GDbComment
rle_string text; /* Contenu du commentaire */
+ char **lines; /* Lignes brutes à représenter */
+ size_t count; /* Quantité de ces lignes */
+
bool inlined; /* Intégration dans une ligne ?*/
union
@@ -60,7 +66,9 @@ struct _GDbComment
bool before; /* Zone dédiée au dessus ? */
};
- GDbComment **oldies; /* Commentaires d'origine ? */
+ GLineGenerator *previous; /* Commentaire remplacé */
+
+ GLineGenerator **old_inlined; /* Commentaires d'origine ? */
size_t old_count; /* Nombre de places à restaurer*/
};
@@ -112,6 +120,29 @@ static bool g_db_comment_prepare_db_statement(const GDbComment *, bound_value **
/* Charge les valeurs utiles pour un commentaire. */
static bool g_db_comment_load(GDbComment *, const bound_value *, size_t);
+/* Définit le commentaire associé à un commentaire. */
+static void g_db_comment_set_text(GDbComment *, const char *);
+
+
+
+/* ------------------------ OFFRE DE CAPACITES DE GENERATION ------------------------ */
+
+
+/* Indique le nombre de ligne prêtes à être générées. */
+static size_t g_db_comment_count_lines(const GDbComment *);
+
+/* Retrouve l'emplacement correspondant à une position donnée. */
+static void g_db_comment_compute_addr(const GDbComment *, gint, vmpa2t *, size_t, size_t);
+
+/* Détermine si le conteneur s'inscrit dans une plage donnée. */
+static int g_db_comment_contains_addr(const GDbComment *, const vmpa2t *, size_t, size_t);
+
+/* Renseigne sur les propriétés liées à un générateur. */
+static BufferLineFlags g_db_comment_get_flags(const GDbComment *, size_t, size_t);
+
+/* Imprime dans une ligne de rendu le contenu représenté. */
+static void g_db_comment_print(GDbComment *, GBufferLine *, size_t, size_t);
+
/* ---------------------- DEFINITION DE LA COLLECTION ASSOCIEE ---------------------- */
@@ -138,6 +169,9 @@ static void g_comment_collection_class_init(GCommentCollectionClass *);
/* Initialise un commentaire sous forme de zone de texte. */
static void g_comment_collection_init(GCommentCollection *);
+/* Procède à l'initialisation de l'interface de génération. */
+static void g_db_comment_interface_init(GLineGeneratorInterface *);
+
/* Supprime toutes les références externes. */
static void g_comment_collection_dispose(GCommentCollection *);
@@ -161,7 +195,8 @@ static GDbItem *g_comment_collection_has_key(GCommentCollection *, va_list);
/* Indique le type défini pour un commentaire à l'intérieur d'une zone de texte. */
-G_DEFINE_TYPE(GDbComment, g_db_comment, G_TYPE_DB_ITEM);
+G_DEFINE_TYPE_WITH_CODE(GDbComment, g_db_comment, G_TYPE_DB_ITEM,
+ G_IMPLEMENT_INTERFACE(G_TYPE_LINE_GENERATOR, g_db_comment_interface_init));
/******************************************************************************
@@ -219,6 +254,31 @@ static void g_db_comment_class_init(GDbCommentClass *klass)
static void g_db_comment_init(GDbComment *comment)
{
+ comment->lines = NULL;
+ comment->count = 0;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : iface = interface GLib à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'interface de génération. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_db_comment_interface_init(GLineGeneratorInterface *iface)
+{
+ iface->count = (linegen_count_lines_fc)g_db_comment_count_lines;
+ iface->compute = (linegen_compute_fc)g_db_comment_compute_addr;
+ iface->contains = (linegen_contains_fc)g_db_comment_contains_addr;
+ iface->get_flags = (linegen_get_flags_fc)g_db_comment_get_flags;
+ iface->print = (linegen_print_fc)g_db_comment_print;
}
@@ -239,11 +299,17 @@ static void g_db_comment_dispose(GDbComment *comment)
{
size_t i; /* Boucle de parcours */
+ for (i = 0; i < comment->count; i++)
+ free(comment->lines[i]);
+
+ if (comment->lines != NULL)
+ free(comment->lines);
+
for (i = 0; i < comment->old_count; i++)
- g_object_unref(G_OBJECT(comment->oldies[i]));
+ g_object_unref(G_OBJECT(comment->old_inlined[i]));
- if (comment->oldies != NULL)
- free(comment->oldies);
+ if (comment->old_inlined != NULL)
+ free(comment->old_inlined);
G_OBJECT_CLASS(g_db_comment_parent_class)->dispose(G_OBJECT(comment));
@@ -516,6 +582,134 @@ static void g_db_comment_build_label(GDbComment *comment)
static bool g_db_comment_run(GDbComment *comment, GLoadedBinary *binary, bool apply)
{
bool result; /* Bilan à faire remonter */
+ GBufferCache *cache; /* Ensemble de lignes à traiter*/
+ size_t index; /* Point d'insertion */
+ GArchProcessor *proc; /* Propriétaire d'instructions */
+ GArchInstruction *instr; /* Instruction à traiter */
+ instr_link_t *sources; /* Instructions diverses liées */
+ size_t scount; /* Nbre de sources affichées */
+ size_t i; /* Boucle de parcours */
+ const mrange_t *range; /* Emplacement d'instruction */
+ size_t linked; /* Indice lié à traiter */
+
+ result = true;
+
+ cache = g_loaded_binary_get_disassembled_cache(binary);
+
+ index = g_buffer_cache_find_index_by_addr(cache, &comment->addr, true);
+
+ index = g_buffer_cache_look_for_flag(cache, index, BLF_HAS_CODE);
+
+ if (comment->inlined)
+ {
+
+#define RUN_INLINED_COMMENT(idx, new, old) \
+ if (apply) \
+ { \
+ old = g_buffer_cache_delete_type_at(cache, idx, G_TYPE_DB_COMMENT, false, false); \
+ \
+ g_buffer_cache_insert_at(cache, idx, G_LINE_GENERATOR(new), false, false); \
+ \
+ } \
+ else \
+ { \
+ g_buffer_cache_delete_type_at(cache, idx, G_TYPE_DB_COMMENT, false, false); \
+ \
+ if (old != NULL) \
+ { \
+ g_buffer_cache_insert_at(cache, idx, old, false, false); \
+ g_object_unref(G_OBJECT(old)); \
+ } \
+ \
+ }
+
+ /* Commentaire principal */
+
+ RUN_INLINED_COMMENT(index, comment, comment->previous);
+
+ /* Renvois répétés */
+
+ if (comment->repeatable)
+ {
+ proc = g_loaded_binary_get_processor(binary);
+
+ instr = g_arch_processor_find_instr_by_address(proc, &comment->addr);
+ assert(instr != NULL);
+
+ scount = g_arch_instruction_get_sources(instr, &sources);
+
+ if (apply)
+ {
+ comment->old_count = scount;
+ comment->old_inlined = (GLineGenerator **)realloc(comment->old_inlined,
+ comment->old_count * sizeof(GLineGenerator *));
+ }
+
+ for (i = 0; i < scount && result; i++)
+ {
+ range = g_arch_instruction_get_range(sources[i].linked);
+
+ /**
+ * On recherche ici une ligne potentiellement BLF_HAS_CODE ou BLF_IS_LABEL.
+ * Comme on ne peut pas traiter les deux cas, on prend la première qui vient
+ * avec BLF_NONE.
+ */
+
+ linked = g_buffer_cache_find_index_by_addr(cache, get_mrange_addr(range), true);
+ assert(linked != g_buffer_cache_count_lines(cache));
+
+ RUN_INLINED_COMMENT(linked, comment, comment->old_inlined[i]);
+
+ }
+
+ if (!apply)
+ {
+ free(comment->old_inlined);
+
+ comment->old_inlined = NULL;
+ comment->old_count = 0;
+
+ }
+
+ g_object_unref(G_OBJECT(proc));
+
+ }
+
+
+
+ }
+
+ else
+ {
+
+
+
+
+
+
+
+
+
+ }
+
+
+ //void g_buffer_cache_insert_at(GBufferCache *cache, size_t index, GLineGenerator *generator, bool before, bool after)
+
+ //GLineGenerator *g_buffer_cache_delete_type_at(GBufferCache *cache, size_t index, GType type, bool before, bool after)
+
+
+
+
+ g_object_unref(G_OBJECT(cache));
+
+ return result;
+
+
+
+
+#if 0
+
+ bool result; /* Bilan à faire remonter */
GCodeBuffer *buffer; /* Tampon de lignes à traiter */
GBufferLine *line; /* Ligne de tampon à marquer */
GArchProcessor *proc; /* Propriétaire d'instructions */
@@ -658,7 +852,7 @@ static bool g_db_comment_run(GDbComment *comment, GLoadedBinary *binary, bool ap
/* TODO g_object_unref(G_OBJECT(buffer));*/
return result;
-
+#endif
}
@@ -884,10 +1078,137 @@ const char *g_db_comment_get_text(const GDbComment *comment)
* *
******************************************************************************/
-void g_db_comment_set_text(GDbComment *comment, const char *text)
+static void g_db_comment_set_text(GDbComment *comment, const char *text)
{
+ GCodingLanguage *lang; /* Langage de sortie préféré */
+
set_rle_string(&comment->text, text);
+ lang = g_asm_language_new();
+
+ comment->lines = strtoka(text, "\n", &comment->count);
+
+ g_coding_language_encapsulate_comments(lang, &comment->lines, &comment->count);
+
+ g_object_unref(G_OBJECT(lang));
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* OFFRE DE CAPACITES DE GENERATION */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : comment = générateur à consulter. *
+* *
+* Description : Indique le nombre de ligne prêtes à être générées. *
+* *
+* Retour : Nombre de lignes devant apparaître au final. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static size_t g_db_comment_count_lines(const GDbComment *comment)
+{
+ return comment->count;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : comment = générateur à consulter. *
+* x = position géographique sur la ligne concernée. *
+* addr = position en mémoire à analyser. *
+* index = indice de cette même ligne dans le tampon global. *
+* repeat = indice d'utilisations successives du générateur. *
+* *
+* Description : Retrouve l'emplacement correspondant à une position donnée. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_db_comment_compute_addr(const GDbComment *comment, gint x, vmpa2t *addr, size_t index, size_t repeat)
+{
+ copy_vmpa(addr, &comment->addr);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : comment = générateur à consulter. *
+* addr = position en mémoire à analyser. *
+* index = indice de cette même ligne dans le tampon global. *
+* repeat = indice d'utilisations successives du générateur. *
+* *
+* Description : Détermine si le conteneur s'inscrit dans une plage donnée. *
+* *
+* Retour : Bilan de la détermination, utilisable en comparaisons. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static int g_db_comment_contains_addr(const GDbComment *comment, const vmpa2t *addr, size_t index, size_t repeat)
+{
+ int result; /* Conclusion à retourner */
+
+ result = cmp_vmpa(addr, &comment->addr);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : comment = générateur à consulter. *
+* index = indice de cette même ligne dans le tampon global. *
+* repeat = indice d'utilisations successives du générateur. *
+* *
+* Description : Renseigne sur les propriétés liées à un générateur. *
+* *
+* Retour : Propriétés particulières associées. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static BufferLineFlags g_db_comment_get_flags(const GDbComment *comment, size_t index, size_t repeat)
+{
+ return BLF_NONE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : comment = générateur à utiliser pour l'impression. *
+* line = ligne de rendu à compléter. *
+* index = indice de cette même ligne dans le tampon global. *
+* repeat = indice d'utilisations successives du générateur. *
+* *
+* Description : Imprime dans une ligne de rendu le contenu représenté. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_db_comment_print(GDbComment *comment, GBufferLine *line, size_t index, size_t repeat)
+{
+ g_buffer_line_append_text(line, BLC_COMMENTS, SL(comment->lines[repeat]), RTT_COMMENT, NULL);
+
}
diff --git a/src/analysis/db/items/comment.h b/src/analysis/db/items/comment.h
index c5bd335..16046bc 100644
--- a/src/analysis/db/items/comment.h
+++ b/src/analysis/db/items/comment.h
@@ -69,15 +69,6 @@ const vmpa2t *g_db_comment_get_address(GDbComment *);
/* Fournit le commentaire associé à un commentaire. */
const char *g_db_comment_get_text(const GDbComment *);
-/* Définit le commentaire associé à un commentaire. */
-void g_db_comment_set_text(GDbComment *, const char *);
-
-
-
-
-
-
-
/* ---------------------- DEFINITION DE LA COLLECTION ASSOCIEE ---------------------- */
diff --git a/src/analysis/db/items/move.h b/src/analysis/db/items/move.h
index a9d6d8d..115bdc8 100644
--- a/src/analysis/db/items/move.h
+++ b/src/analysis/db/items/move.h
@@ -96,4 +96,4 @@ GMoveCollection *g_move_collection_new(void);
-#endif /* _ANALYSIS_DB_ITEMS_SWITCH_H */
+#endif /* _ANALYSIS_DB_ITEMS_MOVE_H */
diff --git a/src/analysis/db/items/switcher.c b/src/analysis/db/items/switcher.c
index 748c934..3d5841c 100644
--- a/src/analysis/db/items/switcher.c
+++ b/src/analysis/db/items/switcher.c
@@ -496,6 +496,9 @@ static void g_db_switcher_build_label(GDbSwitcher *switcher)
static bool g_db_switcher_run(GDbSwitcher *switcher, GLoadedBinary *binary, ImmOperandDisplay *old, ImmOperandDisplay new)
{
+ return false;
+
+#if 0
bool result; /* Bilan à faire remonter */
GArchProcessor *proc; /* Propriétaire d'instructions */
GArchInstruction *instr; /* Instruction à traiter */
@@ -568,7 +571,7 @@ static bool g_db_switcher_run(GDbSwitcher *switcher, GLoadedBinary *binary, ImmO
g_object_unref(G_OBJECT(proc));
return result;
-
+#endif
}
diff --git a/src/analysis/disass/area.h b/src/analysis/disass/area.h
index d5f910b..155db7c 100644
--- a/src/analysis/disass/area.h
+++ b/src/analysis/disass/area.h
@@ -28,6 +28,7 @@
#include "../binary.h"
#include "../../arch/instruction.h"
#include "../../format/symbol.h"
+#include "../../glibext/delayed.h"
#include "../../gtkext/gtkstatusstack.h"
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 5326c36..246a5b2 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -39,11 +39,16 @@
#include "routines.h"
#include "../../format/format.h"
#include "../../glibext/delayed-int.h"
+#include "../../glibext/generators/prologue.h"
#include "../../gui/panels/log.h"
#include "../../plugins/pglist.h"
+#include "../human/asm/lang.h" // TODO : REMME -> format !
+
+
+
/* ------------------------ DESASSEMBLAGE DE BINAIRE DIFFERE ------------------------ */
@@ -54,8 +59,9 @@ struct _GDelayedDisassembly
GLoadedBinary *binary; /* Destinataire final */
GExeFormat *format; /* Format du binaire représenté*/
+ GCodingLanguage *lang; /* Traduction en ASM préférée */
- GCodeBuffer *buffer; /* Tampon pour le rendu */
+ GBufferCache *cache; /* Tampon pour le rendu */
};
@@ -80,7 +86,7 @@ static void g_delayed_disassembly_dispose(GDelayedDisassembly *);
static void g_delayed_disassembly_finalize(GDelayedDisassembly *);
/* Crée une tâche de désassemblage différé. */
-static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *, GCodeBuffer *);
+static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *, GBufferCache *);
/* Opère sur toutes les instructions. */
static void process_all_instructions(wgroup_id_t, GtkStatusStack *, const char *, ins_fallback_cb, GArchProcessor *, GProcContext *, GExeFormat *);
@@ -97,7 +103,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *, GtkStatusStack
/* Construit la description d'introduction du désassemblage. */
-static void build_disass_prologue(GCodeBuffer *, const char *, const char *);
+static void build_disass_prologue(GBufferCache *, const GCodingLanguage *, const char *, const char *);
@@ -172,6 +178,7 @@ static void g_delayed_disassembly_init(GDelayedDisassembly *disass)
static void g_delayed_disassembly_dispose(GDelayedDisassembly *disass)
{
g_object_unref(G_OBJECT(disass->format));
+ g_object_unref(G_OBJECT(disass->lang));
G_OBJECT_CLASS(g_delayed_disassembly_parent_class)->dispose(G_OBJECT(disass));
@@ -211,7 +218,7 @@ static void g_delayed_disassembly_finalize(GDelayedDisassembly *disass)
* *
******************************************************************************/
-static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GCodeBuffer *buffer)
+static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GBufferCache *cache)
{
GDelayedDisassembly *result; /* Tâche à retourner */
@@ -219,8 +226,9 @@ static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *binary, GCo
result->binary = binary;
result->format = g_loaded_binary_get_format(binary);
+ result->lang = g_asm_language_new();
- result->buffer = buffer;
+ result->cache = cache;
return result;
@@ -568,7 +576,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
- print_disassembled_instructions(disass->buffer, disass->format, proc, status);
+ print_disassembled_instructions(disass->cache, disass->lang, disass->binary, status);
@@ -612,10 +620,10 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
/******************************************************************************
* *
-* Paramètres : buffer = tampon de destination pour le texte. *
+* Paramètres : cache = tampon de destination pour le texte. *
+* lang = trauducteur pour l'impression finale. *
* filename = nom du fichier ciblé à décompiler. *
-* data = données en mémoire pour l'empreinte. *
-* length = quantité de données à prendre en compte. *
+* checksum = empreinte identifiant le binaire chargé. *
* *
* Description : Construit la description d'introduction du désassemblage. *
* *
@@ -625,96 +633,32 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
* *
******************************************************************************/
-static void build_disass_prologue(GCodeBuffer *buffer, const char *filename, const char *checksum)
+static void build_disass_prologue(GBufferCache *cache, const GCodingLanguage *lang, const char *filename, const char *checksum)
{
-#if 0
- GLangOutput *output; /* Modèle de sortie adéquat */
- GBufferLine *line; /* Ligne de destination */
- bool managed; /* Groupe déjà défini ? */
- size_t len; /* Taille du texte */
- char *content; /* Contenu textuel d'une ligne */
-
- output = g_asm_output_new();
+ char **text; /* Contenu brute à imprimer */
+ GIntroGenerator *generator; /* Générateur constitué */
- line = g_lang_output_start_comments(output, buffer);
- if (line != NULL)
- {
- g_buffer_line_start_merge_at(line, BLC_PHYSICAL);
- g_buffer_line_add_flag(line, BLF_WIDTH_MANAGER);
-
- g_code_buffer_append_new_line(buffer, line);
-
- }
-
- managed = (line != NULL);
+ text = calloc(4, sizeof(char *));
/* Introduction */
- line = g_lang_output_continue_comments(output, buffer,
- SL(_("Disassembly generated by Chrysalide")));
- g_buffer_line_start_merge_at(line, BLC_PHYSICAL);
-
- if (!managed)
- g_buffer_line_add_flag(line, BLF_WIDTH_MANAGER);
-
- g_code_buffer_append_new_line(buffer, line);
-
- line = g_lang_output_continue_comments(output, buffer,
- SL(_("Chrysalide is free software - © 2008-2015 Cyrille Bagard")));
- g_buffer_line_start_merge_at(line, BLC_PHYSICAL);
-
- g_code_buffer_append_new_line(buffer, line);
-
- line = g_lang_output_continue_comments(output, buffer, NULL, 0);
- g_buffer_line_start_merge_at(line, BLC_PHYSICAL);
-
- g_code_buffer_append_new_line(buffer, line);
+ text[0] = strdup(_("Disassembly generated by Chrysalide"));
+ text[1] = strdup(_("Chrysalide is free software - © 2008-2016 Cyrille Bagard"));
/* Fichier */
- len = strlen(_("File: ")) + strlen(filename) + 1;
- content = (char *)calloc(len, sizeof(char));
-
- snprintf(content, len, "%s%s", _("File: "), filename);
-
- line = g_lang_output_continue_comments(output, buffer, content, len - 1);
- g_buffer_line_start_merge_at(line, BLC_PHYSICAL);
-
- g_code_buffer_append_new_line(buffer, line);
-
- free(content);
+ asprintf(&text[2], "%s%s", _("File: "), filename);
/* Checksum SHA256 */
- len = strlen(_("Sha256: ")) + strlen(checksum);
- content = (char *)calloc(len + 1, sizeof(char));
-
- snprintf(content, len + 1, "%s%s", _("Sha256: "), checksum);
-
- line = g_lang_output_continue_comments(output, buffer, content, len - 1);
- g_buffer_line_start_merge_at(line, BLC_PHYSICAL);
-
- g_code_buffer_append_new_line(buffer, line);
+ asprintf(&text[3], "%s%s", _("Sha256: "), checksum);
- free(content);
+ /* Intégration finale */
- /* Ligne de séparation */
+ generator = g_intro_generator_new(lang, text, 4);
- line = g_lang_output_continue_comments(output, buffer, NULL, 0);
- g_buffer_line_start_merge_at(line, BLC_PHYSICAL);
- g_code_buffer_append_new_line(buffer, line);
+ g_buffer_cache_append(cache, G_LINE_GENERATOR(generator), BLF_NONE);
- /* Conclusion */
-
- line = g_lang_output_end_comments(output, buffer);
- if (line != NULL)
- {
- g_buffer_line_start_merge_at(line, BLC_PHYSICAL);
- g_code_buffer_append_new_line(buffer, line);
- }
-
- g_object_unref(G_OBJECT(output));
-#endif
}
@@ -724,7 +668,7 @@ static void build_disass_prologue(GCodeBuffer *buffer, const char *filename, con
* parts = parties binaires à désassembler. *
* count = nombre de parties à traiter. *
* instrs = liste des instructions chargées. [OUT] *
-* buffer = tampon de code mis en place. [OUT] *
+* cache = tampon de code mis en place. [OUT] *
* ack = fonction à appeler une fois l'opération terminée. *
* *
* Description : Procède au désassemblage d'un contenu binaire donné. *
@@ -735,30 +679,35 @@ static void build_disass_prologue(GCodeBuffer *buffer, const char *filename, con
* *
******************************************************************************/
-void disassemble_binary(GLoadedBinary *binary, GCodeBuffer **buffer, disassembly_ack_fc ack)
+void disassemble_binary(GLoadedBinary *binary, GBufferCache **cache, disassembly_ack_fc ack)
{
GBinFormat *format; /* Format associé au binaire */
+ GCodingLanguage *lang; /* Langage de sortie préféré */
GBinContent *content; /* Contenu bianire manipulé */
const gchar *checksum; /* Identifiant de binaire */
GDelayedDisassembly *disass; /* Désassemblage à mener */
GWorkQueue *queue; /* Gestionnaire de différés */
- *buffer = g_code_buffer_new(BLC_ASSEMBLY);
+ *cache = g_buffer_cache_new();
format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
+ lang = g_asm_language_new();
+
content = g_binary_format_get_content(format);
checksum = g_binary_content_get_checksum(content);
g_object_unref(G_OBJECT(content));
g_object_unref(G_OBJECT(format));
- build_disass_prologue(*buffer, g_binary_content_describe(content, true), checksum);
+ build_disass_prologue(*cache, lang, g_binary_content_describe(content, true), checksum);
- disass = g_delayed_disassembly_new(binary, *buffer);
+ disass = g_delayed_disassembly_new(binary, *cache);
g_signal_connect(disass, "work-completed", G_CALLBACK(ack), binary);
queue = get_work_queue();
g_work_queue_schedule_work(queue, G_DELAYED_WORK(disass), DEFAULT_WORK_GROUP);
+ g_object_unref(G_OBJECT(lang));
+
}
diff --git a/src/analysis/disass/disassembler.h b/src/analysis/disass/disassembler.h
index 9151d23..20c7bdd 100644
--- a/src/analysis/disass/disassembler.h
+++ b/src/analysis/disass/disassembler.h
@@ -59,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 *, GCodeBuffer **, disassembly_ack_fc);
+void disassemble_binary(GLoadedBinary *, GBufferCache **, disassembly_ack_fc);
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index fe4d705..6c044be 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -27,27 +27,18 @@
#include <i18n.h>
-#include "../../arch/processor.h"
-#include "../../common/extstr.h"
#include "../../format/format.h"
+#include "../../glibext/generators/rborder.h"
#include "../../gui/panels/log.h"
-#define ROUTINE_INTRO_MSG "; --------------- BEGIN OF PROCEDURE ---------------"
-
-#define ROUTINE_OUTRO_MSG "; ---------------- END OF PROCEDURE ----------------"
-
-
-
/******************************************************************************
* *
-* Paramètres : buffer = tampon de récueil des résultats d'impression. *
-* format = format du binaire traité. *
-* instrs = ensemble d'instructions à traiter. *
-* routines = liste de routines intervenant dans le flot. *
-* count = quantité de ces routines. *
-* status = barre de statut avec progression à mettre à jour. *
+* Paramètres : cache = tampon de récueil des résultats d'impression. *
+* lang = langage de haut niveau préféré pour l'impression. *
+* binary = tampon de récueil des résultats d'impression. *
+* status = barre de statut avec progression à mettre à jour. *
* *
* Description : Transcrit du code désassemblé en texte humainement lisible. *
* *
@@ -57,8 +48,10 @@
* *
******************************************************************************/
-void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GArchProcessor *proc, GtkStatusStack *status)
+void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang, GLoadedBinary *binary, GtkStatusStack *status)
{
+ GExeFormat *format; /* Format associé au binaire */
+ GArchProcessor *proc; /* Processeur de l'architecture*/
GBinPortion *root; /* Couche première de portions */
GBinPortion **portions; /* Morceaux d'encadrement */
size_t portions_count; /* Taille de cette liste */
@@ -74,22 +67,21 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
size_t i; /* Boucle de parcours */
GArchInstruction *instr; /* Instruction à traiter */
const vmpa2t *iaddr; /* Adresse d'instruction */
- vmpa2t outro_addr; /* Adresse de fin de code */
- GBufferLine *line;
+ GBorderGenerator *border; /* Délimitation de routine */
const vmpa2t *paddr; /* Adresse de portion */
+ GLineGenerator *generator; /* Générateur de contenu ajouté*/
const vmpa2t *saddr; /* Adresse de symbole */
int compared; /* Bilan d'une comparaison */
SymbolType stype; /* Type de symbole trouvé */
- const char *label; /* Etiquette ciblant un symbole*/
- mrange_t range; /* Couverture sans surface */
+ vmpa2t intro_addr; /* Adresse de début de code */
+ vmpa2t outro_addr; /* Adresse de fin de code */
+ BufferLineFlags flags; /* Propriétés pour la ligne */
+ //mrange_t range; /* Couverture sans surface */
GDbComment *comment; /* Commentaire à ajouter */
- const char *text;
-
- char *prefixed;
@@ -98,6 +90,8 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
+ format = g_loaded_binary_get_format(binary);
+ proc = g_loaded_binary_get_processor(binary);
bool collect_all_portions(GBinPortion *portion, GBinPortion *parent, BinaryPortionVisit visit, void *unused)
{
@@ -149,29 +143,8 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
{
expect_outro = false;
- init_mrange(&range, &outro_addr, 0);
-
- line = g_code_buffer_prepare_new_line(buffer, &range);
- g_buffer_line_add_flag(line, BLF_IS_LABEL);
- g_buffer_line_fill_mrange(line, msize, msize);
-
- g_code_buffer_append_new_line(buffer, line);
-
- line = g_code_buffer_prepare_new_line(buffer, &range);
- g_buffer_line_add_flag(line, BLF_IS_LABEL);
- g_buffer_line_fill_mrange(line, msize, msize);
-
- g_buffer_line_start_merge_at(line, BLC_ASSEMBLY_HEAD);
- g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD,
- ROUTINE_OUTRO_MSG, strlen(ROUTINE_OUTRO_MSG), RTT_COMMENT, NULL);
-
- g_code_buffer_append_new_line(buffer, line);
-
- line = g_code_buffer_prepare_new_line(buffer, &range);
- g_buffer_line_add_flag(line, BLF_IS_LABEL);
- g_buffer_line_fill_mrange(line, msize, msize);
-
- g_code_buffer_append_new_line(buffer, line);
+ border = g_border_generator_new(lang, &outro_addr, false, msize);
+ g_buffer_cache_append(cache, G_LINE_GENERATOR(border), BLF_NONE);
}
@@ -184,7 +157,11 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
if (cmp_vmpa_by_phy(iaddr, paddr) != 0)
break;
- g_binary_portion_print(portions[portion_index], buffer, msize);
+ generator = G_LINE_GENERATOR(portions[portion_index]);
+
+ /* Si elle comporte une description ! */
+ if (g_line_generator_count_lines(generator) > 0)
+ g_buffer_cache_append(cache, generator, BLF_NONE);
portion_index++;
@@ -192,7 +169,10 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
/* Début d'un nouveau symbole ? */
- if (sym_index < sym_count)
+ if (sym_index == sym_count)
+ compared = -1;
+
+ else
{
iaddr = get_mrange_addr(g_arch_instruction_get_range(instr));
saddr = get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index]));
@@ -225,29 +205,10 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
{
/* Impression de la marque de début */
- init_mrange(&range, get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index])), 0);
-
- line = g_code_buffer_prepare_new_line(buffer, &range);
- g_buffer_line_add_flag(line, BLF_IS_LABEL);
- g_buffer_line_fill_mrange(line, msize, msize);
-
- g_code_buffer_append_new_line(buffer, line);
-
- line = g_code_buffer_prepare_new_line(buffer, &range);
- g_buffer_line_add_flag(line, BLF_IS_LABEL);
- g_buffer_line_fill_mrange(line, msize, msize);
-
- g_buffer_line_start_merge_at(line, BLC_ASSEMBLY_HEAD);
- g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD,
- ROUTINE_INTRO_MSG, strlen(ROUTINE_INTRO_MSG), RTT_COMMENT, NULL);
-
- g_code_buffer_append_new_line(buffer, line);
+ copy_vmpa(&intro_addr, get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index])));
- line = g_code_buffer_prepare_new_line(buffer, &range);
- g_buffer_line_add_flag(line, BLF_IS_LABEL);
- g_buffer_line_fill_mrange(line, msize, msize);
-
- g_code_buffer_append_new_line(buffer, line);
+ border = g_border_generator_new(lang, &intro_addr, true, msize);
+ g_buffer_cache_append(cache, G_LINE_GENERATOR(border), BLF_NONE);
/* Mémorisation de la fin */
@@ -259,23 +220,10 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
/* Etiquette ? */
- label = g_binary_symbol_get_label(symbols[sym_index]);
-
- if (label != NULL)
- {
- init_mrange(&range, get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index])), 0);
-
- line = g_code_buffer_prepare_new_line(buffer, &range);
- g_buffer_line_add_flag(line, BLF_IS_LABEL);
- g_buffer_line_fill_mrange(line, msize, msize);
-
- g_buffer_line_start_merge_at(line, BLC_ASSEMBLY_HEAD);
- g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD, label, strlen(label), RTT_LABEL, NULL);
- g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD, ":", 1, RTT_PUNCT, NULL);
-
- g_code_buffer_append_new_line(buffer, line);
+ generator = g_binary_symbol_produce_label(symbols[sym_index]);
- }
+ if (generator != NULL)
+ g_buffer_cache_append(cache, generator, BLF_NONE);
}
@@ -283,64 +231,37 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
no_more_symbol_finally:
+ flags = BLF_NONE;
-
- line = g_arch_instruction_print(instr, buffer, msize, content, ASX_INTEL);
-
-
- if (g_arch_instruction_get_flags(instr) & AIF_RETURN_POINT)
- g_buffer_line_add_flag(line, BLF_BOOKMARK);
-
-
- if (sym_index < sym_count)
+ if (compared == 0)
{
- iaddr = get_mrange_addr(g_arch_instruction_get_range(instr));
- saddr = get_mrange_addr(g_binary_symbol_get_range(symbols[sym_index]));
-
- if (cmp_vmpa(iaddr, saddr) == 0)
- {
- /* Point d'entrée ? */
-
- if (g_binary_symbol_get_target_type(symbols[sym_index]) == STP_ENTRY_POINT)
- g_buffer_line_add_flag(line, BLF_ENTRYPOINT);
+ /* Point d'entrée ? */
- /* Début d'un groupe bien cohérent avec les alignements ? */
+ if (g_binary_symbol_get_target_type(symbols[sym_index]) == STP_ENTRY_POINT)
+ flags |= BLF_ENTRYPOINT;
- if (g_binary_symbol_is_block_start(symbols[sym_index]))
- g_buffer_line_add_flag(line, BLF_WIDTH_MANAGER);
+ /* Début d'un groupe bien cohérent avec les alignements ? */
- /* Commentaire ? */
-
- comment = g_binary_symbol_get_comment(symbols[sym_index]);
-
- if (comment != NULL)
- {
+ if (g_binary_symbol_is_block_start(symbols[sym_index]))
+ flags |= BLF_WIDTH_MANAGER;
- /* FIXME : appliquer ! */
-
- text = g_db_comment_get_text(comment);
-
-
- prefixed = strdup("; ");
- prefixed = stradd(prefixed, text);
-
-
-
- g_buffer_line_append_text(line, BLC_COMMENTS, prefixed, strlen(prefixed), RTT_COMMENT, NULL);
+ }
+ g_buffer_cache_append(cache, G_LINE_GENERATOR(instr), flags);
- free(prefixed);
+ if (compared == 0)
+ {
+ /* Commentaire ? */
- }
+ comment = g_binary_symbol_get_comment(symbols[sym_index]);
- sym_index++;
+ if (comment != NULL)
+ g_db_item_apply(G_DB_ITEM(comment), binary);
- }
+ sym_index++;
}
- g_code_buffer_append_new_line(buffer, line);
-
g_object_unref(G_OBJECT(instr));
gtk_status_stack_update_activity_value(status, id, 1);
@@ -356,6 +277,10 @@ void print_disassembled_instructions(GCodeBuffer *buffer, GExeFormat *format, GA
if (portions != NULL)
free(portions);
+ g_object_unref(G_OBJECT(proc));
+ g_object_unref(G_OBJECT(format));
+
+
fprintf(stderr, "MISSING :: %u symbols\n", _missing);
diff --git a/src/analysis/disass/output.h b/src/analysis/disass/output.h
index 801d3f4..35a0108 100644
--- a/src/analysis/disass/output.h
+++ b/src/analysis/disass/output.h
@@ -25,15 +25,15 @@
#define _ANALYSIS_DISASS_OUTPUT_H
-#include "../../arch/processor.h"
-#include "../../format/executable.h"
-#include "../../glibext/gcodebuffer.h"
+#include "../binary.h"
+#include "../human/lang.h"
+#include "../../glibext/gbuffercache.h"
#include "../../gtkext/gtkstatusstack.h"
/* Transcrit du code désassemblé en texte humainement lisible. */
-void print_disassembled_instructions(GCodeBuffer *, GExeFormat *, GArchProcessor *, GtkStatusStack *);
+void print_disassembled_instructions(GBufferCache *, GCodingLanguage *, GLoadedBinary *, GtkStatusStack *);
diff --git a/src/analysis/human/Makefile.am b/src/analysis/human/Makefile.am
new file mode 100755
index 0000000..0cfc4e3
--- /dev/null
+++ b/src/analysis/human/Makefile.am
@@ -0,0 +1,19 @@
+
+noinst_LTLIBRARIES = libanalysishuman.la
+
+
+libanalysishuman_la_SOURCES = \
+ lang-int.h \
+ lang.h lang.c
+
+libanalysishuman_la_LIBADD = \
+ asm/libanalysishumanasm.la
+
+libanalysishuman_la_LDFLAGS =
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBARCHIVE_CFLAGS) $(LIBSQLITE_CFLAGS)
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS = asm
diff --git a/src/analysis/human/asm/Makefile.am b/src/analysis/human/asm/Makefile.am
new file mode 100755
index 0000000..da94071
--- /dev/null
+++ b/src/analysis/human/asm/Makefile.am
@@ -0,0 +1,17 @@
+
+noinst_LTLIBRARIES = libanalysishumanasm.la
+
+
+libanalysishumanasm_la_SOURCES = \
+ lang.h lang.c
+
+libanalysishumanasm_la_LIBADD =
+
+libanalysishumanasm_la_LDFLAGS =
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBARCHIVE_CFLAGS) $(LIBSQLITE_CFLAGS)
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS =
diff --git a/src/analysis/human/asm/lang.c b/src/analysis/human/asm/lang.c
new file mode 100644
index 0000000..27a26dd
--- /dev/null
+++ b/src/analysis/human/asm/lang.c
@@ -0,0 +1,221 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang.c - traduction en language d'assembleur classique
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "lang.h"
+
+
+#include "../lang-int.h"
+#include "../../../common/extstr.h"
+
+
+
+/* Traduction d'éléments en language d'assembleur (instance) */
+struct _GAsmLanguage
+{
+ GCodingLanguage parent; /* A laisser en premier */
+
+};
+
+/* Traduction d'éléments en language d'assembleur (classe) */
+struct _GAsmLanguageClass
+{
+ GCodingLanguageClass parent; /* A laisser en premier */
+
+};
+
+
+/* Initialise la classe des traductions en langage d'assembleur. */
+static void g_asm_language_class_init(GAsmLanguageClass *);
+
+/* Initialise une traduction d'éléments en langage d'assembleur. */
+static void g_asm_language_init(GAsmLanguage *);
+
+/* Supprime toutes les références externes. */
+static void g_asm_language_dispose(GAsmLanguage *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_asm_language_finalize(GAsmLanguage *);
+
+/* Complète du texte pour en faire un vrai commentaire. */
+static void g_asm_language_encapsulate_comment(const GAsmLanguage *, char **);
+
+/* Complète du texte pour en faire de vrais commentaires. */
+static void g_asm_language_encapsulate_comments(const GAsmLanguage *, char ***, size_t *);
+
+
+
+/* Indique le type défini pour une traduction en langage d'assembleur. */
+G_DEFINE_TYPE(GAsmLanguage, g_asm_language, G_TYPE_CODING_LANGUAGE);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des traductions en langage d'assembleur.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_class_init(GAsmLanguageClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GCodingLanguageClass *lang; /* Encore une autre vision... */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_asm_language_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_asm_language_finalize;
+
+ lang = G_CODING_LANGUAGE_CLASS(klass);
+
+ lang->encaps_comment = (encapsulate_comment_fc)g_asm_language_encapsulate_comment;
+ lang->encaps_comments = (encapsulate_comments_fc)g_asm_language_encapsulate_comments;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance à initialiser. *
+* *
+* Description : Initialise une traduction d'éléments en langage d'assembleur.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_init(GAsmLanguage *lang)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_dispose(GAsmLanguage *lang)
+{
+ G_OBJECT_CLASS(g_asm_language_parent_class)->dispose(G_OBJECT(lang));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_finalize(GAsmLanguage *lang)
+{
+ G_OBJECT_CLASS(g_asm_language_parent_class)->finalize(G_OBJECT(lang));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Crée une instance de traduction en langage d'assembleur. *
+* *
+* Retour : Instance mis en place et prête à emploi. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GCodingLanguage *g_asm_language_new(void)
+{
+ GAsmLanguage *result; /* Instance à retourner */
+
+ result = g_object_new(G_TYPE_ASM_LANGUAGE, NULL);
+
+ return G_CODING_LANGUAGE(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = langage de haut niveau à manipuler. *
+* text = adresse de la ligne à compléter. [OUT] *
+* *
+* Description : Complète du texte pour en faire un vrai commentaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_encapsulate_comment(const GAsmLanguage *lang, char **text)
+{
+ *text = strprep(*text, "; ");
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = langage de haut niveau à manipuler. *
+* text = adresse du tableau de lignes à conserver. [OUT] *
+* count = adresse de la taille du tableau fourni. [OUT] *
+* *
+* Description : Complète du texte pour en faire de vrais commentaires. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_asm_language_encapsulate_comments(const GAsmLanguage *lang, char ***text, size_t *count)
+{
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < *count; i++)
+ (*text)[i] = strprep((*text)[i], "; ");
+
+}
diff --git a/src/analysis/human/asm/lang.h b/src/analysis/human/asm/lang.h
new file mode 100644
index 0000000..7381048
--- /dev/null
+++ b/src/analysis/human/asm/lang.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang.h - prototypes pour la traduction en language d'assembleur classique
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ANALYSIS_HUMAN_ASM_LANG_H
+#define _ANALYSIS_HUMAN_ASM_LANG_H
+
+
+#include <glib-object.h>
+
+
+#include "../lang.h"
+
+
+
+#define G_TYPE_ASM_LANGUAGE g_asm_language_get_type()
+#define G_ASM_LANGUAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_asm_language_get_type(), GAsmLanguage))
+#define G_IS_ASM_LANGUAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_asm_language_get_type()))
+#define G_ASM_LANGUAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ASM_LANGUAGE, GAsmLanguageClass))
+#define G_IS_ASM_LANGUAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ASM_LANGUAGE))
+#define G_ASM_LANGUAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ASM_LANGUAGE, GAsmLanguageClass))
+
+
+/* Traduction d'éléments en language d'assembleur (instance) */
+typedef struct _GAsmLanguage GAsmLanguage;
+
+/* Traduction d'éléments en language d'assembleur (classe) */
+typedef struct _GAsmLanguageClass GAsmLanguageClass;
+
+
+/* Indique le type défini pour une traduction en langage d'assembleur. */
+GType g_asm_language_get_type(void);
+
+/* Crée une instance de traduction en langage d'assembleur. */
+GCodingLanguage *g_asm_language_new(void);
+
+
+
+#endif /* _ANALYSIS_HUMAN_ASM_LANG_H */
diff --git a/src/analysis/human/lang-int.h b/src/analysis/human/lang-int.h
new file mode 100644
index 0000000..c20bc8a
--- /dev/null
+++ b/src/analysis/human/lang-int.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang-int.h - prototypes utiles aux traductions en langages de haut niveau
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ANALYSIS_HUMAN_LANG_INT_H
+#define _ANALYSIS_HUMAN_LANG_INT_H
+
+
+#include "lang.h"
+
+
+
+/* Complète du texte pour en faire un vrai commentaire. */
+typedef void (* encapsulate_comment_fc) (const GCodingLanguage *, char **);
+
+/* Complète du texte pour en faire de vrais commentaires. */
+typedef void (* encapsulate_comments_fc) (const GCodingLanguage *, char ***, size_t *);
+
+
+/* Traduction générique en langage humain (instance) */
+struct _GCodingLanguage
+{
+ GObject parent; /* A laisser en premier */
+
+};
+
+/* Traduction générique en langage humain (classe) */
+struct _GCodingLanguageClass
+{
+ GObjectClass parent; /* A laisser en premier */
+
+ encapsulate_comment_fc encaps_comment; /* Encadrement de commentaire */
+ encapsulate_comments_fc encaps_comments;/* Encadrement de commentaires */
+
+};
+
+
+
+#endif /* _ANALYSIS_HUMAN_LANG_INT_H */
diff --git a/src/analysis/human/lang.c b/src/analysis/human/lang.c
new file mode 100644
index 0000000..72002d3
--- /dev/null
+++ b/src/analysis/human/lang.c
@@ -0,0 +1,167 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang.c - traduction en langages de haut niveau
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "lang.h"
+
+
+#include "lang-int.h"
+
+
+
+/* Initialise la classe des traductions en langage humain. */
+static void g_coding_language_class_init(GCodingLanguageClass *);
+
+/* Initialise une instance de traduction en langage humain. */
+static void g_coding_language_init(GCodingLanguage *);
+
+/* Supprime toutes les références externes. */
+static void g_coding_language_dispose(GCodingLanguage *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_coding_language_finalize(GCodingLanguage *);
+
+
+
+/* Indique le type défini pour une traduction en langage humain. */
+G_DEFINE_TYPE(GCodingLanguage, g_coding_language, G_TYPE_OBJECT);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des traductions en langage humain. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_coding_language_class_init(GCodingLanguageClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_coding_language_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_coding_language_finalize;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance à initialiser. *
+* *
+* Description : Initialise une instance de traduction en langage humain. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_coding_language_init(GCodingLanguage *lang)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_coding_language_dispose(GCodingLanguage *lang)
+{
+ G_OBJECT_CLASS(g_coding_language_parent_class)->dispose(G_OBJECT(lang));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_coding_language_finalize(GCodingLanguage *lang)
+{
+ G_OBJECT_CLASS(g_coding_language_parent_class)->finalize(G_OBJECT(lang));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = langage de haut niveau à manipuler. *
+* text = adresse de la ligne à compléter. [OUT] *
+* *
+* Description : Complète du texte pour en faire un vrai commentaire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_coding_language_encapsulate_comment(const GCodingLanguage *lang, char **text)
+{
+ G_CODING_LANGUAGE_GET_CLASS(lang)->encaps_comment(lang, text);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : lang = langage de haut niveau à manipuler. *
+* text = adresse du tableau de lignes à conserver. [OUT] *
+* count = adresse de la taille du tableau fourni. [OUT] *
+* *
+* Description : Complète du texte pour en faire de vrais commentaires. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_coding_language_encapsulate_comments(const GCodingLanguage *lang, char ***text, size_t *count)
+{
+ G_CODING_LANGUAGE_GET_CLASS(lang)->encaps_comments(lang, text, count);
+
+}
diff --git a/src/analysis/human/lang.h b/src/analysis/human/lang.h
new file mode 100644
index 0000000..dc8e398
--- /dev/null
+++ b/src/analysis/human/lang.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lang.h - prototypes pour les traductions en langages de haut niveau
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ANALYSIS_HUMAN_LANG_H
+#define _ANALYSIS_HUMAN_LANG_H
+
+
+#include <glib-object.h>
+
+
+
+#define G_TYPE_CODING_LANGUAGE g_coding_language_get_type()
+#define G_CODING_LANGUAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_CODING_LANGUAGE, GCodingLanguage))
+#define G_IS_CODING_LANGUAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_CODING_LANGUAGE))
+#define G_CODING_LANGUAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_CODING_LANGUAGE, GCodingLanguageClass))
+#define G_IS_CODING_LANGUAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_CODING_LANGUAGE))
+#define G_CODING_LANGUAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_CODING_LANGUAGE, GCodingLanguageClass))
+
+
+/* Traduction générique en langage humain (instance) */
+typedef struct _GCodingLanguage GCodingLanguage;
+
+/* Traduction générique en langage humain (classe) */
+typedef struct _GCodingLanguageClass GCodingLanguageClass;
+
+
+/* Indique le type défini pour une traduction en langage humain. */
+GType g_coding_language_get_type(void);
+
+/* Complète du texte pour en faire un vrai commentaire. */
+void g_coding_language_encapsulate_comment(const GCodingLanguage *, char **);
+
+/* Complète du texte pour en faire de vrais commentaires. */
+void g_coding_language_encapsulate_comments(const GCodingLanguage *, char ***, size_t *);
+
+
+
+#endif /* _ANALYSIS_HUMAN_LANG_H */
diff --git a/src/analysis/project.c b/src/analysis/project.c
index dce55b6..4251dcc 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -39,9 +39,8 @@
#include "../glibext/signal.h"
#include "../gtkext/easygtk.h"
#include "../glibext/delayed-int.h"
-#include "../gtkext/gtkblockview.h"
-#include "../gtkext/gtkgraphview.h"
-#include "../gtkext/gtksourceview.h"
+#include "../gtkext/gtkblockdisplay.h"
+#include "../gtkext/gtkgraphdisplay.h"
#include "../gui/core/panels.h"
#include "../gui/panels/log.h"
#include "../gui/panels/panel.h"
@@ -836,13 +835,10 @@ GPanelItem *_setup_new_panel_item_for_binary(GStudyProject *project, GLoadedBina
switch (i)
{
case BVW_BLOCK:
- display = gtk_block_view_new();
+ display = gtk_block_display_new();
break;
case BVW_GRAPH:
- display = gtk_graph_view_new();
- break;
- case BVW_SOURCE:
- display = gtk_source_view_new();
+ display = gtk_graph_display_new();
break;
default: /* GCC ! */
break;
@@ -894,9 +890,6 @@ GPanelItem *_setup_new_panel_item_for_binary(GStudyProject *project, GLoadedBina
case BVW_GRAPH:
g_object_set_data(G_OBJECT(displays[i]), "graph_alt_view", displays[j]);
break;
- case BVW_SOURCE:
- g_object_set_data(G_OBJECT(displays[i]), "source_alt_view", displays[j]);
- break;
default: /* GCC ! */
break;
}
@@ -1033,9 +1026,6 @@ GtkDisplayPanel *get_alt_view_for_view_panel(GtkDisplayPanel *panel, BinaryView
case BVW_GRAPH:
result = GTK_DISPLAY_PANEL(g_object_get_data(G_OBJECT(panel), "graph_alt_view"));
break;
- case BVW_SOURCE:
- result = GTK_DISPLAY_PANEL(g_object_get_data(G_OBJECT(panel), "source_alt_view"));
- break;
default:
assert(false);
result = NULL;