summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-02-09 20:15:52 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-02-09 20:15:52 (GMT)
commit8d326041a0379b87e54be44506d544367567e89b (patch)
treea3c3555c27c30858155fbee4df0ca236f33774f8 /src/format
parentb70f428256963385a140e9eb503624106df5aa9b (diff)
Registered all the supported processors in the system code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@467 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format')
-rwxr-xr-xsrc/format/dex/dex.c6
-rw-r--r--src/format/elf/elf.c14
-rw-r--r--src/format/elf/helper_arm.c2
-rw-r--r--src/format/elf/helper_x86.c2
-rw-r--r--src/format/elf/symbols.c6
-rw-r--r--src/format/executable-int.h2
-rw-r--r--src/format/executable.c2
-rw-r--r--src/format/executable.h18
-rw-r--r--src/format/format.c15
-rw-r--r--src/format/format.h2
-rwxr-xr-xsrc/format/java/java.c29
-rw-r--r--src/format/pe/pe.c29
12 files changed, 29 insertions, 98 deletions
diff --git a/src/format/dex/dex.c b/src/format/dex/dex.c
index f66f056..c5271e0 100755
--- a/src/format/dex/dex.c
+++ b/src/format/dex/dex.c
@@ -52,7 +52,7 @@ static void g_dex_format_find_all_sources(GDexFormat *);
static void g_dex_format_decompile(const GDexFormat *, GCodeBuffer *, const char *);
/* Indique le type d'architecture visée par le format. */
-static FormatTargetMachine g_dex_format_get_target_machine(const GDexFormat *);
+static const char *g_dex_format_get_target_machine(const GDexFormat *);
/* Fournit les références aux zones binaires à analyser. */
//static GBinPart **g_dex_format_get_parts(const GDexFormat *, size_t *);
@@ -342,9 +342,9 @@ char *_g_data_type_to_string(const GDataType *type, bool simple)
* *
******************************************************************************/
-static FormatTargetMachine g_dex_format_get_target_machine(const GDexFormat *format)
+static const char *g_dex_format_get_target_machine(const GDexFormat *format)
{
- return FTM_DALVIK;
+ return "dalvik";
}
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c
index b659dd7..cc84335 100644
--- a/src/format/elf/elf.c
+++ b/src/format/elf/elf.c
@@ -57,7 +57,7 @@ static void g_elf_format_class_init(GElfFormatClass *);
static void g_elf_format_init(GElfFormat *);
/* Indique le type d'architecture visée par le format. */
-static FormatTargetMachine g_elf_format_get_target_machine(const GElfFormat *);
+static const char *g_elf_format_get_target_machine(const GElfFormat *);
/* Etend la définition des portions au sein d'un binaire. */
static void g_elf_format_refine_portions(const GElfFormat *, GBinPortion *);
@@ -239,27 +239,27 @@ GBinFormat *g_elf_format_new(const bin_t *content, off_t length)
* *
******************************************************************************/
-static FormatTargetMachine g_elf_format_get_target_machine(const GElfFormat *format)
+static const char *g_elf_format_get_target_machine(const GElfFormat *format)
{
- FormatTargetMachine result; /* Identifiant à retourner */
+ const char *result; /* Identifiant à retourner */
switch (ELF_HDR(format, format->header, e_machine))
{
case EM_386:
- result = FTM_386;
+ result = "i386";
break;
case EM_MIPS:
- result = FTM_MIPS;
+ result = "mips";
break;
case EM_ARM:
- result = FTM_ARM;
+ result = "armv7";
break;
case EM_NONE:
default:
- result = FTM_NONE;
+ result = NULL;
break;
}
diff --git a/src/format/elf/helper_arm.c b/src/format/elf/helper_arm.c
index d5e8af8..7282d23 100644
--- a/src/format/elf/helper_arm.c
+++ b/src/format/elf/helper_arm.c
@@ -362,7 +362,7 @@ GArchInstruction **decode_elf_relocations(GElfFormat *format, const elf_shdr *pl
get_elf_section_content(format, plt, &plt_start, &plt_size, &plt_address);
- proc = get_arch_processor_for_type(APT_386);
+ proc = NULL;//get_arch_processor_for_type(APT_386);
for (pos = 0; pos < plt_size; )
{
diff --git a/src/format/elf/helper_x86.c b/src/format/elf/helper_x86.c
index 708a7e1..742d1c3 100644
--- a/src/format/elf/helper_x86.c
+++ b/src/format/elf/helper_x86.c
@@ -216,7 +216,7 @@ GArchInstruction **decode_elf_relocations(GElfFormat *format, const elf_shdr *pl
get_elf_section_content(format, plt, &plt_start, &plt_size, &plt_address);
- proc = get_arch_processor_for_type(APT_386);
+ proc = NULL;//get_arch_processor_for_type(APT_386);
for (pos = 0; pos < plt_size; )
{
diff --git a/src/format/elf/symbols.c b/src/format/elf/symbols.c
index 2d8057e..31fbabd 100644
--- a/src/format/elf/symbols.c
+++ b/src/format/elf/symbols.c
@@ -1852,13 +1852,13 @@ static bool load_elf_external_symbols(GElfFormat *format, const elf_shdr *sectio
result = find_elf_section_by_index(format, ELF_SHDR(format, dynsym, sh_link), &dynstr);
if (result)
- switch (g_exe_format_get_target_machine(G_EXE_FORMAT(format)))
+ switch (ELF_HDR(format, format->header, e_machine))
{
- case FTM_ARM:
+ case EM_ARM:
result = load_elf_arm_relocated_symbols(format, &relxxx, &dynsym, &dynstr);
break;
- case FTM_386:
+ case EM_386:
result = load_elf_x86_relocated_symbols(format, &relxxx, &dynsym, &dynstr);
break;
diff --git a/src/format/executable-int.h b/src/format/executable-int.h
index 119c251..59a513e 100644
--- a/src/format/executable-int.h
+++ b/src/format/executable-int.h
@@ -33,7 +33,7 @@
/* Indique le type d'architecture visée par le format. */
-typedef FormatTargetMachine (* get_target_machine_fc) (const GExeFormat *);
+typedef const char * (* get_target_machine_fc) (const GExeFormat *);
/* Etend la définition des portions au sein d'un binaire. */
typedef void (* refine_portions_fc) (const GExeFormat *, GBinPortion *);
diff --git a/src/format/executable.c b/src/format/executable.c
index c1a0a7c..319d3dd 100644
--- a/src/format/executable.c
+++ b/src/format/executable.c
@@ -102,7 +102,7 @@ static void g_executable_format_init(GExeFormat *format)
* *
******************************************************************************/
-FormatTargetMachine g_exe_format_get_target_machine(const GExeFormat *format)
+const char *g_exe_format_get_target_machine(const GExeFormat *format)
{
return format->get_machine(format);
diff --git a/src/format/executable.h b/src/format/executable.h
index 4dc2ddd..0607a0e 100644
--- a/src/format/executable.h
+++ b/src/format/executable.h
@@ -32,22 +32,6 @@
-/* Architectures de destination des formats */
-typedef enum _FormatTargetMachine
-{
- FTM_NONE, /* Aucune archi. (reconnue) */
-
- FTM_ARM, /* ARM vX */
- FTM_DALVIK, /* Dalvik Virtual Machine */
- FTM_JVM, /* Java Virtual Machine */
- FTM_MIPS, /* Mips 32 ou 64 bits */
- FTM_386, /* Intel 80386 */
-
- FTM_COUNT
-
-} FormatTargetMachine;
-
-
#define G_TYPE_EXE_FORMAT g_executable_format_get_type()
#define G_EXE_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_executable_format_get_type(), GExeFormat))
#define G_IS_EXE_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_executable_format_get_type()))
@@ -69,7 +53,7 @@ GType g_executable_format_get_type(void);
/* Indique le type d'architecture visée par le format. */
-FormatTargetMachine g_exe_format_get_target_machine(const GExeFormat *);
+const char *g_exe_format_get_target_machine(const GExeFormat *);
/* Décrit les différentes portions qui composent le binaire. */
GBinPortion *g_exe_format_get_portions(GExeFormat *);
diff --git a/src/format/format.c b/src/format/format.c
index 73e6794..b44d8ed 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -182,29 +182,22 @@ const bin_t *g_binary_format_get_content(const GBinFormat *format, off_t *length
/******************************************************************************
* *
* Paramètres : format = description de l'exécutable à consulter. *
+* ctx = contexte de désassemblage à préparer. *
* *
* Description : Fournit un contexte initialisé pour un désassemblage. *
* *
-* Retour : Nouveau contexte pour désassemblage prêt à emploi. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-GProcContext *g_binary_format_get_disassembling_context(const GBinFormat *format)
+void g_binary_format_setup_disassembling_context(const GBinFormat *format, GProcContext *ctx)
{
- GProcContext *result; /* Contexte à retourner */
- GArchProcessor *proc; /* Architecture du binaire */
size_t i; /* Boucle de parcours */
- proc = get_arch_processor_from_format(G_EXE_FORMAT(format));
-
- result = g_arch_processor_get_context(proc);
-
for (i = 0; i < format->ep_count; i++)
- g_proc_context_push_drop_point(result, format->entry_points[i]);
-
- return result;
+ g_proc_context_push_drop_point(ctx, format->entry_points[i]);
}
diff --git a/src/format/format.h b/src/format/format.h
index d2034ef..0ac658b 100644
--- a/src/format/format.h
+++ b/src/format/format.h
@@ -60,7 +60,7 @@ GType g_binary_format_get_type(void);
const bin_t *g_binary_format_get_content(const GBinFormat *, off_t *);
/* Fournit un contexte initialisé pour un désassemblage. */
-GProcContext *g_binary_format_get_disassembling_context(const GBinFormat *);
+void g_binary_format_setup_disassembling_context(const GBinFormat *, GProcContext *);
/* Ajoute un symbole à la collection du format binaire. */
void g_binary_format_add_symbol(GBinFormat *, GBinSymbol *);
diff --git a/src/format/java/java.c b/src/format/java/java.c
index 16c9fb7..e477b82 100755
--- a/src/format/java/java.c
+++ b/src/format/java/java.c
@@ -46,7 +46,7 @@ static void g_java_format_class_init(GJavaFormatClass *);
static void g_java_format_init(GJavaFormat *);
/* Indique le type d'architecture visée par le format. */
-static FormatTargetMachine g_java_format_get_target_machine(const GJavaFormat *);
+static const char *g_java_format_get_target_machine(const GJavaFormat *);
/* Fournit la position correspondant à une adresse virtuelle. */
static bool g_java_format_translate_address_into_offset(const GJavaFormat *, vmpa_t, off_t *);
@@ -181,32 +181,9 @@ GBinFormat *g_java_format_new(const bin_t *content, off_t length)
* *
******************************************************************************/
-static FormatTargetMachine g_java_format_get_target_machine(const GJavaFormat *format)
+static const char *g_java_format_get_target_machine(const GJavaFormat *format)
{
- FormatTargetMachine result; /* Identifiant à retourner */
-
- result = FTM_386;
-
- /*
- switch (format->header.e_machine)
- {
- case EM_MIPS:
- result = FTM_MIPS;
- break;
-
- case EM_386:
- result = FTM_386;
- break;
-
- case EM_NONE:
- default:
- result = FTM_NONE;
- break;
-
- }
- */
-
- return result;
+ return "jvm";
}
diff --git a/src/format/pe/pe.c b/src/format/pe/pe.c
index 16a9032..88756dd 100644
--- a/src/format/pe/pe.c
+++ b/src/format/pe/pe.c
@@ -40,7 +40,7 @@ static void g_pe_format_class_init(GPeFormatClass *);
static void g_pe_format_init(GPeFormat *);
/* Indique le type d'architecture visée par le format. */
-static FormatTargetMachine g_pe_format_get_target_machine(const GPeFormat *);
+static const char *g_pe_format_get_target_machine(const GPeFormat *);
/* Fournit les références aux zones binaires à analyser. */
//static GBinPart **g_pe_format_get_parts(const GPeFormat *, size_t *);
@@ -220,32 +220,9 @@ GBinFormat *g_pe_format_new(const bin_t *content, off_t length)
* *
******************************************************************************/
-static FormatTargetMachine g_pe_format_get_target_machine(const GPeFormat *format)
+static const char *g_pe_format_get_target_machine(const GPeFormat *format)
{
- FormatTargetMachine result; /* Identifiant à retourner */
-
- result = FTM_386;
-
- /*
- switch (format->header.e_machine)
- {
- case EM_MIPS:
- result = FTM_MIPS;
- break;
-
- case EM_386:
- result = FTM_386;
- break;
-
- case EM_NONE:
- default:
- result = FTM_NONE;
- break;
-
- }
- */
-
- return result;
+ return "i386";
}