diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2015-02-11 17:05:54 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2015-02-11 17:05:54 (GMT) | 
| commit | bf879f2562545ab7de23f9d38364b7bd4b43fb2c (patch) | |
| tree | 6154160307cbca304ea9e1de178d8c2dfc8e0928 /src/format/elf | |
| parent | abd96dbbe27246e9303173e5e2f47b2e4cedbcb7 (diff) | |
Registered all the supported formats in the system code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@471 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf')
| -rw-r--r-- | src/format/elf/elf.c | 23 | ||||
| -rw-r--r-- | src/format/elf/elf.h | 4 | 
2 files changed, 14 insertions, 13 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c index cc84335..f0c361e 100644 --- a/src/format/elf/elf.c +++ b/src/format/elf/elf.c @@ -72,9 +72,7 @@ static bool g_elf_format_translate_offset_into_address(const GElfFormat *, off_t  /******************************************************************************  *                                                                             * -*  Paramètres  : type    = type de format recherché.                          * -*                content = contenu binaire à parcourir.                       * -*                length  = taille du contenu en question.                     * +*  Paramètres  : content = contenu binaire à parcourir.                       *  *                                                                             *  *  Description : Indique si le format peut être pris en charge ici.           *  *                                                                             * @@ -84,14 +82,17 @@ static bool g_elf_format_translate_offset_into_address(const GElfFormat *, off_t  *                                                                             *  ******************************************************************************/ -bool elf_is_matching(FormatType type, const bin_t *content, off_t length) +bool elf_is_matching(GBinContent *content)  {      bool result;                            /* Bilan à faire connaître     */ +    vmpa2t addr;                            /* Tête de lecture initiale    */ +    char magic[4];                          /* Idenfiant standard          */ + +    init_vmpa(&addr, 0, VMPA_NO_VIRTUAL); -    result = false; +    result = g_binary_content_get_raw(content, &addr, 4, (bin_t *)magic); -    if (length >= 4) -        result = (memcmp(content, "\x7f\x45\x4c\x46" /* .ELF */, 4) == 0); +    result &= (memcmp(magic, "\x7f\x45\x4c\x46" /* .ELF */, 4) == 0);      return result; @@ -150,7 +151,6 @@ static void g_elf_format_init(GElfFormat *format)  /******************************************************************************  *                                                                             *  *  Paramètres  : content = contenu binaire à parcourir.                       * -*                length  = taille du contenu en question.                     *  *                                                                             *  *  Description : Prend en charge un nouveau format ELF.                       *  *                                                                             * @@ -160,13 +160,13 @@ static void g_elf_format_init(GElfFormat *format)  *                                                                             *  ******************************************************************************/ -GBinFormat *g_elf_format_new(const bin_t *content, off_t length) +GBinFormat *g_elf_format_new(GBinContent *content)  {      GElfFormat *result;                     /* Structure à retourner       */      result = g_object_new(G_TYPE_ELF_FORMAT, NULL); -    g_binary_format_set_content(G_BIN_FORMAT(result), content, length); +    g_binary_format_set_content(G_BIN_FORMAT(result), content);      if (!read_elf_header(result, &result->header, &result->is_32b, &result->endian))      { @@ -196,6 +196,7 @@ GBinFormat *g_elf_format_new(const bin_t *content, off_t length)      }      /* FIXME : à améliorer */ +    /*      if ((ELF_HDR(result, result->header, e_shnum) * ELF_HDR(result, result->header, e_shentsize)) >= length)      {          log_variadic_message(LMT_BAD_BINARY, ("Suspicious section table (bigger than the binary !) ; reset !  --  replacing 0x%04hx by 0x%04hx at offset 0x%x"), @@ -203,7 +204,7 @@ GBinFormat *g_elf_format_new(const bin_t *content, off_t length)                               0, ELF_HDR_OFFSET_OF(result, e_shnum));          ELF_HDR_SET(result, result->header, e_shnum, 0);      } - +    */ diff --git a/src/format/elf/elf.h b/src/format/elf/elf.h index 5ea90fd..f18670c 100644 --- a/src/format/elf/elf.h +++ b/src/format/elf/elf.h @@ -49,13 +49,13 @@ typedef struct _GElfFormatClass GElfFormatClass;  /* Indique si le format peut être pris en charge ici. */ -bool elf_is_matching(FormatType, const bin_t *, off_t); +bool elf_is_matching(GBinContent *);  /* Indique le type défini pour un format d'exécutable ELF. */  GType g_elf_format_get_type(void);  /* Prend en charge un nouveau format ELF. */ -GBinFormat *g_elf_format_new(const bin_t *, off_t); +GBinFormat *g_elf_format_new(GBinContent *);  | 
