diff options
Diffstat (limited to 'plugins/arm/v7/instruction.c')
-rw-r--r-- | plugins/arm/v7/instruction.c | 117 |
1 files changed, 113 insertions, 4 deletions
diff --git a/plugins/arm/v7/instruction.c b/plugins/arm/v7/instruction.c index 5c2cd98..eb4a082 100644 --- a/plugins/arm/v7/instruction.c +++ b/plugins/arm/v7/instruction.c @@ -90,10 +90,21 @@ static char *g_armv7_instruction_build_tooltip(const GArmV7Instruction *); /* Charge une instruction depuis une mémoire tampon. */ -static bool g_armv7_instruction_unserialize(GArmV7Instruction *, GAsmStorage *, GBinFormat *, packed_buffer *); +static bool g_armv7_instruction_unserialize(GArmV7Instruction *, GAsmStorage *, GBinFormat *, packed_buffer_t *); /* Sauvegarde une instruction dans une mémoire tampon. */ -static bool g_armv7_instruction_serialize(GArmV7Instruction *, GAsmStorage *, packed_buffer *); +static bool g_armv7_instruction_serialize(GArmV7Instruction *, GAsmStorage *, packed_buffer_t *); + + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_armv7_instruction_load(GArmV7Instruction *, GObjectStorage *, packed_buffer_t *); + +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_armv7_instruction_store(GArmV7Instruction *, GObjectStorage *, packed_buffer_t *); @@ -132,6 +143,9 @@ static void g_armv7_instruction_class_init(GArmV7InstructionClass *klass) instr->unserialize = (unserialize_instruction_fc)g_armv7_instruction_unserialize; instr->serialize = (serialize_instruction_fc)g_armv7_instruction_serialize; + instr->load = (load_instruction_fc)g_armv7_instruction_load; + instr->store = (store_instruction_fc)g_armv7_instruction_store; + } @@ -437,7 +451,7 @@ bool g_armv7_instruction_get_setflags(const GArmV7Instruction *instr) * * ******************************************************************************/ -static bool g_armv7_instruction_unserialize(GArmV7Instruction *instr, GAsmStorage *storage, GBinFormat *format, packed_buffer *pbuf) +static bool g_armv7_instruction_unserialize(GArmV7Instruction *instr, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchInstructionClass *parent; /* Classe parente à consulter */ @@ -481,7 +495,7 @@ static bool g_armv7_instruction_unserialize(GArmV7Instruction *instr, GAsmStorag * * ******************************************************************************/ -static bool g_armv7_instruction_serialize(GArmV7Instruction *instr, GAsmStorage *storage, packed_buffer *pbuf) +static bool g_armv7_instruction_serialize(GArmV7Instruction *instr, GAsmStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchInstructionClass *parent; /* Classe parente à consulter */ @@ -506,3 +520,98 @@ static bool g_armv7_instruction_serialize(GArmV7Instruction *instr, GAsmStorage 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_armv7_instruction_load(GArmV7Instruction *instr, GObjectStorage *storage, packed_buffer_t *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchInstructionClass *parent; /* Classe parente à consulter */ + uleb128_t value; /* Valeur ULEB128 à charger */ + uint8_t boolean; /* Valeur booléenne */ + + parent = G_ARCH_INSTRUCTION_CLASS(g_armv7_instruction_parent_class); + + result = parent->load(G_ARCH_INSTRUCTION(instr), storage, pbuf); + + if (result) + result = unpack_uleb128(&value, pbuf); + + if (result) + instr->sid = value; + + 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 = é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_armv7_instruction_store(GArmV7Instruction *instr, GObjectStorage *storage, packed_buffer_t *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->store(G_ARCH_INSTRUCTION(instr), storage, pbuf); + + if (result) + result = pack_uleb128((uleb128_t []){ instr->sid }, pbuf); + + 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; + +} |