summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis')
-rwxr-xr-xsrc/analysis/Makefile.am2
-rw-r--r--src/analysis/binary.c41
-rw-r--r--src/analysis/line.c2
-rw-r--r--src/analysis/line.h2
-rw-r--r--src/analysis/line_code.c20
-rw-r--r--src/analysis/line_code.h2
6 files changed, 39 insertions, 30 deletions
diff --git a/src/analysis/Makefile.am b/src/analysis/Makefile.am
index 065704a..f763f53 100755
--- a/src/analysis/Makefile.am
+++ b/src/analysis/Makefile.am
@@ -1,5 +1,5 @@
-lib_LTLIBRARIES = libanalysis.la
+noinst_LTLIBRARIES = libanalysis.la
libanalysis_la_SOURCES = \
binary.h binary.c \
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index b606752..e5e14bc 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -46,8 +46,6 @@
-
-
#ifndef _
# define _(str) str
#endif
@@ -68,7 +66,7 @@ struct _openida_binary
uint8_t *bin_data; /* Données binaires brutes */
exe_format *format; /* Format du binaire */
- asm_processor *proc; /* Architecture du binaire */
+ GArchProcessor *proc; /* Architecture du binaire */
GRenderingLine *lines; /* Lignes de rendu en place */
disass_options options; /* Options de désassemblage */
@@ -116,9 +114,17 @@ openida_binary *load_binary_file(const char *filename)
result->format = load_new_exe_format(result->bin_data, result->bin_length);
if (result->format == NULL) goto lbf_error;
+ switch (get_exe_target_machine(result->format))
+ {
+ case FTM_JVM:
+ result->proc = get_arch_processor_for_type(APT_JVM);
+ break;
- result->proc = create_processor();
+ default:
+ goto lbf_error;
+ break;
+ }
result->options.show_address = true;
result->options.show_code = true;
@@ -573,7 +579,9 @@ GRenderingLine *build_binary_prologue(const char *filename, const uint8_t *data,
void disassemble_openida_binary(openida_binary *binary)
{
- asm_instr *instr;
+
+
+ GArchInstruction *instr;
bin_routine **routines; /* Liste des routines trouvées */
size_t routines_count; /* Nombre de ces routines */
@@ -591,7 +599,7 @@ void disassemble_openida_binary(openida_binary *binary)
off_t len;
uint64_t base = 0;
- uint64_t offset = 0;
+ vmpa_t addr = 0;
size_t i;
@@ -616,14 +624,16 @@ void disassemble_openida_binary(openida_binary *binary)
disass = get_one_plugin_for_action(PGA_DISASSEMBLE);
- if (disass != NULL)
+ if (0 && disass != NULL)
binary->lines = g_plugin_module_disassemble_binary_parts(disass, binary);
else
{
- parts = get_elf_default_code_parts(binary->format, &parts_count);
+ parts = get_java_default_code_parts(binary->format, &parts_count);
qsort(parts, parts_count, sizeof(bin_part *), compare_bin_parts);
+ printf("PARTS COUNT :: %d\n", parts_count);
+
for (i = 0; i < parts_count; i++)
{
get_bin_part_values(parts[i], &pos, &len, &base);
@@ -635,19 +645,18 @@ void disassemble_openida_binary(openida_binary *binary)
while (pos < len)
{
- offset = base + pos;
+ addr = base + pos;
- instr = decode_instruction(binary->proc, &binary->bin_data[start], &pos, len, start, offset);
+ instr = g_arch_processor_decode_instruction(binary->proc, &binary->bin_data[start], &pos, len, start, addr);
-
- line = g_code_line_new(offset, instr, &binary->options);
+ line = g_code_line_new(addr, instr, &binary->options);
g_rendering_line_add_to_lines(&binary->lines, line);
}
/* Ajout des prototypes de fonctions */
-
+#if 0
for (k = 0; k < routines_count; k++)
{
routine_offset = get_binary_routine_offset(routines[k]);
@@ -662,16 +671,16 @@ void disassemble_openida_binary(openida_binary *binary)
free(routine_desc);
}
-
+#endif
}
}
-
+ /*
line = g_rendering_line_find_by_offset(binary->lines, get_exe_entry_point(binary->format));
if (line != NULL) g_rendering_line_add_flag(line, RLF_ENTRY_POINT);
-
+ */
diff --git a/src/analysis/line.c b/src/analysis/line.c
index fb8295e..b1af518 100644
--- a/src/analysis/line.c
+++ b/src/analysis/line.c
@@ -38,8 +38,6 @@
-/* FIXME */
-//extern GtkWidget *mywid;
diff --git a/src/analysis/line.h b/src/analysis/line.h
index 0213cab..5744d24 100644
--- a/src/analysis/line.h
+++ b/src/analysis/line.h
@@ -60,7 +60,7 @@ typedef struct _disass_options
bool show_code; /* Affichage du code brut ? */
exe_format *format; /* Format du contenu bianire */
- asm_processor *proc; /* Architecture utilisée */
+ GArchProcessor *proc; /* Architecture utilisée */
} disass_options;
diff --git a/src/analysis/line_code.c b/src/analysis/line_code.c
index 2dd5a7c..44bb59f 100644
--- a/src/analysis/line_code.c
+++ b/src/analysis/line_code.c
@@ -37,7 +37,7 @@ struct _GCodeLine
{
GRenderingLine parent; /* Instance parente */
- asm_instr *instr; /* Instruction représentée */
+ GArchInstruction *instr; /* Instruction représentée */
const disass_options *options; /* Options de représentation */
};
@@ -133,7 +133,7 @@ void g_code_line_get_binary_len(GCodeLine *line, off_t *blen)
{
off_t len; /* Taille propre à la ligne */
- get_asm_instr_offset_and_length(line->instr, NULL, &len);
+ g_arch_instruction_get_location(line->instr, NULL, &len, NULL);
*blen = MAX(*blen, len);
@@ -158,7 +158,8 @@ void g_code_line_refresh_markup(GCodeLine *line)
char *content; /* Contenu réellement imprimé */
off_t bin_offset; /* Début de l'instruction */
off_t bin_len; /* Taille d'instruction */
- char buffer[CODE_BUFFER_LEN]; /* Zone tampon à utiliser */
+ char buffer[CODE_BUFFER_LEN]; /* Zone tampon à utiliser #1 */
+ char *buffer2; /* Zone tampon à utiliser #2 */
const uint8_t *exe_content; /* Contenu binaire global */
char *bin_code; /* Tampon du code binaire */
off_t k; /* Boucle de parcours #2 */
@@ -169,7 +170,7 @@ void g_code_line_refresh_markup(GCodeLine *line)
strcpy(content, "<tt>");
if (line->options->show_code)
- get_asm_instr_offset_and_length(line->instr, &bin_offset, &bin_len);
+ g_arch_instruction_get_location(line->instr, &bin_offset, &bin_len, NULL);
/* Eventuelle adresse virtuelle */
@@ -230,15 +231,16 @@ void g_code_line_refresh_markup(GCodeLine *line)
/* Instruction proprement dite */
- print_hinstruction(line->options->proc, line->options->format,
- line->instr, buffer, CODE_BUFFER_LEN, ASX_INTEL/*FIXME*/);
+ buffer2 = g_arch_instruction_get_text(line->instr, line->options->format, ASX_INTEL/*FIXME*/);
if (line->options->show_address || line->options->show_code) len += strlen("\t");
- len += strlen(buffer);
+ len += strlen(buffer2);
content = (char *)realloc(content, len * sizeof(char));
if (line->options->show_address || line->options->show_code) strcat(content, "\t");
- strcat(content, buffer);
+ strcat(content, buffer2);
+
+ free(buffer2);
/* Finalisation */
@@ -267,7 +269,7 @@ void g_code_line_refresh_markup(GCodeLine *line)
* *
******************************************************************************/
-GRenderingLine *g_code_line_new(uint64_t offset, asm_instr *instr, const disass_options *options)
+GRenderingLine *g_code_line_new(uint64_t offset, GArchInstruction *instr, const disass_options *options)
{
GCodeLine *result; /* Structure à retourner */
diff --git a/src/analysis/line_code.h b/src/analysis/line_code.h
index 3564038..8a06f28 100644
--- a/src/analysis/line_code.h
+++ b/src/analysis/line_code.h
@@ -52,7 +52,7 @@ typedef struct _GCodeLineClass GCodeLineClass;
GType g_code_line_get_type(void);
/* Crée une ligne de code binaire. */
-GRenderingLine *g_code_line_new(uint64_t, asm_instr *, const disass_options *);
+GRenderingLine *g_code_line_new(uint64_t, GArchInstruction *, const disass_options *);