summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--plugins/readdex/header.c1
-rw-r--r--src/arch/instruction-int.h2
-rw-r--r--src/arch/instruction.c41
-rw-r--r--src/arch/instruction.h6
-rw-r--r--src/arch/raw.c135
6 files changed, 95 insertions, 103 deletions
diff --git a/ChangeLog b/ChangeLog
index f5fba2a..31a67f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+17-03-03 Cyrille Bagard <nocbos@gmail.com>
+
+ * plugins/readdex/header.c:
+ Update code.
+
+ * src/arch/instruction-int.h:
+ * src/arch/instruction.c:
+ * src/arch/instruction.h:
+ Show binary code of instructions.
+
+ * src/arch/raw.c:
+ Limit the quantity of binary code shown for arrays.
+
17-03-02 Cyrille Bagard <nocbos@gmail.com>
* src/glibext/gbufferline.c:
diff --git a/plugins/readdex/header.c b/plugins/readdex/header.c
index 365767d..f3928ca 100644
--- a/plugins/readdex/header.c
+++ b/plugins/readdex/header.c
@@ -94,7 +94,6 @@ bool annotate_dex_header(GDexFormat *format)
instr = g_raw_instruction_new_array(content, MDS_32_BITS, 5, &pos, endian);
- g_arch_instruction_set_displayed_max_length(instr, 4);
SET_IMM_DISPLAY(instr, operand, 0, IOD_HEX);
ADD_RAW_AS_SYM(format, symbol, instr, comment, _("SHA-1 signature used to uniquely identify files"));
diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h
index 89f589a..5f6758f 100644
--- a/src/arch/instruction-int.h
+++ b/src/arch/instruction-int.h
@@ -49,8 +49,6 @@ struct _GArchInstruction
{
GObject parent; /* A laisser en premier */
- phys_t max_displayed_len; /* Quantité de code affichée */
-
const instr_hook_fc *hooks; /* Traitements complémentaires */
const GBinContent *content; /* Contenu binaire global */
diff --git a/src/arch/instruction.c b/src/arch/instruction.c
index be049e1..7df72bf 100644
--- a/src/arch/instruction.c
+++ b/src/arch/instruction.c
@@ -145,8 +145,6 @@ static void g_arch_instruction_class_init(GArchInstructionClass *klass)
static void g_arch_instruction_init(GArchInstruction *instr)
{
- instr->max_displayed_len = VMPA_NO_PHYSICAL;
-
instr->from_count = 0;
instr->to_count = 0;
@@ -1006,45 +1004,6 @@ const char *g_arch_instruction_get_keyword(GArchInstruction *instr, AsmSyntax sy
}
-/******************************************************************************
-* *
-* Paramètres : instr = instruction d'assemblage à consulter. *
-* *
-* Description : Indique si elle existe la quantité maximale de code affiché. *
-* *
-* Retour : Quantité de code affichée au plus ou VMPA_NO_PHYSICAL. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-phys_t g_arch_instruction_get_displayed_max_length(const GArchInstruction *instr)
-{
- return instr->max_displayed_len;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : instr = instruction d'assemblage à consulter. *
-* max = quantité affichée au plus ou VMPA_NO_PHYSICAL. *
-* *
-* Description : Définit la quantité maximale de code affiché. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void g_arch_instruction_set_displayed_max_length(GArchInstruction *instr, phys_t max)
-{
- instr->max_displayed_len = max;
-
-}
-
-
/* ---------------------------------------------------------------------------------- */
/* OFFRE DE CAPACITES DE GENERATION */
diff --git a/src/arch/instruction.h b/src/arch/instruction.h
index 27c28f5..6388f94 100644
--- a/src/arch/instruction.h
+++ b/src/arch/instruction.h
@@ -218,12 +218,6 @@ size_t g_arch_instruction_compute_group_index(GArchInstruction **, GArchInstruct
/* Fournit le nom humain de l'instruction manipulée. */
const char *g_arch_instruction_get_keyword(GArchInstruction *, AsmSyntax);
-/* Indique si elle existe la quantité maximale de code affiché. */
-phys_t g_arch_instruction_get_displayed_max_length(const GArchInstruction *);
-
-/* Définit la quantité maximale de code affiché. */
-void g_arch_instruction_set_displayed_max_length(GArchInstruction *, phys_t);
-
#endif /* _ARCH_INSTRUCTION_H */
diff --git a/src/arch/raw.c b/src/arch/raw.c
index 9b4a57d..63dadab 100644
--- a/src/arch/raw.c
+++ b/src/arch/raw.c
@@ -461,6 +461,7 @@ static const char *g_raw_instruction_get_keyword(const GRawInstruction *instr, A
static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, size_t index, size_t repeat)
{
GArchInstruction *base; /* Autre version de l'instance */
+ phys_t max_displayed_len; /* Quantité de code affichée */
const char *key; /* Mot clef principal */
size_t klen; /* Taille de ce mot clef */
char *string; /* Chaîne reconstituée */
@@ -472,63 +473,56 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s
base = G_ARCH_INSTRUCTION(instr);
- if (!instr->is_padding && !instr->is_string)
- G_ARCH_INSTRUCTION_CLASS(g_raw_instruction_parent_class)->print(base, line, index, repeat);
+ /* Localisation */
- else
- {
- g_buffer_line_fill_vmpa(line, get_mrange_addr(&base->range), MDS_32_BITS_UNSIGNED, MDS_32_BITS_UNSIGNED);
-
- g_buffer_line_fill_content(line, base->content, &base->range, VMPA_NO_PHYSICAL);
+ g_buffer_line_fill_vmpa(line, get_mrange_addr(&base->range), MDS_32_BITS_UNSIGNED, MDS_32_BITS_UNSIGNED);
- /* Instruction proprement dite */
+ /* Contenu */
- key = g_arch_instruction_get_keyword(base, 0/*, syntax*/);
- klen = strlen(key);
+ if (instr->is_padding)
+ max_displayed_len = 0;
- g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION, NULL);
+ else if (instr->is_string)
+ max_displayed_len = 1;
- if (instr->is_padding)
- g_buffer_line_append_text(line, BLC_ASSEMBLY, "...", 3, RTT_RAW, NULL);
-
- else /*if (instr->is_string)*/
- {
- string = (char *)calloc(base->operands_count + 3, sizeof(char));
+ else
+ {
+ max_displayed_len = get_mrange_length(&base->range);
+ max_displayed_len /= g_arch_instruction_count_operands(base);
+ }
- strcpy(string, "\"");
- iter = 1;
+ g_buffer_line_fill_content(line, base->content, &base->range, max_displayed_len);
- first = true;
+ /* Zone du code d'assemblage */
- for (i = 0; i < base->operands_count; i++)
- {
- status = g_imm_operand_get_value(G_IMM_OPERAND(base->operands[i]), MDS_8_BITS, &byte);
- assert(status);
+ key = g_arch_instruction_get_keyword(base, 0/*, syntax*/);
+ klen = strlen(key);
- /* Si le caractère doit apparaître en hexadécimal... */
- if (!isprint(byte))
- {
- /* Si une chaîne précède */
- if (iter > 1)
- {
- if (!first)
- {
- g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL);
- g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL);
- }
- else
- first = false;
+ g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION, NULL);
- string[iter++] = '"';
+ if (instr->is_padding)
+ g_buffer_line_append_text(line, BLC_ASSEMBLY, "...", 3, RTT_RAW, NULL);
- g_buffer_line_append_text(line, BLC_ASSEMBLY, string, iter, RTT_STRING, NULL);
+ else if (instr->is_string)
+ {
+ string = (char *)calloc(base->operands_count + 3, sizeof(char));
- iter = 1;
+ strcpy(string, "\"");
+ iter = 1;
- }
+ first = true;
- /* Impression de l'octet */
+ for (i = 0; i < base->operands_count; i++)
+ {
+ status = g_imm_operand_get_value(G_IMM_OPERAND(base->operands[i]), MDS_8_BITS, &byte);
+ assert(status);
+ /* Si le caractère doit apparaître en hexadécimal... */
+ if (!isprint(byte))
+ {
+ /* Si une chaîne précède */
+ if (iter > 1)
+ {
if (!first)
{
g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL);
@@ -537,18 +531,16 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s
else
first = false;
- g_arch_operand_print(base->operands[i], line, 0/*, syntax*/);
+ string[iter++] = '"';
- }
+ g_buffer_line_append_text(line, BLC_ASSEMBLY, string, iter, RTT_STRING, NULL);
- else
- string[iter++] = byte;
+ iter = 1;
- }
+ }
+
+ /* Impression de l'octet */
- /* Si une chaîne reste encore */
- if (iter > 1)
- {
if (!first)
{
g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL);
@@ -557,13 +549,50 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s
else
first = false;
- string[iter++] = '"';
+ g_arch_operand_print(base->operands[i], line, 0/*, syntax*/);
- g_buffer_line_append_text(line, BLC_ASSEMBLY, string, iter, RTT_STRING, NULL);
+ }
+
+ else
+ string[iter++] = byte;
+
+ }
+ /* Si une chaîne reste encore */
+ if (iter > 1)
+ {
+ if (!first)
+ {
+ g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL);
+ g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL);
}
+ else
+ first = false;
+
+ string[iter++] = '"';
+
+ g_buffer_line_append_text(line, BLC_ASSEMBLY, string, iter, RTT_STRING, NULL);
+
+ }
+
+ free(string);
- free(string);
+ }
+
+ else
+ {
+ if (base->operands_count > 0)
+ {
+ g_arch_operand_print(base->operands[0], line, 0/*syntax*/);
+
+ for (i = 1; i < base->operands_count; i++)
+ {
+ g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL);
+ g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL);
+
+ g_arch_operand_print(base->operands[i], line, 0/*syntax*/);
+
+ }
}