summaryrefslogtreecommitdiff
path: root/plugins/fmtp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/fmtp')
-rw-r--r--plugins/fmtp/parser.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/plugins/fmtp/parser.c b/plugins/fmtp/parser.c
index 4a8749d..84bb86f 100644
--- a/plugins/fmtp/parser.c
+++ b/plugins/fmtp/parser.c
@@ -25,10 +25,12 @@
#include <assert.h>
+#include <string.h>
#include <i18n.h>
#include <arch/instructions/raw.h>
+#include <common/extstr.h>
#include <format/known.h>
@@ -63,6 +65,7 @@ static bool parse_field_definition(const fmt_field_def *def, GBinFormat *format,
GArchInstruction *instr; /* Instruction décodée */
GImmOperand *imm; /* Opérande à transformer */
size_t i; /* Boucle de parcours */
+ char *text; /* Texte du commentaire complet*/
const vmpa2t *addr; /* Emplacement d'instruction */
GDbComment *comment; /* Définition de commentaire */
uint64_t raw; /* Valeur brute à étudier */
@@ -125,15 +128,12 @@ static bool parse_field_definition(const fmt_field_def *def, GBinFormat *format,
/* Commentaire */
- addr = get_mrange_addr(g_arch_instruction_get_range(instr));
-
- comment = g_db_comment_new_inlined(addr, BLF_HAS_CODE, false);
- g_db_item_add_flag(G_DB_ITEM(comment), DIF_VOLATILE);
+ text = NULL;
switch (def->ctype)
{
case FCT_PLAIN:
- g_db_comment_add_static_text(comment, _(def->comment.plain));
+ text = strdup(_(def->comment.plain));
break;
case FCT_SWITCH:
@@ -155,13 +155,16 @@ static bool parse_field_definition(const fmt_field_def *def, GBinFormat *format,
else if (raw != def->comment.choices[i].fixed)
continue;
- g_db_comment_add_static_text(comment, _(def->comment.choices[i].desc));
+ text = strnadd(text, _(def->comment.choices[i].desc), strlen(_(def->comment.choices[i].desc)));
break;
}
- if (i == def->comment.ccount)
- g_db_comment_add_static_text(comment, _(def->comment.def_choice));
+ if (text == NULL)
+ {
+ assert(i == def->comment.ccount);
+ text = strdup(_(def->comment.def_choice));
+ }
break;
@@ -174,16 +177,16 @@ static bool parse_field_definition(const fmt_field_def *def, GBinFormat *format,
if (part->is_static)
{
if (part->avoid_i18n)
- g_db_comment_add_static_text(comment, part->static_text);
+ text = strnadd(text, part->static_text, strlen(part->static_text));
else
- g_db_comment_add_static_text(comment, _(part->static_text));
+ text = strnadd(text, _(part->static_text), strlen(_(part->static_text)));
}
else
{
if (part->avoid_i18n)
- g_db_comment_add_dynamic_text(comment, part->dynamic_text);
+ text = strnadd(text, part->dynamic_text, strlen(part->dynamic_text));
else
- g_db_comment_add_dynamic_text(comment, _(part->dynamic_text));
+ text = strnadd(text, _(part->dynamic_text), strlen(_(part->dynamic_text)));
}
}
@@ -192,6 +195,13 @@ static bool parse_field_definition(const fmt_field_def *def, GBinFormat *format,
}
+ addr = get_mrange_addr(g_arch_instruction_get_range(instr));
+
+ comment = g_db_comment_new(addr, CET_INLINED, BLF_HAS_CODE, text);
+ g_db_item_add_flag(G_DB_ITEM(comment), DIF_VOLATILE);
+
+ free(text);
+
/* Insertions */
inserted = g_preload_info_add_instruction(info, instr);