summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-07-24 18:43:55 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-07-24 18:43:55 (GMT)
commit156d2e2f6beda2302552ac79678494d914fda05b (patch)
tree021825960b7ac3315a336fc085a4f1d07c05df39 /src/analysis
parent21537636cd8318cf5a720211619ad3c3023b52e9 (diff)
Replaced all remaining raw accesses to binary contents with the GBinContent wrapper in binary formats.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@555 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binaries/file.c8
-rw-r--r--src/analysis/binary-int.h3
-rw-r--r--src/analysis/binary.c3
-rw-r--r--src/analysis/disass/area.c8
-rw-r--r--src/analysis/disass/disassembler.c4
-rw-r--r--src/analysis/disass/fetch.c4
-rw-r--r--src/analysis/disass/output.c5
7 files changed, 20 insertions, 15 deletions
diff --git a/src/analysis/binaries/file.c b/src/analysis/binaries/file.c
index d49ecb4..c946572 100644
--- a/src/analysis/binaries/file.c
+++ b/src/analysis/binaries/file.c
@@ -173,11 +173,6 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename)
content = g_binary_content_new_from_file(filename);
if (content == NULL) goto lbf_error;
- /////
- loaded->bin_data = g_binary_content_get(content, &loaded->bin_length);
- ///////
-
-
target = find_matching_format(content);
desc = get_binary_format_name(target);
@@ -194,6 +189,7 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename)
if (loaded->format == NULL)
{
+ g_object_unref(G_OBJECT(content));
log_simple_message(LMT_ERROR, _("Error while loading the binary"));
goto lbf_error;
}
@@ -203,6 +199,7 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename)
if (desc == NULL)
{
+ g_object_unref(G_OBJECT(loaded->format));
log_simple_message(LMT_INFO, _("Unknown architecture"));
goto lbf_error;
}
@@ -213,6 +210,7 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename)
if (loaded->proc == NULL)
{
+ g_object_unref(G_OBJECT(loaded->format));
log_simple_message(LMT_ERROR, _("Unable to load the required processor"));
goto lbf_error;
}
diff --git a/src/analysis/binary-int.h b/src/analysis/binary-int.h
index c2657ae..64a957d 100644
--- a/src/analysis/binary-int.h
+++ b/src/analysis/binary-int.h
@@ -60,9 +60,6 @@ struct _GLoadedBinary
save_binary_fc save; /* Sauvegarde au format XML */
get_binary_name_fc get_name; /* Obtention d'une description */
- off_t bin_length; /* Taille des données brutes */
- bin_t *bin_data; /* Données binaires brutes */
-
GExeFormat *format; /* Format du binaire */
GArchProcessor *proc; /* Architecture du binaire */
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index ade1131..06f6b13 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -701,8 +701,9 @@ bool g_loaded_binary_connect(GLoadedBinary *binary)
/* Détermination de l'identifiant */
- content = g_binary_format_get_conten_(G_BIN_FORMAT(binary->format));
+ content = g_binary_format_get_content(G_BIN_FORMAT(binary->format));
checksum = g_binary_content_get_cheksum(content);
+ g_object_unref(G_OBJECT(content));
binary->local = g_db_client_new(g_loaded_binary_get_name(binary, false),
checksum,
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index dd35eaa..3338b03 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -509,7 +509,7 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
proc = g_loaded_binary_get_processor(binary);
- content = g_binary_format_get_conten_(format);
+ content = g_binary_format_get_content(format);
/* TODO : unref */
area = (*list) + *index;
@@ -632,6 +632,8 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
printf("\n");
+ g_object_unref(G_OBJECT(content));
+
g_object_unref(G_OBJECT(proc));
return result;
@@ -680,7 +682,7 @@ 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));
- content = g_binary_format_get_conten_(format);
+ content = g_binary_format_get_content(format);
/* TODO g_object_unref(G_OBJECT(format)); */
proc = g_loaded_binary_get_processor(binary);
@@ -793,6 +795,8 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
}
+ g_object_unref(G_OBJECT(content));
+
}
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index 2b518f9..cd16429 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -700,8 +700,10 @@ void disassemble_binary(GLoadedBinary *binary, GArchInstruction **instrs, GCodeB
*buffer = g_code_buffer_new(BLC_ASSEMBLY);
format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
- content = g_binary_format_get_conten_(format);
+
+ content = g_binary_format_get_content(format);
checksum = g_binary_content_get_cheksum(content);
+ g_object_unref(G_OBJECT(content));
build_disass_prologue(*buffer, g_loaded_binary_get_name(binary, true), checksum);
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c
index d7de724..9ebe231 100644
--- a/src/analysis/disass/fetch.c
+++ b/src/analysis/disass/fetch.c
@@ -169,7 +169,7 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt
/* Définition à la découpe des parties à traiter */
- content = g_binary_format_get_conten_(format);
+ content = g_binary_format_get_content(format);
length = g_binary_content_compute_size(content);
areas = compute_memory_areas(G_EXE_FORMAT(format), length, &count);
@@ -235,6 +235,8 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt
/* free */
+ g_object_unref(G_OBJECT(content));
+
g_object_unref(G_OBJECT(proc));
return result;
diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c
index 91c865a..d698c71 100644
--- a/src/analysis/disass/output.c
+++ b/src/analysis/disass/output.c
@@ -58,7 +58,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
GLangOutput *output; /* Modèle de sortie adéquat */
//GArchProcessor *proc; /* Architecture du binaire */
MemoryDataSize msize; /* Taille du bus d'adresses */
- const bin_t *content; /* Contenu binaire global */
+ const GBinContent *content; /* Contenu binaire global */
#if 0
const mrange_t *range; /* Cou
@@ -130,7 +130,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
//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);
+ content = g_binary_format_get_content(G_BIN_FORMAT(format));
#if 0
g_arch_instruction_get_location(instrs, NULL, NULL, &start);
@@ -276,6 +276,7 @@ void print_disassembled_instructions(GCodeBuffer *buffer, const GExeFormat *form
}
+ g_object_unref(G_OBJECT(content));
/* free portions... */