summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analysis/binary.c56
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);