diff options
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/dalvik/register.c | 2 | ||||
| -rw-r--r-- | src/arch/immediate.c | 70 | ||||
| -rw-r--r-- | src/arch/instruction-int.h | 5 | ||||
| -rw-r--r-- | src/arch/instruction.c | 170 | ||||
| -rw-r--r-- | src/arch/instruction.h | 3 | ||||
| -rw-r--r-- | src/arch/jvm/operand.c | 11 | ||||
| -rw-r--r-- | src/arch/mips/operand.c | 34 | ||||
| -rw-r--r-- | src/arch/operand-int.h | 9 | ||||
| -rw-r--r-- | src/arch/operand.c | 49 | ||||
| -rw-r--r-- | src/arch/operand.h | 8 | ||||
| -rw-r--r-- | src/arch/x86/Makefile.am | 2 | ||||
| -rw-r--r-- | src/arch/x86/operands/data.c | 16 | ||||
| -rw-r--r-- | src/arch/x86/operands/modrm.c | 15 | ||||
| -rw-r--r-- | src/arch/x86/operands/modrm.h | 2 | ||||
| -rw-r--r-- | src/arch/x86/operands/moffs.c | 14 | ||||
| -rw-r--r-- | src/arch/x86/operands/register.c | 42 | ||||
| -rw-r--r-- | src/arch/x86/operands/register.h | 2 | ||||
| -rw-r--r-- | src/arch/x86/operands/relative.c | 14 | ||||
| -rw-r--r-- | src/arch/x86/register.c (renamed from src/arch/x86/registers.c) | 157 | ||||
| -rw-r--r-- | src/arch/x86/register.h (renamed from src/arch/x86/registers.h) | 15 | 
20 files changed, 148 insertions, 492 deletions
| diff --git a/src/arch/dalvik/register.c b/src/arch/dalvik/register.c index 6e709f9..b2023b5 100644 --- a/src/arch/dalvik/register.c +++ b/src/arch/dalvik/register.c @@ -61,7 +61,7 @@ static void g_dalvik_register_init(GDalvikRegister *);  /* Indique le type défini pour une représentation d'un registre Dalvik. */ -G_DEFINE_TYPE(GDalvikRegister, g_dalvik_register, G_TYPE_CONTENT_EXPORTER); +G_DEFINE_TYPE(GDalvikRegister, g_dalvik_register, G_TYPE_ARCH_OPERAND);  /****************************************************************************** diff --git a/src/arch/immediate.c b/src/arch/immediate.c index 72faf4c..e8f0212 100644 --- a/src/arch/immediate.c +++ b/src/arch/immediate.c @@ -90,12 +90,6 @@ static void g_imm_operand_init(GImmOperand *);  /* Construit la chaîne de caractères correspondant à l'opérande. */  static size_t g_imm_operand_to_string(const GImmOperand *, AsmSyntax, char [VMPA_MAX_SIZE]); -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_imm_operand_add_text(const GImmOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_imm_operand_to_buffer(const GImmOperand *, GBufferLine *, GRenderingOptions *); -  /* Traduit un opérande en version humainement lisible. */  static void g_imm_operand_print(const GImmOperand *, GBufferLine *, AsmSyntax); @@ -138,13 +132,7 @@ static void g_imm_operand_class_init(GImmOperandClass *klass)  static void g_imm_operand_init(GImmOperand *operand)  { -    GContentExporter *parent;               /* Instance parente #1         */ -    GArchOperand *arch;                     /* Instance parente #2         */ - -    parent = G_CONTENT_EXPORTER(operand); - -    parent->add_text = (add_text_fc)g_imm_operand_add_text; -    parent->export_buffer = (export_buffer_fc)g_imm_operand_to_buffer; +    GArchOperand *arch;                     /* Instance parente            */      arch = G_ARCH_OPERAND(operand); @@ -722,62 +710,6 @@ static size_t g_imm_operand_to_string(const GImmOperand *operand, AsmSyntax synt  /******************************************************************************  *                                                                             * -*  Paramètres  : operand   = opérande à transcrire.                           * -*                options   = options de rendu.                                * -*                rendering = support effectif final des lignes de code.       * -*                stream    = flux ouvert en écriture.                         * -*                                                                             * -*  Description : Ajoute du texte simple à un fichier ouvert en écriture.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_imm_operand_add_text(const GImmOperand *operand, GRenderingOptions *options, MainRendering rendering, FILE *stream) -{ -    char value[VMPA_MAX_SIZE];              /* Chaîne à imprimer           */ -    size_t len;                             /* Taille de l'élément inséré  */ - -    len = g_imm_operand_to_string(operand, g_rendering_options_get_syntax(options), value); - -    g_content_exporter_insert_text(G_CONTENT_EXPORTER(operand), stream, value, len, RTT_IMMEDIATE); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : operand = opérande à transcrire.                             * -*                buffer  = espace où placer ledit contenu.                    * -*                options = options de rendu.                                  * -*                                                                             * -*  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_imm_operand_to_buffer(const GImmOperand *operand, GBufferLine *buffer, GRenderingOptions *options) -{ -    AsmSyntax syntax;                       /* Choix de l'exportation      */ -    char value[VMPA_MAX_SIZE];              /* Chaîne à imprimer           */ -    size_t len;                             /* Taille de l'élément inséré  */ - -    syntax = (options == NULL ? ASX_COUNT : g_rendering_options_get_syntax(options)); -    len = g_imm_operand_to_string(operand, syntax, value); - -    g_content_exporter_insert_into_buffer(G_CONTENT_EXPORTER(operand), buffer, BLC_ASSEMBLY, -                                          value, len, RTT_IMMEDIATE); - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : operand = opérande à traiter.                                *  *                line    = ligne tampon où imprimer l'opérande donné.         *  *                syntax  = type de représentation demandée.                   * diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h index 83a2eef..e323d6c 100644 --- a/src/arch/instruction-int.h +++ b/src/arch/instruction-int.h @@ -28,7 +28,6 @@  #include "archbase.h"  #include "instruction.h"  #include "translate.h" -#include "../analysis/exporter-int.h"  #include "../common/dllist.h" @@ -49,7 +48,7 @@ typedef bool (* is_instruction_return_fc) (const GArchInstruction *);  /* Définition générique d'une instruction d'architecture (instance) */  struct _GArchInstruction  { -    GContentExporter parent;                /* A laisser en premier        */ +    GObject parent;                         /* A laisser en premier        */      DL_LIST_ITEM(flow);                     /* Maillon de liste chaînée    */ @@ -79,7 +78,7 @@ struct _GArchInstruction  /* Définition générique d'une instruction d'architecture (classe) */  struct _GArchInstructionClass  { -    GContentExporterClass parent;           /* A laisser en premier        */ +    GObjectClass parent;                    /* A laisser en premier        */  }; diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 240ffbe..b553aec 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -38,12 +38,6 @@ static void g_arch_instruction_class_init(GArchInstructionClass *);  /* Initialise une instance d'opérande d'architecture. */  static void g_arch_instruction_init(GArchInstruction *); -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_arch_instruction_add_text(const GArchInstruction *, GRenderingOptions *, MainRendering, FILE *) __attribute__ ((deprecated)); - -/*  Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_arch_instruction_to_buffer(const GArchInstruction *, GBufferLine *, GRenderingOptions *) __attribute__ ((deprecated)); -  /* --------------------- CONVERSIONS DU FORMAT DES INSTRUCTIONS --------------------- */ @@ -55,7 +49,7 @@ static void _g_arch_instruction_print(const GArchInstruction *, GCodeBuffer *, M  /* Indique le type défini pour une instruction d'architecture. */ -G_DEFINE_TYPE(GArchInstruction, g_arch_instruction, G_TYPE_CONTENT_EXPORTER); +G_DEFINE_TYPE(GArchInstruction, g_arch_instruction, G_TYPE_OBJECT);  /****************************************************************************** @@ -90,13 +84,6 @@ static void g_arch_instruction_class_init(GArchInstructionClass *klass)  static void g_arch_instruction_init(GArchInstruction *instr)  { -    GContentExporter *parent;               /* Instance parente            */ - -    parent = G_CONTENT_EXPORTER(instr); - -    parent->add_text = (add_text_fc)g_arch_instruction_add_text; -    parent->export_buffer = (export_buffer_fc)g_arch_instruction_to_buffer; -      DL_LIST_ITEM_INIT(&instr->flow);  } @@ -104,114 +91,6 @@ static void g_arch_instruction_init(GArchInstruction *instr)  /******************************************************************************  *                                                                             * -*  Paramètres  : instr     = instruction à transcrire.                        * -*                options   = options de rendu.                                * -*                rendering = support effectif final des lignes de code.       * -*                stream    = flux ouvert en écriture.                         * -*                                                                             * -*  Description : Ajoute du texte simple à un fichier ouvert en écriture.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_instruction_add_text(const GArchInstruction *instr, GRenderingOptions *options, MainRendering rendering, FILE *stream) -{ -    GContentExporter *exporter;             /* Autre vision de l'objet     */ -    const char *key;                        /* Mot clef principal          */ -    size_t klen;                            /* Taille de ce mot clef       */ -    size_t i;                               /* Boucle de parcours          */ - -    exporter = G_CONTENT_EXPORTER(instr); - -    key = instr->get_text(instr, -                          g_rendering_options_get_format(options), -                          g_rendering_options_get_syntax(options)); -    klen = strlen(key); - -    g_content_exporter_insert_text(exporter, stream, key, klen, RTT_INSTRUCTION); - -    if (instr->operands_count > 0) -    { -        g_content_exporter_insert_text(exporter, stream, "\t", 1, RTT_NONE); - -        g_content_exporter_add_text(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[0]), -                                    options, rendering, stream); - -        for (i = 1; i < instr->operands_count; i++) -        { -            g_content_exporter_insert_text(exporter, stream, ",", 1, RTT_NONE/* FIXME */); - -            g_content_exporter_insert_text(exporter, stream, " ", 1, RTT_NONE); - -            g_content_exporter_add_text(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[i]), -                                        options, rendering, stream); - -        } - -    } - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : instr   = instruction d'assemblage à représenter.            * -*                buffer  = espace où placer ledit contenu.                    * -*                options = options de rendu.                                  * -*                                                                             * -*  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_arch_instruction_to_buffer(const GArchInstruction *instr, GBufferLine *buffer, GRenderingOptions *options) -{ -    GContentExporter *exporter;             /* Autre vision de l'objet     */ -    const char *key;                        /* Mot clef principal          */ -    size_t klen;                            /* Taille de ce mot clef       */ -    size_t i;                               /* Boucle de parcours          */ - -    exporter = G_CONTENT_EXPORTER(instr); - -    key = instr->get_text(instr, -                          g_rendering_options_get_format(options), -                          g_rendering_options_get_syntax(options)); -    klen = strlen(key); - -    g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY_HEAD, -                                          key, klen, RTT_INSTRUCTION); - -    if (instr->operands_count > 0) -    { -        g_content_exporter_to_buffer(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[0]), -                                     buffer, options); - -        for (i = 1; i < instr->operands_count; i++) -        { -            g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                  ",", 1, RTT_NONE/* FIXME */); - -            g_content_exporter_insert_into_buffer(exporter, buffer, BLC_ASSEMBLY, -                                                  " ", 1, RTT_NONE); - -            g_content_exporter_to_buffer(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[i]), -                                         buffer, options); - -        } - -    } - -} - - -/****************************************************************************** -*                                                                             *  *  Paramètres  : instr   = instruction quelconque à modifier.                 *  *                offset  = position physique dans le code binaire.            *  *                length  = taille de l'instruction.                           * @@ -385,53 +264,6 @@ void g_arch_instruction_detach_operand(GArchInstruction *instr, GArchOperand *op  } -/****************************************************************************** -*                                                                             * -*  Paramètres  : instr  = instruction à traiter.                              * -*                format = format du binaire manipulé.                         * -*                syntax = type de représentation demandée.                    * -*                                                                             * -*  Description : Traduit une instruction en version humainement lisible.      * -*                                                                             * -*  Retour      : Chaîne de caractères à libérer de la mémoire.                * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -char *g_arch_instruction_get_text(const GArchInstruction *instr, const GExeFormat *format, AsmSyntax syntax) -{ -    char *result;                           /* Chaîne à retourner          */ -    size_t i;                               /* Boucle de parcours          */ -    char *opstr;                            /* Chaîne d'opérande           */ -    return strdup(""); -    if (instr->operands_count == 0) -        result = strdup(instr->get_text(instr, format, syntax)); - -    else -    { -        result = g_arch_operand_get_text(G_ARCH_INSTRUCTION(instr)->operands[0], format, syntax); - -        for (i = 1; i < instr->operands_count; i++) -        { -            result = stradd(result, ", "); - -            opstr = g_arch_operand_get_text(G_ARCH_INSTRUCTION(instr)->operands[i], format, syntax); -            result = stradd(result, opstr); -            free(opstr); - -        } - -        result = strprep(result, "\t"); -        result = strprep(result, instr->get_text(instr, format, syntax)); - -    } - -    return result; - -} - -  /* ---------------------------------------------------------------------------------- */  /*                     DEFINITION DES LIAISONS ENTRE INSTRUCTIONS                     */ diff --git a/src/arch/instruction.h b/src/arch/instruction.h index bf78bfd..efd2b75 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -87,9 +87,6 @@ void g_arch_instruction_replace_operand(GArchInstruction *, GArchOperand *, cons  /* Détache un opérande liée d'une instruction. */  void g_arch_instruction_detach_operand(GArchInstruction *, GArchOperand *); -/* Traduit une instruction en version humainement lisible. */ -char *g_arch_instruction_get_text(const GArchInstruction *, const GExeFormat *, AsmSyntax) __attribute__ ((deprecated)); -  /* ------------------- DEFINITION DES LIAISONS ENTRE INSTRUCTIONS ------------------- */ diff --git a/src/arch/jvm/operand.c b/src/arch/jvm/operand.c index b0f2fa0..11458a9 100644 --- a/src/arch/jvm/operand.c +++ b/src/arch/jvm/operand.c @@ -87,9 +87,6 @@ static void g_jvm_ref_operand_class_init(GJvmRefOperandClass *);  /* Initialise une instance d'opérande de référence pour la JVM. */  static void g_jvm_ref_operand_init(GJvmRefOperand *); -/* Traduit un opérande en version humainement lisible. */ -static char *g_jvm_ref_operand_get_text(const GJvmRefOperand *, const exe_format *, AsmSyntax); - @@ -188,11 +185,6 @@ static void g_jvm_ref_operand_class_init(GJvmRefOperandClass *klass)  static void g_jvm_ref_operand_init(GJvmRefOperand *operand)  { -    GArchOperand *parent;                   /* Instance parente            */ - -    parent = G_ARCH_OPERAND(operand); - -    parent->get_text = (get_operand_text_fc)g_jvm_ref_operand_get_text;  } @@ -236,6 +228,7 @@ GArchOperand *g_jvm_ref_operand_new(const bin_t *data, off_t *pos, off_t len, Jv  } +#if 0  /******************************************************************************  *                                                                             *  *  Paramètres  : operand = opérande à traiter.                                * @@ -273,7 +266,7 @@ static char *g_jvm_ref_operand_get_text(const GJvmRefOperand *operand, const exe      return result;  } - +#endif diff --git a/src/arch/mips/operand.c b/src/arch/mips/operand.c index c470e74..a976543 100644 --- a/src/arch/mips/operand.c +++ b/src/arch/mips/operand.c @@ -88,9 +88,6 @@ static void g_mips_register_operand_class_init(GMipsRegisterOperandClass *);  /* Initialise une instance d'opérande de registre MIPS. */  static void g_mips_register_operand_init(GMipsRegisterOperand *); -/* Traduit un opérande en version humainement lisible. */ -static char *g_mips_register_operand_get_text(const GMipsRegisterOperand *, const GExeFormat *, AsmSyntax); -  /* -------------------------- OPERANDES DE CONTENU MEMOIRE -------------------------- */ @@ -121,9 +118,6 @@ static void g_mips_mem_content_operand_class_init(GMipsMemContentOperandClass *)  /* Initialise une instance d'opérande MIPS de contenu mémoire. */  static void g_mips_mem_content_operand_init(GMipsMemContentOperand *); -/* Traduit un opérande en version humainement lisible. */ -static char *g_mips_mem_content_operand_get_text(const GMipsMemContentOperand *, const GExeFormat *, AsmSyntax); -  /* ----------------------------- OPERANDES DE DECALLAGE ----------------------------- */ @@ -153,9 +147,6 @@ static void g_mips_offset_operand_class_init(GMipsOffsetOperandClass *);  /* Initialise une instance d'opérande MIPS de décallage. */  static void g_mips_offset_operand_init(GMipsOffsetOperand *); -/* Traduit un opérande en version humainement lisible. */ -static char *g_mips_offset_operand_get_text(const GMipsOffsetOperand *, const GExeFormat *, AsmSyntax); -  /* ---------------------------------------------------------------------------------- */ @@ -245,11 +236,6 @@ static void g_mips_register_operand_class_init(GMipsRegisterOperandClass *klass)  static void g_mips_register_operand_init(GMipsRegisterOperand *operand)  { -    GArchOperand *parent;                   /* Instance parente            */ - -    parent = G_ARCH_OPERAND(operand); - -    parent->get_text = (get_operand_text_fc)g_mips_register_operand_get_text;  } @@ -287,6 +273,7 @@ GArchOperand *g_mips_register_operand_new(bin_t index)  } +#if 0  /******************************************************************************  *                                                                             *  *  Paramètres  : operand = opérande à traiter.                                * @@ -310,6 +297,7 @@ static char *g_mips_register_operand_get_text(const GMipsRegisterOperand *operan      return result;  } +#endif  /****************************************************************************** @@ -373,11 +361,6 @@ static void g_mips_mem_content_operand_class_init(GMipsMemContentOperandClass *k  static void g_mips_mem_content_operand_init(GMipsMemContentOperand *operand)  { -    GArchOperand *parent;                   /* Instance parente            */ - -    parent = G_ARCH_OPERAND(operand); - -    parent->get_text = (get_operand_text_fc)g_mips_mem_content_operand_get_text;  } @@ -417,6 +400,7 @@ GArchOperand *g_mips_mem_content_operand_new(bin_t index, int16_t offset)  } +#if 0  /******************************************************************************  *                                                                             *  *  Paramètres  : operand = opérande à traiter.                                * @@ -443,15 +427,18 @@ static char *g_mips_mem_content_operand_get_text(const GMipsMemContentOperand *o      if (g_imm_operand_is_negative(operand->offset)) result = stradd(result, "-");      else result = stradd(result, "+"); +    /* FIXME !      tmp = g_arch_operand_get_text(G_ARCH_OPERAND(operand->offset), format, syntax);      result = stradd(result, tmp);      free(tmp); +    */      result = stradd(result, "]");      return result;  } +#endif @@ -496,11 +483,6 @@ static void g_mips_offset_operand_class_init(GMipsOffsetOperandClass *klass)  static void g_mips_offset_operand_init(GMipsOffsetOperand *operand)  { -    GArchOperand *parent;                   /* Instance parente            */ - -    parent = G_ARCH_OPERAND(operand); - -    parent->get_text = (get_operand_text_fc)g_mips_offset_operand_get_text;  } @@ -530,6 +512,7 @@ GArchOperand *g_mips_offset_operand_new(int16_t offset)  } +#if 0  /******************************************************************************  *                                                                             *  *  Paramètres  : operand = opérande à traiter.                                * @@ -546,9 +529,10 @@ GArchOperand *g_mips_offset_operand_new(int16_t offset)  static char *g_mips_offset_operand_get_text(const GMipsOffsetOperand *operand, const GExeFormat *format, AsmSyntax syntax)  { -    return g_arch_operand_get_text(G_ARCH_OPERAND(operand->offset), format, syntax); +    return strdup("");/* FIXME g_arch_operand_get_text(G_ARCH_OPERAND(operand->offset), format, syntax); */  } +#endif diff --git a/src/arch/operand-int.h b/src/arch/operand-int.h index 9bb9da1..d9ebde0 100644 --- a/src/arch/operand-int.h +++ b/src/arch/operand-int.h @@ -26,7 +26,6 @@  #include "operand.h" -#include "../analysis/exporter-int.h" @@ -34,19 +33,15 @@  typedef bool (* operand_compare_fc) (const GArchOperand *, const GArchOperand *);  /* Traduit un opérande en version humainement lisible. */ -typedef char * (* get_operand_text_fc) (const GArchOperand *, const GExeFormat *, AsmSyntax); - -/* Traduit un opérande en version humainement lisible. */  typedef void (* operand_print_fc) (const GArchOperand *, GBufferLine *, AsmSyntax);  /* Définition générique d'un opérande d'architecture (instance) */  struct _GArchOperand  { -    GContentExporter parent;                /* A laisser en premier        */ +    GObject parent;                         /* A laisser en premier        */      operand_compare_fc compare;             /* Comparaison d'opérandes     */ -    get_operand_text_fc get_text;           /* Texte humain équivalent     */      operand_print_fc print;                 /* Texte humain équivalent     */  }; @@ -55,7 +50,7 @@ struct _GArchOperand  /* Définition générique d'un opérande d'architecture (classe) */  struct _GArchOperandClass  { -    GContentExporterClass parent;           /* A laisser en premier        */ +    GObjectClass parent;                    /* A laisser en premier        */  }; diff --git a/src/arch/operand.c b/src/arch/operand.c index 43d0027..e98683e 100644 --- a/src/arch/operand.c +++ b/src/arch/operand.c @@ -37,7 +37,7 @@ static void g_arch_operand_init(GArchOperand *);  /* Indique le type défini pour un opérande d'architecture. */ -G_DEFINE_TYPE(GArchOperand, g_arch_operand, G_TYPE_CONTENT_EXPORTER); +G_DEFINE_TYPE(GArchOperand, g_arch_operand, G_TYPE_OBJECT); @@ -79,21 +79,27 @@ static void g_arch_operand_init(GArchOperand *operand)  /******************************************************************************  *                                                                             * -*  Paramètres  : operand = opérande à traiter.                                * -*                format  = format du binaire manipulé.                        * -*                syntax  = type de représentation demandée.                   * +*  Paramètres  : a = premier opérande à consulter.                            * +*                b = second opérande à consulter.                             *  *                                                                             * -*  Description : Traduit un opérande en version humainement lisible.          * +*  Description : Compare un opérande avec un autre.                           *  *                                                                             * -*  Retour      : Chaîne de caractères à libérer de la mémoire.                * +*  Retour      : Bilan de la comparaison.                                     *  *                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ -char *g_arch_operand_get_text(const GArchOperand *operand, const GExeFormat *format, AsmSyntax syntax) +bool g_arch_operand_compare(const GArchOperand *a, const GArchOperand *b)  { -    return operand->get_text(operand, format, syntax); +    bool result;                            /* Bilan à faire remonter      */ + +    result = (G_OBJECT_TYPE(G_OBJECT(a)) == G_OBJECT_TYPE(G_OBJECT(b))); + +    if (result) +        result = a->compare(a, b); + +    return result;  } @@ -117,30 +123,3 @@ void g_arch_operand_print(const GArchOperand *operand, GBufferLine *line, AsmSyn      return operand->print(operand, line, syntax);  } - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : a = premier opérande à consulter.                            * -*                b = second opérande à consulter.                             * -*                                                                             * -*  Description : Compare un opérande avec un autre.                           * -*                                                                             * -*  Retour      : Bilan de la comparaison.                                     * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -bool g_arch_operand_compare(const GArchOperand *a, const GArchOperand *b) -{ -    bool result;                            /* Bilan à faire remonter      */ - -    result = (G_OBJECT_TYPE(G_OBJECT(a)) == G_OBJECT_TYPE(G_OBJECT(b))); - -    if (result) -        result = a->compare(a, b); - -    return result; - -} diff --git a/src/arch/operand.h b/src/arch/operand.h index 6eac263..c0cd767 100644 --- a/src/arch/operand.h +++ b/src/arch/operand.h @@ -28,7 +28,6 @@  #include <glib-object.h> -#include "../format/executable.h"   /* FIXME : remme ! */  #include "../glibext/gbufferline.h" @@ -49,15 +48,12 @@ typedef struct _GArchOperandClass GArchOperandClass;  /* Indique le type défini pour un opérande d'architecture. */  GType g_arch_operand_get_type(void); -/* Traduit un opérande en version humainement lisible. */ -char *g_arch_operand_get_text(const GArchOperand *, const GExeFormat *, AsmSyntax); +/* Compare un opérande avec un autre. */ +bool g_arch_operand_compare(const GArchOperand *, const GArchOperand *);  /* Traduit un opérande en version humainement lisible. */  void g_arch_operand_print(const GArchOperand *, GBufferLine *, AsmSyntax); -/* Compare un opérande avec un autre. */ -bool g_arch_operand_compare(const GArchOperand *, const GArchOperand *); -  #endif  /* _ARCH_OPERAND_H */ diff --git a/src/arch/x86/Makefile.am b/src/arch/x86/Makefile.am index b7b72d6..e657699 100644 --- a/src/arch/x86/Makefile.am +++ b/src/arch/x86/Makefile.am @@ -5,7 +5,7 @@ libarchx86_la_SOURCES =					\  	instruction.h instruction.c			\  	operand.h operand.c					\  	processor.h processor.c				\ -	registers.h registers.c +	register.h register.c  libarchx86_la_LIBADD =					\  	opcodes/libarchx86opcodes.la		\ diff --git a/src/arch/x86/operands/data.c b/src/arch/x86/operands/data.c index 22f16b7..32b9bcd 100644 --- a/src/arch/x86/operands/data.c +++ b/src/arch/x86/operands/data.c @@ -24,7 +24,7 @@  #include "data.h" -#include "../registers.h" +#include "../register.h"  #include "../../operand-int.h" @@ -53,12 +53,6 @@ static void g_x86_data_operand_class_init(GX86DataOperandClass *);  /* Initialise une instance d'opérande x86 pointant des données. */  static void g_x86_data_operand_init(GX86DataOperand *); -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_x86_data_operand_add_text(const GX86DataOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_x86_data_operand_to_buffer(const GX86DataOperand *, GBufferLine *, GRenderingOptions *); -  /* Indique le type défini par la GLib pour un opérande x86 de manipulation de données. */ @@ -97,12 +91,6 @@ static void g_x86_data_operand_class_init(GX86DataOperandClass *klass)  static void g_x86_data_operand_init(GX86DataOperand *operand)  { -    GContentExporter *parent;               /* Instance parente            */ - -    parent = G_CONTENT_EXPORTER(operand); - -    parent->add_text = (add_text_fc)g_x86_data_operand_add_text; -    parent->export_buffer = (export_buffer_fc)g_x86_data_operand_to_buffer;  } @@ -134,6 +122,7 @@ GArchOperand *g_x86_data_operand_new(MemoryDataSize size, bool dest)  } +#if 0  /******************************************************************************  *                                                                             *  *  Paramètres  : operand = opérande à transcrire.                             * @@ -205,3 +194,4 @@ static void g_x86_data_operand_to_buffer(const GX86DataOperand *operand, GBuffer                                            "]", 1, RTT_HOOK);  } +#endif diff --git a/src/arch/x86/operands/modrm.c b/src/arch/x86/operands/modrm.c index 892d5dc..e23f499 100644 --- a/src/arch/x86/operands/modrm.c +++ b/src/arch/x86/operands/modrm.c @@ -59,12 +59,6 @@ static void g_x86_mod_rm_operand_class_init(GX86ModRMOperandClass *);  /* Initialise une instance d'opérande x86 de type ModRM. */  static void g_x86_mod_rm_operand_init(GX86ModRMOperand *); -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_x86_mod_rm_operand_add_text(const GX86ModRMOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_x86_mod_rm_operand_to_buffer(const GX86ModRMOperand *, GBufferLine *, GRenderingOptions *); -  /* Indique le type défini par la GLib pour un opérande x86 de type ModRM. */ @@ -103,12 +97,6 @@ static void g_x86_mod_rm_operand_class_init(GX86ModRMOperandClass *klass)  static void g_x86_mod_rm_operand_init(GX86ModRMOperand *operand)  { -    GContentExporter *parent;               /* Instance parente            */ - -    parent = G_CONTENT_EXPORTER(operand); - -    parent->add_text = (add_text_fc)g_x86_mod_rm_operand_add_text; -    parent->export_buffer = (export_buffer_fc)g_x86_mod_rm_operand_to_buffer;  } @@ -215,7 +203,7 @@ GArchOperand *g_x86_mod_rm_operand_new(const bin_t *data, off_t *pos, off_t len,  } - +#if 0  /******************************************************************************  *                                                                             *  *  Paramètres  : operand   = opérande à transcrire.                           * @@ -374,6 +362,7 @@ static void g_x86_mod_rm_operand_to_buffer(const GX86ModRMOperand *operand, GBuf      }  } +#endif  /****************************************************************************** diff --git a/src/arch/x86/operands/modrm.h b/src/arch/x86/operands/modrm.h index 89a274f..428d481 100644 --- a/src/arch/x86/operands/modrm.h +++ b/src/arch/x86/operands/modrm.h @@ -28,7 +28,7 @@  #include <glib-object.h> -#include "../registers.h" +#include "../register.h"  #include "../../immediate.h"  #include "../../operand.h"  #include "../../../common/endianness.h" diff --git a/src/arch/x86/operands/moffs.c b/src/arch/x86/operands/moffs.c index 3754e79..4d3c57b 100644 --- a/src/arch/x86/operands/moffs.c +++ b/src/arch/x86/operands/moffs.c @@ -52,12 +52,6 @@ static void g_x86_moffs_operand_class_init(GX86MOffsOperandClass *);  /* Initialise une instance d'opérande d'emplacement mémoire x86. */  static void g_x86_moffs_operand_init(GX86MOffsOperand *); -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_x86_moffs_operand_add_text(const GX86MOffsOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_x86_moffs_operand_to_buffer(const GX86MOffsOperand *, GBufferLine *, GRenderingOptions *); -  /* Indique le type défini par la GLib pour un opérande d'emplacement mémoire x86. */ @@ -96,12 +90,6 @@ static void g_x86_moffs_operand_class_init(GX86MOffsOperandClass *klass)  static void g_x86_moffs_operand_init(GX86MOffsOperand *operand)  { -    GContentExporter *parent;               /* Instance parente            */ - -    parent = G_CONTENT_EXPORTER(operand); - -    parent->add_text = (add_text_fc)g_x86_moffs_operand_add_text; -    parent->export_buffer = (export_buffer_fc)g_x86_moffs_operand_to_buffer;  } @@ -141,6 +129,7 @@ GArchOperand *g_x86_moffs_operand_new(const bin_t *data, off_t *pos, off_t len,  } +#if 0  /******************************************************************************  *                                                                             *  *  Paramètres  : operand   = opérande à transcrire.                           * @@ -187,3 +176,4 @@ static void g_x86_moffs_operand_to_buffer(const GX86MOffsOperand *operand, GBuff      g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->offset), buffer, options);  } +#endif diff --git a/src/arch/x86/operands/register.c b/src/arch/x86/operands/register.c index a70ea60..4ca695f 100644 --- a/src/arch/x86/operands/register.c +++ b/src/arch/x86/operands/register.c @@ -52,11 +52,11 @@ static void g_x86_register_operand_class_init(GX86RegisterOperandClass *);  /* Initialise une instance d'opérande de registre x86. */  static void g_x86_register_operand_init(GX86RegisterOperand *); -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_x86_register_operand_add_text(const GX86RegisterOperand *, GRenderingOptions *, MainRendering, FILE *); +/* Compare un opérande avec un autre. */ +static bool g_x86_register_operand_compare(const GX86RegisterOperand *, const GX86RegisterOperand *); -/*  Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_x86_register_operand_to_buffer(const GX86RegisterOperand *, GBufferLine *, GRenderingOptions *); +/* Traduit un opérande en version humainement lisible. */ +static void g_x86_register_operand_print(const GX86RegisterOperand *, GBufferLine *, AsmSyntax); @@ -96,12 +96,12 @@ static void g_x86_register_operand_class_init(GX86RegisterOperandClass *klass)  static void g_x86_register_operand_init(GX86RegisterOperand *operand)  { -    GContentExporter *parent;               /* Instance parente            */ +    GArchOperand *parent;                   /* Instance parente            */ -    parent = G_CONTENT_EXPORTER(operand); +    parent = G_ARCH_OPERAND(operand); -    parent->add_text = (add_text_fc)g_x86_register_operand_add_text; -    parent->export_buffer = (export_buffer_fc)g_x86_register_operand_to_buffer; +    parent->compare = (operand_compare_fc)g_x86_register_operand_compare; +    parent->print = (operand_print_fc)g_x86_register_operand_print;  } @@ -224,33 +224,31 @@ GArchOperand *g_x86_register_operand_new_from_index(bin_t index, MemoryDataSize  /******************************************************************************  *                                                                             * -*  Paramètres  : operand = opérande à transcrire.                             * -*                options   = options de rendu.                                * -*                rendering = support effectif final des lignes de code.       * -*                stream    = flux ouvert en écriture.                         * +*  Paramètres  : a = premier opérande à consulter.                            * +*                b = second opérande à consulter.                             *  *                                                                             * -*  Description : Ajoute du texte simple à un fichier ouvert en écriture.      * +*  Description : Compare un opérande avec un autre.                           *  *                                                                             * -*  Retour      : -                                                            * +*  Retour      : Bilan de la comparaison.                                     *  *                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ -static void g_x86_register_operand_add_text(const GX86RegisterOperand *operand, GRenderingOptions *options, MainRendering rendering, FILE *stream) +static bool g_x86_register_operand_compare(const GX86RegisterOperand *a, const GX86RegisterOperand *b)  { -    g_content_exporter_add_text(G_CONTENT_EXPORTER(operand->reg), options, rendering, stream); +    return g_x86_register_compare(a->reg, b->reg);  }  /******************************************************************************  *                                                                             * -*  Paramètres  : operand = opérande à transcrire.                             * -*                buffer  = espace où placer ledit contenu.                    * -*                options = options de rendu.                                  * +*  Paramètres  : operand = opérande à traiter.                                * +*                line    = ligne tampon où imprimer l'opérande donné.         * +*                syntax  = type de représentation demandée.                   *  *                                                                             * -*  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  * +*  Description : Traduit un opérande en version humainement lisible.          *  *                                                                             *  *  Retour      : -                                                            *  *                                                                             * @@ -258,8 +256,8 @@ static void g_x86_register_operand_add_text(const GX86RegisterOperand *operand,  *                                                                             *  ******************************************************************************/ -static void g_x86_register_operand_to_buffer(const GX86RegisterOperand *operand, GBufferLine *buffer, GRenderingOptions *options) +static void g_x86_register_operand_print(const GX86RegisterOperand *operand, GBufferLine *line, AsmSyntax syntax)  { -    g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->reg), buffer, options); +    g_x86_pool_operand_print(operand->reg, line, syntax);  } diff --git a/src/arch/x86/operands/register.h b/src/arch/x86/operands/register.h index 11bc87e..e679410 100644 --- a/src/arch/x86/operands/register.h +++ b/src/arch/x86/operands/register.h @@ -28,7 +28,7 @@  #include <glib-object.h> -#include "../registers.h" +#include "../register.h"  #include "../../operand.h"  #include "../../../common/endianness.h" diff --git a/src/arch/x86/operands/relative.c b/src/arch/x86/operands/relative.c index 3235a0d..cd69748 100644 --- a/src/arch/x86/operands/relative.c +++ b/src/arch/x86/operands/relative.c @@ -51,12 +51,6 @@ static void g_x86_relative_operand_class_init(GX86RelativeOperandClass *);  /* Initialise une instance d'opérande x86 d'adresse relative. */  static void g_x86_relative_operand_init(GX86RelativeOperand *); -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_x86_relative_operand_add_text(const GX86RelativeOperand *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_x86_relative_operand_to_buffer(const GX86RelativeOperand *, GBufferLine *, GRenderingOptions *); -  /* Indique le type défini par la GLib pour un opérande x86 d'adresse relative. */ @@ -95,12 +89,6 @@ static void g_x86_relative_operand_class_init(GX86RelativeOperandClass *klass)  static void g_x86_relative_operand_init(GX86RelativeOperand *operand)  { -    GContentExporter *parent;               /* Instance parente            */ - -    parent = G_CONTENT_EXPORTER(operand); - -    parent->add_text = (add_text_fc)g_x86_relative_operand_add_text; -    parent->export_buffer = (export_buffer_fc)g_x86_relative_operand_to_buffer;  } @@ -159,6 +147,7 @@ GArchOperand *g_x86_relative_operand_new(const bin_t *data, off_t *pos, off_t le  } +#if 0  /******************************************************************************  *                                                                             *  *  Paramètres  : operand   = opérande à transcrire.                           * @@ -200,6 +189,7 @@ static void g_x86_relative_operand_to_buffer(const GX86RelativeOperand *operand,      g_content_exporter_to_buffer(G_CONTENT_EXPORTER(operand->immediate), buffer, options);  } +#endif  /****************************************************************************** diff --git a/src/arch/x86/registers.c b/src/arch/x86/register.c index e0a4df1..53b9b2e 100644 --- a/src/arch/x86/registers.c +++ b/src/arch/x86/register.c @@ -1,6 +1,6 @@  /* OpenIDA - Outil d'analyse de fichiers binaires - * registers.c - aides auxiliaires relatives aux registres x86 + * register.c - aides auxiliaires relatives aux registres x86   *   * Copyright (C) 2009-2010 Cyrille Bagard   * @@ -21,7 +21,7 @@   */ -#include "registers.h" +#include "register.h"  #include <stdio.h> @@ -109,26 +109,23 @@ struct _GX86RegisterClass  #define MAX_REGNAME_LEN 5 -/* Construit la chaîne de caractères correspondant à l'opérande. */ -static void g_x86_register_to_string(const GX86Register *, AsmSyntax, char [MAX_REGNAME_LEN], size_t *); +/* Initialise la classe des registres x86. */ +static void g_x86_register_class_init(GX86RegisterClass *); -/* Ajoute du texte simple à un fichier ouvert en écriture. */ -static void g_x86_register_add_text(const GX86Register *, GRenderingOptions *, MainRendering, FILE *); - -/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void g_x86_register_to_buffer(const GX86Register *, GBufferLine *, GRenderingOptions *); +/* Initialise une instance de registre x86. */ +static void g_x86_register_init(GX86Register *);  /* Indique le type défini pour une représentation d'un registre x86. */ -G_DEFINE_TYPE(GX86Register, g_x86_register, G_TYPE_CONTENT_EXPORTER); +G_DEFINE_TYPE(GX86Register, g_x86_register, G_TYPE_ARCH_OPERAND);  /******************************************************************************  *                                                                             *  *  Paramètres  : klass = classe à initialiser.                                *  *                                                                             * -*  Description : Initialise la classe des lignes de représentation.           * +*  Description : Initialise la classe des registres x86.                      *  *                                                                             *  *  Retour      : -                                                            *  *                                                                             * @@ -146,7 +143,7 @@ static void g_x86_register_class_init(GX86RegisterClass *klass)  *                                                                             *  *  Paramètres  : reg = instance à initialiser.                                *  *                                                                             * -*  Description : Initialise une instance de ligne de représentation.          * +*  Description : Initialise une instance de registre x86.                     *  *                                                                             *  *  Retour      : -                                                            *  *                                                                             * @@ -156,12 +153,6 @@ static void g_x86_register_class_init(GX86RegisterClass *klass)  static void g_x86_register_init(GX86Register *reg)  { -    GContentExporter *parent;               /* Instance parente            */ - -    parent = G_CONTENT_EXPORTER(reg); - -    parent->add_text = (add_text_fc)g_x86_register_add_text; -    parent->export_buffer = (export_buffer_fc)g_x86_register_to_buffer;  } @@ -235,22 +226,65 @@ GX86Register *g_x86_register_new(MemoryDataSize size, bin_t value)   gxrn_error: -    /* FIXME free(result); */ +    g_object_unref(G_OBJECT(result));      return NULL;  } +/****************************************************************************** +*                                                                             * +*  Paramètres  : a = premier opérande à consulter.                            * +*                b = second opérande à consulter.                             * +*                                                                             * +*  Description : Compare un registre avec un autre.                           * +*                                                                             * +*  Retour      : Bilan de la comparaison.                                     * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool g_x86_register_compare(const GX86Register *a, const GX86Register *b) +{ +    bool result;                            /* Bilan à retourner           */ + +    if (a->size != b->size) +        return false; + +    switch (a->size) +    { +        case MDS_8_BITS: +            result = (a->reg.reg8 == b->reg.reg8); +            break; + +        case MDS_16_BITS: +            result = (a->reg.reg16 == b->reg.reg16); +            break; + +        case MDS_32_BITS: +            result = (a->reg.reg32 == b->reg.reg32); +            break; + +        default: +            result = false; +            break; + +    } + +    return result; + +} +  /******************************************************************************  *                                                                             * -*  Paramètres  : operand = opérande à transcrire.                             * -*                syntax  = type de représentation demandée.                   * -*                key     = description humaine du registre. [OUT]             * -*                klen    = nombre de caractères utilisés. [OUT]               * +*  Paramètres  : reg    = registre à transcrire.                              * +*                line   = ligne tampon où imprimer l'opérande donné.          * +*                syntax = type de représentation demandée.                    *  *                                                                             * -*  Description : Construit la chaîne de caractères correspondant à l'opérande.* +*  Description : Traduit un registre en version humainement lisible.          *  *                                                                             *  *  Retour      : -                                                            *  *                                                                             * @@ -258,9 +292,10 @@ GX86Register *g_x86_register_new(MemoryDataSize size, bin_t value)  *                                                                             *  ******************************************************************************/ -static void g_x86_register_to_string(const GX86Register *reg, AsmSyntax syntax, char key[MAX_REGNAME_LEN], size_t *klen) +void g_x86_pool_operand_print(const GX86Register *reg, GBufferLine *line, AsmSyntax syntax)  { -    *klen = 0; +    char key[MAX_REGNAME_LEN];              /* Mot clef principal          */ +    size_t klen;                            /* Taille de ce mot clef       */      switch (syntax)      { @@ -268,7 +303,7 @@ static void g_x86_register_to_string(const GX86Register *reg, AsmSyntax syntax,              switch (reg->size)              {                  case MDS_8_BITS: -                    *klen = 2; +                    klen = 2;                      switch (reg->reg.reg8)                      {                          case X86_REG8_AL: @@ -302,7 +337,7 @@ static void g_x86_register_to_string(const GX86Register *reg, AsmSyntax syntax,                      break;                  case MDS_16_BITS: -                    *klen = 2; +                    klen = 2;                      switch (reg->reg.reg16)                      {                          case X86_REG16_AX: @@ -336,7 +371,7 @@ static void g_x86_register_to_string(const GX86Register *reg, AsmSyntax syntax,                      break;                  case MDS_32_BITS: -                    *klen = 3; +                    klen = 3;                      switch (reg->reg.reg32)                      {                          case X86_REG32_EAX: @@ -371,6 +406,7 @@ static void g_x86_register_to_string(const GX86Register *reg, AsmSyntax syntax,                      break;                  default: +                    klen = 0;                      break;              } @@ -380,7 +416,7 @@ static void g_x86_register_to_string(const GX86Register *reg, AsmSyntax syntax,              switch (reg->size)              {                  case MDS_8_BITS: -                    *klen = 3; +                    klen = 3;                      switch (reg->reg.reg8)                      {                          case X86_REG8_AL: @@ -414,7 +450,7 @@ static void g_x86_register_to_string(const GX86Register *reg, AsmSyntax syntax,                      break;                  case MDS_16_BITS: -                    *klen = 3; +                    klen = 3;                      switch (reg->reg.reg16)                      {                          case X86_REG16_AX: @@ -448,7 +484,7 @@ static void g_x86_register_to_string(const GX86Register *reg, AsmSyntax syntax,                      break;                  case MDS_32_BITS: -                    *klen = 4; +                    klen = 4;                      switch (reg->reg.reg32)                      {                          case X86_REG32_EAX: @@ -482,70 +518,19 @@ static void g_x86_register_to_string(const GX86Register *reg, AsmSyntax syntax,                      break;                  default: +                    klen = 0;                      break;              }              break;          default: +            klen = 0;              break;      } -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : reg       = registre X86 à transcrire.                       * -*                options   = options de rendu.                                * -*                rendering = support effectif final des lignes de code.       * -*                stream    = flux ouvert en écriture.                         * -*                                                                             * -*  Description : Ajoute du texte simple à un fichier ouvert en écriture.      * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_x86_register_add_text(const GX86Register *reg, GRenderingOptions *options, MainRendering rendering, FILE *stream) -{ -    char key[MAX_REGNAME_LEN];              /* Mot clef principal          */ -    size_t klen;                            /* Taille de ce mot clef       */ - -    g_x86_register_to_string(reg, g_rendering_options_get_syntax(options), key, &klen); - -    g_content_exporter_insert_text(G_CONTENT_EXPORTER(reg), stream, -                                   key, klen, RTT_REGISTER); - -} - - -/****************************************************************************** -*                                                                             * -*  Paramètres  : reg     = registre X86 à transcrire.                         * -*                buffer  = espace où placer ledit contenu.                    * -*                options = options de rendu.                                  * -*                                                                             * -*  Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée.  * -*                                                                             * -*  Retour      : -                                                            * -*                                                                             * -*  Remarques   : -                                                            * -*                                                                             * -******************************************************************************/ - -static void g_x86_register_to_buffer(const GX86Register *reg, GBufferLine *buffer, GRenderingOptions *options) -{ -    char key[MAX_REGNAME_LEN];              /* Mot clef principal          */ -    size_t klen;                            /* Taille de ce mot clef       */ - -    g_x86_register_to_string(reg, g_rendering_options_get_syntax(options), key, &klen); - -    g_content_exporter_insert_into_buffer(G_CONTENT_EXPORTER(reg), buffer, BLC_ASSEMBLY, -                                          key, klen, RTT_REGISTER); +    g_buffer_line_insert_text(line, BLC_ASSEMBLY, key, klen, RTT_REGISTER);  } diff --git a/src/arch/x86/registers.h b/src/arch/x86/register.h index 18bced7..5491c08 100644 --- a/src/arch/x86/registers.h +++ b/src/arch/x86/register.h @@ -1,6 +1,6 @@  /* OpenIDA - Outil d'analyse de fichiers binaires - * registers.h - prototypes pour les aides auxiliaires relatives aux registres x86 + * register.h - prototypes pour les aides auxiliaires relatives aux registres x86   *   * Copyright (C) 2009 Cyrille Bagard   * @@ -21,8 +21,8 @@   */ -#ifndef _ARCH_X86_REGISTERS_H -#define _ARCH_X86_REGISTERS_H +#ifndef _ARCH_X86_REGISTER_H +#define _ARCH_X86_REGISTER_H  #include <glib-object.h> @@ -30,6 +30,7 @@  #include "../archbase.h" +#include "../../glibext/gbufferline.h" @@ -54,6 +55,12 @@ GType g_x86_register_get_type(void);  /* Crée une réprésentation de registre x86. */  GX86Register *g_x86_register_new(MemoryDataSize, bin_t); +/* Compare un registre avec un autre. */ +bool g_x86_register_compare(const GX86Register *, const GX86Register *); + +/* Traduit un registre en version humainement lisible. */ +void g_x86_pool_operand_print(const GX86Register *, GBufferLine *, AsmSyntax); +  /* Indique si le registre correspond à ebp ou similaire. */  bool g_x86_register_is_base_pointer(const GX86Register *); @@ -62,4 +69,4 @@ bool g_x86_register_is_stack_pointer(const GX86Register *); -#endif  /* _ARCH_X86_REGISTERS_H */ +#endif  /* _ARCH_X86_REGISTER_H */ | 
