summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-08-06 17:43:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-08-06 17:43:08 (GMT)
commitf1d0462ab0f41ace04d8db02dd8ae3ee37f41a58 (patch)
treee3d9cf75f0adf14f73ca8f62e81fececd60e744e /src/analysis
parente59544bb61b0043d82946918ece144cae2749d53 (diff)
Allowed to add or remove instructions once a binary analysis is over.
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binary.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index c4f05f3..db3f509 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -51,6 +51,7 @@
#include "../core/params.h"
#include "../core/processors.h"
//#include "../glibext/chrysamarshal.h"
+#include "../glibext/gbinarycursor.h"
#include "../glibext/gloadedpanel.h"
#include "../gtkext/easygtk.h"
#include "../gtkext/gtkblockdisplay.h"
@@ -159,6 +160,9 @@ static const char *g_loaded_binary_get_format_name(const GLoadedBinary *);
/* Assure le désassemblage en différé. */
static bool g_loaded_binary_analyze(GLoadedBinary *, wgroup_id_t, GtkStatusStack *);
+/* Prend note d'une variation des instructions désassemblées. */
+static void on_binary_processor_changed(GArchProcessor *, GArchInstruction *, gboolean, GLoadedBinary *);
+
/* Fournit le désignation associée à l'élément chargé. */
static const char *g_loaded_binary_describe(const GLoadedBinary *, bool);
@@ -1558,6 +1562,8 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, wgroup_id_t gid, GtkS
goto glba_exit;
}
+ g_signal_connect(binary->proc, "changed", G_CALLBACK(on_binary_processor_changed), binary);
+
has_virt = g_arch_processor_has_virtual_space(binary->proc);
g_display_options_set(binary->options[BVW_BLOCK], BLC_VIRTUAL, has_virt);
@@ -1594,6 +1600,105 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, wgroup_id_t gid, GtkS
/******************************************************************************
* *
+* Paramètres : proc = processeur dont l'ensemble des instructions a varié.*
+* instr = instruction à l'origine de la procédure. *
+* added = précise s'il s'agit d'un ajout ou d'un retrait. *
+* binary = élément chargé à consulter. *
+* *
+* Description : Prend note d'une variation des instructions désassemblées. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void on_binary_processor_changed(GArchProcessor *proc, GArchInstruction *instr, gboolean added, GLoadedBinary *binary)
+{
+ const mrange_t *range; /* Emplacement de l'instruction*/
+ BufferLineFlags flags; /* Propriétés pour la ligne */
+ GBinSymbol *symbol; /* Symbole présent à l'adresse */
+ SymbolType stype; /* Type de symbole rencontré */
+ instr_iter_t *iter; /* Boucle de parcours */
+ GArchInstruction *next; /* Instruction suivante */
+ GLineCursor *cursor; /* Emplacement dans un tampon */
+ size_t index; /* Indice de ligne à traiter */
+
+ if (binary->disass_cache != NULL)
+ {
+ range = g_arch_instruction_get_range(instr);
+
+ if (added)
+ {
+ flags = BLF_NONE;
+
+ if (g_binary_format_find_symbol_at(G_BIN_FORMAT(binary->format), get_mrange_addr(range), &symbol))
+ {
+ /**
+ * Pour le choix des fanions, se référer au code similaire de
+ * la fonction print_disassembled_instructions().
+ */
+
+ stype = g_binary_symbol_get_target_type(symbol);
+
+ if (stype == STP_ENTRY_POINT)
+ flags |= BLF_ENTRYPOINT;
+
+ if (stype != STP_DYN_STRING)
+ flags |= BLF_WIDTH_MANAGER;
+
+ g_object_unref(G_OBJECT(symbol));
+
+ }
+
+ iter = g_arch_processor_get_iter_from_address(proc, get_mrange_addr(range));
+
+ next = get_instruction_iterator_next(iter);
+
+ delete_instruction_iterator(iter);
+
+ if (next == NULL)
+ g_buffer_cache_append(binary->disass_cache, G_LINE_GENERATOR(instr), flags);
+
+ else
+ {
+ range = g_arch_instruction_get_range(next);
+
+ cursor = g_binary_cursor_new();
+ g_binary_cursor_update(G_BINARY_CURSOR(cursor), get_mrange_addr(range));
+
+ index = g_buffer_cache_find_index_by_cursor(binary->disass_cache, cursor, true);
+
+ g_object_unref(G_OBJECT(cursor));
+
+ g_object_unref(G_OBJECT(next));
+
+ g_buffer_cache_insert_at(binary->disass_cache, index, G_LINE_GENERATOR(instr), flags, true, false);
+
+ }
+
+ }
+
+ else
+ {
+ cursor = g_binary_cursor_new();
+ g_binary_cursor_update(G_BINARY_CURSOR(cursor), get_mrange_addr(range));
+
+ index = g_buffer_cache_find_index_by_cursor(binary->disass_cache, cursor, true);
+
+ g_object_unref(G_OBJECT(cursor));
+
+ g_buffer_cache_delete_at(binary->disass_cache, index);
+
+ }
+
+ }
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : binary = élément chargé à consulter. *
* full = précise s'il s'agit d'une version longue ou non. *
* *