summaryrefslogtreecommitdiff
path: root/src/glibext/generators
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 /src/glibext/generators
parentdac61a1c5fdb5e3630dc0907a5e0e1a22789de9d (diff)
Given valid addresses to prologue lines.
Diffstat (limited to 'src/glibext/generators')
-rw-r--r--src/glibext/generators/prologue.c24
-rw-r--r--src/glibext/generators/prologue.h3
2 files changed, 16 insertions, 11 deletions
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);