diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/analysis/binary.c | 4 | ||||
-rw-r--r-- | src/arch/processor-int.h | 27 | ||||
-rw-r--r-- | src/arch/processor.c | 48 | ||||
-rw-r--r-- | src/arch/processor.h | 2 | ||||
-rw-r--r-- | src/core/processors.c | 3 |
5 files changed, 61 insertions, 23 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c index e875679..0f7b096 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -1647,7 +1647,7 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool connect, bool ca bool result; /* Bilan à retourner */ GBinFormat *format; /* Format lié au binaire */ const char *arch; /* Architecture d'exécution */ - const char *desc; /* Description humaine associée*/ + char *desc; /* Description humaine associée*/ bool has_virt; /* Présence de virtuel ? */ GProcContext *context; /* Contexte de suivi dédié */ GWidthTracker *tracker; /* Gestionnaire de largeur */ @@ -1690,6 +1690,8 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool connect, bool ca log_variadic_message(LMT_INFO, _("Detected architecture: %s"), desc); + free(desc); + g_signal_connect(binary->proc, "changed", G_CALLBACK(on_binary_processor_changed), binary); has_virt = g_arch_processor_has_virtual_space(binary->proc); diff --git a/src/arch/processor-int.h b/src/arch/processor-int.h index 34ba66a..6187ff0 100644 --- a/src/arch/processor-int.h +++ b/src/arch/processor-int.h @@ -36,6 +36,18 @@ /* Fournit la désignation interne du processeur d'architecture. */ typedef char * (* get_processor_key_fc) (const GArchProcessor *); +/* Fournit le nom humain de l'architecture visée. */ +typedef char * (* get_processor_desc_fc) (const GArchProcessor *); + +/* Fournit la taille de l'espace mémoire d'une architecture. */ +typedef MemoryDataSize (* get_processor_memsize_fc) (const GArchProcessor *); + +/* Fournit la taille min. des instructions d'une architecture. */ +typedef MemoryDataSize (* get_processor_inssize_fc) (const GArchProcessor *); + +/* Indique si l'architecture possède un espace virtuel ou non. */ +typedef bool (* has_processor_vspace_fc) (const GArchProcessor *); + /* Fournit un contexte propre au processeur d'une architecture. */ typedef GProcContext * (* get_processor_context_fc) (const GArchProcessor *); @@ -69,6 +81,8 @@ struct _GArchProcessor { GObject parent; /* A laisser en premier */ + SourceEndian endianness; /* Boutisme de l'architecture */ + GArchInstruction **instructions; /* Instructions désassemblées */ size_t instr_count; /* Taille de la liste aplatie */ unsigned int stamp; /* Marque de suivi des modifs */ @@ -95,16 +109,13 @@ struct _GArchProcessorClass { GObjectClass parent; /* A laisser en premier */ - const char *desc; /* Description humaine liée */ - - SourceEndian endianness; /* Boutisme de l'architecture */ - MemoryDataSize memsize; /* Taille de l'espace mémoire */ - MemoryDataSize inssize; /* Taille min. d'encodage */ - bool virt_space; /* Présence d'espace virtuel ? */ - get_processor_key_fc get_key; /* Code représentant la classe */ - get_processor_context_fc get_ctx; /* Obtention d'un contexte */ + get_processor_desc_fc get_desc; /* Description humaine */ + get_processor_memsize_fc get_memsize; /* Taille d'un mot classique */ + get_processor_inssize_fc get_inssize; /* Taille minimale d'instruct° */ + has_processor_vspace_fc has_vspace; /* Présence d'un espace virtuel*/ + get_processor_context_fc get_ctx; /* Obtention d'un contexte */ disass_instr_fc disassemble; /* Traduction en instructions */ /* Signaux */ diff --git a/src/arch/processor.c b/src/arch/processor.c index 7dbd8eb..59af6cd 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -290,7 +290,10 @@ char *g_arch_processor_get_key(const GArchProcessor *proc) class = G_ARCH_PROCESSOR_GET_CLASS(proc); if (class->get_key == NULL) + { + assert(false); result = NULL; + } else result = class->get_key(proc); @@ -312,14 +315,21 @@ char *g_arch_processor_get_key(const GArchProcessor *proc) * * ******************************************************************************/ -const char *g_arch_processor_get_desc(const GArchProcessor *proc) +char *g_arch_processor_get_desc(const GArchProcessor *proc) { - const char *result; /* Désignation à renvoyer */ + char *result; /* Désignation à renvoyer */ GArchProcessorClass *class; /* Classe de l'instance */ class = G_ARCH_PROCESSOR_GET_CLASS(proc); - result = class->desc; + if (class->get_desc == NULL) + { + assert(false); + result = NULL; + } + + else + result = class->get_desc(proc); return result; @@ -341,11 +351,8 @@ const char *g_arch_processor_get_desc(const GArchProcessor *proc) SourceEndian g_arch_processor_get_endianness(const GArchProcessor *proc) { SourceEndian result; /* Boutisme à retourner */ - GArchProcessorClass *class; /* Classe de l'instance */ - class = G_ARCH_PROCESSOR_GET_CLASS(proc); - - result = class->endianness; + result = proc->endianness; return result; @@ -371,7 +378,14 @@ MemoryDataSize g_arch_processor_get_memory_size(const GArchProcessor *proc) class = G_ARCH_PROCESSOR_GET_CLASS(proc); - result = class->memsize; + if (class->get_memsize == NULL) + { + assert(false); + result = MDS_UNDEFINED; + } + + else + result = class->get_memsize(proc); return result; @@ -397,7 +411,14 @@ MemoryDataSize g_arch_processor_get_instruction_min_size(const GArchProcessor *p class = G_ARCH_PROCESSOR_GET_CLASS(proc); - result = class->inssize; + if (class->get_inssize == NULL) + { + assert(false); + result = MDS_UNDEFINED; + } + + else + result = class->get_inssize(proc); return result; @@ -423,7 +444,14 @@ bool g_arch_processor_has_virtual_space(const GArchProcessor *proc) class = G_ARCH_PROCESSOR_GET_CLASS(proc); - result = class->virt_space; + if (class->has_vspace == NULL) + { + assert(false); + result = false; + } + + else + result = class->has_vspace(proc); return result; diff --git a/src/arch/processor.h b/src/arch/processor.h index 7edf341..b88fa6f 100644 --- a/src/arch/processor.h +++ b/src/arch/processor.h @@ -59,7 +59,7 @@ GType g_arch_processor_get_type(void); char *g_arch_processor_get_key(const GArchProcessor *); /* Fournit le nom humain de l'architecture visée. */ -const char *g_arch_processor_get_desc(const GArchProcessor *); +char *g_arch_processor_get_desc(const GArchProcessor *); /* Fournit le boustime du processeur d'une architecture. */ SourceEndian g_arch_processor_get_endianness(const GArchProcessor *); diff --git a/src/core/processors.c b/src/core/processors.c index 7234365..48e2cd2 100644 --- a/src/core/processors.c +++ b/src/core/processors.c @@ -108,9 +108,6 @@ bool register_processor_type(GType type) key = g_arch_processor_get_key(proc); if (key == NULL) goto done; - result = (key != NULL); - - G_LOCK(_pdef_access); new = find_processor_by_key(key); |