summaryrefslogtreecommitdiff
path: root/plugins/arm/v7/instruction.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-05-14 19:40:07 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-05-14 19:40:07 (GMT)
commit0286b53bad21abf91cbe17c4772ca9cde6a89cbc (patch)
tree3bec9dc7e118c00ce9c748576b01606a71880ad7 /plugins/arm/v7/instruction.c
parent267b1ae8608ed4bf52de743798e8647c903ee1b4 (diff)
Created an instruction database for Chrysalide.
Diffstat (limited to 'plugins/arm/v7/instruction.c')
-rw-r--r--plugins/arm/v7/instruction.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/plugins/arm/v7/instruction.c b/plugins/arm/v7/instruction.c
index d45979b..9eb43ac 100644
--- a/plugins/arm/v7/instruction.c
+++ b/plugins/arm/v7/instruction.c
@@ -86,6 +86,17 @@ static char *g_armv7_instruction_build_tooltip(const GArmV7Instruction *);
+/* -------------------- CONSERVATION SUR DISQUE DES INSTRUCTIONS -------------------- */
+
+
+/* Charge une instruction depuis une mémoire tampon. */
+static bool g_armv7_instruction_unserialize(GArmV7Instruction *, GAsmStorage *, GBinFormat *, packed_buffer *);
+
+/* Sauvegarde une instruction dans une mémoire tampon. */
+static bool g_armv7_instruction_serialize(GArmV7Instruction *, GAsmStorage *, packed_buffer *);
+
+
+
/* Indique le type défini pour une représentation d'une instruction ARMv7. */
G_DEFINE_TYPE(GArmV7Instruction, g_armv7_instruction, G_TYPE_ARM_INSTRUCTION);
@@ -118,6 +129,9 @@ static void g_armv7_instruction_class_init(GArmV7InstructionClass *klass)
instr->call_hook = (call_instruction_hook_fc)g_armv7_instruction_call_hook;
instr->build_tooltip = (build_instruction_tooltip_fc)g_armv7_instruction_build_tooltip;
+ instr->unserialize = (unserialize_instruction_fc)g_armv7_instruction_unserialize;
+ instr->serialize = (serialize_instruction_fc)g_armv7_instruction_serialize;
+
}
@@ -397,3 +411,95 @@ bool g_armv7_instruction_get_setflags(const GArmV7Instruction *instr)
return instr->setflags;
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* CONSERVATION SUR DISQUE DES INSTRUCTIONS */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction d'assemblage à consulter. *
+* storage = mécanisme de sauvegarde à manipuler. *
+* format = format binaire chargé associé à l'architecture. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Charge une instruction depuis une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_armv7_instruction_unserialize(GArmV7Instruction *instr, GAsmStorage *storage, GBinFormat *format, packed_buffer *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GArchInstructionClass *parent; /* Classe parente à consulter */
+ uint8_t boolean; /* Valeur booléenne */
+
+ parent = G_ARCH_INSTRUCTION_CLASS(g_armv7_instruction_parent_class);
+
+ result = parent->unserialize(G_ARCH_INSTRUCTION(instr), storage, format, pbuf);
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &instr->sid, sizeof(ARMv7Syntax), true);
+
+ if (result)
+ result = extract_packed_buffer(pbuf, &instr->encoding, sizeof(char), false);
+
+ if (result)
+ {
+ result = extract_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false);
+
+ if (result)
+ instr->setflags = (boolean == 1 ? true : false);
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction d'assemblage à consulter. *
+* storage = mécanisme de sauvegarde à manipuler. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Sauvegarde une instruction dans une mémoire tampon. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_armv7_instruction_serialize(GArmV7Instruction *instr, GAsmStorage *storage, packed_buffer *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ GArchInstructionClass *parent; /* Classe parente à consulter */
+ uint8_t boolean; /* Valeur booléenne */
+
+ parent = G_ARCH_INSTRUCTION_CLASS(g_armv7_instruction_parent_class);
+
+ result = parent->serialize(G_ARCH_INSTRUCTION(instr), storage, pbuf);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &instr->sid, sizeof(ARMv7Syntax), true);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, &instr->encoding, sizeof(char), false);
+
+ if (result)
+ {
+ boolean = (instr->setflags ? 1 : 0);
+ result = extend_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false);
+ }
+
+ return result;
+
+}