diff options
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/immediate.h | 2 | ||||
-rw-r--r-- | src/arch/instruction-int.h | 2 | ||||
-rw-r--r-- | src/arch/instruction.c | 26 | ||||
-rw-r--r-- | src/arch/instruction.h | 2 | ||||
-rw-r--r-- | src/arch/raw.c | 96 | ||||
-rw-r--r-- | src/arch/raw.h | 6 | ||||
-rw-r--r-- | src/arch/vmpa.c | 2 |
7 files changed, 119 insertions, 17 deletions
diff --git a/src/arch/immediate.h b/src/arch/immediate.h index 71d482a..99d1b7f 100644 --- a/src/arch/immediate.h +++ b/src/arch/immediate.h @@ -70,7 +70,7 @@ GArchOperand *_g_imm_operand_new_from_data(MemoryDataSize, const bin_t *, off_t /* Crée un opérande réprésentant une valeur numérique. */ GArchOperand *_g_imm_operand_new_from_data2(MemoryDataSize, const bin_t *, vmpa2t *, off_t, bool *, SourceEndian); -#define g_imm_operand_new_from_data2(size, data, pos, len, endian) _g_imm_operand_new_from_data(size, data, pos, len, NULL, endian) +#define g_imm_operand_new_from_data2(size, data, pos, len, endian) _g_imm_operand_new_from_data2(size, data, pos, len, NULL, endian) /* Crée un opérande réprésentant une valeur numérique. */ GArchOperand *g_imm_operand_new_from_value(MemoryDataSize, ...); diff --git a/src/arch/instruction-int.h b/src/arch/instruction-int.h index 8730792..28caf78 100644 --- a/src/arch/instruction-int.h +++ b/src/arch/instruction-int.h @@ -36,7 +36,7 @@ typedef void (* get_instruction_rw_regs_fc) (const GArchInstruction *, GArchRegister ***, size_t *, GArchRegister ***, size_t *); /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -typedef void (* print_instruction_fc) (const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); +typedef GBufferLine * (* print_instruction_fc) (const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); /* Traduit une instruction en version humainement lisible. */ typedef const char * (* get_instruction_keyword_fc) (const GArchInstruction *, AsmSyntax); diff --git a/src/arch/instruction.c b/src/arch/instruction.c index e1ee023..ea713cd 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -51,7 +51,7 @@ static void g_arch_instruction_finalize(GArchInstruction *); /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static void _g_arch_instruction_print(const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); +static GBufferLine *_g_arch_instruction_print(const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); @@ -692,39 +692,41 @@ const char *g_arch_instruction_get_keyword(const GArchInstruction *instr, AsmSyn * * ******************************************************************************/ -static void _g_arch_instruction_print(const GArchInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const bin_t *content, AsmSyntax syntax) +static GBufferLine *_g_arch_instruction_print(const GArchInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const bin_t *content, AsmSyntax syntax) { - GBufferLine *line; /* Ligne de destination */ + GBufferLine *result; /* Ligne de destination */ const char *key; /* Mot clef principal */ size_t klen; /* Taille de ce mot clef */ size_t i; /* Boucle de parcours */ - line = g_code_buffer_append_new_line(buffer, &instr->address2); + result = g_code_buffer_append_new_line(buffer, &instr->address2); - g_buffer_line_fill_for_instr(line, msize/* TODO ! */, msize, content, instr->length, true); + g_buffer_line_fill_for_instr(result, msize/* TODO ! */, msize, content, instr->length, true); /* Instruction proprement dite */ key = g_arch_instruction_get_keyword(instr, syntax); klen = strlen(key); - g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION); + g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION); if (instr->operands_count > 0) { - g_arch_operand_print(instr->operands[0], line, syntax); + g_arch_operand_print(instr->operands[0], result, syntax); for (i = 1; i < instr->operands_count; i++) { - g_buffer_line_insert_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT); - g_buffer_line_insert_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW); + g_buffer_line_insert_text(result, BLC_ASSEMBLY, ",", 1, RTT_PUNCT); + g_buffer_line_insert_text(result, BLC_ASSEMBLY, " ", 1, RTT_RAW); - g_arch_operand_print(instr->operands[i], line, syntax); + g_arch_operand_print(instr->operands[i], result, syntax); } } + return result; + } @@ -742,9 +744,9 @@ static void _g_arch_instruction_print(const GArchInstruction *instr, GCodeBuffer * * ******************************************************************************/ -void g_arch_instruction_print(const GArchInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const bin_t *content, AsmSyntax syntax) +GBufferLine *g_arch_instruction_print(const GArchInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const bin_t *content, AsmSyntax syntax) { - G_ARCH_INSTRUCTION_GET_CLASS(instr)->print(instr, buffer, msize, content, syntax); + return G_ARCH_INSTRUCTION_GET_CLASS(instr)->print(instr, buffer, msize, content, syntax); } diff --git a/src/arch/instruction.h b/src/arch/instruction.h index 08135a9..f04a458 100644 --- a/src/arch/instruction.h +++ b/src/arch/instruction.h @@ -152,7 +152,7 @@ size_t g_arch_instruction_compute_group_index(GArchInstruction **, GArchInstruct const char *g_arch_instruction_get_keyword(const GArchInstruction *, AsmSyntax); /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -void g_arch_instruction_print(const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); +GBufferLine *g_arch_instruction_print(const GArchInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); /* Décompile une instruction de façon générique. */ GDecInstruction *g_arch_instruction_decompile(const GArchInstruction *, GDecContext *); diff --git a/src/arch/raw.c b/src/arch/raw.c index 0d6ae4a..842c2b4 100644 --- a/src/arch/raw.c +++ b/src/arch/raw.c @@ -37,6 +37,8 @@ struct _GRawInstruction { GArchInstruction parent; /* A laisser en premier */ + bool is_padding; /* Bourrage à représenter ? */ + }; /* Définition générique d'une instruction d'architecture inconnue (classe) */ @@ -59,6 +61,9 @@ static void g_raw_instruction_dispose(GRawInstruction *); /* Procède à la libération totale de la mémoire. */ static void g_raw_instruction_finalize(GRawInstruction *); +/* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ +static GBufferLine *g_raw_instruction_print(const GRawInstruction *, GCodeBuffer *, MemoryDataSize, const bin_t *, AsmSyntax); + /* Fournit le nom humain de l'instruction manipulée. */ static const char *g_raw_instruction_get_keyword(const GRawInstruction *, AsmSyntax); @@ -97,6 +102,7 @@ static void g_raw_instruction_class_init(GRawInstructionClass *klass) instr = G_ARCH_INSTRUCTION_CLASS(klass); + instr->print = (print_instruction_fc)g_raw_instruction_print; instr->get_key = (get_instruction_keyword_fc)g_raw_instruction_get_keyword; } @@ -219,6 +225,54 @@ GArchInstruction *g_raw_instruction_new_array(const bin_t *data, MemoryDataSize /****************************************************************************** * * +* Paramètres : instr = instruction d'assemblage à représenter. * +* buffer = espace où placer ledit contenu. * +* syntax = type de représentation demandée. * +* * +* Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GBufferLine *g_raw_instruction_print(const GRawInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const bin_t *content, AsmSyntax syntax) +{ + GBufferLine *result; /* Ligne de destination */ + GArchInstruction *base; /* Autre version de l'instance */ + const char *key; /* Mot clef principal */ + size_t klen; /* Taille de ce mot clef */ + + base = G_ARCH_INSTRUCTION(instr); + + if (!instr->is_padding) + result = G_ARCH_INSTRUCTION_CLASS(g_raw_instruction_parent_class)->print(base, buffer, msize, content, syntax); + + else + { + result = g_code_buffer_append_new_line(buffer, &base->address2); + + g_buffer_line_fill_for_instr(result, msize/* TODO ! */, msize, content, base->length, true); + + /* Instruction proprement dite */ + + key = g_arch_instruction_get_keyword(base, syntax); + klen = strlen(key); + + g_buffer_line_insert_text(result, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION); + + g_buffer_line_insert_text(result, BLC_ASSEMBLY, "...", 3, RTT_RAW); + + } + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : instr = instruction à traiter. * * format = format du binaire manipulé. * * syntax = type de représentation demandée. * @@ -238,9 +292,49 @@ static const char *g_raw_instruction_get_keyword(const GRawInstruction *instr, A static char *defines[] = { "dn", "db", "dw", "dd", "dq" }; - operand = g_arch_instruction_get_operand(instr, 0); + operand = g_arch_instruction_get_operand(G_ARCH_INSTRUCTION(instr), 0); size = g_imm_operand_get_size(G_IMM_OPERAND(operand)); return defines[MDS_RANGE(size)]; } + + +/****************************************************************************** +* * +* Paramètres : instr = instruction à traiter. * +* is_padding = nouveau statut à associer au contenu. * +* * +* Description : Marque l'instruction comme ne contenant que du bourrage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_raw_instruction_mark_as_padding(GRawInstruction *instr, bool is_padding) +{ + instr->is_padding = is_padding; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction à traiter. * +* is_padding = nouveau statut à associer au contenu. * +* * +* Description : Indique si le contenu de l'instruction est du bourrage. * +* * +* Retour : Statut du contenu de l'instruction. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_raw_instruction_is_padding(const GRawInstruction *instr) +{ + return instr->is_padding; + +} diff --git a/src/arch/raw.h b/src/arch/raw.h index 08dc620..ce324f5 100644 --- a/src/arch/raw.h +++ b/src/arch/raw.h @@ -55,6 +55,12 @@ GType g_raw_instruction_get_type(void); /* Crée une instruction de type 'db/dw/etc' étendue. */ GArchInstruction *g_raw_instruction_new_array(const bin_t *, MemoryDataSize, size_t, vmpa2t *, off_t, SourceEndian); +/* Marque l'instruction comme ne contenant que du bourrage. */ +void g_raw_instruction_mark_as_padding(GRawInstruction *, bool); + +/* Indique si le contenu de l'instruction est du bourrage. */ +bool g_raw_instruction_is_padding(const GRawInstruction *); + #endif /* _ARCH_RAW_H */ diff --git a/src/arch/vmpa.c b/src/arch/vmpa.c index 93bbfc8..edff789 100644 --- a/src/arch/vmpa.c +++ b/src/arch/vmpa.c @@ -191,7 +191,7 @@ void advance_vmpa(vmpa2t *addr, off_t qty) addr->physical += qty; if (addr->virtual != VMPA_NO_VIRTUAL) - addr->virtual =+ qty; + addr->virtual += qty; } |