diff options
Diffstat (limited to 'src/format')
| -rw-r--r-- | src/format/executable.c | 67 | ||||
| -rw-r--r-- | src/format/flat.c | 27 | 
2 files changed, 57 insertions, 37 deletions
| diff --git a/src/format/executable.c b/src/format/executable.c index 80bfc9d..d0fc3e2 100644 --- a/src/format/executable.c +++ b/src/format/executable.c @@ -27,7 +27,6 @@  #include <assert.h>  #include <malloc.h>  #include <stdio.h> -//#include <stdlib.h>  #include <i18n.h> @@ -35,9 +34,10 @@  #include "executable-int.h"  #include "../core/logs.h" -/* -#include "../plugins/pglist.h" -*/ + + + +/* ------------------------- GESTION D'UN FORMAT EXECUTABLE ------------------------- */  /* Initialise la classe des formats d'exécutables génériques. */ @@ -54,6 +54,19 @@ static void g_executable_format_finalize(GExecutableFormat *); +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Assure l'interprétation d'un format en différé. */ +static bool g_executable_format_analyze(GExecutableFormat *); + + + +/* ---------------------------------------------------------------------------------- */ +/*                           GESTION D'UN FORMAT EXECUTABLE                           */ +/* ---------------------------------------------------------------------------------- */ + +  /* Indique le type défini pour un format d'exécutable générique. */  G_DEFINE_TYPE(GExecutableFormat, g_executable_format, G_TYPE_PROGRAM_FORMAT); @@ -73,12 +86,17 @@ G_DEFINE_TYPE(GExecutableFormat, g_executable_format, G_TYPE_PROGRAM_FORMAT);  static void g_executable_format_class_init(GExecutableFormatClass *klass)  {      GObjectClass *object;                   /* Autre version de la classe  */ +    GKnownFormatClass *known;               /* Version de format connu     */      object = G_OBJECT_CLASS(klass);      object->dispose = (GObjectFinalizeFunc/* ! */)g_executable_format_dispose;      object->finalize = (GObjectFinalizeFunc)g_executable_format_finalize; +    known = G_KNOWN_FORMAT_CLASS(klass); + +    known->analyze = (known_analyze_fc)g_executable_format_analyze; +  } @@ -159,7 +177,6 @@ bool g_executable_format_create(GExecutableFormat *format, GBinContent *content)      bool result;                            /* Bilan à retourner           */      vmpa2t addr;                            /* Emplacement vide de sens    */      phys_t length;                          /* Taille de portion globale   */ -    GExecutableFormatClass *class;          /* Classe de l'instance        */      result = g_program_format_create(G_PROGRAM_FORMAT(format), content);      if (!result) goto exit; @@ -175,11 +192,6 @@ bool g_executable_format_create(GExecutableFormat *format, GBinContent *content)      format->portions = g_binary_portion_new(&addr, length); -    class = G_EXECUTABLE_FORMAT_GET_CLASS(format); - -    if (class->refine_portions != NULL) -        result = class->refine_portions(format); -   exit:      return result; @@ -511,3 +523,38 @@ bool g_executable_format_translate_address_into_vmpa_with_portions(GExecutableFo      return result;  } + + + +/* ---------------------------------------------------------------------------------- */ +/*                       IMPLEMENTATION DES FONCTIONS DE CLASSE                       */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : format = format chargé dont l'analyse est lancée.            * +*                                                                             * +*  Description : Assure l'interprétation d'un format en différé.              * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_executable_format_analyze(GExecutableFormat *format) +{ +    bool result;                            /* Bilan à retourner           */ +    GExecutableFormatClass *class;          /* Classe de l'instance        */ + +    class = G_EXECUTABLE_FORMAT_GET_CLASS(format); + +    if (class->refine_portions != NULL) +        result = class->refine_portions(format); +    else +        result = true; + +    return result; + +} diff --git a/src/format/flat.c b/src/format/flat.c index c4e6edb..51f37fa 100644 --- a/src/format/flat.c +++ b/src/format/flat.c @@ -58,9 +58,6 @@ static char *g_flat_format_get_key(const GFlatFormat *);  /* Fournit une description humaine du format. */  static char *g_flat_format_get_description(const GFlatFormat *); -/* Assure l'interprétation d'un format en différé. */ -static bool g_flat_format_analyze(GFlatFormat *); -  /* Informe quant au boutisme utilisé. */  static SourceEndian g_flat_format_get_endianness(const GFlatFormat *); @@ -113,7 +110,6 @@ static void g_flat_format_class_init(GFlatFormatClass *klass)      known->get_key = (known_get_key_fc)g_flat_format_get_key;      known->get_desc = (known_get_desc_fc)g_flat_format_get_description; -    known->analyze = (known_analyze_fc)g_flat_format_analyze;      prgm = G_PROGRAM_FORMAT_CLASS(klass); @@ -303,29 +299,6 @@ static char *g_flat_format_get_description(const GFlatFormat *format)  /******************************************************************************  *                                                                             * -*  Paramètres  : format = format chargé dont l'analyse est lancée.            * -*                                                                             * -*  Description : Assure l'interprétation d'un format en différé.              * -*                                                                             * -*  Retour      : Bilan de l'opération.                                        * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static bool g_flat_format_analyze(GFlatFormat *format) -{ -    bool result;                            /* Bilan à retourner           */ - -    result = true; - -    return result; - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : format = informations chargées à consulter.                  *  *                                                                             *  *  Description : Informe quant au boutisme utilisé.                           * | 
