diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-11-30 02:17:31 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-11-30 02:17:31 (GMT) |
commit | 94efb7bf5239cf984a0dda9949a26719a8ae2090 (patch) | |
tree | 99141ef5dcfce3ed0bdb7afcfdef7291e925c484 /src/analysis | |
parent | de06b3ebc7021c20d94013bd39f4ba2c2e5ce3fa (diff) |
Ensure the processor is known when providing the content class.
Diffstat (limited to 'src/analysis')
-rw-r--r-- | src/analysis/binary.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c index 9c3b3b9..141fac2 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -356,11 +356,39 @@ static void g_loaded_binary_finalize(GLoadedBinary *binary) GLoadedContent *g_loaded_binary_new(GExeFormat *format) { GLoadedBinary *result; /* Adresse à retourner */ + const char *arch; /* Architecture d'exécution */ + GArchProcessor *proc; /* Architecture du binaire */ + + result = NULL; + + /* Architecture visée */ + + arch = g_exe_format_get_target_machine(format); + + if (arch == NULL) + { + log_simple_message(LMT_INFO, _("Unknown architecture")); + goto exit; + } + + proc = get_arch_processor_for_key(arch); + + if (proc == NULL) + { + log_variadic_message(LMT_ERROR, _("Unable to load the required processor (%s)"), arch); + goto exit; + } + + /* Mise en place complète */ result = g_object_new(G_TYPE_LOADED_BINARY, NULL); result->format = format; + result->proc = proc; + + exit: + return G_LOADED_CONTENT(result); } @@ -1435,7 +1463,6 @@ 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 */ char *desc; /* Description humaine associée*/ bool has_virt; /* Présence de virtuel ? */ GProcContext *context; /* Contexte de suivi dédié */ @@ -1446,38 +1473,19 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool connect, bool ca format = G_BIN_FORMAT(binary->format); desc = g_known_format_get_description(G_KNOWN_FORMAT(format)); + assert(desc != NULL); - if (desc == NULL) - log_simple_message(LMT_WARNING, _("Unnamed format")); - else - log_variadic_message(LMT_INFO, _("Selected format: %s"), desc); + log_variadic_message(LMT_INFO, _("Selected format: %s"), desc); free(desc); result = g_known_format_analyze(G_KNOWN_FORMAT(format), gid, status); if (!result) goto glba_exit; - /* Architecture visée */ - - arch = g_exe_format_get_target_machine(binary->format); - - if (arch == NULL) - { - log_simple_message(LMT_INFO, _("Unknown architecture")); - result = false; - goto glba_exit; - } - - binary->proc = get_arch_processor_for_key(arch); - - if (binary->proc == NULL) - { - log_variadic_message(LMT_ERROR, _("Unable to load the required processor (%s)"), arch); - result = false; - goto glba_exit; - } + /* Interprétation de l'architecture associée */ desc = g_arch_processor_get_desc(binary->proc); + assert(desc != NULL); log_variadic_message(LMT_INFO, _("Detected architecture: %s"), desc); |