diff options
Diffstat (limited to 'src/format')
| -rw-r--r-- | src/format/Makefile.am | 11 | ||||
| -rw-r--r-- | src/format/format-int.h | 78 | ||||
| -rw-r--r-- | src/format/format.c | 402 | ||||
| -rw-r--r-- | src/format/format.h | 1 | ||||
| -rw-r--r-- | src/format/known-int.h | 10 | ||||
| -rw-r--r-- | src/format/known.c | 181 | ||||
| -rw-r--r-- | src/format/known.h | 1 | ||||
| -rw-r--r-- | src/format/strsym.c | 14 | ||||
| -rw-r--r-- | src/format/symbol-int.h | 74 | ||||
| -rw-r--r-- | src/format/symbol.c | 322 | 
10 files changed, 958 insertions, 136 deletions
diff --git a/src/format/Makefile.am b/src/format/Makefile.am index 2004f93..305cd92 100644 --- a/src/format/Makefile.am +++ b/src/format/Makefile.am @@ -19,18 +19,9 @@ libformat_la_SOURCES =					\  	symbol-int.h						\  	symbol.h symbol.c -libformat_la_LIBADD =  - -libformat_la_LDFLAGS =  +libformat_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS)  devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%)  dev_HEADERS = $(libformat_la_SOURCES:%c=) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - -SUBDIRS =  diff --git a/src/format/format-int.h b/src/format/format-int.h index de29751..f18bb24 100644 --- a/src/format/format-int.h +++ b/src/format/format-int.h @@ -31,7 +31,6 @@  #include "known-int.h"  #include "preload.h"  #include "../glibext/objhole.h" -#include "../gtkext/gtkstatusstack.h"  #include "../mangling/demangler.h" @@ -45,18 +44,22 @@ typedef SourceEndian (* format_get_endian_fc) (const GBinFormat *);  /* Rythme des allocations pour les entrées de code */  #define EXTRA_POINT_BLOCK 20 -/* Informations glissées dans la structure GObject de GBinFormat */ -typedef union _fmt_obj_extra + +/* Informations glissées dans la structure GObject de GArchOperand */ +typedef struct _fmt_extra_data_t  { -    struct -    { -        FormatFlag flags;                   /* Informations complémentaires*/ +    FormatFlag flags;                       /* Informations complémentaires*/ + +} fmt_extra_data_t; -    }; +/* Encapsulation avec un verrou d'accès */ +typedef union _fmt_obj_extra_t +{ +    fmt_extra_data_t data;                  /* Données embarquées          */ +    lockable_obj_extra_t lockable;          /* Gestion d'accès aux fanions */ -    gint lock;                              /* Gestion d'accès aux fanions */ +} fmt_obj_extra_t; -} fmt_obj_extra;  /* Description d'une erreur */  typedef struct _fmt_error @@ -73,6 +76,19 @@ struct _GBinFormat  {      GKnownFormat parent;                    /* A laisser en premier        */ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ + +    /** +     * L'inclusion des informations suivantes dépend de l'architecture. +     * +     * Si la structure GObject possède un trou, on remplit de préférence +     * ce dernier. +     */ + +    fmt_obj_extra_t extra;                  /* Externalisation embarquée   */ + +#endif +      virt_t *start_points[DPL_COUNT];        /* Départ de désassemblage     */      size_t pt_allocated[DPL_COUNT];         /* Taille d'inscription allouée*/      size_t pt_count[DPL_COUNT];             /* Nombre de points enregistrés*/ @@ -97,53 +113,37 @@ struct _GBinFormat      gint error_locked;                      /* Statut d'accès à la liste   */  #endif -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +}; -    /** -     * L'inclusion des informations suivantes dépend de l'architecture. -     * -     * Si la structure GObject possède un trou, on remplit de préférence -     * ce dernier. -     */ +/* Format binaire générique (classe) */ +struct _GBinFormatClass +{ +    GKnownFormatClass parent;               /* A laisser en premier        */ -    fmt_obj_extra extra;                    /* Externalisation embarquée   */ +    format_get_endian_fc get_endian;        /* Boutisme employé            */ -#endif +    /* Signaux */ + +    void (* symbol_added) (GBinFormat *, GBinSymbol *); +    void (* symbol_removed) (GBinFormat *, GBinSymbol *);  }; +  /**   * Accès aux informations éventuellement déportées.   */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ - -#   define INIT_BIN_FORMAT_EXTRA(fmt) fmt->extra.lock = 0 +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -#   define GET_BIN_FORMAT_EXTRA(fmt) &fmt->extra +#   define GET_BIN_FORMAT_EXTRA(fmt) (fmt_extra_data_t *)&fmt->extra  #else -#   define INIT_BIN_FORMAT_EXTRA(fmt) INIT_GOBJECT_EXTRA(G_OBJECT(fmt)) - -#   define GET_BIN_FORMAT_EXTRA(fmt) GET_GOBJECT_EXTRA(G_OBJECT(fmt), fmt_obj_extra) +#   define GET_BIN_FORMAT_EXTRA(fmt) GET_GOBJECT_EXTRA(G_OBJECT(fmt), fmt_extra_data_t)  #endif -/* Format binaire générique (classe) */ -struct _GBinFormatClass -{ -    GKnownFormatClass parent;               /* A laisser en premier        */ - -    format_get_endian_fc get_endian;        /* Boutisme employé            */ - -    /* Signaux */ - -    void (* symbol_added) (GBinFormat *, GBinSymbol *); -    void (* symbol_removed) (GBinFormat *, GBinSymbol *); - -}; -  /* ------------------------------ DECODAGE DE SYMBOLES ------------------------------ */ diff --git a/src/format/format.c b/src/format/format.c index 045bc92..d126236 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -33,6 +33,7 @@  #include "preload.h"  #include "../arch/processor.h"  #include "../common/sort.h" +#include "../core/demanglers.h"  #include "../plugins/pglist.h" @@ -49,6 +50,12 @@ static void g_binary_format_dispose(GBinFormat *);  /* Procède à la libération totale de la mémoire. */  static void g_binary_format_finalize(GBinFormat *); +/* Charge les plages de couvertures depuis une mémoire tampon. */ +static bool g_binary_format_load_start_points(GBinFormat *, packed_buffer_t *); + +/* Sauvegarde les points de départ enregistrés pour un format. */ +static bool g_binary_format_store_start_points(GBinFormat *, packed_buffer_t *); +  /* ---------------------- RASSEMBLEMENT ET GESTION DE SYMBOLES ---------------------- */ @@ -65,6 +72,30 @@ static bool __g_binary_format_find_symbol(const GBinFormat *, const void *, __co +/* ------------------ CONSERVATION DES SOUCIS DURANT LE CHARGEMENT ------------------ */ + + +/* Charge les erreurs de chargement depuis une mémoire tampon. */ +static bool g_binary_format_load_errors(GBinFormat *, packed_buffer_t *); + +/* Sauvegarde les erreurs de chargement dans une mémoire tampon. */ +static bool g_binary_format_store_errors(GBinFormat *, packed_buffer_t *); + + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Charge un format depuis une mémoire tampon. */ +static bool g_binary_format_load(GBinFormat *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un format dans une mémoire tampon. */ +static bool g_binary_format_store(GBinFormat *, GObjectStorage *, packed_buffer_t *); + + + + +  /* Indique le type défini pour un format binaire générique. */  G_DEFINE_TYPE(GBinFormat, g_binary_format, G_TYPE_KNOWN_FORMAT); @@ -84,12 +115,18 @@ G_DEFINE_TYPE(GBinFormat, g_binary_format, G_TYPE_KNOWN_FORMAT);  static void g_binary_format_class_init(GBinFormatClass *klass)  {      GObjectClass *object;                   /* Autre version de la classe  */ +    GKnownFormatClass *known;               /* Version de classe parente   */      object = G_OBJECT_CLASS(klass);      object->dispose = (GObjectFinalizeFunc/* ! */)g_binary_format_dispose;      object->finalize = (GObjectFinalizeFunc)g_binary_format_finalize; +    known = G_KNOWN_FORMAT_CLASS(klass); + +    known->load = (load_known_fc)g_binary_format_load; +    known->store = (load_known_fc)g_binary_format_store; +      g_signal_new("symbol-added",                   G_TYPE_BIN_FORMAT,                   G_SIGNAL_RUN_LAST, @@ -123,7 +160,11 @@ static void g_binary_format_class_init(GBinFormatClass *klass)  static void g_binary_format_init(GBinFormat *format)  { -    INIT_BIN_FORMAT_EXTRA(format); +    fmt_extra_data_t *extra;                /* Données insérées à modifier */ + +    extra = GET_BIN_FORMAT_EXTRA(format); + +    INIT_GOBJECT_EXTRA_LOCK(extra);      g_rw_lock_init(&format->pt_lock); @@ -235,17 +276,17 @@ static void g_binary_format_finalize(GBinFormat *format)  bool g_binary_format_set_flag(GBinFormat *format, FormatFlag flag)  {      bool result;                            /* Bilan à retourner           */ -    fmt_obj_extra *extra;                   /* Données insérées à modifier */ +    fmt_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_FORMAT_EXTRA(format); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = !(extra->flags & flag);      extra->flags |= flag; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -268,17 +309,17 @@ bool g_binary_format_set_flag(GBinFormat *format, FormatFlag flag)  bool g_binary_format_unset_flag(GBinFormat *format, FormatFlag flag)  {      bool result;                            /* Bilan à retourner           */ -    fmt_obj_extra *extra;                   /* Données insérées à modifier */ +    fmt_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_FORMAT_EXTRA(format); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = (extra->flags & flag);      extra->flags &= ~flag; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -301,15 +342,15 @@ bool g_binary_format_unset_flag(GBinFormat *format, FormatFlag flag)  bool g_binary_format_has_flag(const GBinFormat *format, FormatFlag flag)  {      bool result;                            /* Bilan à retourner           */ -    fmt_obj_extra *extra;                   /* Données insérées à modifier */ +    fmt_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_FORMAT_EXTRA(format); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = (extra->flags & flag); -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -331,15 +372,15 @@ bool g_binary_format_has_flag(const GBinFormat *format, FormatFlag flag)  FormatFlag g_binary_format_get_flags(const GBinFormat *format)  {      FormatFlag result;                      /* Fanions à retourner         */ -    fmt_obj_extra *extra;                   /* Données insérées à modifier */ +    fmt_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_FORMAT_EXTRA(format); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = (extra->flags & FFL_MASK); -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -407,6 +448,101 @@ void g_binary_format_register_code_point(GBinFormat *format, virt_t pt, DisassPr  /******************************************************************************  *                                                                             * +*  Paramètres  : proc = architecture concernée par la procédure.              * +*                pbuf = zone tampon à vider.                                  * +*                                                                             * +*  Description : Charge les plages de couvertures depuis une mémoire tampon.  * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_format_load_start_points(GBinFormat *format, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    DisassPriorityLevel i;                  /* Boucle de parcours #1       */ +    uleb128_t count;                        /* Quantité de points présents */ +    size_t k;                               /* Boucle de parcours #2       */ +    uleb128_t value;                        /* Valeur ULEB128 à charger    */ + +    result = true; + +    g_rw_lock_writer_lock(&format->pt_lock); + +    for (i = 0; i < DPL_COUNT && result; i++) +    { +        result = unpack_uleb128(&count, pbuf); +        if (!result) break; + +        format->pt_allocated[i] = count; +        format->pt_count[i] = count; + +        format->start_points[i] = calloc(format->pt_count[i], sizeof(virt_t)); + +        for (k = 0; k < format->pt_count[i] && result; k++) +        { +            result = unpack_uleb128(&value, pbuf); +            if (!result) break; + +            format->start_points[i][k] = value; + +        } + +    } + +    g_rw_lock_writer_unlock(&format->pt_lock); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : format = description de l'exécutable à consulter.            * +*                pbuf = zone tampon à remplir.                                * +*                                                                             * +*  Description : Sauvegarde les points de départ enregistrés pour un format.  * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_format_store_start_points(GBinFormat *format, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    DisassPriorityLevel i;                  /* Boucle de parcours #1       */ +    size_t count;                           /* Quantité de points présents */ +    size_t k;                               /* Boucle de parcours #2       */ + +    result = true; + +    g_rw_lock_writer_lock(&format->pt_lock); + +    for (i = 0; i < DPL_COUNT && result; i++) +    { +        count = format->pt_count[i]; + +        result = pack_uleb128((uleb128_t []){ count }, pbuf); + +        for (k = 0; k < count && result; k++) +            result = pack_uleb128((uleb128_t []){ format->start_points[i][k] }, pbuf); + +    } + +    g_rw_lock_writer_unlock(&format->pt_lock); + +    return result; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : format = description de l'exécutable à consulter.            *  *                ctx    = contexte de désassemblage à préparer.               *  *                status = barre de statut à tenir informée.                   * @@ -1542,3 +1678,243 @@ bool g_binary_format_get_error(GBinFormat *format, size_t index, BinaryFormatErr      return result;  } + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : format = format de binaire concerné par la procédure.        * +*                pbuf   = zone tampon à vider.                                * +*                                                                             * +*  Description : Charge les erreurs de chargement depuis une mémoire tampon.  * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_format_load_errors(GBinFormat *format, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    uleb128_t value;                        /* Valeur ULEB128 à charger    */ +    size_t i;                               /* Boucle de parcours          */ +    fmt_error *error;                       /* Raccourci de confort        */ +    rle_string str;                         /* Chaîne à charger            */ + +    g_binary_format_lock_errors(format); + +    result = unpack_uleb128(&value, pbuf); +    if (!result) goto exit; + +    format->error_count = value; + +    format->errors = calloc(format->error_count, sizeof(fmt_error)); + +    for (i = 0; i < format->error_count && result; i++) +    { +        error = &format->errors[i]; + +        result = unpack_uleb128(&value, pbuf); +        if (!result) break; + +        error->type = value; + +        result = unpack_vmpa(&error->addr, pbuf); +        if (!result) break; + +        setup_empty_rle_string(&str); + +        result = unpack_rle_string(&str, pbuf); +        if (!result) break; + +        if (get_rle_string(&str) != NULL) +            error->desc = strdup(get_rle_string(&str)); + +        exit_rle_string(&str); + +    } + + exit: + +    g_binary_format_unlock_errors(format); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : format = format de binaire concerné par la procédure.        * +*                pbuf   = zone tampon à remplir.                              * +*                                                                             * +*  Description : Sauvegarde les erreurs de chargement dans une mémoire tampon.* +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_format_store_errors(GBinFormat *format, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    size_t i;                               /* Boucle de parcours          */ +    fmt_error *error;                       /* Raccourci de confort        */ +    rle_string str;                         /* Chaîne à conserver          */ + +    g_binary_format_lock_errors(format); + +    result = pack_uleb128((uleb128_t []){ format->error_count }, pbuf); + +    for (i = 0; i < format->error_count && result; i++) +    { +        error = &format->errors[i]; + +        result = pack_uleb128((uleb128_t []){ error->type }, pbuf); +        if (!result) break; + +        result = pack_vmpa(&error->addr, pbuf); +        if (!result) break; + +        init_static_rle_string(&str, error->desc); + +        result = pack_rle_string(&str, pbuf); + +        exit_rle_string(&str); + +    } + +    g_binary_format_unlock_errors(format); + +    return result; + +} + + + +/* ---------------------------------------------------------------------------------- */ +/*                       IMPLEMENTATION DES FONCTIONS DE CLASSE                       */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = élément GLib à constuire.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à lire.                                * +*                                                                             * +*  Description : Charge un format depuis une mémoire tampon.                  * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_format_load(GBinFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    fmt_extra_data_t *extra;                /* Données insérées à consulter*/ +    uleb128_t value;                        /* Valeur ULEB128 à charger    */ +    rle_string str;                         /* Chaîne à charger            */ + +    extra = GET_BIN_FORMAT_EXTRA(format); + +    LOCK_GOBJECT_EXTRA(extra); + +    result = unpack_uleb128(&value, pbuf); + +    if (result) +        extra->flags = value; + +    UNLOCK_GOBJECT_EXTRA(extra); + +    if (result) +        result = g_binary_format_load_start_points(format, pbuf); + +    if (result) +    { +        setup_empty_rle_string(&str); + +        result = unpack_rle_string(&str, pbuf); + +        if (result) +            result = (get_rle_string(&str) != NULL); + +        if (result) +            format->demangler = get_compiler_demangler_for_key(get_rle_string(&str)); + +        if (result) +            result = (format->demangler != NULL); + +        exit_rle_string(&str); + +    } + + + + + +    if (result) +        result = g_binary_format_load_errors(format, pbuf); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = élément GLib à consulter.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à remplir.                             * +*                                                                             * +*  Description : Sauvegarde un format dans une mémoire tampon.                * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_format_store(GBinFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    fmt_extra_data_t *extra;                /* Données insérées à consulter*/ +    char *key;                              /* Désignation du décodeur     */ +    rle_string str;                         /* Chaîne à conserver          */ + +    extra = GET_BIN_FORMAT_EXTRA(format); + +    LOCK_GOBJECT_EXTRA(extra); + +    result = pack_uleb128((uleb128_t []){ extra->flags }, pbuf); + +    UNLOCK_GOBJECT_EXTRA(extra); + +    if (result) +        result = g_binary_format_store_start_points(format, pbuf); + +    if (result) +    { +        key = g_compiler_demangler_get_key(format->demangler); +        init_dynamic_rle_string(&str, key); + +        result = pack_rle_string(&str, pbuf); + +        exit_rle_string(&str); + +    } + + + + + + +    if (result) +        result = g_binary_format_store_errors(format, pbuf); + +    return result; + +} diff --git a/src/format/format.h b/src/format/format.h index a23782c..f9aa430 100644 --- a/src/format/format.h +++ b/src/format/format.h @@ -34,6 +34,7 @@  #include "../analysis/content.h"  #include "../arch/context.h"  #include "../glibext/delayed.h" +#include "../glibext/notifier.h" diff --git a/src/format/known-int.h b/src/format/known-int.h index 950c75f..3328a96 100644 --- a/src/format/known-int.h +++ b/src/format/known-int.h @@ -26,6 +26,7 @@  #include "known.h" +#include "../analysis/storage/storage.h" @@ -41,6 +42,12 @@ typedef bool (* known_analyze_fc) (GKnownFormat *, wgroup_id_t, GtkStatusStack *  /* Réalise un traitement post-désassemblage. */  typedef void (* known_complete_analysis_fc) (GKnownFormat *, wgroup_id_t, GtkStatusStack *); +/* Charge un format depuis une mémoire tampon. */ +typedef bool (* load_known_fc) (GKnownFormat *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un format dans une mémoire tampon. */ +typedef bool (* store_known_fc) (GKnownFormat *, GObjectStorage *, packed_buffer_t *); +  /* Format binaire générique (instance) */  struct _GKnownFormat @@ -62,6 +69,9 @@ struct _GKnownFormatClass      known_analyze_fc analyze;               /* Interprétation du format    */      known_complete_analysis_fc complete;    /* Terminaison d'analyse       */ +    load_known_fc load;                     /* Chargement depuis un tampon */ +    store_known_fc store;                   /* Conservation dans un tampon */ +  }; diff --git a/src/format/known.c b/src/format/known.c index 6865d0d..7512ae1 100644 --- a/src/format/known.c +++ b/src/format/known.c @@ -28,16 +28,23 @@  #include "known-int.h" +#include "../analysis/storage/serialize-int.h"  #include "../plugins/pglist.h" +/* ---------------------- DEFINITION DE LA BASE DE TOUT FORMAT ---------------------- */ + +  /* Initialise la classe des formats binaires génériques. */  static void g_known_format_class_init(GKnownFormatClass *);  /* Initialise une instance de format binaire générique. */  static void g_known_format_init(GKnownFormat *); +/* Procède à l'initialisation de l'interface de sérialisation. */ +static void g_known_format_serializable_init(GSerializableObjectInterface *); +  /* Supprime toutes les références externes. */  static void g_known_format_dispose(GKnownFormat *); @@ -46,8 +53,31 @@ static void g_known_format_finalize(GKnownFormat *); +/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */ + + +/* Charge un format depuis une mémoire tampon. */ +static bool _g_known_format_load(GKnownFormat *, GObjectStorage *, packed_buffer_t *); + +/* Charge un format depuis une mémoire tampon. */ +static bool g_known_format_load(GKnownFormat *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un format dans une mémoire tampon. */ +static bool _g_known_format_store(GKnownFormat *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un format dans une mémoire tampon. */ +static bool g_known_format_store(GKnownFormat *, GObjectStorage *, packed_buffer_t *); + + + +/* ---------------------------------------------------------------------------------- */ +/*                        DEFINITION DE LA BASE DE TOUT FORMAT                        */ +/* ---------------------------------------------------------------------------------- */ + +  /* Indique le type défini pour un format binaire générique. */ -G_DEFINE_TYPE(GKnownFormat, g_known_format, G_TYPE_OBJECT); +G_DEFINE_TYPE_WITH_CODE(GKnownFormat, g_known_format, G_TYPE_OBJECT, +                        G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_known_format_serializable_init));  /****************************************************************************** @@ -71,6 +101,9 @@ static void g_known_format_class_init(GKnownFormatClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_known_format_dispose;      object->finalize = (GObjectFinalizeFunc)g_known_format_finalize; +    klass->load = (load_known_fc)_g_known_format_load; +    klass->store = (store_known_fc)_g_known_format_store; +  } @@ -95,6 +128,26 @@ static void g_known_format_init(GKnownFormat *format)  /******************************************************************************  *                                                                             * +*  Paramètres  : iface = interface GLib à initialiser.                        * +*                                                                             * +*  Description : Procède à l'initialisation de l'interface de sérialisation.  * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_known_format_serializable_init(GSerializableObjectInterface *iface) +{ +    iface->load = (load_serializable_object_cb)g_known_format_load; +    iface->store = (store_serializable_object_cb)g_known_format_store; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : format = instance d'objet GLib à traiter.                    *  *                                                                             *  *  Description : Supprime toutes les références externes.                     * @@ -289,3 +342,129 @@ void g_known_format_complete_analysis(GKnownFormat *format, wgroup_id_t gid, Gtk      handle_known_format_analysis(PGA_FORMAT_POST_ANALYSIS_ENDED, format, gid, status);  } + + + +/* ---------------------------------------------------------------------------------- */ +/*                      CONSERVATION ET RECHARGEMENT DES DONNEES                      */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = élément GLib à constuire.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à lire.                                * +*                                                                             * +*  Description : Charge un format depuis une mémoire tampon.                  * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool _g_known_format_load(GKnownFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    GBinContent *content;                   /* Contenu binaire rechargé    */ + +    content = G_BIN_CONTENT(g_object_storage_unpack_object(storage, "contents", pbuf)); +    result = (content != NULL); + +    if (result) +    { +        g_known_format_set_content(format, content); + +        g_object_unref(G_OBJECT(content)); + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = élément GLib à constuire.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à lire.                                * +*                                                                             * +*  Description : Charge un format depuis une mémoire tampon.                  * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_known_format_load(GKnownFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    GKnownFormatClass *class;               /* Classe à activer            */ + +    class = G_KNOWN_FORMAT_GET_CLASS(format); + +    result = class->load(format, storage, pbuf); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = élément GLib à consulter.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à remplir.                             * +*                                                                             * +*  Description : Sauvegarde un format dans une mémoire tampon.                * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool _g_known_format_store(GKnownFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ + +    if (format->content == NULL) +        result = false; + +    else +        result = g_object_storage_pack_object(storage, "contents", G_SERIALIZABLE_OBJECT(format->content), pbuf); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = élément GLib à consulter.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à remplir.                             * +*                                                                             * +*  Description : Sauvegarde un format dans une mémoire tampon.                * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_known_format_store(GKnownFormat *format, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    GKnownFormatClass *class;               /* Classe à activer            */ + +    class = G_KNOWN_FORMAT_GET_CLASS(format); + +    result = class->store(format, storage, pbuf); + +    return result; + +} diff --git a/src/format/known.h b/src/format/known.h index 8319a63..dcc8669 100644 --- a/src/format/known.h +++ b/src/format/known.h @@ -31,6 +31,7 @@  #include "../analysis/content.h"  #include "../glibext/delayed.h" +#include "../glibext/notifier.h" diff --git a/src/format/strsym.c b/src/format/strsym.c index aedd779..c352a0e 100644 --- a/src/format/strsym.c +++ b/src/format/strsym.c @@ -33,7 +33,7 @@  #include "symbol-int.h"  #include "../arch/operands/feeder-int.h"  #include "../common/alloc.h" -#include "../gtkext/gtkblockdisplay.h" +#include "../core/columns.h" @@ -98,10 +98,10 @@ int g_string_symbol_compare(const GStrSymbol *, const GStrSymbol *);  void g_string_symbol_print(const GStrSymbol *, GBufferLine *);  /* Charge un fournisseur depuis une mémoire tampon. */ -bool g_string_symbol_unserialize(GStrSymbol *, GBinFormat *, packed_buffer *); +bool g_string_symbol_unserialize(GStrSymbol *, GBinFormat *, packed_buffer_t *);  /* Sauvegarde un fournisseur dans une mémoire tampon. */ -bool g_string_symbol_serialize(const GStrSymbol *, packed_buffer *); +bool g_string_symbol_serialize(const GStrSymbol *, packed_buffer_t *); @@ -182,8 +182,8 @@ static void g_string_symbol_feeder_interface_init(GProxyFeederInterface *iface)      iface->print = (print_proxy_feeder_fc)g_string_symbol_print; -    iface->unserialize = (unserialize_proxy_feeder_fc)g_string_symbol_unserialize; -    iface->serialize = (serialize_proxy_feeder_fc)g_string_symbol_serialize; +    //iface->unserialize = (unserialize_proxy_feeder_fc)g_string_symbol_unserialize; +    //iface->serialize = (serialize_proxy_feeder_fc)g_string_symbol_serialize;  } @@ -860,7 +860,7 @@ void g_string_symbol_print(const GStrSymbol *symbol, GBufferLine *line)  *                                                                             *  ******************************************************************************/ -bool g_string_symbol_unserialize(GStrSymbol *symbol, GBinFormat *format, packed_buffer *pbuf) +bool g_string_symbol_unserialize(GStrSymbol *symbol, GBinFormat *format, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */      vmpa2t addr;                            /* Adresse à cibler            */ @@ -885,7 +885,7 @@ bool g_string_symbol_unserialize(GStrSymbol *symbol, GBinFormat *format, packed_  *                                                                             *  ******************************************************************************/ -bool g_string_symbol_serialize(const GStrSymbol *symbol, packed_buffer *pbuf) +bool g_string_symbol_serialize(const GStrSymbol *symbol, packed_buffer_t *pbuf)  {      bool result;                            /* Bilan à retourner           */      const mrange_t *range;                  /* Emplacement du symbole      */ diff --git a/src/format/symbol-int.h b/src/format/symbol-int.h index 99cee88..48a27ed 100644 --- a/src/format/symbol-int.h +++ b/src/format/symbol-int.h @@ -26,6 +26,7 @@  #include "symbol.h" +#include "../analysis/storage/serialize-int.h"  #include "../glibext/objhole.h" @@ -33,35 +34,40 @@  /* Fournit une étiquette pour viser un symbole. */  typedef char * (* get_symbol_label_fc) (const GBinSymbol *); +/* Charge un contenu depuis une mémoire tampon. */ +typedef bool (* load_symbol_fc) (GBinSymbol *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un contenu dans une mémoire tampon. */ +typedef bool (* store_symbol_fc) (GBinSymbol *, GObjectStorage *, packed_buffer_t *); +  /* Informations glissées dans la structure GObject de GBinSymbol */ -typedef union _sym_obj_extra +typedef struct _sym_extra_data_t  { -    struct -    { -        SymbolType stype;                   /* Type du symbole             */ -        SymbolStatus status;                /* Visibilité du symbole       */ +    SymbolType stype;                       /* Type du symbole             */ +    SymbolStatus status;                    /* Visibilité du symbole       */ -        char nm_prefix;                     /* Eventuel préfixe "nm"       */ +    char nm_prefix;                         /* Eventuel préfixe "nm"       */ -        SymbolFlag flags;                   /* Informations complémentaires*/ +    SymbolFlag flags;                       /* Informations complémentaires*/ -    }; +} sym_extra_data_t; -    gint lock;                              /* Gestion d'accès aux fanions */ +/* Encapsulation avec un verrou d'accès */ +typedef union _symbol_obj_extra_t +{ +    sym_extra_data_t data;                  /* Données embarquées          */ +    lockable_obj_extra_t lockable;          /* Gestion d'accès aux fanions */ + +} symbol_obj_extra_t; -} sym_obj_extra;  /* Symbole d'exécutable (instance) */  struct _GBinSymbol  {      GObject parent;                         /* A laisser en premier        */ -    mrange_t range;                         /* Couverture mémoire          */ - -    char *alt;                              /* Nom alternatif              */ - -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__      /**       * L'inclusion des informations suivantes dépend de l'architecture. @@ -70,38 +76,42 @@ struct _GBinSymbol       * ce dernier.       */ -    sym_obj_extra extra;                    /* Externalisation embarquée   */ +    symbol_obj_extra_t extra;               /* Externalisation embarquée   */  #endif +    mrange_t range;                         /* Couverture mémoire          */ + +    char *alt;                              /* Nom alternatif              */ +  }; -/** - * Accès aux informations éventuellement déportées. - */ +/* Symbole d'exécutable (classe) */ +struct _GBinSymbolClass +{ +    GObjectClass parent;                    /* A laisser en premier        */ -#if __SIZEOF_INT__ == __SIZEOF_LONG__ +    get_symbol_label_fc get_label;          /* Obtention d'une étiquette   */ -#   define INIT_BIN_SYMBOL_EXTRA(sym) sym->extra.lock = 0 +    load_symbol_fc load;                    /* Chargement depuis un tampon */ +    store_symbol_fc store;                  /* Conservation dans un tampon */ -#   define GET_BIN_SYMBOL_EXTRA(sym) &sym->extra +}; -#else -#   define INIT_BIN_SYMBOL_EXTRA(sym) INIT_GOBJECT_EXTRA(G_OBJECT(sym)) +/** + * Accès aux informations éventuellement déportées. + */ -#   define GET_BIN_SYMBOL_EXTRA(sym) GET_GOBJECT_EXTRA(G_OBJECT(sym), sym_obj_extra) +#if 1 //__SIZEOF_INT__ == __SIZEOF_LONG__ -#endif +#   define GET_BIN_SYMBOL_EXTRA(sym) (sym_extra_data_t *)&sym->extra -/* Symbole d'exécutable (classe) */ -struct _GBinSymbolClass -{ -    GObjectClass parent;                    /* A laisser en premier        */ +#else -    get_symbol_label_fc get_label;          /* Obtention d'une étiquette   */ +#   define GET_BIN_SYMBOL_EXTRA(sym) GET_GOBJECT_EXTRA(G_OBJECT(sym), sym_extra_data_t) -}; +#endif diff --git a/src/format/symbol.c b/src/format/symbol.c index eb61db8..5684928 100644 --- a/src/format/symbol.c +++ b/src/format/symbol.c @@ -30,9 +30,12 @@  #include "symbol-int.h" -#include "../glibext/gbinarycursor.h" +#include "../analysis/db/misc/rlestr.h" +#include "../core/columns.h" +#ifdef INCLUDE_GTK_SUPPORT +#   include "../glibext/gbinarycursor.h" +#endif  #include "../glibext/linegen-int.h" -#include "../gtkext/gtkblockdisplay.h" @@ -48,6 +51,9 @@ static void g_binary_symbol_init(GBinSymbol *);  /* Procède à l'initialisation de l'interface de génération. */  static void g_binary_symbol_interface_init(GLineGeneratorInterface *); +/* Procède à l'initialisation de l'interface de sérialisation. */ +static void g_binary_symbol_serializable_init(GSerializableObjectInterface *); +  /* Supprime toutes les références externes. */  static void g_binary_symbol_dispose(GBinSymbol *); @@ -62,12 +68,16 @@ static void g_binary_symbol_finalize(GBinSymbol *);  /* Indique le nombre de ligne prêtes à être générées. */  static size_t g_binary_symbol_count_lines(const GBinSymbol *); +#ifdef INCLUDE_GTK_SUPPORT +  /* Retrouve l'emplacement correspondant à une position donnée. */  static void g_binary_symbol_compute_cursor(const GBinSymbol *, gint, size_t, size_t, GLineCursor **);  /* Détermine si le conteneur s'inscrit dans une plage donnée. */  static int g_binary_symbol_contain_cursor(const GBinSymbol *, size_t, size_t, const GLineCursor *); +#endif +  /* Renseigne sur les propriétés liées à un générateur. */  static BufferLineFlags g_binary_symbol_get_line_flags(const GBinSymbol *, size_t, size_t); @@ -76,6 +86,23 @@ static void g_binary_symbol_print(GBinSymbol *, GBufferLine *, size_t, size_t, c +/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */ + + +/* Charge un contenu depuis une mémoire tampon. */ +static bool _g_binary_symbol_load(GBinSymbol *, GObjectStorage *, packed_buffer_t *); + +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_binary_symbol_load(GBinSymbol *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool _g_binary_symbol_store(GBinSymbol *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_binary_symbol_store(GBinSymbol *, GObjectStorage *, packed_buffer_t *); + + +  /* ---------------------------------------------------------------------------------- */  /*                       FONCTIONNALITES BASIQUES POUR SYMBOLES                       */  /* ---------------------------------------------------------------------------------- */ @@ -83,7 +110,8 @@ static void g_binary_symbol_print(GBinSymbol *, GBufferLine *, size_t, size_t, c  /* Indique le type défini pour un symbole d'exécutable. */  G_DEFINE_TYPE_WITH_CODE(GBinSymbol, g_binary_symbol, G_TYPE_OBJECT, -                        G_IMPLEMENT_INTERFACE(G_TYPE_LINE_GENERATOR, g_binary_symbol_interface_init)); +                        G_IMPLEMENT_INTERFACE(G_TYPE_LINE_GENERATOR, g_binary_symbol_interface_init) +                        G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_binary_symbol_serializable_init));  /****************************************************************************** @@ -107,6 +135,9 @@ static void g_binary_symbol_class_init(GBinSymbolClass *klass)      object->dispose = (GObjectFinalizeFunc/* ! */)g_binary_symbol_dispose;      object->finalize = (GObjectFinalizeFunc)g_binary_symbol_finalize; +    klass->load = (load_symbol_fc)_g_binary_symbol_load; +    klass->store = (store_symbol_fc)_g_binary_symbol_store; +  } @@ -124,7 +155,11 @@ static void g_binary_symbol_class_init(GBinSymbolClass *klass)  static void g_binary_symbol_init(GBinSymbol *symbol)  { -    INIT_BIN_SYMBOL_EXTRA(symbol); +    sym_extra_data_t *extra;                /* Données insérées à modifier */ + +    extra = GET_BIN_SYMBOL_EXTRA(symbol); + +    INIT_GOBJECT_EXTRA_LOCK(extra);      g_binary_symbol_set_stype(symbol, STP_COUNT); @@ -148,8 +183,10 @@ static void g_binary_symbol_init(GBinSymbol *symbol)  static void g_binary_symbol_interface_init(GLineGeneratorInterface *iface)  {      iface->count = (linegen_count_lines_fc)g_binary_symbol_count_lines; +#ifdef INCLUDE_GTK_SUPPORT      iface->compute = (linegen_compute_fc)g_binary_symbol_compute_cursor;      iface->contain = (linegen_contain_fc)g_binary_symbol_contain_cursor; +#endif      iface->get_flags = (linegen_get_flags_fc)g_binary_symbol_get_line_flags;      iface->print = (linegen_print_fc)g_binary_symbol_print; @@ -158,6 +195,26 @@ static void g_binary_symbol_interface_init(GLineGeneratorInterface *iface)  /******************************************************************************  *                                                                             * +*  Paramètres  : iface = interface GLib à initialiser.                        * +*                                                                             * +*  Description : Procède à l'initialisation de l'interface de sérialisation.  * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_binary_symbol_serializable_init(GSerializableObjectInterface *iface) +{ +    iface->load = (load_serializable_object_cb)g_binary_symbol_load; +    iface->store = (store_serializable_object_cb)g_binary_symbol_store; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : symbol = instance d'objet GLib à traiter.                    *  *                                                                             *  *  Description : Supprime toutes les références externes.                     * @@ -331,15 +388,15 @@ const mrange_t *g_binary_symbol_get_range(const GBinSymbol *symbol)  void g_binary_symbol_set_stype(GBinSymbol *symbol, SymbolType type)  { -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      extra->stype = type; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);  } @@ -359,15 +416,15 @@ void g_binary_symbol_set_stype(GBinSymbol *symbol, SymbolType type)  SymbolType g_binary_symbol_get_stype(const GBinSymbol *symbol)  {      SymbolType result;                      /* Type à retourner            */ -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = extra->stype; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -389,15 +446,15 @@ SymbolType g_binary_symbol_get_stype(const GBinSymbol *symbol)  void g_binary_symbol_set_status(GBinSymbol *symbol, SymbolStatus status)  { -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      extra->status = status; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);  } @@ -417,15 +474,15 @@ void g_binary_symbol_set_status(GBinSymbol *symbol, SymbolStatus status)  SymbolStatus g_binary_symbol_get_status(const GBinSymbol *symbol)  {      SymbolStatus result;                    /* Visibilité à retourner      */ -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = extra->status; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -448,17 +505,17 @@ SymbolStatus g_binary_symbol_get_status(const GBinSymbol *symbol)  bool g_binary_symbol_set_flag(GBinSymbol *symbol, SymbolFlag flag)  {      bool result;                            /* Bilan à retourner           */ -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = !(extra->flags & flag);      extra->flags |= flag; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -481,17 +538,17 @@ bool g_binary_symbol_set_flag(GBinSymbol *symbol, SymbolFlag flag)  bool g_binary_symbol_unset_flag(GBinSymbol *symbol, SymbolFlag flag)  {      bool result;                            /* Bilan à retourner           */ -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = (extra->flags & flag);      extra->flags &= ~flag; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -514,15 +571,15 @@ bool g_binary_symbol_unset_flag(GBinSymbol *symbol, SymbolFlag flag)  bool g_binary_symbol_has_flag(const GBinSymbol *symbol, SymbolFlag flag)  {      bool result;                            /* Bilan à retourner           */ -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = (extra->flags & flag); -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -544,15 +601,15 @@ bool g_binary_symbol_has_flag(const GBinSymbol *symbol, SymbolFlag flag)  SymbolFlag g_binary_symbol_get_flags(const GBinSymbol *symbol)  {      SymbolFlag result;                      /* Fanions à retourner         */ -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = extra->flags; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -575,18 +632,18 @@ SymbolFlag g_binary_symbol_get_flags(const GBinSymbol *symbol)  bool g_binary_symbol_get_nm_prefix(const GBinSymbol *symbol, char *prefix)  {      bool result;                            /* Validité à retourner        */ -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      result = (extra->flags & SFL_HAS_NM_PREFIX);      if (result)          *prefix = extra->nm_prefix; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);      return result; @@ -607,16 +664,16 @@ bool g_binary_symbol_get_nm_prefix(const GBinSymbol *symbol, char *prefix)  void g_binary_symbol_set_nm_prefix(const GBinSymbol *symbol, char prefix)  { -    sym_obj_extra *extra;                   /* Données insérées à modifier */ +    sym_extra_data_t *extra;                /* Données insérées à modifier */      extra = GET_BIN_SYMBOL_EXTRA(symbol); -    g_bit_lock(&extra->lock, HOLE_LOCK_BIT); +    LOCK_GOBJECT_EXTRA(extra);      extra->nm_prefix = prefix;      extra->flags |= SFL_HAS_NM_PREFIX; -    g_bit_unlock(&extra->lock, HOLE_LOCK_BIT); +    UNLOCK_GOBJECT_EXTRA(extra);  } @@ -735,6 +792,9 @@ static size_t g_binary_symbol_count_lines(const GBinSymbol *symbol)  } +#ifdef INCLUDE_GTK_SUPPORT + +  /******************************************************************************  *                                                                             *  *  Paramètres  : symbol = générateur à consulter.                             * @@ -802,6 +862,9 @@ static int g_binary_symbol_contain_cursor(const GBinSymbol *symbol, size_t index  } +#endif + +  /******************************************************************************  *                                                                             *  *  Paramètres  : symbol = générateur à consulter.                             * @@ -867,3 +930,194 @@ static void g_binary_symbol_print(GBinSymbol *symbol, GBufferLine *line, size_t      }  } + + + +/* ---------------------------------------------------------------------------------- */ +/*                      CONSERVATION ET RECHARGEMENT DES DONNEES                      */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol  = élément GLib à constuire.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à lire.                                * +*                                                                             * +*  Description : Charge un contenu depuis une mémoire tampon.                 * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool _g_binary_symbol_load(GBinSymbol *symbol, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    sym_extra_data_t *extra;                /* Données insérées à consulter*/ +    uleb128_t value;                        /* Valeur ULEB128 à charger    */ +    rle_string str;                         /* Chaîne à charger            */ + +    extra = GET_BIN_SYMBOL_EXTRA(symbol); + +    LOCK_GOBJECT_EXTRA(extra); + +    result = unpack_uleb128(&value, pbuf); + +    if (result) +        extra->stype = value; + +    if (result) +    { +        result = unpack_uleb128(&value, pbuf); + +        if (result) +            extra->status = value; + +    } + +    if (result) +        result = extract_packed_buffer(pbuf, &extra->nm_prefix, 1, false); + +    if (result) +    { +        result = unpack_uleb128(&value, pbuf); + +        if (result) +            extra->flags = value; + +    } + +    UNLOCK_GOBJECT_EXTRA(extra); + +    if (result) +        result = unpack_mrange(&symbol->range, pbuf); + +    if (result) +    { +        setup_empty_rle_string(&str); + +        result = unpack_rle_string(&str, pbuf); + +        if (result && get_rle_string(&str) != NULL) +            symbol->alt = strdup(get_rle_string(&str)); + +        exit_rle_string(&str); + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol  = élément GLib à constuire.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à lire.                                * +*                                                                             * +*  Description : Charge un contenu depuis une mémoire tampon.                 * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_symbol_load(GBinSymbol *symbol, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    GBinSymbolClass *class;                 /* Classe à activer            */ + +    class = G_BIN_SYMBOL_GET_CLASS(symbol); + +    result = class->load(symbol, storage, pbuf); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol  = élément GLib à consulter.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à remplir.                             * +*                                                                             * +*  Description : Sauvegarde un contenu dans une mémoire tampon.               * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool _g_binary_symbol_store(GBinSymbol *symbol, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    sym_extra_data_t *extra;                /* Données insérées à consulter*/ +    rle_string str;                         /* Chaîne à conserver          */ + +    extra = GET_BIN_SYMBOL_EXTRA(symbol); + +    LOCK_GOBJECT_EXTRA(extra); + +    result = pack_uleb128((uleb128_t []){ extra->stype }, pbuf); + +    if (result) +        result = pack_uleb128((uleb128_t []){ extra->status }, pbuf); + +    if (result) +        result = extend_packed_buffer(pbuf, &extra->nm_prefix, 1, false); + +    if (result) +        result = pack_uleb128((uleb128_t []){ extra->flags }, pbuf); + +    UNLOCK_GOBJECT_EXTRA(extra); + +    if (result) +        result = pack_mrange(&symbol->range, pbuf); + +    if (result) +    { +        init_static_rle_string(&str, symbol->alt); + +        result = pack_rle_string(&str, pbuf); + +        exit_rle_string(&str); + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol  = élément GLib à consulter.                          * +*                storage = conservateur de données à manipuler ou NULL.       * +*                pbuf    = zone tampon à remplir.                             * +*                                                                             * +*  Description : Sauvegarde un contenu dans une mémoire tampon.               * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_binary_symbol_store(GBinSymbol *symbol, GObjectStorage *storage, packed_buffer_t *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    GBinSymbolClass *class;                 /* Classe à activer            */ + +    class = G_BIN_SYMBOL_GET_CLASS(symbol); + +    result = class->store(symbol, storage, pbuf); + +    return result; + +}  | 
