summaryrefslogtreecommitdiff
path: root/plugins/dex
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dex')
-rw-r--r--plugins/dex/dex-int.c42
-rw-r--r--plugins/dex/format.c32
-rw-r--r--plugins/dex/pool.c2
3 files changed, 40 insertions, 36 deletions
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);