summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-07-16 00:17:48 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-07-16 00:17:48 (GMT)
commita61f089babe336b012da31a494b0f7470b6e1a9a (patch)
tree0dccd2fe50375e84de49b1119a3feec68b6bd23d /src/analysis
parent46c8fd10ec5bff1ee1146a0b6a7aa7eb9f47a2da (diff)
Used the binary contents a little bit more.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@551 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/binary.c23
-rw-r--r--src/analysis/binary.h3
-rw-r--r--src/analysis/disass/area.c25
-rw-r--r--src/analysis/disass/fetch.c7
4 files changed, 17 insertions, 41 deletions
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index 7e16990..e5b9a46 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -938,29 +938,6 @@ const char *g_loaded_binary_get_name(const GLoadedBinary *binary, bool full)
/******************************************************************************
* *
* Paramètres : binary = élément binaire à consulter. *
-* length = taille en octets des données chargées. [OUT] *
-* *
-* Description : Fournit les détails du contenu binaire chargé en mémoire. *
-* *
-* Retour : Pointeur vers le début des données. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bin_t *g_loaded_binary_get_data(const GLoadedBinary *binary, off_t *length)
-{
- if (length != NULL)
- *length = binary->bin_length;
-
- return binary->bin_data;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : binary = élément binaire à consulter. *
* *
* Description : Fournit le format de fichier reconnu dans le contenu binaire.*
* *
diff --git a/src/analysis/binary.h b/src/analysis/binary.h
index 163caaa..b67881c 100644
--- a/src/analysis/binary.h
+++ b/src/analysis/binary.h
@@ -151,9 +151,6 @@ void g_loaded_binary_analyse(GLoadedBinary *);
/* Fournit le nom associé à l'élément binaire. */
const char *g_loaded_binary_get_name(const GLoadedBinary *, bool);
-/* Fournit les détails du contenu binaire chargé en mémoire. */
-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 *);
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index 4c54a27..a7c44c0 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -474,8 +474,7 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
GBinFormat *format; /* Format du fichier binaire */
GArchProcessor *proc; /* Architecture du binaire */
- off_t bin_length; /* Taille des données à lire */
- bin_t *bin_data; /* Données binaires à lire */
+ GBinContent *content; /* Données binaires à lire */
phys_t diff; /* Volume de données traité */
phys_t alen; /* Taille de l'aire utilisée */
@@ -510,7 +509,8 @@ 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);
- bin_data = g_loaded_binary_get_data(binary, &bin_length);
+ content = g_binary_format_get_conten_(format);
+ /* TODO : unref */
area = (*list) + *index;
@@ -532,8 +532,6 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
printf(" START @ 0x%08x\n", (unsigned int)get_virt_addr(&pos));
- bin_length = (get_phy_addr(get_mrange_addr(&area->range)) + alen);
-
for (i = diff; i < alen; i += diff)
{
@@ -544,7 +542,9 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
copy_vmpa(&prev, &pos);
- instr = g_arch_processor_disassemble(proc, ctx, bin_data, &pos, bin_length);
+ instr = g_arch_processor_disassemble(proc, ctx, content, &pos);
+
+ /* TODO : valider que la taille de l'instruction obtenue ne dépasse pas la zone */
//printf(" @ 0x%08x -> %p\n", (uint32_t)get_virt_addr(&prev), instr);
@@ -660,10 +660,9 @@ bool load_code_from_mem_area(mem_area **list, size_t *count, size_t *index, cons
static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count, const GLoadedBinary *binary, GProcContext *ctx, const vmpa2t *start, status_blob_info *info)
{
GBinFormat *format; /* Format du fichier binaire */
+ GBinContent *content; /* Données binaires à lire */
GArchProcessor *proc; /* Architecture du binaire */
SourceEndian endianness; /* Boutisme de cette machine */
- off_t bin_length; /* Taille des données à lire */
- bin_t *bin_data; /* Données binaires à lire */
phys_t diff; /* Volume de données traité */
phys_t alen; /* Taille de l'aire utilisée */
phys_t i; /* Boucle de parcours */
@@ -681,13 +680,13 @@ 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);
+ /* TODO g_object_unref(G_OBJECT(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);
alen = get_mrange_length(&area->range);
@@ -718,7 +717,7 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
init_mrange(&range, &pos, 4);
if (is_range_blank_in_mem_areas(list, count, &range))
- instr = g_raw_instruction_new_array_old(bin_data, MDS_32_BITS, 1, &pos, bin_length, endianness);
+ instr = g_raw_instruction_new_array(content, MDS_32_BITS, 1, &pos, endianness);
}
*/
@@ -728,7 +727,7 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
init_mrange(&range, &pos, 2);
if (is_range_blank_in_mem_areas(list, count, &range))
- instr = g_raw_instruction_new_array_old(bin_data, MDS_16_BITS, 1, &pos, bin_length, endianness);
+ instr = g_raw_instruction_new_array(content, MDS_16_BITS, 1, &pos, endianness);
}
@@ -738,7 +737,7 @@ static void load_data_from_mem_area(mem_area *area, mem_area *list, size_t count
init_mrange(&range, &pos, 1);
if (is_range_blank_in_mem_areas(list, count, &range))
- instr = g_raw_instruction_new_array_old(bin_data, MDS_8_BITS, 1, &pos, bin_length, endianness);
+ instr = g_raw_instruction_new_array(content, MDS_8_BITS, 1, &pos, endianness);
else
{
/**
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c
index b30d5a6..d7de724 100644
--- a/src/analysis/disass/fetch.c
+++ b/src/analysis/disass/fetch.c
@@ -148,7 +148,8 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt
GBinFormat *format; /* Format du fichier binaire */
GArchProcessor *proc; /* Architecture du binaire */
GProcContext *ctx; /* Contexte de désassemblage */
- off_t length; /* Taille des données à lire */
+ GBinContent *content; /* Contenu binaire à manipuler */
+ phys_t length; /* Taille des données à lire */
mem_area *areas; /* Zone de productions */
size_t count; /* Nombre de ces zones */
status_blob_info *info; /* Informations de progression */
@@ -168,7 +169,9 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GtkExt
/* Définition à la découpe des parties à traiter */
- g_loaded_binary_get_data(binary, &length);
+ content = g_binary_format_get_conten_(format);
+ length = g_binary_content_compute_size(content);
+
areas = compute_memory_areas(G_EXE_FORMAT(format), length, &count);
/**