diff options
Diffstat (limited to 'src/analysis/binary.c')
-rw-r--r-- | src/analysis/binary.c | 41 |
1 files changed, 25 insertions, 16 deletions
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); - + */ |