summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analysis/binary.c29
-rw-r--r--src/analysis/binary.h3
-rw-r--r--src/analysis/content-int.h2
-rw-r--r--src/analysis/content.c44
-rw-r--r--src/analysis/content.h2
-rw-r--r--src/analysis/contents/encapsulated.c12
-rw-r--r--src/analysis/contents/file.c17
-rw-r--r--src/analysis/contents/memory.c8
-rw-r--r--src/analysis/disass/disassembler.c4
-rw-r--r--src/gui/dialogs/export_disass.c6
-rw-r--r--src/gui/panels/bintree.c7
11 files changed, 68 insertions, 66 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index aee4499..c671827 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -400,35 +400,6 @@ GLoadedContent *g_loaded_binary_new(GExeFormat *format)
}
-/******************************************************************************
-* *
-* Paramètres : binary = élément binaire à consulter. *
-* full = précise s'il s'agit d'une version longue ou non. *
-* *
-* Description : Fournit le nom associé à l'élément binaire. *
-* *
-* Retour : Nom de fichier avec chemin absolu. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-const char *g_loaded_binary_get_name(const GLoadedBinary *binary, bool full)
-{
- const char *result; /* Description à retourner */
- GBinContent *content; /* Contenu binaire mannipulé */
-
- content = g_known_format_get_content(G_KNOWN_FORMAT(binary->format));
-
- result = g_binary_content_describe(content, full);
-
- g_object_unref(G_OBJECT(content));
-
- return result;
-
-}
-
-
/* ---------------------------------------------------------------------------------- */
/* INFORMATIONS D'ENREGISTREMENTS */
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 74c5f7f..178d186 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -76,9 +76,6 @@ GType g_loaded_binary_get_type(void);
/* Interprète un contenu binaire chargé. */
GLoadedContent *g_loaded_binary_new(GExeFormat *);
-/* Fournit le nom associé à l'élément binaire. */
-const char *g_loaded_binary_get_name(const GLoadedBinary *, bool);
-
/* ------------------------- INFORMATIONS D'ENREGISTREMENTS ------------------------- */
diff --git a/src/analysis/content-int.h b/src/analysis/content-int.h
index ad13b8d..886c196 100644
--- a/src/analysis/content-int.h
+++ b/src/analysis/content-int.h
@@ -39,7 +39,7 @@ typedef GContentAttributes * (* get_content_attributes) (const GBinContent *);
typedef GBinContent * (* get_content_root_fc) (GBinContent *);
/* Fournit le nom associé au contenu binaire. */
-typedef const char * (* describe_content_fc) (const GBinContent *, bool);
+typedef char * (* describe_content_fc) (const GBinContent *, bool);
/* Ecrit une sauvegarde de contenu binaire dans un fichier XML. */
typedef bool (* save_content_fc) (const GBinContent *, xmlDocPtr, xmlXPathContextPtr, const char *, const char *);
diff --git a/src/analysis/content.c b/src/analysis/content.c
index 86fa490..8b83261 100644
--- a/src/analysis/content.c
+++ b/src/analysis/content.c
@@ -197,14 +197,14 @@ GBinContent *g_binary_content_get_root(GBinContent *content)
* *
******************************************************************************/
-const char *g_binary_content_describe(const GBinContent *content, bool full)
+char *g_binary_content_describe(const GBinContent *content, bool full)
{
char *result; /* Description à retourner */
GBinContentIface *iface; /* Interface utilisée */
iface = G_BIN_CONTENT_GET_IFACE(content);
- result = strdup(iface->describe(content, full));
+ result = iface->describe(content, full);
return result;
@@ -418,11 +418,14 @@ const bin_t *g_binary_content_get_raw_access(const GBinContent *content, vmpa2t
bool g_binary_content_read_raw(const GBinContent *content, vmpa2t *addr, phys_t length, bin_t *out)
{
+ bool result; /* Bilan à remonter */
GBinContentIface *iface; /* Interface utilisée */
iface = G_BIN_CONTENT_GET_IFACE(content);
- return iface->read_raw(content, addr, length, out);
+ result = iface->read_raw(content, addr, length, out);
+
+ return result;
}
@@ -444,11 +447,14 @@ bool g_binary_content_read_raw(const GBinContent *content, vmpa2t *addr, phys_t
bool g_binary_content_read_u4(const GBinContent *content, vmpa2t *addr, bool *low, uint8_t *val)
{
+ bool result; /* Bilan à remonter */
GBinContentIface *iface; /* Interface utilisée */
iface = G_BIN_CONTENT_GET_IFACE(content);
- return iface->read_u4(content, addr, low, val);
+ result = iface->read_u4(content, addr, low, val);
+
+ return result;
}
@@ -470,11 +476,14 @@ bool g_binary_content_read_u4(const GBinContent *content, vmpa2t *addr, bool *lo
bool g_binary_content_read_u8(const GBinContent *content, vmpa2t *addr, uint8_t *val)
{
+ bool result; /* Bilan à remonter */
GBinContentIface *iface; /* Interface utilisée */
iface = G_BIN_CONTENT_GET_IFACE(content);
- return iface->read_u8(content, addr, val);
+ result = iface->read_u8(content, addr, val);
+
+ return result;
}
@@ -496,11 +505,14 @@ bool g_binary_content_read_u8(const GBinContent *content, vmpa2t *addr, uint8_t
bool g_binary_content_read_u16(const GBinContent *content, vmpa2t *addr, SourceEndian endian, uint16_t *val)
{
+ bool result; /* Bilan à remonter */
GBinContentIface *iface; /* Interface utilisée */
iface = G_BIN_CONTENT_GET_IFACE(content);
- return iface->read_u16(content, addr, endian, val);
+ result = iface->read_u16(content, addr, endian, val);
+
+ return result;
}
@@ -522,11 +534,14 @@ bool g_binary_content_read_u16(const GBinContent *content, vmpa2t *addr, SourceE
bool g_binary_content_read_u32(const GBinContent *content, vmpa2t *addr, SourceEndian endian, uint32_t *val)
{
+ bool result; /* Bilan à remonter */
GBinContentIface *iface; /* Interface utilisée */
iface = G_BIN_CONTENT_GET_IFACE(content);
- return iface->read_u32(content, addr, endian, val);
+ result = iface->read_u32(content, addr, endian, val);
+
+ return result;
}
@@ -548,11 +563,14 @@ bool g_binary_content_read_u32(const GBinContent *content, vmpa2t *addr, SourceE
bool g_binary_content_read_u64(const GBinContent *content, vmpa2t *addr, SourceEndian endian, uint64_t *val)
{
+ bool result; /* Bilan à remonter */
GBinContentIface *iface; /* Interface utilisée */
iface = G_BIN_CONTENT_GET_IFACE(content);
- return iface->read_u64(content, addr, endian, val);
+ result = iface->read_u64(content, addr, endian, val);
+
+ return result;
}
@@ -573,11 +591,14 @@ bool g_binary_content_read_u64(const GBinContent *content, vmpa2t *addr, SourceE
bool g_binary_content_read_uleb128(const GBinContent *content, vmpa2t *addr, uleb128_t *val)
{
+ bool result; /* Bilan à remonter */
GBinContentIface *iface; /* Interface utilisée */
iface = G_BIN_CONTENT_GET_IFACE(content);
- return iface->read_uleb128(content, addr, val);
+ result = iface->read_uleb128(content, addr, val);
+
+ return result;
}
@@ -598,10 +619,13 @@ bool g_binary_content_read_uleb128(const GBinContent *content, vmpa2t *addr, ule
bool g_binary_content_read_leb128(const GBinContent *content, vmpa2t *addr, leb128_t *val)
{
+ bool result; /* Bilan à remonter */
GBinContentIface *iface; /* Interface utilisée */
iface = G_BIN_CONTENT_GET_IFACE(content);
- return iface->read_leb128(content, addr, val);
+ result = iface->read_leb128(content, addr, val);
+
+ return result;
}
diff --git a/src/analysis/content.h b/src/analysis/content.h
index 9f901e7..d7f5536 100644
--- a/src/analysis/content.h
+++ b/src/analysis/content.h
@@ -68,7 +68,7 @@ GContentAttributes *g_binary_content_get_attributes(const GBinContent *);
GBinContent *g_binary_content_get_root(GBinContent *);
/* Fournit le nom associé au contenu binaire. */
-const char *g_binary_content_describe(const GBinContent *, bool);
+char *g_binary_content_describe(const GBinContent *, bool);
/* Ecrit une sauvegarde de contenu binaire dans un fichier XML. */
bool g_binary_content_save(const GBinContent *, xmlDocPtr, xmlXPathContextPtr, const char *, const char *);
diff --git a/src/analysis/contents/encapsulated.c b/src/analysis/contents/encapsulated.c
index 569df10..59b0c9e 100644
--- a/src/analysis/contents/encapsulated.c
+++ b/src/analysis/contents/encapsulated.c
@@ -74,7 +74,7 @@ static void g_encaps_content_finalize(GEncapsContent *);
static GBinContent *g_encaps_content_get_root(GEncapsContent *);
/* Fournit le nom associé au contenu binaire. */
-static const char *g_encaps_content_describe(const GEncapsContent *, bool);
+static char *g_encaps_content_describe(const GEncapsContent *, bool);
/* Ecrit une sauvegarde de contenu binaire dans un fichier XML. */
static bool g_encaps_content_save(const GEncapsContent *, xmlDocPtr, xmlXPathContextPtr, const char *, const char *);
@@ -296,7 +296,7 @@ GBinContent *g_encaps_content_new(GBinContent *base, const char *path, GBinConte
/* Description complète */
- result->full_desc = stradd(result->full_desc, g_binary_content_describe(result->base, true));
+ result->full_desc = g_binary_content_describe(result->base, true);
result->full_desc = stradd(result->full_desc, G_DIR_SEPARATOR_S);
@@ -416,14 +416,14 @@ static GBinContent *g_encaps_content_get_root(GEncapsContent *content)
* *
******************************************************************************/
-static const char *g_encaps_content_describe(const GEncapsContent *content, bool full)
+static char *g_encaps_content_describe(const GEncapsContent *content, bool full)
{
- const char *result; /* Description à retourner */
+ char *result; /* Description à retourner */
if (full)
- result = content->full_desc;
+ result = strdup(content->full_desc);
else
- result = content->desc;
+ result = strdup(content->desc);
return result;
diff --git a/src/analysis/contents/file.c b/src/analysis/contents/file.c
index b133336..7bb0be8 100644
--- a/src/analysis/contents/file.c
+++ b/src/analysis/contents/file.c
@@ -86,7 +86,7 @@ static GContentAttributes *g_file_content_get_attributes(const GFileContent *);
static GBinContent *g_file_content_get_root(GFileContent *);
/* Fournit le nom associé au contenu binaire. */
-static const char *g_file_content_describe(const GFileContent *, bool);
+static char *g_file_content_describe(const GFileContent *, bool);
/* Ecrit une sauvegarde de contenu binaire dans un fichier XML. */
static bool g_file_content_save(const GFileContent *, xmlDocPtr, xmlXPathContextPtr, const char *, const char *);
@@ -489,22 +489,23 @@ static GBinContent *g_file_content_get_root(GFileContent *content)
* *
******************************************************************************/
-static const char *g_file_content_describe(const GFileContent *content, bool full)
+static char *g_file_content_describe(const GFileContent *content, bool full)
{
- const char *result; /* Description à retourner */
+ char *result; /* Description à retourner */
+ const char *sep; /* Caractère de séparation */
if (full)
- result = content->filename;
+ result = strdup(content->filename);
else
{
- result = strrchr(content->filename, G_DIR_SEPARATOR);
+ sep = strrchr(content->filename, G_DIR_SEPARATOR);
- if (result == NULL)
- result = content->filename;
+ if (sep == NULL)
+ result = strdup(content->filename);
else
- result++;
+ result = strdup(++sep);
}
diff --git a/src/analysis/contents/memory.c b/src/analysis/contents/memory.c
index 232a41d..a37a7d4 100644
--- a/src/analysis/contents/memory.c
+++ b/src/analysis/contents/memory.c
@@ -77,7 +77,7 @@ static void g_memory_content_finalize(GMemoryContent *);
static GBinContent *g_memory_content_get_root(GMemoryContent *);
/* Fournit le nom associé au contenu binaire. */
-static const char *g_memory_content_describe(const GMemoryContent *, bool);
+static char *g_memory_content_describe(const GMemoryContent *, bool);
/* Ecrit une sauvegarde de contenu binaire dans un fichier XML. */
static bool g_memory_content_save(const GMemoryContent *, xmlDocPtr, xmlXPathContextPtr, const char *, const char *);
@@ -399,11 +399,11 @@ static GBinContent *g_memory_content_get_root(GMemoryContent *content)
* *
******************************************************************************/
-static const char *g_memory_content_describe(const GMemoryContent *content, bool full)
+static char *g_memory_content_describe(const GMemoryContent *content, bool full)
{
- const char *result; /* Description à retourner */
+ char *result; /* Description à retourner */
- result = "In-memory content";
+ result = strdup("In-memory content");
return result;
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 607f1e4..af67fdf 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -389,7 +389,7 @@ void output_disassembly(GLoadedBinary *binary, GProcContext *context, GtkStatusS
GBinContent *content; /* Contenu bianire manipulé */
GCodingLanguage *lang; /* Langage de sortie préféré */
char **text; /* Contenu brute à imprimer */
- const char *desc; /* Désignation du binaire */
+ char *desc; /* Désignation du binaire */
const gchar *checksum; /* Identifiant de binaire */
GIntroGenerator *generator; /* Générateur constitué */
@@ -420,6 +420,8 @@ void output_disassembly(GLoadedBinary *binary, GProcContext *context, GtkStatusS
asprintf(&text[2], "%s%s", _("Source: "), desc);
+ free(desc);
+
/* Checksum SHA256 */
checksum = g_binary_content_get_checksum(content);
diff --git a/src/gui/dialogs/export_disass.c b/src/gui/dialogs/export_disass.c
index beaa3c8..314b9cf 100644
--- a/src/gui/dialogs/export_disass.c
+++ b/src/gui/dialogs/export_disass.c
@@ -875,7 +875,7 @@ static void register_output_panel(GtkAssistant *assistant)
GtkWidget *entry; /* Zone de saisie de texte */
GtkWidget *button; /* Sélection de fichier */
GLoadedBinary *binary; /* Binaire chargé à parcourir */
- const char *filename; /* Chemin d'accès par défaut */
+ char *filename; /* Chemin d'accès par défaut */
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
qck_set_margins(vbox, 8, 8, 8, 8);
@@ -907,11 +907,13 @@ static void register_output_panel(GtkAssistant *assistant)
/* Choix par défaut */
binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(assistant), "binary"));
- filename = g_loaded_binary_get_name(binary, true);
+ filename = g_loaded_content_describe(G_LOADED_CONTENT(binary), true);
gtk_entry_set_text(GTK_ENTRY(entry), filename);
gtk_editable_insert_text(GTK_EDITABLE(entry), ".html", -1, (gint []) { strlen(filename) });
+ free(filename);
+
g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(on_export_filename_changed), assistant);
}
diff --git a/src/gui/panels/bintree.c b/src/gui/panels/bintree.c
index 220a31d..a949b0d 100644
--- a/src/gui/panels/bintree.c
+++ b/src/gui/panels/bintree.c
@@ -688,6 +688,7 @@ static void reload_portions_for_new_tree_view(const GBintreePanel *panel, GtkSta
GBinPortion *portions; /* Couche première de portions */
size_t count; /* Compteur de portions */
GtkTreeIter top; /* Racine de l'arborescence */
+ char *desc; /* Description de contenu */
gint max_depth; /* Profondeur maximale */
GtkSpinButton *depth_spin; /* Bouton de variation */
GtkTreeView *treeview; /* Arborescence constituée */
@@ -708,11 +709,15 @@ static void reload_portions_for_new_tree_view(const GBintreePanel *panel, GtkSta
gtk_tree_store_append(store, &top, NULL);
+ desc = g_loaded_content_describe(G_LOADED_CONTENT(panel->binary), false);
+
gtk_tree_store_set(store, &top,
BTC_ICON, NULL,
- BTC_CAPTION, g_loaded_binary_get_name(panel->binary, false),
+ BTC_CAPTION, desc,
-1);
+ free(desc);
+
data->panel = panel;
data->top = ⊤
data->status = status;