summaryrefslogtreecommitdiff
path: root/src/arch/instruction.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2014-12-25 16:31:33 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2014-12-25 16:31:33 (GMT)
commit19e1a97fafb1b73d0efcd995b31951daf1a5c661 (patch)
tree9cbc897ddb1d3005fb8dadfa3ad830c607acdddd /src/arch/instruction.c
parent9cab778bfaaca2589a383445e8569d99d73374d5 (diff)
Cleaned all the code for immediate operands.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@444 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r--src/arch/instruction.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index a96f0e4..598da6d 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -24,6 +24,7 @@
#include "instruction.h"
+#include <assert.h>
#include <stdarg.h>
#include <string.h>
@@ -168,9 +169,10 @@ void g_arch_instruction_append_suffix(GArchInstruction *instr, const char *suffi
/******************************************************************************
* *
* Paramètres : instr = instruction quelconque à modifier. *
-* post = fonction à appeler sur commande. *
+* type = type de procédure à mémoriser. *
+* hook = fonction à appeler sur commande. *
* *
-* Description : Définit une fonction de post-traitement après désassemblage. *
+* Description : Définit un traitement complémentare au désassemblage. *
* *
* Retour : - *
* *
@@ -178,17 +180,21 @@ void g_arch_instruction_append_suffix(GArchInstruction *instr, const char *suffi
* *
******************************************************************************/
-void g_arch_instruction_set_post_prod_function(GArchInstruction *instr, instr_post_prod_fc post)
+void g_arch_instruction_set_hook(GArchInstruction *instr, InstrProcessHook type, instr_hook_fc hook)
{
- instr->post_prod = post;
+ assert(type < IPH_COUNT);
+
+ instr->hooks[type] = hook;
}
/******************************************************************************
* *
-* Paramètres : instr = instruction quelconque à traiter. *
-* data = données éventuelles associées à l'opération. *
+* Paramètres : instr = instruction quelconque à traiter. *
+* type = type de procédure à utiliser. *
+* context = contexte associé à la phase de désassemblage. *
+* format = accès aux données du binaire d'origine. *
* *
* Description : Complète un désassemblage accompli pour une instruction. *
* *
@@ -198,16 +204,14 @@ void g_arch_instruction_set_post_prod_function(GArchInstruction *instr, instr_po
* *
******************************************************************************/
-void g_arch_instruction_call_post_prod_function(GArchInstruction *instr, void *data)
+void g_arch_instruction_call_hook(GArchInstruction *instr, InstrProcessHook type, GProcContext *context, GBinFormat *format)
{
- if (instr->post_prod != NULL)
- instr->post_prod(instr, data);
-
-}
-
-
+ assert(type < IPH_COUNT);
+ if (instr->hooks[type] != NULL)
+ instr->hooks[type](instr, context, format);
+}
/******************************************************************************
@@ -338,6 +342,8 @@ GArchOperand *g_arch_instruction_get_operand(const GArchInstruction *instr, size
if (index >= instr->operands_count) result = NULL;
else result = instr->operands[index];
+ /* TODO : incrémenter la référence ! */
+
return result;
}