summaryrefslogtreecommitdiff
path: root/plugins/arm/instruction.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/arm/instruction.c')
-rw-r--r--plugins/arm/instruction.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/plugins/arm/instruction.c b/plugins/arm/instruction.c
index 4872aba..c42250f 100644
--- a/plugins/arm/instruction.c
+++ b/plugins/arm/instruction.c
@@ -29,6 +29,7 @@
#include <string.h>
+#include <analysis/db/misc/rlestr.h>
#include <common/extstr.h>
#include <core/logs.h>
@@ -62,6 +63,17 @@ static bool g_arm_instruction_serialize(GArmInstruction *, GAsmStorage *, packed
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_arm_instruction_load(GArmInstruction *, GObjectStorage *, packed_buffer_t *);
+
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_arm_instruction_store(GArmInstruction *, GObjectStorage *, packed_buffer_t *);
+
+
+
/* Indique le type défini pour une représentation d'une instruction ARM. */
G_DEFINE_TYPE(GArmInstruction, g_arm_instruction, G_TYPE_ARCH_INSTRUCTION);
@@ -93,6 +105,9 @@ static void g_arm_instruction_class_init(GArmInstructionClass *klass)
instr->unserialize = (unserialize_instruction_fc)g_arm_instruction_unserialize;
instr->serialize = (serialize_instruction_fc)g_arm_instruction_serialize;
+ instr->load = (load_instruction_fc)g_arm_instruction_load;
+ instr->store = (store_instruction_fc)g_arm_instruction_store;
+
}
@@ -382,3 +397,109 @@ static bool g_arm_instruction_serialize(GArmInstruction *instr, GAsmStorage *sto
return result;
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = é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_arm_instruction_load(GArmInstruction *instr, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GArchInstructionClass *parent; /* Classe parente à consulter */
+ rle_string str; /* Chaîne à charger */
+ uleb128_t value; /* Valeur ULEB128 à charger */
+
+ parent = G_ARCH_INSTRUCTION_CLASS(g_arm_instruction_parent_class);
+
+ result = parent->load(G_ARCH_INSTRUCTION(instr), storage, pbuf);
+
+ if (result)
+ {
+ setup_empty_rle_string(&str);
+
+ result = unpack_rle_string(&str, pbuf);
+
+ if (result)
+ {
+ result = (get_rle_string(&str) != NULL);
+
+ if (result)
+ result = g_arm_instruction_extend_keyword(instr, get_rle_string(&str));
+
+ exit_rle_string(&str);
+
+ }
+
+ }
+
+ if (result)
+ {
+ result = unpack_uleb128(&value, pbuf);
+
+ if (result)
+ instr->cond = value;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = é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_arm_instruction_store(GArmInstruction *instr, GObjectStorage *storage, packed_buffer_t *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GArchInstructionClass *parent; /* Classe parente à consulter */
+ rle_string str; /* Chaîne à conserver */
+
+ parent = G_ARCH_INSTRUCTION_CLASS(g_arm_instruction_parent_class);
+
+ result = parent->store(G_ARCH_INSTRUCTION(instr), storage, pbuf);
+
+ if (result)
+ {
+ init_static_rle_string(&str, instr->suffix);
+
+ result = pack_rle_string(&str, pbuf);
+
+ exit_rle_string(&str);
+
+ }
+
+ if (result)
+ result = pack_uleb128((uleb128_t []){ instr->cond }, pbuf);
+
+ return result;
+
+}