diff options
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r-- | src/arch/instruction.c | 32 |
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; } |