diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2018-05-14 19:40:07 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2018-05-14 19:40:07 (GMT) | 
| commit | 0286b53bad21abf91cbe17c4772ca9cde6a89cbc (patch) | |
| tree | 3bec9dc7e118c00ce9c748576b01606a71880ad7 /plugins/arm/v7/operands/rotation.c | |
| parent | 267b1ae8608ed4bf52de743798e8647c903ee1b4 (diff) | |
Created an instruction database for Chrysalide.
Diffstat (limited to 'plugins/arm/v7/operands/rotation.c')
| -rw-r--r-- | plugins/arm/v7/operands/rotation.c | 97 | 
1 files changed, 96 insertions, 1 deletions
| diff --git a/plugins/arm/v7/operands/rotation.c b/plugins/arm/v7/operands/rotation.c index 2b47d73..c091044 100644 --- a/plugins/arm/v7/operands/rotation.c +++ b/plugins/arm/v7/operands/rotation.c @@ -66,6 +66,17 @@ static void g_armv7_rotation_operand_print(const GArmV7RotationOperand *, GBuffe +/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ + + +/* Charge un opérande depuis une mémoire tampon. */ +static bool g_armv7_rotation_operand_unserialize(GArmV7RotationOperand *, GAsmStorage *, GBinFormat *, packed_buffer *); + +/* Sauvegarde un opérande dans une mémoire tampon. */ +static bool g_armv7_rotation_operand_serialize(const GArmV7RotationOperand *, GAsmStorage *, packed_buffer *); + + +  /* Indique le type défini par la GLib pour une opérande de rotation ARMv7. */  G_DEFINE_TYPE(GArmV7RotationOperand, g_armv7_rotation_operand, G_TYPE_ARCH_OPERAND); @@ -96,6 +107,9 @@ static void g_armv7_rotation_operand_class_init(GArmV7RotationOperandClass *klas      operand->compare = (operand_compare_fc)g_armv7_rotation_operand_compare;      operand->print = (operand_print_fc)g_armv7_rotation_operand_print; +    operand->unserialize = (unserialize_operand_fc)g_armv7_rotation_operand_unserialize; +    operand->serialize = (serialize_operand_fc)g_armv7_rotation_operand_serialize; +  } @@ -113,6 +127,7 @@ static void g_armv7_rotation_operand_class_init(GArmV7RotationOperandClass *klas  static void g_armv7_rotation_operand_init(GArmV7RotationOperand *operand)  { +    operand->value = NULL;  } @@ -131,7 +146,8 @@ static void g_armv7_rotation_operand_init(GArmV7RotationOperand *operand)  static void g_armv7_rotation_operand_dispose(GArmV7RotationOperand *operand)  { -    g_object_unref(G_OBJECT(operand->value)); +    if (operand->value != NULL) +        g_object_unref(G_OBJECT(operand->value));      G_OBJECT_CLASS(g_armv7_rotation_operand_parent_class)->dispose(G_OBJECT(operand)); @@ -254,3 +270,82 @@ GArchOperand *g_armv7_rotation_operand_get_value(const GArmV7RotationOperand *op      return result;  } + + + +/* ---------------------------------------------------------------------------------- */ +/*                       TRANSPOSITIONS VIA CACHE DES OPERANDES                       */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = opérande d'assemblage à constituer.                * +*                storage = mécanisme de sauvegarde à manipuler.               * +*                format  = format binaire chargé associé à l'architecture.    * +*                pbuf    = zone tampon à remplir.                             * +*                                                                             * +*  Description : Charge un opérande depuis une mémoire tampon.                * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_armv7_rotation_operand_unserialize(GArmV7RotationOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    GArchOperandClass *parent;              /* Classe parente à consulter  */ +    GArchOperand *value;                    /* Valeur à intégrer           */ + +    parent = G_ARCH_OPERAND_CLASS(g_armv7_rotation_operand_parent_class); + +    result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); + +    if (result) +    { +        value = g_arch_operand_load(storage, format, pbuf); + +        if (value == NULL) +            result = false; + +        else +            operand->value = value; + +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : operand = opérande d'assemblage à consulter.                 * +*                storage = mécanisme de sauvegarde à manipuler.               * +*                pbuf    = zone tampon à remplir.                             * +*                                                                             * +*  Description : Sauvegarde un opérande dans une mémoire tampon.              * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static bool g_armv7_rotation_operand_serialize(const GArmV7RotationOperand *operand, GAsmStorage *storage, packed_buffer *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    GArchOperandClass *parent;              /* Classe parente à consulter  */ + +    parent = G_ARCH_OPERAND_CLASS(g_armv7_rotation_operand_parent_class); + +    result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); + +    if (result) +        result = g_arch_operand_store(operand->value, storage, pbuf); + +    return result; + +} | 
