summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/arm/v7/fetch.c3
-rw-r--r--plugins/devdbg/speed.c2
-rw-r--r--plugins/devdbg/speed.h2
-rw-r--r--plugins/dex/dex-int.c42
-rw-r--r--plugins/dex/format.c32
-rw-r--r--plugins/dex/pool.c2
-rw-r--r--plugins/dwarf/abbrev.c2
-rw-r--r--plugins/dwarf/format.c32
-rw-r--r--plugins/dwarf/info.c4
-rw-r--r--plugins/elf/dynamic.c4
-rw-r--r--plugins/elf/elf-int.c14
-rw-r--r--plugins/elf/format.c30
-rw-r--r--plugins/elf/helper_arm.c4
-rw-r--r--plugins/elf/loading.c6
-rw-r--r--plugins/elf/section.c2
-rw-r--r--plugins/elf/strings.c2
-rw-r--r--plugins/elf/symbols.c14
-rw-r--r--plugins/fmtp/parser.c3
-rw-r--r--plugins/mobicore/mclf-int.c4
-rw-r--r--plugins/mobicore/mclf.c32
-rw-r--r--plugins/pychrysalide/format/format.c167
-rw-r--r--plugins/pychrysalide/format/known.c177
-rw-r--r--plugins/pychrysalide/format/known.h3
-rw-r--r--plugins/pychrysalide/format/strsym.c8
-rw-r--r--plugins/pychrysalide/helpers.c25
-rw-r--r--plugins/pychrysalide/helpers.h11
-rw-r--r--plugins/pychrysalide/plugin.c8
-rw-r--r--plugins/readdex/ids.c3
-rw-r--r--plugins/readelf/strtab.c4
-rw-r--r--plugins/ropgadgets/finder.c4
-rw-r--r--plugins/ropgadgets/select.c3
31 files changed, 359 insertions, 290 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 */