diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-02-09 20:15:52 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-02-09 20:15:52 (GMT) |
commit | 8d326041a0379b87e54be44506d544367567e89b (patch) | |
tree | a3c3555c27c30858155fbee4df0ca236f33774f8 /src/analysis | |
parent | b70f428256963385a140e9eb503624106df5aa9b (diff) |
Registered all the supported processors in the system code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@467 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rw-r--r-- | src/analysis/binaries/file.c | 39 | ||||
-rw-r--r-- | src/analysis/binary.c | 27 | ||||
-rw-r--r-- | src/analysis/binary.h | 3 | ||||
-rw-r--r-- | src/analysis/decomp/decompiler.c | 2 | ||||
-rw-r--r-- | src/analysis/disass/area.c | 10 | ||||
-rw-r--r-- | src/analysis/disass/disassembler.c | 5 | ||||
-rw-r--r-- | src/analysis/disass/fetch.c | 13 | ||||
-rw-r--r-- | src/analysis/disass/output.c | 6 | ||||
-rw-r--r-- | src/analysis/disass/output.h | 3 | ||||
-rw-r--r-- | src/analysis/roptions.c | 2 |
10 files changed, 72 insertions, 38 deletions
diff --git a/src/analysis/binaries/file.c b/src/analysis/binaries/file.c index d833828..a724cb7 100644 --- a/src/analysis/binaries/file.c +++ b/src/analysis/binaries/file.c @@ -33,6 +33,7 @@ #include "../binary-int.h" #include "../../common/extstr.h" +#include "../../core/processors.h" #include "../../gui/panels/log.h" @@ -164,6 +165,8 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename) struct stat info; /* Informations sur le fichier */ int ret; /* Bilan d'un appel */ void *content; /* Contenu brut du fichier */ + const char *target; /* Architecture requise */ + const char *desc; /* Description humaine associée*/ result = g_object_new(G_TYPE_FILE_BINARY, NULL); loaded = G_LOADED_BINARY(result); @@ -216,30 +219,24 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename) goto lbf_error; } - switch (g_exe_format_get_target_machine(loaded->format)) + target = g_exe_format_get_target_machine(loaded->format); + desc = get_arch_processor_name(target); + + if (desc == NULL) { - case FTM_ARM: - log_simple_message(LMT_INFO, _("Detected architecture: ARM")); - break; - case FTM_DALVIK: - log_simple_message(LMT_INFO, _("Detected architecture: Dalvik Virtual Machine")); - break; - case FTM_JVM: - log_simple_message(LMT_INFO, _("Detected architecture: Java Virtual Machine")); - break; - case FTM_MIPS: - log_simple_message(LMT_INFO, _("Detected architecture: Microprocessor without Interlocked Pipeline Stages")); - break; - case FTM_386: - log_simple_message(LMT_INFO, _("Detected architecture: i386")); - break; - default: - log_simple_message(LMT_INFO, _("Unknown architecture")); - goto lbf_error; - break; + log_simple_message(LMT_INFO, _("Unknown architecture")); + goto lbf_error; } + else + log_variadic_message(LMT_INFO, _("Detected architecture: %s"), desc); + + loaded->proc = get_arch_processor_for_type(target); - loaded->proc = get_arch_processor_from_format(loaded->format); + if (loaded->proc == NULL) + { + log_simple_message(LMT_ERROR, _("Unable to load the required processor")); + goto lbf_error; + } return G_LOADED_BINARY(result); diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 35f7acd..55b984a 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -962,6 +962,8 @@ bin_t *g_loaded_binary_get_data(const GLoadedBinary *binary, off_t *length) GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *binary) { + /* TODO : inc ref ! */ + return binary->format; } @@ -971,6 +973,31 @@ GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *binary) * * * Paramètres : binary = élément binaire à consulter. * * * +* Description : Fournit le processeur de l'architecture liée au binaire. * +* * +* Retour : Adresse du processeur associé. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *binary) +{ + GArchProcessor *result; /* Instance à retourner */ + + result = binary->proc; + + g_object_ref(G_OBJECT(result)); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : binary = élément binaire à consulter. * +* * * Description : Fournit les instructions issues du désassemblage. * * * * Retour : Instructions issues du désassemblage. * diff --git a/src/analysis/binary.h b/src/analysis/binary.h index 8ce64cb..625ff4a 100644 --- a/src/analysis/binary.h +++ b/src/analysis/binary.h @@ -156,6 +156,9 @@ bin_t *g_loaded_binary_get_data(const GLoadedBinary *, off_t *); /* Fournit le format de fichier reconnu dans le contenu binaire. */ GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *); +/* Fournit le processeur de l'architecture liée au binaire. */ +GArchProcessor *g_loaded_binary_get_processor(const GLoadedBinary *); + /* Fournit les instructions issues du désassemblage. */ GArchInstruction *g_loaded_binary_get_instructions(const GLoadedBinary *); diff --git a/src/analysis/decomp/decompiler.c b/src/analysis/decomp/decompiler.c index aa2fc84..150f03c 100644 --- a/src/analysis/decomp/decompiler.c +++ b/src/analysis/decomp/decompiler.c @@ -149,7 +149,7 @@ static void prepare_all_routines_for_decomp(const GLoadedBinary *binary, const c //vmpa_t max; /* Première adresse à écarter */ format = g_loaded_binary_get_format(binary); - proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); + proc = NULL;//get_arch_processor_from_format(G_EXE_FORMAT(format)); routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &count); diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c index 17df2af..a6e58cd 100644 --- a/src/analysis/disass/area.c +++ b/src/analysis/disass/area.c @@ -440,7 +440,7 @@ void load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons /* Récupération des informations de base */ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); - proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); + proc = g_loaded_binary_get_processor(binary); bin_data = g_loaded_binary_get_data(binary, &bin_length); area = (*list) + *index; @@ -581,6 +581,9 @@ void load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons printf("\n"); + g_object_unref(G_OBJECT(proc)); + + } @@ -626,8 +629,11 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count /* Récupération des informations de base */ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); - proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); + + proc = g_loaded_binary_get_processor(binary); endianness = g_arch_processor_get_endianness(proc); + g_object_unref(G_OBJECT(proc)); + bin_data = g_loaded_binary_get_data(binary, &bin_length); diff = compute_vmpa_diff(get_mrange_addr(&area->range), start); diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index ac6eb5b..c39073c 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -199,6 +199,7 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta bstatus_id_t id; /* Identifiant de statut */ + GArchProcessor *proc; /* Architecture du binaire */ @@ -268,10 +269,12 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkExtSta qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_compare); + proc = g_loaded_binary_get_processor(disass->binary); - print_disassembled_instructions(disass->buffer, disass->format, *disass->instrs, + print_disassembled_instructions(disass->buffer, disass->format, proc, *disass->instrs, routines, routines_count, statusbar, id); + g_object_unref(G_OBJECT(proc)); diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index b912ff2..16b81c8 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -143,7 +143,7 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt { GArchInstruction *result; /* Instruction désassemblées */ GBinFormat *format; /* Format du fichier binaire */ - //GArchProcessor *proc; /* Architecture du binaire */ + GArchProcessor *proc; /* Architecture du binaire */ GProcContext *ctx; /* Contexte de désassemblage */ off_t length; /* Taille des données à lire */ mem_area *areas; /* Zone de productions */ @@ -158,15 +158,10 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt double done; /* Portion de travail accompli */ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); - - /* - proc = get_arch_processor_from_format(G_EXE_FORMAT(format)); + proc = g_loaded_binary_get_processor(binary); ctx = g_arch_processor_get_context(proc); - */ - - ctx = g_binary_format_get_disassembling_context(format); - + g_binary_format_setup_disassembling_context(format, ctx); /* Définition à la découpe des parties à traiter */ @@ -234,6 +229,8 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt /* free */ + g_object_unref(G_OBJECT(proc)); + return result; } diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c index 87d0407..2ecb5f4 100644 --- a/src/analysis/disass/output.c +++ b/src/analysis/disass/output.c @@ -49,10 +49,10 @@ * * ******************************************************************************/ -void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *format, const GArchInstruction *instrs, GBinRoutine * const *routines, size_t count, GtkExtStatusBar *statusbar, bstatus_id_t id) +void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *format, GArchProcessor *proc, const GArchInstruction *instrs, GBinRoutine * const *routines, size_t count, GtkExtStatusBar *statusbar, bstatus_id_t id) { GLangOutput *output; /* Modèle de sortie adéquat */ - GArchProcessor *proc; /* Architecture du binaire */ + //GArchProcessor *proc; /* Architecture du binaire */ MemoryDataSize msize; /* Taille du bus d'adresses */ const bin_t *content; /* Contenu binaire global */ @@ -121,7 +121,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form - proc = get_arch_processor_from_format(format); + //proc = get_arch_processor_from_format(format); msize = g_arch_processor_get_memory_size(proc); content = g_binary_format_get_content(G_BIN_FORMAT(format), NULL); diff --git a/src/analysis/disass/output.h b/src/analysis/disass/output.h index 04cb643..549fa23 100644 --- a/src/analysis/disass/output.h +++ b/src/analysis/disass/output.h @@ -27,13 +27,14 @@ #include "../routine.h" #include "../../arch/instruction.h" +#include "../../arch/processor.h" #include "../../glibext/gcodebuffer.h" #include "../../gtkext/gtkextstatusbar.h" /* Transcrit du code désassemblé en texte humainement lisible. */ -void print_disassembled_instructions(GCodeBuffer *, const GExeFormat *, const GArchInstruction *, GBinRoutine * const *, size_t, GtkExtStatusBar *, bstatus_id_t); +void print_disassembled_instructions(GCodeBuffer *, const GExeFormat *, GArchProcessor *, const GArchInstruction *, GBinRoutine * const *, size_t, GtkExtStatusBar *, bstatus_id_t); diff --git a/src/analysis/roptions.c b/src/analysis/roptions.c index 896a2e1..8da348f 100644 --- a/src/analysis/roptions.c +++ b/src/analysis/roptions.c @@ -113,7 +113,7 @@ GRenderingOptions *g_rendering_options_new(GExeFormat *format) result = g_object_new(G_TYPE_RENDERING_OPTIONS, NULL); result->format = format; - result->proc = get_arch_processor_from_format(format); + result->proc = NULL;//get_arch_processor_from_format(format); return result; |