summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-05-14 15:52:32 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-05-14 15:52:32 (GMT)
commit6178efcee9fc18d11a773827dca8b95304e75731 (patch)
tree77c664dfac355b7af803d33b1afded7925647b6d /src/arch
parentaba51093c8ebe4b0550557281f8d0d025027b1cb (diff)
Used unique identifiers for instructions everywhere.
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/instruction-int.h4
-rw-r--r--src/arch/instruction.c53
-rw-r--r--src/arch/instruction.h3
3 files changed, 8 insertions, 52 deletions
diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h
index c0ae3a7..2adeed0 100644
--- a/src/arch/instruction-int.h
+++ b/src/arch/instruction-int.h
@@ -37,6 +37,9 @@ typedef const char * (* get_instruction_encoding_fc) (const GArchInstruction *);
/* Fournit le nom humain de l'instruction manipulée. */
typedef const char * (* get_instruction_keyword_fc) (GArchInstruction *, AsmSyntax );
+/* Complète un désassemblage accompli pour une instruction. */
+typedef void (* call_instruction_hook_fc) (GArchInstruction *, InstrProcessHook, GArchProcessor *, GProcContext *, GExeFormat *);
+
/* Construit un petit résumé concis de l'instruction. */
typedef char * (* build_instruction_tooltip_fc) (const GArchInstruction *);
@@ -99,6 +102,7 @@ struct _GArchInstructionClass
get_instruction_encoding_fc get_encoding; /* Obtention de l'encodage */
get_instruction_keyword_fc get_keyword; /* Texte humain équivalent */
+ call_instruction_hook_fc call_hook; /* Décrochages éventuels */
build_instruction_tooltip_fc build_tooltip; /* Construction d'une bulle*/
get_instruction_desc_fc get_desc; /* Description assez complète */
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index 962b0e8..be7ff37 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -34,16 +34,6 @@
-/* Accès aux décrochages */
-static const char *_hook_names[IPH_COUNT] = {
-
- [IPH_FETCH] = "IPH_FETCH",
- [IPH_LINK] = "IPH_LINK",
- [IPH_POST] = "IPH_POST"
-
-};
-
-
/* Initialise la classe générique des instructions. */
static void g_arch_instruction_class_init(GArchInstructionClass *);
@@ -287,30 +277,6 @@ ArchInstrFlag g_arch_instruction_get_flags(const GArchInstruction *instr)
/******************************************************************************
* *
-* Paramètres : instr = instruction quelconque à modifier. *
-* type = type de procédure à mémoriser. *
-* hook = fonction à appeler sur commande. *
-* *
-* Description : Définit un traitement complémentare au désassemblage. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_arch_instruction_set_hooks(GArchInstruction *instr, const instr_hook_fc hooks[IPH_COUNT])
-{
- InstrProcessHook i; /* Boucle de parcours */
-
- for (i = 0; i < IPH_COUNT; i++)
- g_object_set_data(G_OBJECT(instr), _hook_names[i], hooks[i]);
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : instr = instruction quelconque à traiter. *
* type = type de procédure à utiliser. *
* proc = représentation de l'architecture utilisée. *
@@ -327,23 +293,12 @@ void g_arch_instruction_set_hooks(GArchInstruction *instr, const instr_hook_fc h
void g_arch_instruction_call_hook(GArchInstruction *instr, InstrProcessHook type, GArchProcessor *proc, GProcContext *context, GExeFormat *format)
{
- instr_hook_fc hook;
-
- assert(type < IPH_COUNT);
-
- hook = g_object_get_data(G_OBJECT(instr), _hook_names[type]);
-
- if (hook != NULL)
- {
- /**
- * Comme ce genre d'appel n'est effectué normalement qu'une seule fois
- * par instruction, on libère la mémoire au moment de cet unique appel.
- */
- g_object_set_data(G_OBJECT(instr), _hook_names[type], NULL);
+ GArchInstructionClass *class; /* Classe des instructions */
- hook(instr, proc, context, format);
+ class = G_ARCH_INSTRUCTION_GET_CLASS(instr);
- }
+ if (class->call_hook != NULL)
+ class->call_hook(instr, type, proc, context, format);
}
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index e0c8fdc..497b7f6 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -108,9 +108,6 @@ typedef struct _GArchProcessor GArchProcessor;
/* Complète un désassemblage accompli pour une instruction. */
typedef void (* instr_hook_fc) (GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *);
-/* Définit un traitement complémentare au désassemblage. */
-void g_arch_instruction_set_hooks(GArchInstruction *, const instr_hook_fc [IPH_COUNT]);
-
/* Complète un désassemblage accompli pour une instruction. */
void g_arch_instruction_call_hook(GArchInstruction *, InstrProcessHook, GArchProcessor *, GProcContext *, GExeFormat *);