diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-05-21 12:08:29 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-05-21 12:08:29 (GMT) |
commit | 7e5b1add6fdeb74b2356acf8ccf7009f45cfa85e (patch) | |
tree | b7373554017e97fcbe24db79d9818272764e858d | |
parent | 5dd935b27a765177960bdfe4d2fcb296cbbd41da (diff) |
Changed the hierarchy of format objects.
51 files changed, 462 insertions, 610 deletions
diff --git a/plugins/arm/v7/fetch.c b/plugins/arm/v7/fetch.c index a24f99a..876ad51 100644 --- a/plugins/arm/v7/fetch.c +++ b/plugins/arm/v7/fetch.c @@ -33,6 +33,7 @@ #include <arch/instructions/raw.h> #include <arch/operands/immediate.h> #include <arch/operands/register.h> +#include <format/known.h> #include <format/format.h> #include <format/preload.h> @@ -457,7 +458,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst base = G_BIN_FORMAT(format); - content = g_binary_format_get_content(base); + content = g_known_format_get_content(G_KNOWN_FORMAT(base)); endian = g_binary_format_get_endianness(base); diff --git a/plugins/devdbg/speed.c b/plugins/devdbg/speed.c index c8416d1..c643a91 100644 --- a/plugins/devdbg/speed.c +++ b/plugins/devdbg/speed.c @@ -155,7 +155,7 @@ static void show_elapsed_time(const char *title, const speed_measure *measure) * * ******************************************************************************/ -G_MODULE_EXPORT bool chrysalide_plugin_handle_binary_format_analysis(const GPluginModule *plugin, PluginAction action, GBinFormat *format, wgroup_id_t gid, GtkStatusStack *status) +G_MODULE_EXPORT bool chrysalide_plugin_handle_binary_format_analysis(const GPluginModule *plugin, PluginAction action, GKnownFormat *format, wgroup_id_t gid, GtkStatusStack *status) { speed_measure *measure; /* Suivi des progressions */ struct timeval point; /* Point de mesure courant */ diff --git a/plugins/devdbg/speed.h b/plugins/devdbg/speed.h index 2347706..245ae15 100644 --- a/plugins/devdbg/speed.h +++ b/plugins/devdbg/speed.h @@ -31,7 +31,7 @@ /* Procède à une opération liée à l'analyse d'un format. */ -G_MODULE_EXPORT bool chrysalide_plugin_handle_binary_format_analysis(const GPluginModule *, PluginAction, GBinFormat *, wgroup_id_t, GtkStatusStack *); +G_MODULE_EXPORT bool chrysalide_plugin_handle_binary_format_analysis(const GPluginModule *, PluginAction, GKnownFormat *, wgroup_id_t, GtkStatusStack *); /* Exécute une action pendant un désassemblage de binaire. */ G_MODULE_EXPORT void chrysalide_plugin_process_disassembly_event(const GPluginModule *, PluginAction , GLoadedBinary *, GtkStatusStack *, GProcContext *); diff --git a/plugins/dex/dex-int.c b/plugins/dex/dex-int.c index c8989d7..5b59a2f 100644 --- a/plugins/dex/dex-int.c +++ b/plugins/dex/dex-int.c @@ -67,7 +67,7 @@ bool read_dex_header(const GDexFormat *format, vmpa2t *pos, dex_header *header) result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; for (i = 0; i < DEX_FILE_MAGIC_LEN && result; i++) result = g_binary_content_read_u8(content, pos, &header->magic[i]); @@ -133,7 +133,7 @@ bool read_dex_string_id_item(const GDexFormat *format, vmpa2t *pos, string_id_it /* Respect de l'alignement sur 4 octets */ if (get_phy_addr(pos) % 4 != 0) return false; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_u32(content, pos, SRE_LITTLE, &str_id->string_data_off); @@ -170,7 +170,7 @@ bool read_dex_string_data_item(const GDexFormat *format, vmpa2t *pos, vmpa2t *in size_t used; /* Quantié d'octets consommés */ unichar_t ch; /* Unité de code MUTF-8 */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_uleb128(content, pos, &str_data->utf16_size); @@ -260,7 +260,7 @@ bool read_dex_type_id_item(const GDexFormat *format, vmpa2t *pos, type_id_item * /* Respect de l'alignement sur 4 octets */ if (get_phy_addr(pos) % 4 != 0) return false; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_u32(content, pos, SRE_LITTLE, &item->descriptor_idx); @@ -291,7 +291,7 @@ bool read_dex_proto_id_item(const GDexFormat *format, vmpa2t *pos, proto_id_item /* Respect de l'alignement sur 4 octets */ if (get_phy_addr(pos) % 4 != 0) return false; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_u32(content, pos, SRE_LITTLE, &proto_id->shorty_idx); result &= g_binary_content_read_u32(content, pos, SRE_LITTLE, &proto_id->return_type_idx); @@ -324,7 +324,7 @@ bool read_dex_field_id_item(const GDexFormat *format, vmpa2t *pos, field_id_item /* Respect de l'alignement sur 4 octets */ if (get_phy_addr(pos) % 4 != 0) return false; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_u16(content, pos, SRE_LITTLE, &field_id->class_idx); result &= g_binary_content_read_u16(content, pos, SRE_LITTLE, &field_id->type_idx); @@ -357,7 +357,7 @@ bool read_dex_method_id_item(const GDexFormat *format, vmpa2t *pos, method_id_it /* Respect de l'alignement sur 4 octets */ if (get_phy_addr(pos) % 4 != 0) return false; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_u16(content, pos, SRE_LITTLE, &meth_id->class_idx); result &= g_binary_content_read_u16(content, pos, SRE_LITTLE, &meth_id->proto_idx); @@ -390,7 +390,7 @@ bool read_dex_class_def_item(const GDexFormat *format, vmpa2t *pos, class_def_it /* Respect de l'alignement sur 4 octets */ if (get_phy_addr(pos) % 4 != 0) return false; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_u32(content, pos, SRE_LITTLE, &class_def->class_idx); result &= g_binary_content_read_u32(content, pos, SRE_LITTLE, &class_def->access_flags); @@ -433,7 +433,7 @@ bool read_dex_encoded_field(const GDexFormat *format, vmpa2t *pos, encoded_field result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result &= g_binary_content_read_uleb128(content, pos, &field->field_idx_diff); result &= g_binary_content_read_uleb128(content, pos, &field->access_flags); @@ -464,7 +464,7 @@ bool read_dex_encoded_method(const GDexFormat *format, vmpa2t *pos, encoded_meth result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; copy_vmpa(&method->origin, pos); @@ -496,7 +496,7 @@ bool read_dex_type_item(const GDexFormat *format, vmpa2t *pos, type_item *item) bool result; /* Bilan à retourner */ GBinContent *content; /* Contenu binaire à lire */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_u16(content, pos, SRE_LITTLE, &item->type_idx); @@ -529,7 +529,7 @@ bool read_dex_type_list(const GDexFormat *format, vmpa2t *pos, type_list *list) result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result &= g_binary_content_read_u32(content, pos, SRE_LITTLE, &list->size); @@ -568,7 +568,7 @@ bool read_dex_class_data_item(const GDexFormat *format, vmpa2t *pos, class_data_ item->direct_methods = NULL; item->virtual_methods = NULL; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result &= g_binary_content_read_uleb128(content, pos, &item->static_fields_size); result &= g_binary_content_read_uleb128(content, pos, &item->instance_fields_size); @@ -679,7 +679,7 @@ bool read_dex_encoded_type_addr_pair(const GDexFormat *format, vmpa2t *pos, enco result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result &= g_binary_content_read_uleb128(content, pos, &pair->type_idx); result &= g_binary_content_read_uleb128(content, pos, &pair->addr); @@ -712,7 +712,7 @@ bool read_dex_encoded_catch_handler(const GDexFormat *format, vmpa2t *pos, encod result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; handler->offset = get_phy_addr(pos); @@ -786,7 +786,7 @@ bool read_dex_encoded_catch_handler_list(const GDexFormat *format, vmpa2t *pos, saved_off = get_phy_addr(pos); - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result &= g_binary_content_read_uleb128(content, pos, &list->size); @@ -857,7 +857,7 @@ bool read_dex_try_item(const GDexFormat *format, vmpa2t *pos, try_item *item) result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result &= g_binary_content_read_u32(content, pos, SRE_LITTLE, &item->start_addr); result &= g_binary_content_read_u16(content, pos, SRE_LITTLE, &item->insn_count); @@ -895,7 +895,7 @@ bool read_dex_code_item(const GDexFormat *format, vmpa2t *pos, code_item *item) result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result &= g_binary_content_read_u16(content, pos, SRE_LITTLE, &item->registers_size); result &= g_binary_content_read_u16(content, pos, SRE_LITTLE, &item->ins_size); @@ -1018,7 +1018,7 @@ bool read_dex_packed_switch(const GDexFormat *format, vmpa2t *pos, packed_switch packed->targets = NULL; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result &= g_binary_content_read_u16(content, pos, SRE_LITTLE, &packed->ident); result &= g_binary_content_read_u16(content, pos, SRE_LITTLE, &packed->size); @@ -1083,7 +1083,7 @@ bool read_dex_sparse_switch(const GDexFormat *format, vmpa2t *pos, sparse_switch result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; sparse->keys = NULL; sparse->targets = NULL; @@ -1157,7 +1157,7 @@ bool read_dex_switch(const GDexFormat *format, vmpa2t *pos, dex_switch *dswitch) result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result &= g_binary_content_read_u16(content, pos, SRE_LITTLE, &ident); diff --git a/plugins/dex/format.c b/plugins/dex/format.c index 495f327..84ddb4d 100644 --- a/plugins/dex/format.c +++ b/plugins/dex/format.c @@ -53,10 +53,10 @@ static void g_dex_format_dispose(GDexFormat *); static void g_dex_format_finalize(GDexFormat *); /* Indique la désignation interne du format. */ -static const char *g_dex_format_get_name(const GDexFormat *); +static char *g_dex_format_get_key(const GDexFormat *); /* Fournit une description humaine du format. */ -static const char *g_dex_format_get_description(const GDexFormat *); +static char *g_dex_format_get_description(const GDexFormat *); /* Assure l'interprétation d'un format en différé. */ static bool g_dex_format_analyze(GDexFormat *, wgroup_id_t, GtkStatusStack *); @@ -139,6 +139,7 @@ G_DEFINE_TYPE(GDexFormat, g_dex_format, G_TYPE_EXE_FORMAT); static void g_dex_format_class_init(GDexFormatClass *klass) { GObjectClass *object; /* Autre version de la classe */ + GKnownFormatClass *known; /* Version de format connu */ GBinFormatClass *fmt; /* Version en format basique */ GExeFormatClass *exe; /* Version en exécutable */ @@ -147,11 +148,14 @@ static void g_dex_format_class_init(GDexFormatClass *klass) object->dispose = (GObjectFinalizeFunc/* ! */)g_dex_format_dispose; object->finalize = (GObjectFinalizeFunc)g_dex_format_finalize; + known = G_KNOWN_FORMAT_CLASS(klass); + + known->get_key = (known_get_key_fc)g_dex_format_get_key; + known->get_desc = (known_get_desc_fc)g_dex_format_get_description; + known->analyze = (known_analyze_fc)g_dex_format_analyze; + fmt = G_BIN_FORMAT_CLASS(klass); - fmt->get_name = (format_get_name_fc)g_dex_format_get_name; - fmt->get_desc = (format_get_desc_fc)g_dex_format_get_description; - fmt->analyze = (format_analyze_fc)g_dex_format_analyze; fmt->get_endian = (format_get_endian_fc)g_dex_format_get_endianness; exe = G_EXE_FORMAT_CLASS(klass); @@ -252,7 +256,7 @@ GExeFormat *g_dex_format_new(GBinContent *content) result = g_object_new(G_TYPE_DEX_FORMAT, NULL); - g_binary_format_set_content(G_BIN_FORMAT(result), content); + g_known_format_set_content(G_KNOWN_FORMAT(result), content); result->pool = g_dex_pool_new(result); @@ -267,17 +271,17 @@ GExeFormat *g_dex_format_new(GBinContent *content) * * * Description : Indique la désignation interne du format. * * * -* Retour : Description du format. * +* Retour : Désignation du format. * * * * Remarques : - * * * ******************************************************************************/ -static const char *g_dex_format_get_name(const GDexFormat *format) +static char *g_dex_format_get_key(const GDexFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = "dex"; + result = strdup("dex"); return result; @@ -296,11 +300,11 @@ static const char *g_dex_format_get_name(const GDexFormat *format) * * ******************************************************************************/ -static const char *g_dex_format_get_description(const GDexFormat *format) +static char *g_dex_format_get_description(const GDexFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = "Dalvik Executable format (version '035')"; + result = strdup("Dalvik Executable format (version '035')"); return result; @@ -344,7 +348,7 @@ static bool g_dex_format_analyze(GDexFormat *format, wgroup_id_t gid, GtkStatusS /* Vérification des tailles fournies */ - size = g_binary_content_compute_size(base->content); + size = g_binary_content_compute_size(G_KNOWN_FORMAT(base)->content); if (size >= 0xffffffffllu) { diff --git a/plugins/dex/pool.c b/plugins/dex/pool.c index dc9031b..6007019 100644 --- a/plugins/dex/pool.c +++ b/plugins/dex/pool.c @@ -387,7 +387,7 @@ GBinSymbol *g_dex_pool_get_string_symbol(GDexPool *pool, uint32_t index) base = G_BIN_FORMAT(pool->format); - new = g_string_symbol_new_read_only(SET_MUTF_8, base, &range); + new = g_string_symbol_new_read_only(SET_MUTF_8, G_KNOWN_FORMAT(base), &range); if (new != NULL) g_string_symbol_build_label(G_STR_SYMBOL(new), base); diff --git a/plugins/dwarf/abbrev.c b/plugins/dwarf/abbrev.c index 0deb12f..0c528b0 100644 --- a/plugins/dwarf/abbrev.c +++ b/plugins/dwarf/abbrev.c @@ -427,7 +427,7 @@ dw_abbrev_brotherhood *load_all_dwarf_abbreviations(GDwarfFormat *format, const { /* Définition d'un zone de travail */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; restricted = g_restricted_content_new(content, &range); copy_vmpa(&pos, get_mrange_addr(&range)); diff --git a/plugins/dwarf/format.c b/plugins/dwarf/format.c index cedac49..867ccd3 100644 --- a/plugins/dwarf/format.c +++ b/plugins/dwarf/format.c @@ -49,10 +49,10 @@ static void g_dwarf_format_dispose(GDwarfFormat *); static void g_dwarf_format_finalize(GDwarfFormat *); /* Indique la désignation interne du format. */ -static const char *g_dwarf_format_get_name(const GDwarfFormat *); +static char *g_dwarf_format_get_key(const GDwarfFormat *); /* Fournit une description humaine du format. */ -static const char *g_dwarf_format_get_description(const GDwarfFormat *); +static char *g_dwarf_format_get_description(const GDwarfFormat *); /* Assure l'interprétation d'un format en différé. */ static bool g_dwarf_format_analyze(GDwarfFormat *, wgroup_id_t, GtkStatusStack *); @@ -116,18 +116,18 @@ G_DEFINE_TYPE(GDwarfFormat, g_dwarf_format, G_TYPE_DBG_FORMAT); static void g_dwarf_format_class_init(GDwarfFormatClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GBinFormatClass *fmt; /* Version en format basique */ + GKnownFormatClass *known; /* Version de format connu */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_dwarf_format_dispose; object->finalize = (GObjectFinalizeFunc)g_dwarf_format_finalize; - fmt = G_BIN_FORMAT_CLASS(klass); + known = G_KNOWN_FORMAT_CLASS(klass); - fmt->get_name = (format_get_name_fc)g_dwarf_format_get_name; - fmt->get_desc = (format_get_desc_fc)g_dwarf_format_get_description; - fmt->analyze = (format_analyze_fc)g_dwarf_format_analyze; + known->get_key = (known_get_key_fc)g_dwarf_format_get_key; + known->get_desc = (known_get_desc_fc)g_dwarf_format_get_description; + known->analyze = (known_analyze_fc)g_dwarf_format_analyze; } @@ -218,9 +218,9 @@ GDbgFormat *g_dwarf_format_new(GExeFormat *parent) g_debuggable_format_attach_executable(G_DBG_FORMAT(result), parent); - content = G_BIN_FORMAT(parent)->content; + content = G_KNOWN_FORMAT(parent)->content; - G_BIN_FORMAT(result)->content = content; + G_KNOWN_FORMAT(result)->content = content; g_object_ref(G_OBJECT(content)); return G_DBG_FORMAT(result); @@ -234,17 +234,17 @@ GDbgFormat *g_dwarf_format_new(GExeFormat *parent) * * * Description : Indique la désignation interne du format. * * * -* Retour : Description du format. * +* Retour : Désignation du format. * * * * Remarques : - * * * ******************************************************************************/ -static const char *g_dwarf_format_get_name(const GDwarfFormat *format) +static char *g_dwarf_format_get_key(const GDwarfFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = "dwarf"; + result = strdup("dwarf"); return result; @@ -263,11 +263,11 @@ static const char *g_dwarf_format_get_name(const GDwarfFormat *format) * * ******************************************************************************/ -static const char *g_dwarf_format_get_description(const GDwarfFormat *format) +static char *g_dwarf_format_get_description(const GDwarfFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = "DWARF Debugging Information Format"; + result = strdup("DWARF Debugging Information Format"); return result; diff --git a/plugins/dwarf/info.c b/plugins/dwarf/info.c index ad4b69a..10c6a82 100644 --- a/plugins/dwarf/info.c +++ b/plugins/dwarf/info.c @@ -101,7 +101,7 @@ bool load_dwarf_debug_information(GDwarfFormat *format, wgroup_id_t gid, GtkStat if (result) { - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; restricted = g_restricted_content_new(content, &range); @@ -228,7 +228,7 @@ static bool extract_dies_from_debug_info(const work_data *data, size_t i, GtkSta * différents cas ici. */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; exe = G_DBG_FORMAT(format)->executable; diff --git a/plugins/elf/dynamic.c b/plugins/elf/dynamic.c index 13292ec..6ab2ce2 100644 --- a/plugins/elf/dynamic.c +++ b/plugins/elf/dynamic.c @@ -272,7 +272,7 @@ const char **list_elf_needed_objects(const GElfFormat *format, size_t *count) /* Seconde passe : recherche des objets requis */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; g_binary_content_compute_end_pos(content, &end); @@ -343,7 +343,7 @@ bool resolve_plt_using_got(GElfFormat *format, virt_t *virt) if (!g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), got_virt, &got_addr)) goto exit; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; /** * Quelques pistes pour la connaissance des premières cellules d'une GOT : diff --git a/plugins/elf/elf-int.c b/plugins/elf/elf-int.c index 8fb290e..bfe183a 100644 --- a/plugins/elf/elf-int.c +++ b/plugins/elf/elf-int.c @@ -49,7 +49,7 @@ bool read_elf_header(GElfFormat *format, elf_header *header, bool *is_32b, Sourc const GBinContent *content; /* Contenu binaire à lire */ vmpa2t pos; /* Position de lecture */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; init_vmpa(&pos, 0, VMPA_NO_VIRTUAL); @@ -143,7 +143,7 @@ bool read_elf_program_header(const GElfFormat *format, phys_t phys, elf_phdr *he const GBinContent *content; /* Contenu binaire à lire */ vmpa2t pos; /* Position de lecture */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; init_vmpa(&pos, phys, VMPA_NO_VIRTUAL); @@ -199,7 +199,7 @@ bool read_elf_section_header(const GElfFormat *format, phys_t phys, elf_shdr *se result = true; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; init_vmpa(&pos, phys, VMPA_NO_VIRTUAL); @@ -261,7 +261,7 @@ bool read_elf_dynamic_entry(const GElfFormat *format, phys_t phys, elf_dyn *dyn) const GBinContent *content; /* Contenu binaire à lire */ vmpa2t pos; /* Position de lecture */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; init_vmpa(&pos, phys, VMPA_NO_VIRTUAL); @@ -301,7 +301,7 @@ bool read_elf_symbol(const GElfFormat *format, phys_t *phys, elf_sym *sym) const GBinContent *content; /* Contenu binaire à lire */ vmpa2t pos; /* Position de lecture */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; init_vmpa(&pos, *phys, VMPA_NO_VIRTUAL); @@ -352,7 +352,7 @@ bool read_elf_relocation(const GElfFormat *format, phys_t *phys, elf_rel *reloc) const GBinContent *content; /* Contenu binaire à lire */ vmpa2t pos; /* Position de lecture */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; init_vmpa(&pos, *phys, VMPA_NO_VIRTUAL); @@ -396,7 +396,7 @@ bool read_elf_note(const GElfFormat *format, GBinContent *content, phys_t *phys, vmpa2t pos; /* Position de lecture */ if (content == NULL) - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; init_vmpa(&pos, *phys, VMPA_NO_VIRTUAL); diff --git a/plugins/elf/format.c b/plugins/elf/format.c index d102ad8..75b9a6c 100644 --- a/plugins/elf/format.c +++ b/plugins/elf/format.c @@ -63,10 +63,10 @@ static void g_elf_format_dispose(GElfFormat *); static void g_elf_format_finalize(GElfFormat *); /* Indique la désignation interne du format. */ -static const char *g_elf_format_get_name(const GElfFormat *); +static char *g_elf_format_get_key(const GElfFormat *); /* Fournit une description humaine du format. */ -static const char *g_elf_format_get_description(const GElfFormat *); +static char *g_elf_format_get_description(const GElfFormat *); /* Assure l'interprétation d'un format en différé. */ static bool g_elf_format_analyze(GElfFormat *, wgroup_id_t, GtkStatusStack *); @@ -137,6 +137,7 @@ G_DEFINE_TYPE(GElfFormat, g_elf_format, G_TYPE_EXE_FORMAT); static void g_elf_format_class_init(GElfFormatClass *klass) { GObjectClass *object; /* Autre version de la classe */ + GKnownFormatClass *known; /* Version de format connu */ GBinFormatClass *fmt; /* Version en format basique */ GExeFormatClass *exe; /* Version en exécutable */ @@ -145,11 +146,14 @@ static void g_elf_format_class_init(GElfFormatClass *klass) object->dispose = (GObjectFinalizeFunc/* ! */)g_elf_format_dispose; object->finalize = (GObjectFinalizeFunc)g_elf_format_finalize; + known = G_KNOWN_FORMAT_CLASS(klass); + + known->get_key = (known_get_key_fc)g_elf_format_get_key; + known->get_desc = (known_get_desc_fc)g_elf_format_get_description; + known->analyze = (known_analyze_fc)g_elf_format_analyze; + fmt = G_BIN_FORMAT_CLASS(klass); - fmt->get_name = (format_get_name_fc)g_elf_format_get_name; - fmt->get_desc = (format_get_desc_fc)g_elf_format_get_description; - fmt->analyze = (format_analyze_fc)g_elf_format_analyze; fmt->get_endian = (format_get_endian_fc)g_elf_format_get_endianness; exe = G_EXE_FORMAT_CLASS(klass); @@ -249,7 +253,7 @@ GExeFormat *g_elf_format_new(GBinContent *content) result = g_object_new(G_TYPE_ELF_FORMAT, NULL); - g_binary_format_set_content(G_BIN_FORMAT(result), content); + g_known_format_set_content(G_KNOWN_FORMAT(result), content); return G_EXE_FORMAT(result); @@ -262,17 +266,17 @@ GExeFormat *g_elf_format_new(GBinContent *content) * * * Description : Indique la désignation interne du format. * * * -* Retour : Description du format. * +* Retour : Désignation du format. * * * * Remarques : - * * * ******************************************************************************/ -static const char *g_elf_format_get_name(const GElfFormat *format) +static char *g_elf_format_get_key(const GElfFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = "elf"; + result = strdup("elf"); return result; @@ -291,11 +295,11 @@ static const char *g_elf_format_get_name(const GElfFormat *format) * * ******************************************************************************/ -static const char *g_elf_format_get_description(const GElfFormat *format) +static char *g_elf_format_get_description(const GElfFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = "Executable and Linkable Format"; + result = strdup("Executable and Linkable Format"); return result; diff --git a/plugins/elf/helper_arm.c b/plugins/elf/helper_arm.c index cc0a233..8a80243 100644 --- a/plugins/elf/helper_arm.c +++ b/plugins/elf/helper_arm.c @@ -107,7 +107,7 @@ bool find_first_plt_entry(GElfFormat *format, vmpa2t *addr) result = false; - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; while (!result) { @@ -161,7 +161,7 @@ bool retrieve_arm_linkage_offset(GElfFormat *format, vmpa2t *addr, uint64_t *off * */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_u32(content, addr, format->endian, &raw); if (!result) goto exit; diff --git a/plugins/elf/loading.c b/plugins/elf/loading.c index 181c864..976dd49 100644 --- a/plugins/elf/loading.c +++ b/plugins/elf/loading.c @@ -422,7 +422,7 @@ GElfLoading *g_elf_loading_new_for_strings(GElfFormat *format, phys_t begin, phy result->global_end = gb_end; result->global_addr = addr; - result->content = g_binary_format_get_content(G_BIN_FORMAT(format)); + result->content = g_known_format_get_content(G_KNOWN_FORMAT(format)); init_vmpa(&pos, gb_start, addr); @@ -590,7 +590,7 @@ const char *g_elf_loading_build_name(const GElfLoading *loading, uint32_t name, { init_vmpa(&pos, loading->str_start + name, VMPA_NO_VIRTUAL); - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = (const char *)g_binary_content_get_raw_access(content, &pos, 1); @@ -739,7 +739,7 @@ GBinSymbol *g_elf_loading_build_plt_symbol(const GElfLoading *loading, uint64_t init_vmpa(&pos, offset, VMPA_NO_VIRTUAL); base = G_BIN_FORMAT(format); - content = base->content; + content = G_KNOWN_FORMAT(base)->content; raw_label = (const char *)g_binary_content_get_raw_access(content, &pos, 1); diff --git a/plugins/elf/section.c b/plugins/elf/section.c index 2121ca9..3d87da2 100644 --- a/plugins/elf/section.c +++ b/plugins/elf/section.c @@ -349,7 +349,7 @@ const char *extract_name_from_elf_string_section(const GElfFormat *format, const init_vmpa(&pos, phys, VMPA_NO_VIRTUAL); - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = (const char *)g_binary_content_get_raw_access(content, &pos, 1); diff --git a/plugins/elf/strings.c b/plugins/elf/strings.c index 9b14753..e74b666 100644 --- a/plugins/elf/strings.c +++ b/plugins/elf/strings.c @@ -359,7 +359,7 @@ static bool do_elf_string_loading(GElfLoading *loading, GElfFormat *format, phys { range = g_arch_instruction_get_range(instr); - symbol = g_string_symbol_new_read_only(SET_GUESS, base, range); + symbol = g_string_symbol_new_read_only(SET_GUESS, G_KNOWN_FORMAT(base), range); g_object_ref(G_OBJECT(symbol)); diff --git a/plugins/elf/symbols.c b/plugins/elf/symbols.c index 004ac6a..a7cf05c 100644 --- a/plugins/elf/symbols.c +++ b/plugins/elf/symbols.c @@ -572,7 +572,7 @@ static bool count_elf_global_symbols(GElfFormat *format, GExeFormat *exec, uint3 advance_vmpa(&addr, sizeof(uint32_t)); - result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, count); + result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, count); if (!result) goto exit; goto exit; @@ -588,13 +588,13 @@ static bool count_elf_global_symbols(GElfFormat *format, GExeFormat *exec, uint3 result = g_exe_format_translate_address_into_vmpa(exec, ELF_DYN(format, hash, d_un.d_ptr), &addr); if (!result) goto exit; - result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &n_buckets); + result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &n_buckets); if (!result) goto exit; - result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &sym_offset); + result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &sym_offset); if (!result) goto exit; - result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &bloom_size); + result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &bloom_size); if (!result) goto exit; /* Saut de bloom_shift */ @@ -612,7 +612,7 @@ static bool count_elf_global_symbols(GElfFormat *format, GExeFormat *exec, uint3 for (i = 0; i < n_buckets; i++) { - result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &start); + result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &start); if (!result) goto exit; if (last_symbol < start) @@ -634,7 +634,7 @@ static bool count_elf_global_symbols(GElfFormat *format, GExeFormat *exec, uint3 while (true) { - result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &value); + result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &value); if (!result) goto exit; last_symbol++; @@ -1274,7 +1274,7 @@ static bool load_elf_entry_points_from_array(GElfFormat *format, const elf_dyn * assert(sizeof(fullname) >= (strlen(prefix) + sizeof(XSTR(UINT64_MAX) + 1))); base = G_BIN_FORMAT(format); - content = base->content; + content = G_KNOWN_FORMAT(base)->content; result = g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), ELF_DYN(format, *array, d_un.d_val), diff --git a/plugins/fmtp/parser.c b/plugins/fmtp/parser.c index 3379ac2..4a8749d 100644 --- a/plugins/fmtp/parser.c +++ b/plugins/fmtp/parser.c @@ -29,6 +29,7 @@ #include <i18n.h> #include <arch/instructions/raw.h> +#include <format/known.h> @@ -70,7 +71,7 @@ static bool parse_field_definition(const fmt_field_def *def, GBinFormat *format, /* Lecture */ - content = g_binary_format_get_content(format); + content = g_known_format_get_content(G_KNOWN_FORMAT(format)); endian = g_binary_format_get_endianness(format); if (def->get_value != NULL) diff --git a/plugins/mobicore/mclf-int.c b/plugins/mobicore/mclf-int.c index d2d5b18..d947525 100644 --- a/plugins/mobicore/mclf-int.c +++ b/plugins/mobicore/mclf-int.c @@ -46,7 +46,7 @@ bool read_mclf_header(GMCLFFormat *format, mclf_header_t *header, SourceEndian e vmpa2t pos; /* Position de lecture */ uint32_t tmp; /* Espace de transition */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; init_vmpa(&pos, 0, VMPA_NO_VIRTUAL); @@ -103,7 +103,7 @@ bool read_mclf_segment_desc(GMCLFFormat *format, segment_descriptor_t *segment, bool result; /* Bilan à retourner */ GBinContent *content; /* Contenu binaire à lire */ - content = G_BIN_FORMAT(format)->content; + content = G_KNOWN_FORMAT(format)->content; result = g_binary_content_read_u32(content, pos, endian, &segment->start); result &= g_binary_content_read_u32(content, pos, endian, &segment->len); diff --git a/plugins/mobicore/mclf.c b/plugins/mobicore/mclf.c index 12374b6..564a6df 100644 --- a/plugins/mobicore/mclf.c +++ b/plugins/mobicore/mclf.c @@ -50,10 +50,10 @@ static void g_mclf_format_dispose(GMCLFFormat *); static void g_mclf_format_finalize(GMCLFFormat *); /* Indique la désignation interne du format. */ -static const char *g_mclf_format_get_name(const GMCLFFormat *); +static char *g_mclf_format_get_key(const GMCLFFormat *); /* Fournit une description humaine du format. */ -static const char *g_mclf_format_get_description(const GMCLFFormat *); +static char *g_mclf_format_get_description(const GMCLFFormat *); /* Assure l'interprétation d'un format en différé. */ static bool g_mclf_format_analyze(GMCLFFormat *, wgroup_id_t, GtkStatusStack *); @@ -118,6 +118,7 @@ G_DEFINE_TYPE(GMCLFFormat, g_mclf_format, G_TYPE_EXE_FORMAT); static void g_mclf_format_class_init(GMCLFFormatClass *klass) { GObjectClass *object; /* Autre version de la classe */ + GKnownFormatClass *known; /* Version de format connu */ GBinFormatClass *fmt; /* Version en format basique */ GExeFormatClass *exe; /* Version en exécutable */ @@ -126,11 +127,14 @@ static void g_mclf_format_class_init(GMCLFFormatClass *klass) object->dispose = (GObjectFinalizeFunc/* ! */)g_mclf_format_dispose; object->finalize = (GObjectFinalizeFunc)g_mclf_format_finalize; + known = G_KNOWN_FORMAT_CLASS(klass); + + known->get_key = (known_get_key_fc)g_mclf_format_get_key; + known->get_desc = (known_get_desc_fc)g_mclf_format_get_description; + known->analyze = (known_analyze_fc)g_mclf_format_analyze; + fmt = G_BIN_FORMAT_CLASS(klass); - fmt->get_name = (format_get_name_fc)g_mclf_format_get_name; - fmt->get_desc = (format_get_desc_fc)g_mclf_format_get_description; - fmt->analyze = (format_analyze_fc)g_mclf_format_analyze; fmt->get_endian = (format_get_endian_fc)g_mclf_format_get_endianness; exe = G_EXE_FORMAT_CLASS(klass); @@ -218,7 +222,7 @@ GExeFormat *g_mclf_format_new(GBinContent *content) result = g_object_new(G_TYPE_MCLF_FORMAT, NULL); - g_binary_format_set_content(G_BIN_FORMAT(result), content); + g_known_format_set_content(G_KNOWN_FORMAT(result), content); return G_EXE_FORMAT(result); @@ -231,17 +235,17 @@ GExeFormat *g_mclf_format_new(GBinContent *content) * * * Description : Indique la désignation interne du format. * * * -* Retour : Description du format. * +* Retour : Désignation du format. * * * * Remarques : - * * * ******************************************************************************/ -static const char *g_mclf_format_get_name(const GMCLFFormat *format) +static char *g_mclf_format_get_key(const GMCLFFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = "mclf"; + result = strdup("mclf"); return result; @@ -260,11 +264,11 @@ static const char *g_mclf_format_get_name(const GMCLFFormat *format) * * ******************************************************************************/ -static const char *g_mclf_format_get_description(const GMCLFFormat *format) +static char *g_mclf_format_get_description(const GMCLFFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = "MobiCore Load Format"; + result = strdup("MobiCore Load Format"); return result; @@ -422,7 +426,7 @@ static void g_mclf_format_refine_portions(GMCLFFormat *format) /* Signature finale */ - length = g_binary_content_compute_size(G_BIN_FORMAT(format)->content); + length = g_binary_content_compute_size(G_KNOWN_FORMAT(format)->content); if (length > 521) { diff --git a/plugins/pychrysalide/format/format.c b/plugins/pychrysalide/format/format.c index 6c1d2da..34826cf 100644 --- a/plugins/pychrysalide/format/format.c +++ b/plugins/pychrysalide/format/format.c @@ -33,6 +33,7 @@ #include "constants.h" #include "executable.h" +#include "known.h" #include "symbol.h" #include "symiter.h" #include "../access.h" @@ -53,9 +54,6 @@ static PyObject *py_binary_format_unset_flag(PyObject *, PyObject *); /* Détermine si un format possède un fanion particulier. */ static PyObject *py_binary_format_has_flag(PyObject *, PyObject *); -/* Assure l'interprétation d'un format en différé. */ -static PyObject *py_binary_format_analyze(PyObject *, PyObject *, PyObject *); - /* Enregistre une adresse comme début d'une zone de code. */ static PyObject *py_binary_format_register_code_point(PyObject *, PyObject *); @@ -80,15 +78,6 @@ static PyObject *py_binary_format_resolve_symbol(PyObject *, PyObject *); /* Fournit les particularités du format. */ static PyObject *py_binary_format_get_flags(PyObject *, void *); -/* Indique la désignation interne du format. */ -static PyObject *py_binary_format_get_name(PyObject *, void *); - -/* Indique la désignation humaine du format. */ -static PyObject *py_binary_format_get_description(PyObject *, void *); - -/* Fournit une référence vers le contenu binaire analysé. */ -static PyObject *py_binary_format_get_content(PyObject *, void *); - /* Fournit la liste de tous les symboles détectés. */ static PyObject *py_binary_format_get_symbols(PyObject *, void *); @@ -263,50 +252,6 @@ static PyObject *py_binary_format_has_flag(PyObject *self, PyObject *args) /****************************************************************************** * * -* Paramètres : self = contenu binaire à manipuler. * -* args = arguments fournis à l'appel. * -* kwds = arguments de type key=val fournis. * -* * -* Description : Assure l'interprétation d'un format en différé. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_binary_format_analyze(PyObject *self, PyObject *args, PyObject *kwds) -{ - PyObject *result; /* Bilan à retourner */ - GBinFormat *format; /* Version GLib de l'élément */ - bool status; /* Bilan d'analyse à recevoir */ - -#define BINARY_FORMAT_ANALYZE_METHOD PYTHON_METHOD_DEF \ -( \ - analyze, "$self", \ - METH_NOARGS, py_binary_format, \ - "Analyze the the format recognized from a binary content.\n" \ - "\n" \ - "Once this analysis is done, a few early symbols and the mapped" \ - " sections are expected to be defined.\n" \ - "\n" \ - "The return value is a boolean status of the operation." \ -) - - format = G_BIN_FORMAT(pygobject_get(self)); - - status = g_binary_format_analyze(format, 0, NULL); - - result = status ? Py_True : Py_False; - Py_INCREF(result); - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : self = classe représentant un format. * * args = arguments fournis à l'appel. * * * @@ -642,98 +587,6 @@ static PyObject *py_binary_format_get_flags(PyObject *self, void *closure) /****************************************************************************** * * -* Paramètres : self = objet Python concerné par l'appel. * -* closure = non utilisé ici. * -* * -* Description : Indique la désignation interne du format. * -* * -* Retour : Description du format. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_binary_format_get_name(PyObject *self, void *closure) -{ - PyObject *result; /* Trouvailles à retourner */ - GBinFormat *format; /* Format de binaire manipulé */ - const char *name; /* Description interne */ - - format = G_BIN_FORMAT(pygobject_get(self)); - - name = g_binary_format_get_name(format); - - result = PyUnicode_FromString(name); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : self = objet Python concerné par l'appel. * -* closure = non utilisé ici. * -* * -* Description : Indique la désignation humaine du format. * -* * -* Retour : Description du format. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_binary_format_get_description(PyObject *self, void *closure) -{ - PyObject *result; /* Trouvailles à retourner */ - GBinFormat *format; /* Format de binaire manipulé */ - const char *desc; /* Description humaine */ - - format = G_BIN_FORMAT(pygobject_get(self)); - - desc = g_binary_format_get_description(format); - - result = PyUnicode_FromString(desc); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : self = objet Python concerné par l'appel. * -* closure = non utilisé ici. * -* * -* Description : Fournit une référence vers le contenu binaire analysé. * -* * -* Retour : Gestionnaire de contenu binaire en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PyObject *py_binary_format_get_content(PyObject *self, void *closure) -{ - PyObject *result; /* Trouvailles à retourner */ - GBinFormat *format; /* Format de binaire manipulé */ - GBinContent *content; /* Instance GLib correspondante*/ - - format = G_BIN_FORMAT(pygobject_get(self)); - - content = g_binary_format_get_content(format); - - result = pygobject_new(G_OBJECT(content)); - - g_object_unref(content); - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : self = classe représentant un format binaire. * * closure = adresse non utilisée ici. * * * @@ -884,7 +737,6 @@ PyTypeObject *get_python_binary_format_type(void) BINARY_FORMAT_SET_FLAG_METHOD, BINARY_FORMAT_UNSET_FLAG_METHOD, BINARY_FORMAT_HAS_FLAG_METHOD, - BINARY_FORMAT_ANALYZE_METHOD, { "register_code_point", py_binary_format_register_code_point, METH_VARARGS, @@ -931,18 +783,6 @@ PyTypeObject *get_python_binary_format_type(void) static PyGetSetDef py_bin_format_getseters[] = { BINARY_FORMAT_FLAGS_ATTRIB, { - "name", py_binary_format_get_name, NULL, - "Internal name of the binary format.", NULL - }, - { - "description", py_binary_format_get_description, NULL, - "Human description of the binary format.", NULL - }, - { - "content", py_binary_format_get_content, NULL, - "Content of the binary format.", NULL - }, - { "symbols", py_binary_format_get_symbols, NULL, "Iterable list of all symbols found in the binary format.", NULL }, @@ -1002,7 +842,10 @@ bool ensure_python_binary_format_is_registered(void) dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_BIN_FORMAT, type, &PyGObject_Type)) + if (!ensure_python_known_format_is_registered()) + return false; + + if (!register_class_for_pygobject(dict, G_TYPE_BIN_FORMAT, type, get_python_known_format_type())) return false; if (!define_binary_format_constants(type)) diff --git a/plugins/pychrysalide/format/known.c b/plugins/pychrysalide/format/known.c index c3b5b9d..d75dd05 100644 --- a/plugins/pychrysalide/format/known.c +++ b/plugins/pychrysalide/format/known.c @@ -60,6 +60,9 @@ static char *py_known_format_get_description_wrapper(const GKnownFormat *); /* Assure l'interprétation d'un format en différé. */ static bool py_known_format_analyze_wrapper(GKnownFormat *, wgroup_id_t, GtkStatusStack *); +/* Réalise un traitement post-désassemblage. */ +static void py_known_format_complete_analysis_wrapper(GKnownFormat *, wgroup_id_t, GtkStatusStack *); + /* --------------------------- DEFINITION DU FORMAT CONNU --------------------------- */ @@ -68,6 +71,9 @@ static bool py_known_format_analyze_wrapper(GKnownFormat *, wgroup_id_t, GtkStat /* Assure l'interprétation d'un format en différé. */ static PyObject *py_known_format_analyze(PyObject *, PyObject *); +/* Réalise un traitement post-désassemblage. */ +static PyObject *py_known_format_complete_analysis(PyObject *, PyObject *); + /* Indique la désignation interne du format. */ static PyObject *py_known_format_get_key(PyObject *, void *); @@ -166,6 +172,7 @@ static void py_known_format_init_gclass(GKnownFormatClass *class, gpointer unuse class->get_desc = py_known_format_get_description_wrapper; class->analyze = py_known_format_analyze_wrapper; + class->complete = py_known_format_complete_analysis_wrapper; } @@ -203,6 +210,9 @@ static int py_known_format_init(PyObject *self, PyObject *args, PyObject *kwds) "* pychrysalide.format.KnownFormat._get_description();\n" \ "* pychrysalide.format.KnownFormat._analyze().\n" \ "\n" \ + "The following method may also be defined for new classes too:\n" \ + "* pychrysalide.format.KnownFormat._complete_analysis().\n" \ + "\n" \ "Calls to the *__init__* constructor of this abstract object expect"\ " only one argument: a binary content, provided as a" \ " pychrysalide.analysis.BinContent instance." @@ -401,6 +411,62 @@ static bool py_known_format_analyze_wrapper(GKnownFormat *format, wgroup_id_t gi } +/****************************************************************************** +* * +* Paramètres : format = format chargé dont l'analyse est lancée. * +* gid = groupe de travail dédié. * +* status = barre de statut à tenir informée. * +* * +* Description : Réalise un traitement post-désassemblage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void py_known_format_complete_analysis_wrapper(GKnownFormat *format, wgroup_id_t gid, GtkStatusStack *status) +{ + PyGILState_STATE gstate; /* Sauvegarde d'environnement */ + PyObject *pyobj; /* Objet Python concerné */ + PyObject *args; /* Arguments pour l'appel */ + PyObject *pyret; /* Bilan d'exécution */ + +#define KNOWN_FORMAT_COMPLETE_ANALYSIS_WRAPPER PYTHON_VOID_WRAPPER_DEF \ +( \ + _complete_analysis, "$self, gid, status, /", \ + METH_VARARGS, \ + "Abstract method used to complete an analysis of a known format.\n" \ + "\n" \ + "The identifier refers to the working queue used to process the" \ + " analysis. A reference to the main status bar may also be" \ + " provided, as a pychrysalide.gtkext.StatusStack instance if" \ + " running in graphical mode or None otherwise.\n" \ +) + + gstate = PyGILState_Ensure(); + + pyobj = pygobject_new(G_OBJECT(format)); + + if (has_python_method(pyobj, "_complete_analysis")) + { + args = PyTuple_New(2); + + PyTuple_SetItem(args, 0, PyLong_FromUnsignedLong(gid)); + PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(status))); + + pyret = run_python_method(pyobj, "_complete_analysis", args); + + Py_DECREF(args); + Py_XDECREF(pyret); + + } + + PyGILState_Release(gstate); + +} + + /* ---------------------------------------------------------------------------------- */ /* DEFINITION DU FORMAT CONNU */ @@ -461,6 +527,57 @@ static PyObject *py_known_format_analyze(PyObject *self, PyObject *args) /****************************************************************************** * * +* Paramètres : self = objet représentant un format connu. * +* args = arguments fournis pour l'opération. * +* * +* Description : Réalise un traitement post-désassemblage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_known_format_complete_analysis(PyObject *self, PyObject *args) +{ + PyObject *result; /* Bilan à retourner */ + int ret; /* Bilan de lecture des args. */ + GKnownFormat *format; /* Format connu manipulé */ + +#define KNOWN_FORMAT_COMPLETE_ANALYSIS_METHOD PYTHON_METHOD_DEF \ +( \ + complete_analysis, "$self, gid, status, /", \ + METH_VARARGS, py_known_format, \ + "Complete an analysis of a known format.\n" \ + "\n" \ + "This process is usually done once the disassembling process" \ + " is completed.\n" \ + "\n" \ + "The identifier refers to the working queue used to process" \ + " the analysis. A reference to the main status bar may also be" \ + " provided, as a pychrysalide.gtkext.StatusStack instance if" \ + " running in graphical mode or None otherwise.\n" \ + "\n" \ + "The return value is a boolean status of the operation." \ +) + + ret = PyArg_ParseTuple(args, "");//|KO!", &gid, &status); + if (!ret) return NULL; + + format = G_KNOWN_FORMAT(pygobject_get(self)); + + g_known_format_complete_analysis(format, 0, NULL); + + result = Py_None; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : self = objet Python concerné par l'appel. * * closure = non utilisé ici. * * * @@ -566,9 +683,16 @@ static PyObject *py_known_format_get_content(PyObject *self, void *closure) content = g_known_format_get_content(format); - result = pygobject_new(G_OBJECT(content)); - - g_object_unref(content); + if (content != NULL) + { + result = pygobject_new(G_OBJECT(content)); + g_object_unref(content); + } + else + { + result = Py_None; + Py_INCREF(result); + } return result; @@ -592,7 +716,9 @@ PyTypeObject *get_python_known_format_type(void) static PyMethodDef py_known_format_methods[] = { KNOWN_FORMAT_GET_DESCRIPTION_WRAPPER, KNOWN_FORMAT_ANALYZE_WRAPPER, + KNOWN_FORMAT_COMPLETE_ANALYSIS_WRAPPER, KNOWN_FORMAT_ANALYZE_METHOD, + KNOWN_FORMAT_COMPLETE_ANALYSIS_METHOD, { NULL } }; @@ -661,3 +787,48 @@ bool ensure_python_known_format_is_registered(void) return true; } + + +/****************************************************************************** +* * +* Paramètres : arg = argument quelconque à tenter de convertir. * +* dst = destination des valeurs récupérées en cas de succès. * +* * +* Description : Tente de convertir en format connu. * +* * +* Retour : Bilan de l'opération, voire indications supplémentaires. * +* * +* Remarques : - * +* * +******************************************************************************/ + +int convert_to_known_format(PyObject *arg, void *dst) +{ + int result; /* Bilan à retourner */ + + result = PyObject_IsInstance(arg, (PyObject *)get_python_known_format_type()); + + switch (result) + { + case -1: + /* L'exception est déjà fixée par Python */ + result = 0; + break; + + case 0: + PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to known format"); + break; + + case 1: + *((GKnownFormat **)dst) = G_KNOWN_FORMAT(pygobject_get(arg)); + break; + + default: + assert(false); + break; + + } + + return result; + +} diff --git a/plugins/pychrysalide/format/known.h b/plugins/pychrysalide/format/known.h index 16cbf83..45d0e2c 100644 --- a/plugins/pychrysalide/format/known.h +++ b/plugins/pychrysalide/format/known.h @@ -37,6 +37,9 @@ PyTypeObject *get_python_known_format_type(void); /* Prend en charge l'objet 'pychrysalide.format.KnownFormat'. */ bool ensure_python_known_format_is_registered(void); +/* Tente de convertir en format connu. */ +int convert_to_known_format(PyObject *, void *); + #endif /* _PLUGINS_PYCHRYSALIDE_FORMAT_KNOWN_H */ diff --git a/plugins/pychrysalide/format/strsym.c b/plugins/pychrysalide/format/strsym.c index 2824677..9c86df4 100644 --- a/plugins/pychrysalide/format/strsym.c +++ b/plugins/pychrysalide/format/strsym.c @@ -37,7 +37,7 @@ #include "constants.h" -#include "format.h" +#include "known.h" #include "symbol.h" #include "../access.h" #include "../helpers.h" @@ -159,7 +159,7 @@ static PyObject *py_string_symbol_new(PyTypeObject *type, PyObject *args, PyObje static int py_string_symbol_init(PyObject *self, PyObject *args, PyObject *kwds) { StringEncodingType encoding; /* Encodage spécifié */ - GBinFormat *format; /* Format au contenu à relire */ + GKnownFormat *format; /* Format au contenu à relire */ mrange_t range; /* Version native d'un espace */ const char *string; /* Chaîne de caractères soumise*/ vmpa2t *addr; /* Emplacement de chaîne */ @@ -173,7 +173,7 @@ static int py_string_symbol_init(PyObject *self, PyObject *args, PyObject *kwds) "\n" \ "Instances can be created using one of the following constructors:\n" \ "\n" \ - " StrSymbol(encoding, format=pychrysalide.format.BinFormat," \ + " StrSymbol(encoding, format=pychrysalide.format.KnownFormat," \ " range=pychrysalide.arch.mrange)" \ "\n" \ " StrSymbol(encoding, string=string, addr=pychrysalide.arch.vmpa)" \ @@ -198,7 +198,7 @@ static int py_string_symbol_init(PyObject *self, PyObject *args, PyObject *kwds) ret = PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&O&sO&", kwlist, convert_to_string_encoding_type, &encoding, - convert_to_binary_format, &format, + convert_to_known_format, &format, convert_any_to_mrange, &range, &string, convert_any_to_vmpa, &addr); if (!ret) return -1; diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c index 73fb4a7..5c7ae75 100644 --- a/plugins/pychrysalide/helpers.c +++ b/plugins/pychrysalide/helpers.c @@ -619,6 +619,31 @@ PyObject *not_yet_implemented_method(PyObject *self, PyObject *args) /****************************************************************************** * * +* Paramètres : self = objet quelconque. * +* args = arguments fournis à l'appel. * +* * +* Description : Retourne toujours rien. * +* * +* Retour : None. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyObject *py_return_none(PyObject *self, PyObject *args) +{ + PyObject *result; /* Bilan à retourner */ + + result = Py_None; + Py_INCREF(result); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : spec = définition à mettre en place dynamiquement. * * * * Description : Définit dans le tas de Python un nouveau type. * diff --git a/plugins/pychrysalide/helpers.h b/plugins/pychrysalide/helpers.h index 5f28c57..fd0ece7 100644 --- a/plugins/pychrysalide/helpers.h +++ b/plugins/pychrysalide/helpers.h @@ -97,6 +97,14 @@ bool register_python_module_object(PyObject *, PyTypeObject *); #name "(" args ")\n--\n\n" doc \ } +#define PYTHON_VOID_WRAPPER_DEF(name, args, flags, doc) \ + { \ + #name, (PyCFunction)py_return_none, \ + flags, \ + #name "(" args ")\n--\n\n" doc \ + } + + #define PYTHON_GETSET_DEF(name, get, set, doc, closure) \ { \ name, get, set, \ @@ -132,6 +140,9 @@ PyObject *no_python_constructor_allowed(PyTypeObject *, PyObject *, PyObject *); /* Marque l'absence d'implémentation pour une méthode donnée. */ PyObject *not_yet_implemented_method(PyObject *, PyObject *); +/* Retourne toujours rien. */ +PyObject *py_return_none(PyObject *, PyObject *); + /* Définit dans le tas de Python un nouveau type. */ PyTypeObject *define_python_dynamic_type(const PyTypeObject *); diff --git a/plugins/pychrysalide/plugin.c b/plugins/pychrysalide/plugin.c index 3f3b56a..77647b5 100644 --- a/plugins/pychrysalide/plugin.c +++ b/plugins/pychrysalide/plugin.c @@ -69,7 +69,7 @@ static void py_plugin_module_handle_binary_content_wrapper(const GPluginModule * static void py_plugin_module_handle_loaded_content_wrapper(const GPluginModule *, PluginAction, GLoadedContent *, wgroup_id_t, GtkStatusStack *); /* Procède à une opération liée à l'analyse d'un format. */ -static bool py_plugin_module_handle_binary_format_analysis_wrapper(const GPluginModule *, PluginAction, GBinFormat *, wgroup_id_t, GtkStatusStack *); +static bool py_plugin_module_handle_known_format_analysis_wrapper(const GPluginModule *, PluginAction, GKnownFormat *, wgroup_id_t, GtkStatusStack *); /* Procède à un préchargement de format de fichier. */ static bool py_plugin_module_preload_binary_format_wrapper(const GPluginModule *, PluginAction, GBinFormat *, GPreloadInfo *, GtkStatusStack *); @@ -219,7 +219,7 @@ static void py_plugin_module_init_gclass(GPluginModuleClass *class, gpointer unu class->handle_content = py_plugin_module_handle_binary_content_wrapper; class->handle_loaded = py_plugin_module_handle_loaded_content_wrapper; - class->handle_fmt_analysis = py_plugin_module_handle_binary_format_analysis_wrapper; + class->handle_fmt_analysis = py_plugin_module_handle_known_format_analysis_wrapper; class->preload_format = py_plugin_module_preload_binary_format_wrapper; class->attach_debug = py_plugin_module_attach_debug_format_wrapper; @@ -668,7 +668,7 @@ static void py_plugin_module_handle_loaded_content_wrapper(const GPluginModule * * * ******************************************************************************/ -static bool py_plugin_module_handle_binary_format_analysis_wrapper(const GPluginModule *plugin, PluginAction action, GBinFormat *format, wgroup_id_t gid, GtkStatusStack *status) +static bool py_plugin_module_handle_known_format_analysis_wrapper(const GPluginModule *plugin, PluginAction action, GKnownFormat *format, wgroup_id_t gid, GtkStatusStack *status) { bool result; /* Bilan à retourner */ PyGILState_STATE gstate; /* Sauvegarde d'environnement */ @@ -685,7 +685,7 @@ static bool py_plugin_module_handle_binary_format_analysis_wrapper(const GPlugin "* at the beginning and at the end of the extra final pass.\n" \ "\n" \ "The expected action is a pychrysalide.PluginModule.PluginAction" \ - " value and the provided format is a pychrysalide.format.BinFormat" \ + " value and the provided format is a pychrysalide.format.KnownFormat" \ " instance. The identifier refers to the working queue used to process the" \ " analysis. A reference to the main status bar may also be provided, as a" \ " pychrysalide.gtkext.StatusStack instance if running in graphical mode or" \ diff --git a/plugins/readdex/ids.c b/plugins/readdex/ids.c index 72c4072..1d5f687 100644 --- a/plugins/readdex/ids.c +++ b/plugins/readdex/ids.c @@ -30,6 +30,7 @@ #include <i18n.h> #include <arch/instructions/raw.h> +#include <format/known.h> #include <format/symbol.h> #include <plugins/dex/dex_def.h> #include <plugins/fmtp/parser.h> @@ -254,7 +255,7 @@ bool annotate_dex_string_ids(const GDexFormat *format, GPreloadInfo *info, GtkSt uleb128_t length; /* Taille de la chaîne en cours*/ GArchInstruction *instr; /* Instruction décodée */ - content = g_binary_format_get_content(G_BIN_FORMAT(format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(format)); header = g_dex_format_get_header(format); endian = g_binary_format_get_endianness(G_BIN_FORMAT(format)); diff --git a/plugins/readelf/strtab.c b/plugins/readelf/strtab.c index 19b44bf..262be56 100644 --- a/plugins/readelf/strtab.c +++ b/plugins/readelf/strtab.c @@ -118,7 +118,7 @@ static void parse_elf_string_table(GElfFormat *format, GPreloadInfo *info, const { irange = g_arch_instruction_get_range(instr); - symbol = g_string_symbol_new_read_only(SET_GUESS, base, irange); + symbol = g_string_symbol_new_read_only(SET_GUESS, G_KNOWN_FORMAT(base), irange); g_object_ref(G_OBJECT(symbol)); @@ -167,7 +167,7 @@ void show_elf_section_string_table(GElfFormat *format, GPreloadInfo *info, GtkSt mrange_t range; /* Espace à parcourir */ bool found; /* Détection d'une section */ - content = g_binary_format_get_content(G_BIN_FORMAT(format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(format)); found = find_elf_section_range_by_name(format, ".interp", &range); diff --git a/plugins/ropgadgets/finder.c b/plugins/ropgadgets/finder.c index 3fa1ea4..5655735 100644 --- a/plugins/ropgadgets/finder.c +++ b/plugins/ropgadgets/finder.c @@ -29,7 +29,7 @@ #include <core/processors.h> -#include <format/format.h> +#include <format/known.h> #include "helper.h" @@ -384,7 +384,7 @@ found_rop_list *list_all_gadgets(GExeFormat *format, unsigned int max_depth, upd g_object_ref(G_OBJECT(format)); domain.format = format; - domain.content = g_binary_format_get_content(G_BIN_FORMAT(format)); + domain.content = g_known_format_get_content(G_KNOWN_FORMAT(format)); target = g_exe_format_get_target_machine(format); domain.proc = get_arch_processor_for_key(target); diff --git a/plugins/ropgadgets/select.c b/plugins/ropgadgets/select.c index be2086e..aebe433 100644 --- a/plugins/ropgadgets/select.c +++ b/plugins/ropgadgets/select.c @@ -40,6 +40,7 @@ #include <common/cpp.h> #include <common/extstr.h> #include <core/processors.h> +#include <format/known.h> #include <gui/core/global.h> #include <gtkext/easygtk.h> @@ -1511,7 +1512,7 @@ static void add_new_gadgets_for_category(GExeFormat *format, GtkComboBoxText *co char *partial_markup; /* Contenu de la ligne visée */ GtkTreeIter iter; /* Point d'insertion */ - content = g_binary_format_get_content(G_BIN_FORMAT(format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(format)); /* Conversion en contenu textuel */ diff --git a/src/analysis/binary.c b/src/analysis/binary.c index bdee11b..ad4ec1f 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -47,6 +47,7 @@ #include "../core/logs.h" #include "../core/params.h" #include "../core/processors.h" +#include "../format/known.h" #include "../glibext/gbinarycursor.h" #include "../glibext/gloadedpanel.h" #include "../gtkext/easygtk.h" @@ -417,7 +418,7 @@ const char *g_loaded_binary_get_name(const GLoadedBinary *binary, bool full) const char *result; /* Description à retourner */ GBinContent *content; /* Contenu binaire mannipulé */ - content = g_binary_format_get_content(G_BIN_FORMAT(binary->format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(binary->format)); result = g_binary_content_describe(content, full); @@ -851,7 +852,7 @@ static bool g_loaded_binary_connect_internal(GLoadedBinary *binary) /* Détermination de l'identifiant */ - content = g_binary_format_get_content(G_BIN_FORMAT(binary->format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(binary->format)); checksum = g_binary_content_get_checksum(content); g_object_unref(G_OBJECT(content)); @@ -888,7 +889,7 @@ static bool g_loaded_binary_connect_remote(GLoadedBinary *binary) /* Détermination de l'identifiant */ - content = g_binary_format_get_content(G_BIN_FORMAT(binary->format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(binary->format)); checksum = g_binary_content_get_checksum(content); g_object_unref(G_OBJECT(content)); @@ -1596,7 +1597,7 @@ static GBinContent *g_loaded_binary_get_content(const GLoadedBinary *binary) { GBinContent *result; /* Contenu interne à renvoyer */ - result = g_binary_format_get_content(G_BIN_FORMAT(binary->format)); + result = g_known_format_get_content(G_KNOWN_FORMAT(binary->format)); return result; @@ -1619,7 +1620,7 @@ static const char *g_loaded_binary_get_format_name(const GLoadedBinary *binary) { const char *result; /* Désignation à retourner */ - result = g_binary_format_get_name(G_BIN_FORMAT(binary->format)); + result = g_known_format_get_key(G_KNOWN_FORMAT(binary->format)); return result; @@ -1656,14 +1657,16 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool connect, bool ca format = G_BIN_FORMAT(binary->format); - desc = g_binary_format_get_description(format); + desc = g_known_format_get_description(G_KNOWN_FORMAT(format)); if (desc == NULL) log_simple_message(LMT_WARNING, _("Unnamed format")); else log_variadic_message(LMT_INFO, _("Selected format: %s"), desc); - result = g_binary_format_analyze(format, gid, status); + free(desc); + + result = g_known_format_analyze(G_KNOWN_FORMAT(format), gid, status); if (!result) goto glba_exit; /* Architecture visée */ @@ -1707,7 +1710,7 @@ static bool g_loaded_binary_analyze(GLoadedBinary *binary, bool connect, bool ca disassemble_binary(binary, gid, status, &context); - g_binary_format_complete_analysis(format, gid, status); + g_known_format_complete_analysis(G_KNOWN_FORMAT(format), gid, status); if (cache) { @@ -1847,7 +1850,7 @@ static const char *g_loaded_binary_describe(const GLoadedBinary *binary, bool fu const char *result; /* Description à retourner */ GBinContent *content; /* Contenu binaire mannipulé */ - content = g_binary_format_get_content(G_BIN_FORMAT(binary->format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(binary->format)); result = g_binary_content_describe(content, full); @@ -1967,7 +1970,7 @@ static GtkWidget *g_loaded_binary_build_view(GLoadedBinary *binary, unsigned int switch (index) { case BVW_HEX: - content = g_binary_format_get_content(G_BIN_FORMAT(binary->format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(binary->format)); display = gtk_hex_display_new(content); g_object_unref(G_OBJECT(content)); break; diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c index eaec25d..351bb9e 100644 --- a/src/analysis/disass/area.c +++ b/src/analysis/disass/area.c @@ -40,6 +40,7 @@ #include "../../core/global.h" #include "../../core/logs.h" #include "../../core/nproc.h" +#include "../../format/known.h" #include "../../format/format.h" #include "../../glibext/delayed-int.h" @@ -282,7 +283,7 @@ static void init_mem_area_from_addr(mem_area *area, const vmpa2t *addr, phys_t l init_mrange(&area->range, addr, len); - content = g_binary_format_get_content(area->format); + content = g_known_format_get_content(G_KNOWN_FORMAT(area->format)); area->content = g_restricted_content_new(content, &area->range); diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index d35628b..607f1e4 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -398,7 +398,7 @@ void output_disassembly(GLoadedBinary *binary, GProcContext *context, GtkStatusS */ format = G_BIN_FORMAT(g_loaded_binary_get_format(binary)); - content = g_binary_format_get_content(format); + content = g_known_format_get_content(G_KNOWN_FORMAT(format)); lang = g_asm_language_new(); *cache = g_buffer_cache_new(content); diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c index dc06511..f3fd462 100644 --- a/src/analysis/disass/fetch.c +++ b/src/analysis/disass/fetch.c @@ -32,6 +32,7 @@ #include "area.h" #include "../../core/global.h" +#include "../../format/known.h" #include "../../format/format.h" #include "../../glibext/delayed-int.h" @@ -411,7 +412,7 @@ GArchInstruction **disassemble_binary_content(GLoadedBinary *binary, GProcContex template.ctx = ctx; - content = g_binary_format_get_content(format); + content = g_known_format_get_content(G_KNOWN_FORMAT(format)); length = g_binary_content_compute_size(content); g_object_unref(G_OBJECT(content)); diff --git a/src/analysis/disass/output.c b/src/analysis/disass/output.c index ff2b526..f2e423c 100644 --- a/src/analysis/disass/output.c +++ b/src/analysis/disass/output.c @@ -31,6 +31,7 @@ #include "../../core/logs.h" +#include "../../format/known.h" #include "../../format/format.h" #include "../../format/symiter.h" #include "../../glibext/generators/rborder.h" @@ -125,7 +126,7 @@ void print_disassembled_instructions(GBufferCache *cache, GCodingLanguage *lang, msize = g_arch_processor_get_memory_size(proc); - content = g_binary_format_get_content(G_BIN_FORMAT(format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(format)); g_arch_processor_lock(proc); diff --git a/src/format/executable.c b/src/format/executable.c index 553b157..26c418e 100644 --- a/src/format/executable.c +++ b/src/format/executable.c @@ -174,7 +174,7 @@ void g_exe_format_add_debug_info(GExeFormat *format, GDbgFormat *info) { const char *desc; /* Description humaine associée*/ - desc = g_binary_format_get_description(G_BIN_FORMAT(info)); + desc = g_known_format_get_description(G_KNOWN_FORMAT(info)); if (desc == NULL) log_simple_message(LMT_WARNING, _("Unnamed debug information")); @@ -313,20 +313,17 @@ bool g_exe_format_get_main_address(GExeFormat *format, vmpa2t *addr) void g_executable_format_setup_portions(GExeFormat *format, GtkStatusStack *status) { - GBinFormat *base; /* Version basique du format */ vmpa2t addr; /* Emplacement vide de sens */ phys_t length; /* Taille de portion globale */ GExeFormatClass *class; /* Classe de l'instance */ size_t i; /* Boucle de parcours */ - base = G_BIN_FORMAT(format); - /** * Avant de lire l'entête du format, on ne sait pas où on se trouve ! */ init_vmpa(&addr, 0, VMPA_NO_VIRTUAL); - length = g_binary_content_compute_size(base->content); + length = g_binary_content_compute_size(G_KNOWN_FORMAT(format)->content); format->portions = g_binary_portion_new(BPC_RAW, &addr, length); @@ -364,7 +361,6 @@ bool g_executable_format_complete_loading(GExeFormat *format, wgroup_id_t gid, G size_t count; /* Qté d'infos supplémentaires */ size_t i; /* Boucle de parcours */ GDbgFormat *dbg; /* Informations de débogage */ - GBinFormat *base; /* Version basique du format */ result = true; @@ -376,20 +372,12 @@ bool g_executable_format_complete_loading(GExeFormat *format, wgroup_id_t gid, G { dbg = g_exe_format_get_debug_info(format, i); - result = g_binary_format_analyze(G_BIN_FORMAT(dbg), gid, status); + result = g_known_format_analyze(G_KNOWN_FORMAT(dbg), gid, status); g_object_unref(G_OBJECT(dbg)); } - if (result) - { - base = G_BIN_FORMAT(format); - - result = g_binary_format_complete_loading(base, status); - - } - return result; } @@ -445,7 +433,7 @@ void g_exe_format_include_portion(GExeFormat *format, GBinPortion *portion, cons phys_t remaining; /* Taille maximale envisageable*/ bool truncated; /* Modification faite ? */ - available = g_binary_content_compute_size(G_BIN_FORMAT(format)->content); + available = g_binary_content_compute_size(G_KNOWN_FORMAT(format)->content); range = g_binary_portion_get_range(portion); diff --git a/src/format/flat.c b/src/format/flat.c index 75e359e..6b8b074 100644 --- a/src/format/flat.c +++ b/src/format/flat.c @@ -28,9 +28,6 @@ #include <string.h> -#include <i18n.h> - - #include "flat-int.h" @@ -48,10 +45,10 @@ static void g_flat_format_dispose(GFlatFormat *); static void g_flat_format_finalize(GFlatFormat *); /* Indique la désignation interne du format. */ -static const char *g_flat_format_get_name(const GFlatFormat *); +static char *g_flat_format_get_key(const GFlatFormat *); /* Fournit une description humaine du format. */ -static const char *g_flat_format_get_description(const GFlatFormat *); +static char *g_flat_format_get_description(const GFlatFormat *); /* Assure l'interprétation d'un format en différé. */ static bool g_flat_format_analyze(GFlatFormat *, wgroup_id_t, GtkStatusStack *); @@ -86,6 +83,7 @@ G_DEFINE_TYPE(GFlatFormat, g_flat_format, G_TYPE_EXE_FORMAT); static void g_flat_format_class_init(GFlatFormatClass *klass) { GObjectClass *object; /* Autre version de la classe */ + GKnownFormatClass *known; /* Version de format connu */ GBinFormatClass *fmt; /* Version en format basique */ GExeFormatClass *exe; /* Version en exécutable */ @@ -94,11 +92,15 @@ static void g_flat_format_class_init(GFlatFormatClass *klass) object->dispose = (GObjectFinalizeFunc/* ! */)g_flat_format_dispose; object->finalize = (GObjectFinalizeFunc)g_flat_format_finalize; + known = G_KNOWN_FORMAT_CLASS(klass); + + known->get_key = (known_get_key_fc)g_flat_format_get_key; + known->get_desc = (known_get_desc_fc)g_flat_format_get_description; + + known->analyze = (known_analyze_fc)g_flat_format_analyze; + fmt = G_BIN_FORMAT_CLASS(klass); - fmt->get_name = (format_get_name_fc)g_flat_format_get_name; - fmt->get_desc = (format_get_desc_fc)g_flat_format_get_description; - fmt->analyze = (format_analyze_fc)g_flat_format_analyze; fmt->get_endian = (format_get_endian_fc)g_flat_format_get_endianness; exe = G_EXE_FORMAT_CLASS(klass); @@ -191,7 +193,7 @@ GExeFormat *g_flat_format_new(GBinContent *content, const char *machine, SourceE result = g_object_new(G_TYPE_FLAT_FORMAT, NULL); - g_binary_format_set_content(G_BIN_FORMAT(result), content); + g_known_format_set_content(G_KNOWN_FORMAT(result), content); result->machine = strdup(machine); result->endian = endian; @@ -207,17 +209,17 @@ GExeFormat *g_flat_format_new(GBinContent *content, const char *machine, SourceE * * * Description : Indique la désignation interne du format. * * * -* Retour : Description du format. * +* Retour : Désignation du format. * * * * Remarques : - * * * ******************************************************************************/ -static const char *g_flat_format_get_name(const GFlatFormat *format) +static char *g_flat_format_get_key(const GFlatFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = "flat"; + result = strdup("flat"); return result; @@ -236,11 +238,11 @@ static const char *g_flat_format_get_name(const GFlatFormat *format) * * ******************************************************************************/ -static const char *g_flat_format_get_description(const GFlatFormat *format) +static char *g_flat_format_get_description(const GFlatFormat *format) { - const char *result; /* Désignation à retourner */ + char *result; /* Désignation à retourner */ - result = _("Flat executable format"); + result = strdup("Flat executable format"); return result; diff --git a/src/format/format-int.h b/src/format/format-int.h index 4ef9793..de29751 100644 --- a/src/format/format-int.h +++ b/src/format/format-int.h @@ -28,6 +28,7 @@ #include "format.h" +#include "known-int.h" #include "preload.h" #include "../glibext/objhole.h" #include "../gtkext/gtkstatusstack.h" @@ -38,22 +39,9 @@ /* ------------------------ TRAITEMENT INDIVIDUEL DE FORMATS ------------------------ */ -/* Indique la désignation interne du format. */ -typedef const char * (* format_get_name_fc) (const GBinFormat *); - -/* Fournit une description humaine du format. */ -typedef const char * (* format_get_desc_fc) (const GBinFormat *); - -/*Assure l'interprétation d'un format en différé. */ -typedef bool (* format_analyze_fc) (GBinFormat *, wgroup_id_t, GtkStatusStack *); - /* Indique le boutisme employé par le format binaire analysé. */ typedef SourceEndian (* format_get_endian_fc) (const GBinFormat *); -/* Réalise un traitement post-désassemblage. */ -typedef void (* format_complete_analysis_fc) (GBinFormat *, wgroup_id_t, GtkStatusStack *); - - /* Rythme des allocations pour les entrées de code */ #define EXTRA_POINT_BLOCK 20 @@ -83,9 +71,7 @@ typedef struct _fmt_error /* Format binaire générique (instance) */ struct _GBinFormat { - GObject parent; /* A laisser en premier */ - - GBinContent *content; /* Contenu binaire à étudier */ + GKnownFormat parent; /* A laisser en premier */ virt_t *start_points[DPL_COUNT]; /* Départ de désassemblage */ size_t pt_allocated[DPL_COUNT]; /* Taille d'inscription allouée*/ @@ -147,17 +133,10 @@ struct _GBinFormat /* Format binaire générique (classe) */ struct _GBinFormatClass { - GObjectClass parent; /* A laisser en premier */ - - format_get_name_fc get_name; /* Désignation interne */ - format_get_desc_fc get_desc; /* Désignation humaine */ - - format_analyze_fc analyze; /* Interprétation du format */ + GKnownFormatClass parent; /* A laisser en premier */ format_get_endian_fc get_endian; /* Boutisme employé */ - format_complete_analysis_fc complete; /* Terminaison d'analyse */ - /* Signaux */ void (* symbol_added) (GBinFormat *, GBinSymbol *); @@ -166,14 +145,6 @@ struct _GBinFormatClass }; -/* Effectue les ultimes opérations de chargement d'un binaire. */ -bool g_binary_format_complete_loading(GBinFormat *, GtkStatusStack *); - -/* Définit le contenu binaire à analyser. */ -void g_binary_format_set_content(GBinFormat *, GBinContent *); - - - /* ------------------------------ DECODAGE DE SYMBOLES ------------------------------ */ diff --git a/src/format/format.c b/src/format/format.c index 18ddc03..0cebc98 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -66,7 +66,7 @@ static bool __g_binary_format_find_symbol(const GBinFormat *, const void *, __co /* Indique le type défini pour un format binaire générique. */ -G_DEFINE_TYPE(GBinFormat, g_binary_format, G_TYPE_OBJECT); +G_DEFINE_TYPE(GBinFormat, g_binary_format, G_TYPE_KNOWN_FORMAT); /****************************************************************************** @@ -162,8 +162,6 @@ static void g_binary_format_dispose(GBinFormat *format) { size_t i; /* Boucle de parcours */ - g_clear_object(&format->content); - g_rw_lock_clear(&format->pt_lock); g_clear_object(&format->info); @@ -223,75 +221,6 @@ static void g_binary_format_finalize(GBinFormat *format) /****************************************************************************** * * -* Paramètres : format = instance à traiter. * -* status = barre de statut à tenir informée. * -* * -* Description : Effectue les ultimes opérations de chargement d'un binaire. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_binary_format_complete_loading(GBinFormat *format, GtkStatusStack *status) -{ - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : format = description de l'exécutable à consulter. * -* content = contenu binaire à parcourir. * -* * -* Description : Définit le contenu binaire à analyser. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_binary_format_set_content(GBinFormat *format, GBinContent *content) -{ - assert(format->content == NULL); - - g_object_ref(G_OBJECT(content)); - - format->content = content; - -} - - -/****************************************************************************** -* * -* Paramètres : format = description de l'exécutable à consulter. * -* * -* Description : Fournit une référence vers le contenu binaire analysé. * -* * -* Retour : Gestionnaire de contenu binaire en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GBinContent *g_binary_format_get_content(const GBinFormat *format) -{ - GBinContent *result; /* Instance à retourner */ - - result = format->content; - - g_object_ref(G_OBJECT(result)); - - return result; - -} - - -/****************************************************************************** -* * * Paramètres : format = format à venir modifier. * * flag = drapeau d'information complémentaire à planter. * * * @@ -421,84 +350,6 @@ FormatFlag g_binary_format_get_flags(const GBinFormat *format) * * * Paramètres : format = description de l'exécutable à consulter. * * * -* Description : Indique la désignation interne du format. * -* * -* Retour : Description du format. * -* * -* Remarques : - * -* * -******************************************************************************/ - -const char *g_binary_format_get_name(const GBinFormat *format) -{ - const char *result; /* Désignation à retourner */ - - result = G_BIN_FORMAT_GET_CLASS(format)->get_name(format); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : format = description de l'exécutable à consulter. * -* * -* Description : Fournit une description humaine du format. * -* * -* Retour : Description du format. * -* * -* Remarques : - * -* * -******************************************************************************/ - -const char *g_binary_format_get_description(const GBinFormat *format) -{ - const char *result; /* Désignation à retourner */ - - result = G_BIN_FORMAT_GET_CLASS(format)->get_desc(format); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : format = format chargé dont l'analyse est lancée. * -* gid = groupe de travail dédié. * -* status = barre de statut à tenir informée. * -* * -* Description : Assure l'interprétation d'un format en différé. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_binary_format_analyze(GBinFormat *format, wgroup_id_t gid, GtkStatusStack *status) -{ - bool result; /* Bilan à retourner */ - GBinFormatClass *class; /* Classe de l'instance */ - - handle_binary_format_analysis(PGA_FORMAT_ANALYSIS_STARTED, format, gid, status); - - class = G_BIN_FORMAT_GET_CLASS(format); - - result = class->analyze(format, gid, status); - - handle_binary_format_analysis(PGA_FORMAT_ANALYSIS_ENDED, format, gid, status); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : format = description de l'exécutable à consulter. * -* * * Description : Indique le boutisme employé par le format binaire analysé. * * * * Retour : Boutisme associé au format. * @@ -601,36 +452,6 @@ void g_binary_format_activate_disassembling_context(GBinFormat *format, GProcCon } -/****************************************************************************** -* * -* Paramètres : format = description de l'exécutable à manipuler. * -* gid = groupe de travail dédié. * -* status = barre de statut à tenir informée. * -* * -* Description : Réalise un traitement post-désassemblage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_binary_format_complete_analysis(GBinFormat *format, wgroup_id_t gid, GtkStatusStack *status) -{ - GBinFormatClass *class; /* Classe de l'instance */ - - handle_binary_format_analysis(PGA_FORMAT_POST_ANALYSIS_STARTED, format, gid, status); - - class = G_BIN_FORMAT_GET_CLASS(format); - - if (class->complete != NULL) - class->complete(format, gid, status); - - handle_binary_format_analysis(PGA_FORMAT_POST_ANALYSIS_ENDED, format, gid, status); - -} - - /* ---------------------------------------------------------------------------------- */ /* DECODAGE DE SYMBOLES */ diff --git a/src/format/format.h b/src/format/format.h index f11b1db..a23782c 100644 --- a/src/format/format.h +++ b/src/format/format.h @@ -69,9 +69,6 @@ typedef struct _GBinFormatClass GBinFormatClass; /* Indique le type défini pour un format binaire générique. */ GType g_binary_format_get_type(void); -/* Fournit une référence vers le contenu binaire analysé. */ -GBinContent *g_binary_format_get_content(const GBinFormat *); - /* Ajoute une information complémentaire à un format. */ bool g_binary_format_set_flag(GBinFormat *, FormatFlag); @@ -84,15 +81,6 @@ bool g_binary_format_has_flag(const GBinFormat *, FormatFlag); /* Fournit les particularités du format. */ FormatFlag g_binary_format_get_flags(const GBinFormat *); -/* Indique la désignation interne du format. */ -const char *g_binary_format_get_name(const GBinFormat *); - -/* Fournit une description humaine du format. */ -const char *g_binary_format_get_description(const GBinFormat *); - -/* Assure l'interprétation d'un format en différé. */ -bool g_binary_format_analyze(GBinFormat *, wgroup_id_t, GtkStatusStack *); - /* Indique le boutisme employé par le format binaire analysé. */ SourceEndian g_binary_format_get_endianness(const GBinFormat *); @@ -105,9 +93,6 @@ void g_binary_format_preload_disassembling_context(GBinFormat *, GProcContext *, /* Définit les points de départ d'un contexte de désassemblage. */ void g_binary_format_activate_disassembling_context(GBinFormat *, GProcContext *, GtkStatusStack *); -/* Réalise un traitement post-désassemblage. */ -void g_binary_format_complete_analysis(GBinFormat *, wgroup_id_t, GtkStatusStack *); - /* ------------------------------ DECODAGE DE SYMBOLES ------------------------------ */ diff --git a/src/format/known-int.h b/src/format/known-int.h index 7b79e50..950c75f 100644 --- a/src/format/known-int.h +++ b/src/format/known-int.h @@ -38,6 +38,9 @@ typedef char * (* known_get_desc_fc) (const GKnownFormat *); /*Assure l'interprétation d'un format en différé. */ typedef bool (* known_analyze_fc) (GKnownFormat *, wgroup_id_t, GtkStatusStack *); +/* Réalise un traitement post-désassemblage. */ +typedef void (* known_complete_analysis_fc) (GKnownFormat *, wgroup_id_t, GtkStatusStack *); + /* Format binaire générique (instance) */ struct _GKnownFormat @@ -57,6 +60,7 @@ struct _GKnownFormatClass known_get_desc_fc get_desc; /* Désignation humaine */ known_analyze_fc analyze; /* Interprétation du format */ + known_complete_analysis_fc complete; /* Terminaison d'analyse */ }; diff --git a/src/format/known.c b/src/format/known.c index c1850bc..6865d0d 100644 --- a/src/format/known.c +++ b/src/format/known.c @@ -175,7 +175,8 @@ GBinContent *g_known_format_get_content(const GKnownFormat *format) result = format->content; - g_object_ref(G_OBJECT(result)); + if (result != NULL) + g_object_ref(G_OBJECT(result)); return result; @@ -258,3 +259,33 @@ bool g_known_format_analyze(GKnownFormat *format, wgroup_id_t gid, GtkStatusStac return result; } + + +/****************************************************************************** +* * +* Paramètres : format = description de l'exécutable à manipuler. * +* gid = groupe de travail dédié. * +* status = barre de statut à tenir informée. * +* * +* Description : Réalise un traitement post-désassemblage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_known_format_complete_analysis(GKnownFormat *format, wgroup_id_t gid, GtkStatusStack *status) +{ + GKnownFormatClass *class; /* Classe de l'instance */ + + handle_known_format_analysis(PGA_FORMAT_POST_ANALYSIS_STARTED, format, gid, status); + + class = G_KNOWN_FORMAT_GET_CLASS(format); + + if (class->complete != NULL) + class->complete(format, gid, status); + + handle_known_format_analysis(PGA_FORMAT_POST_ANALYSIS_ENDED, format, gid, status); + +} diff --git a/src/format/known.h b/src/format/known.h index 2d30147..8319a63 100644 --- a/src/format/known.h +++ b/src/format/known.h @@ -67,6 +67,9 @@ char *g_known_format_get_description(const GKnownFormat *); /* Assure l'interprétation d'un format en différé. */ bool g_known_format_analyze(GKnownFormat *, wgroup_id_t, GtkStatusStack *); +/* Réalise un traitement post-désassemblage. */ +void g_known_format_complete_analysis(GKnownFormat *, wgroup_id_t, GtkStatusStack *); + #endif /* _FORMAT_KNOWN_H */ diff --git a/src/format/strsym.c b/src/format/strsym.c index 91232f4..97c62d9 100644 --- a/src/format/strsym.c +++ b/src/format/strsym.c @@ -245,7 +245,7 @@ static void g_string_symbol_finalize(GStrSymbol *symbol) * * ******************************************************************************/ -GBinSymbol *g_string_symbol_new_read_only(StringEncodingType encoding, GBinFormat *format, const mrange_t *range) +GBinSymbol *g_string_symbol_new_read_only(StringEncodingType encoding, GKnownFormat *format, const mrange_t *range) { GStrSymbol *result; /* Nouveau symbole à renvoyer */ @@ -273,7 +273,7 @@ GBinSymbol *g_string_symbol_new_read_only(StringEncodingType encoding, GBinForma * * ******************************************************************************/ -void g_string_symbol_init_read_only(GStrSymbol *symbol, StringEncodingType encoding, GBinFormat *format, const mrange_t *range) +void g_string_symbol_init_read_only(GStrSymbol *symbol, StringEncodingType encoding, GKnownFormat *format, const mrange_t *range) { GBinSymbol *parent; /* Type d'instance parent */ @@ -284,7 +284,7 @@ void g_string_symbol_init_read_only(GStrSymbol *symbol, StringEncodingType encod symbol->encoding = encoding; - symbol->content = g_binary_format_get_content(format); + symbol->content = g_known_format_get_content(format); symbol->has_content = true; g_string_symbol_check_encoding(symbol); diff --git a/src/format/strsym.h b/src/format/strsym.h index 6900251..5c8a34f 100644 --- a/src/format/strsym.h +++ b/src/format/strsym.h @@ -28,6 +28,7 @@ #include <glib-object.h> +#include "known.h" #include "format.h" #include "symbol.h" @@ -50,12 +51,12 @@ typedef enum _StringEncodingType } StringEncodingType; -#define G_TYPE_STR_SYMBOL g_string_symbol_get_type() -#define G_STR_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_string_symbol_get_type(), GStrSymbol)) -#define G_IS_STR_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_string_symbol_get_type())) -#define G_STR_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_STR_SYMBOL, GStrSymbolClass)) -#define G_IS_STR_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_STR_SYMBOL)) -#define G_STR_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_STR_SYMBOL, GStrSymbolClass)) +#define G_TYPE_STR_SYMBOL g_string_symbol_get_type() +#define G_STR_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_string_symbol_get_type(), GStrSymbol)) +#define G_IS_STR_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_string_symbol_get_type())) +#define G_STR_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_STR_SYMBOL, GStrSymbolClass)) +#define G_IS_STR_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_STR_SYMBOL)) +#define G_STR_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_STR_SYMBOL, GStrSymbolClass)) /*/* Symbole pour chaîne de caractères (instance) */ @@ -69,10 +70,10 @@ typedef struct _GStrSymbolClass GStrSymbolClass; GType g_string_symbol_get_type(void); /* Crée un nouveau symbole pour chaîne de caractères. */ -GBinSymbol *g_string_symbol_new_read_only(StringEncodingType, GBinFormat *, const mrange_t *); +GBinSymbol *g_string_symbol_new_read_only(StringEncodingType, GKnownFormat *, const mrange_t *); /* Réalise la complète initialisation d'unsymbole pour chaîne. */ -void g_string_symbol_init_read_only(GStrSymbol *, StringEncodingType, GBinFormat *, const mrange_t *); +void g_string_symbol_init_read_only(GStrSymbol *, StringEncodingType, GKnownFormat *, const mrange_t *); /* Crée un nouveau symbole pour chaîne de caractères. */ GBinSymbol *g_string_symbol_new_dynamic(StringEncodingType, const char *, const vmpa2t *); diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c index ad5afde..2eee482 100644 --- a/src/gui/panels/strings.c +++ b/src/gui/panels/strings.c @@ -38,6 +38,7 @@ #include "../../common/extstr.h" #include "../../core/params.h" #include "../../core/queue.h" +#include "../../format/known.h" #include "../../format/format.h" #include "../../format/strsym.h" #include "../../format/symiter.h" @@ -759,7 +760,7 @@ static void reload_strings_for_new_list_view(const GStringsPanel *panel, GtkStat format = g_loaded_binary_get_format(panel->binary); portions = g_exe_format_get_portions(format); - content = g_binary_format_get_content(G_BIN_FORMAT(format)); + content = g_known_format_get_content(G_KNOWN_FORMAT(format)); siter = create_symbol_iterator(G_BIN_FORMAT(format), 0); diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h index b4eddbc..ae71458 100644 --- a/src/plugins/pglist.h +++ b/src/plugins/pglist.h @@ -108,9 +108,6 @@ GPluginModule **get_all_plugins_for_action(PluginAction, size_t *); #define handle_known_format_analysis(a, f, g, s) \ process_all_plugins_for(a, g_plugin_module_handle_known_format_analysis, f, g, s) -#define handle_binary_format_analysis(a, f, g, s) \ - process_all_plugins_for(a, g_plugin_module_handle_binary_format_analysis, f, g, s) - #define preload_binary_format(a, f, i, s) \ process_all_plugins_for(a, g_plugin_module_preload_binary_format, f, i, s) diff --git a/src/plugins/plugin-int.h b/src/plugins/plugin-int.h index 4f245b1..6b7eb7f 100644 --- a/src/plugins/plugin-int.h +++ b/src/plugins/plugin-int.h @@ -55,7 +55,7 @@ typedef void (* pg_handle_loaded_fc) (const GPluginModule *, PluginAction, GLoad typedef void (* pg_include_theme_fc) (const GPluginModule *, PluginAction, gboolean, char ***, size_t *); /* Assure l'interprétation d'un format en différé. */ -typedef bool (* pg_handle_format_analysis_fc) (const GPluginModule *, PluginAction, GBinFormat *, wgroup_id_t, GtkStatusStack *); +typedef bool (* pg_handle_format_analysis_fc) (const GPluginModule *, PluginAction, GKnownFormat *, wgroup_id_t, GtkStatusStack *); /* Procède à un préchargement de format de fichier. */ typedef bool (* pg_preload_format_fc) (const GPluginModule *, PluginAction, GBinFormat *, GPreloadInfo *, GtkStatusStack *); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index dc8fc59..e96ddc9 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -1170,38 +1170,14 @@ void g_plugin_module_handle_loaded_content(const GPluginModule *plugin, PluginAc bool g_plugin_module_handle_known_format_analysis(const GPluginModule *plugin, PluginAction action, GKnownFormat *format, wgroup_id_t gid, GtkStatusStack *status) { + bool result; /* Bilan à retourner */ GPluginModuleClass *class; /* Classe de l'instance active */ class = G_PLUGIN_MODULE_GET_CLASS(plugin); - return false;//class->handle_fmt_analysis(plugin, action, G_BIN_FORMAT(format), gid, status); - -} - - -/****************************************************************************** -* * -* Paramètres : plugin = greffon à manipuler. * -* action = type d'action attendue. * -* format = format de binaire à manipuler pendant l'opération. * -* gid = groupe de travail dédié. * -* status = barre de statut à tenir informée. * -* * -* Description : Procède à une opération liée à l'analyse d'un format. * -* * -* Retour : Bilan de l'exécution du traitement. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_plugin_module_handle_binary_format_analysis(const GPluginModule *plugin, PluginAction action, GBinFormat *format, wgroup_id_t gid, GtkStatusStack *status) -{ - GPluginModuleClass *class; /* Classe de l'instance active */ - - class = G_PLUGIN_MODULE_GET_CLASS(plugin); + result = class->handle_fmt_analysis(plugin, action, format, gid, status); - return class->handle_fmt_analysis(plugin, action, format, gid, status); + return result; } diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index 3a55041..37e4c57 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -114,9 +114,6 @@ void g_plugin_module_handle_loaded_content(const GPluginModule *, PluginAction, /* Procède à une opération liée à l'analyse d'un format. */ bool g_plugin_module_handle_known_format_analysis(const GPluginModule *, PluginAction, GKnownFormat *, wgroup_id_t, GtkStatusStack *); -/* Procède à une opération liée à l'analyse d'un format. */ -bool g_plugin_module_handle_binary_format_analysis(const GPluginModule *, PluginAction, GBinFormat *, wgroup_id_t, GtkStatusStack *); - /* Procède à un préchargement de format de fichier. */ bool g_plugin_module_preload_binary_format(const GPluginModule *, PluginAction, GBinFormat *, GPreloadInfo *, GtkStatusStack *); |