summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-01-20 07:05:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-01-20 07:05:53 (GMT)
commit93463ae02aa643d6370c7ed5bf61a815949b0d41 (patch)
treed0c6d0f75049eb004cea234fd457836fa9997d2e
parentdac61a1c5fdb5e3630dc0907a5e0e1a22789de9d (diff)
Given valid addresses to prologue lines.
-rw-r--r--ChangeLog7
-rw-r--r--src/analysis/disass/disassembler.c9
-rw-r--r--src/glibext/generators/prologue.c24
-rw-r--r--src/glibext/generators/prologue.h3
4 files changed, 28 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 005094a..9edebd6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
17-01-20 Cyrille Bagard <nocbos@gmail.com>
+ * src/analysis/disass/disassembler.c:
+ * src/glibext/generators/prologue.c:
+ * src/glibext/generators/prologue.h:
+ Give valid addresses to prologue lines.
+
+17-01-20 Cyrille Bagard <nocbos@gmail.com>
+
* src/analysis/disass/output.c:
Ensure all block closing marks have an existing address.
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index c3e1098..c9aa472 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -103,7 +103,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *, GtkStatusStack
/* Construit la description d'introduction du désassemblage. */
-static void build_disass_prologue(GBufferCache *, const GCodingLanguage *, const char *, const char *);
+static void build_disass_prologue(GBufferCache *, const GBinFormat *, const GCodingLanguage *, const char *, const char *);
@@ -621,6 +621,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
/******************************************************************************
* *
* Paramètres : cache = tampon de destination pour le texte. *
+* format = format associé au contenu représenté. *
* lang = trauducteur pour l'impression finale. *
* filename = nom du fichier ciblé à décompiler. *
* checksum = empreinte identifiant le binaire chargé. *
@@ -633,7 +634,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
* *
******************************************************************************/
-static void build_disass_prologue(GBufferCache *cache, const GCodingLanguage *lang, const char *filename, const char *checksum)
+static void build_disass_prologue(GBufferCache *cache, const GBinFormat *format, const GCodingLanguage *lang, const char *filename, const char *checksum)
{
char **text; /* Contenu brute à imprimer */
GIntroGenerator *generator; /* Générateur constitué */
@@ -655,7 +656,7 @@ static void build_disass_prologue(GBufferCache *cache, const GCodingLanguage *la
/* Intégration finale */
- generator = g_intro_generator_new(lang, text, 4);
+ generator = g_intro_generator_new(format, lang, text, 4);
g_buffer_cache_append(cache, G_LINE_GENERATOR(generator), BLF_NONE);
@@ -700,7 +701,7 @@ void disassemble_binary(GLoadedBinary *binary, GBufferCache **cache, disassembly
g_object_unref(G_OBJECT(format));
- build_disass_prologue(*cache, lang, g_binary_content_describe(content, true), checksum);
+ build_disass_prologue(*cache, format, lang, g_binary_content_describe(content, true), checksum);
disass = g_delayed_disassembly_new(binary, *cache);
g_signal_connect(disass, "work-completed", G_CALLBACK(ack), binary);
diff --git a/src/glibext/generators/prologue.c b/src/glibext/generators/prologue.c
index 33a0c4c..f88393b 100644
--- a/src/glibext/generators/prologue.c
+++ b/src/glibext/generators/prologue.c
@@ -31,6 +31,7 @@
#include "../gbufferline.h"
#include "../linegen-int.h"
#include "../linesegment.h"
+#include "../../format/executable.h"
@@ -39,6 +40,8 @@ struct _GIntroGenerator
{
GObject parent; /* A laisser en premier */
+ vmpa2t addr; /* Position première */
+
char **text; /* Lignes brutes à représenter */
size_t count; /* Quantité de ces lignes */
@@ -210,18 +213,24 @@ static void g_intro_generator_finalize(GIntroGenerator *generator)
* *
* Description : Crée un nouveau générateur de lignes d'introduction. *
* *
-* Retour : Composant GLib créé. *
+* Retour : Composant GLib créé ou NULL en cas d'échec. *
* *
* Remarques : - *
* *
******************************************************************************/
-GIntroGenerator *g_intro_generator_new(const GCodingLanguage *lang, char **text, size_t count)
+GIntroGenerator *g_intro_generator_new(const GBinFormat *format, const GCodingLanguage *lang, char **text, size_t count)
{
- GIntroGenerator *result; /* Composant à retourner */
+ GIntroGenerator *result; /* Composant à retourner */
+ vmpa2t first; /* Première position */
+
+ if (!g_exe_format_translate_offset_into_vmpa(G_EXE_FORMAT(format), 0, &first))
+ return NULL;
result = g_object_new(G_TYPE_INTRO_GENERATOR, NULL);
+ copy_vmpa(&result->addr, &first);
+
result->text = text;
result->count = count;
@@ -273,7 +282,7 @@ static size_t g_intro_generator_count_lines(const GIntroGenerator *generator)
static void g_intro_generator_compute_addr(const GIntroGenerator *generator, gint x, vmpa2t *addr, size_t index, size_t repeat)
{
- init_vmpa(addr, 0, 0);
+ copy_vmpa(addr, &generator->addr);
}
@@ -295,12 +304,7 @@ static void g_intro_generator_compute_addr(const GIntroGenerator *generator, gin
static int g_intro_generator_contains_addr(const GIntroGenerator *generator, const vmpa2t *addr, size_t index, size_t repeat)
{
- /**
- * Les lignes générées sont purement artificielles et sans attache.
- * Elles n'existent donc pas.
- */
-
- return 1;
+ return cmp_vmpa(addr, &generator->addr);
}
diff --git a/src/glibext/generators/prologue.h b/src/glibext/generators/prologue.h
index b4c2711..5bfc548 100644
--- a/src/glibext/generators/prologue.h
+++ b/src/glibext/generators/prologue.h
@@ -29,6 +29,7 @@
#include "../../analysis/human/lang.h"
+#include "../../format/format.h"
@@ -51,7 +52,7 @@ typedef struct _GIntroGeneratorClass GIntroGeneratorClass;
GType g_intro_generator_get_type(void);
/* Crée un nouveau générateur de lignes d'introduction. */
-GIntroGenerator *g_intro_generator_new(const GCodingLanguage *, char **, size_t);
+GIntroGenerator *g_intro_generator_new(const GBinFormat *, const GCodingLanguage *, char **, size_t);