summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-03-08 16:09:24 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-03-08 16:09:24 (GMT)
commita33dd28e763e3a8b04145fb549aca9320e100a4b (patch)
tree26a99bc5b7e640c751dfbeba93994aa74b2ea9df
parent2a03971cd2b19a6716a0e5e6896dcfcc91031a6a (diff)
Prepared instructions to generate tooltips.
-rw-r--r--ChangeLog12
-rw-r--r--plugins/arm/v7/instruction.c28
-rw-r--r--plugins/dalvik/instruction.c33
-rw-r--r--src/arch/instruction-int.h4
-rw-r--r--src/arch/instruction.c31
-rw-r--r--src/arch/instruction.h3
-rw-r--r--src/gtkext/gtkblockdisplay.c6
7 files changed, 112 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index d47d490..efb168a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+18-03-08 Cyrille Bagard <nocbos@gmail.com>
+
+ * plugins/arm/v7/instruction.c:
+ * plugins/dalvik/instruction.c:
+ * src/arch/instruction-int.h:
+ * src/arch/instruction.c:
+ * src/arch/instruction.h:
+ Prepare instructions to generate tooltips.
+
+ * src/gtkext/gtkblockdisplay.c:
+ Accept tooltips from instructions.
+
18-02-21 Cyrille Bagard <nocbos@gmail.com>
* src/gui/panels/panel.c:
diff --git a/plugins/arm/v7/instruction.c b/plugins/arm/v7/instruction.c
index d9e4275..0e9bd23 100644
--- a/plugins/arm/v7/instruction.c
+++ b/plugins/arm/v7/instruction.c
@@ -69,6 +69,10 @@ static void g_armv7_instruction_finalize(GArmV7Instruction *);
/* Indique l'encodage d'une instruction de façon détaillée. */
static const char *g_armv7_instruction_get_encoding(const GArmV7Instruction *);
+/* Construit un petit résumé concis de l'instruction. */
+static char *g_armv7_instruction_build_tooltip(const GArmV7Instruction *);
+
+
/* Indique le type défini pour une représentation d'une instruction ARMv7. */
G_DEFINE_TYPE(GArmV7Instruction, g_armv7_instruction, G_TYPE_ARM_INSTRUCTION);
@@ -98,6 +102,7 @@ static void g_armv7_instruction_class_init(GArmV7InstructionClass *klass)
object_class->finalize = (GObjectFinalizeFunc)g_armv7_instruction_finalize;
instr->get_encoding = (get_instruction_encoding_fc)g_armv7_instruction_get_encoding;
+ instr->build_tooltip = (build_instruction_tooltip_fc)g_armv7_instruction_build_tooltip;
}
@@ -245,6 +250,29 @@ void g_armv7_instruction_set_encoding(GArmV7Instruction *instr, const char *enco
/******************************************************************************
* *
+* Paramètres : instr = instruction Dalvik à consulter. *
+* *
+* Description : Construit un petit résumé concis de l'instruction. *
+* *
+* Retour : Chaîne de caractères à libérer après usage ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_armv7_instruction_build_tooltip(const GArmV7Instruction *instr)
+{
+ char *result; /* Description à retourner */
+
+ result = NULL;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : instr = instruction ARMv7 à mettre à jour. *
* set = statut à enregistrer. *
* *
diff --git a/plugins/dalvik/instruction.c b/plugins/dalvik/instruction.c
index aafd34e..7105dc9 100644
--- a/plugins/dalvik/instruction.c
+++ b/plugins/dalvik/instruction.c
@@ -52,7 +52,10 @@ static void g_dalvik_instruction_finalize(GDalvikInstruction *);
static const char *g_dalvik_instruction_get_encoding(const GDalvikInstruction *);
/* Fournit le nom humain de l'instruction manipulée. */
-static const char *dalvik_instruction_get_keyword(const GDalvikInstruction *, AsmSyntax);
+static const char *g_dalvik_instruction_get_keyword(const GDalvikInstruction *, AsmSyntax);
+
+/* Construit un petit résumé concis de l'instruction. */
+static char *g_dalvik_instruction_build_tooltip(const GDalvikInstruction *);
@@ -86,7 +89,8 @@ static void g_dalvik_instruction_class_init(GDalvikInstructionClass *klass)
instr = G_ARCH_INSTRUCTION_CLASS(klass);
instr->get_encoding = (get_instruction_encoding_fc)g_dalvik_instruction_get_encoding;
- instr->get_keyword = (get_instruction_keyword_fc)dalvik_instruction_get_keyword;
+ instr->get_keyword = (get_instruction_keyword_fc)g_dalvik_instruction_get_keyword;
+ instr->build_tooltip = (build_instruction_tooltip_fc)g_dalvik_instruction_build_tooltip;
}
@@ -208,7 +212,7 @@ static const char *g_dalvik_instruction_get_encoding(const GDalvikInstruction *i
* *
******************************************************************************/
-static const char *dalvik_instruction_get_keyword(const GDalvikInstruction *instr, AsmSyntax syntax)
+static const char *g_dalvik_instruction_get_keyword(const GDalvikInstruction *instr, AsmSyntax syntax)
{
return instr->keyword;
@@ -219,6 +223,29 @@ static const char *dalvik_instruction_get_keyword(const GDalvikInstruction *inst
* *
* Paramètres : instr = instruction Dalvik à consulter. *
* *
+* Description : Construit un petit résumé concis de l'instruction. *
+* *
+* Retour : Chaîne de caractères à libérer après usage ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_dalvik_instruction_build_tooltip(const GDalvikInstruction *instr)
+{
+ char *result; /* Description à retourner */
+
+ result = NULL;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction Dalvik à consulter. *
+* *
* Description : Indique l'opcode associé à une instruction Dalvik. *
* *
* Retour : Identifiant de l'instruction en place. *
diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h
index fb1f796..081adba 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 );
+/* Construit un petit résumé concis de l'instruction. */
+typedef char * (* build_instruction_tooltip_fc) (const GArchInstruction *);
+
/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */
typedef GBufferLine * (* print_instruction_fc) (const GArchInstruction *, GBufferLine *, size_t, size_t, const GBinContent *);
@@ -91,6 +94,7 @@ struct _GArchInstructionClass
get_instruction_encoding_fc get_encoding; /* Obtention de l'encodage */
get_instruction_keyword_fc get_keyword; /* Texte humain équivalent */
+ build_instruction_tooltip_fc build_tooltip; /* Construction d'une bulle*/
print_instruction_fc print; /* Imprime l'ensemble */
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index 7e1e646..0041129 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -1059,6 +1059,35 @@ const char *g_arch_instruction_get_keyword(GArchInstruction *instr, AsmSyntax sy
}
+/******************************************************************************
+* *
+* Paramètres : instr = instruction d'assemblage à consulter. *
+* *
+* Description : Construit un petit résumé concis de l'instruction. *
+* *
+* Retour : Chaîne de caractères à libérer après usage ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+char *g_arch_instruction_build_tooltip(const GArchInstruction *instr)
+{
+ char *result; /* Description à retourner */
+ GArchInstructionClass *class; /* Classe des instructions */
+
+ class = G_ARCH_INSTRUCTION_GET_CLASS(instr);
+
+ if (class->build_tooltip != NULL)
+ result = class->build_tooltip(instr);
+
+ else
+ result = NULL;
+
+ return result;
+
+}
+
/* ---------------------------------------------------------------------------------- */
/* OFFRE DE CAPACITES DE GENERATION */
@@ -1188,7 +1217,7 @@ static void _g_arch_instruction_print(GArchInstruction *instr, GBufferLine *line
key = g_arch_instruction_get_keyword(instr, 0/*, syntax*/);
klen = strlen(key);
- g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION, NULL);
+ g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION, G_OBJECT(instr));
/* Liste des opérandes */
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index f508c35..ca047b7 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -248,6 +248,9 @@ GArchInstruction *g_arch_instruction_get_given_destination(GArchInstruction *, I
/* Fournit le nom humain de l'instruction manipulée. */
const char *g_arch_instruction_get_keyword(GArchInstruction *, AsmSyntax);
+/* Construit un petit résumé concis de l'instruction. */
+char *g_arch_instruction_build_tooltip(const GArchInstruction *);
+
#endif /* _ARCH_INSTRUCTION_H */
diff --git a/src/gtkext/gtkblockdisplay.c b/src/gtkext/gtkblockdisplay.c
index e4d9d48..8078e7e 100644
--- a/src/gtkext/gtkblockdisplay.c
+++ b/src/gtkext/gtkblockdisplay.c
@@ -25,6 +25,7 @@
#include "gtkbufferdisplay-int.h"
+#include "../arch/instruction.h"
#include "../arch/operand.h"
#include "../analysis/loaded.h"
@@ -305,7 +306,10 @@ static gboolean gtk_block_display_query_tooltip(GtkWidget *widget, gint x, gint
if (creator != NULL)
{
- if (G_IS_ARCH_OPERAND(creator))
+ if (G_IS_ARCH_INSTRUCTION(creator))
+ info = g_arch_instruction_build_tooltip(G_ARCH_INSTRUCTION(creator));
+
+ else if (G_IS_ARCH_OPERAND(creator))
info = g_arch_operand_build_tooltip(G_ARCH_OPERAND(creator), panel->binary);
else