summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-06-06 14:08:21 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-06-06 14:08:21 (GMT)
commitb5934203c1cb287eb46b07e866b54d1de240b87b (patch)
tree283fad2a6d4517b84985331e5234095c71c8734b /src/format
parente72eea33b9967d4169d2c8ffcb4a9e85c4c3ee8c (diff)
Used a treeview with icons to show all known symbols.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@165 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format')
-rw-r--r--src/format/dex/dex-int.c67
-rwxr-xr-xsrc/format/dex/dex-int.h6
-rwxr-xr-xsrc/format/dex/dex_def.h15
-rw-r--r--src/format/dex/pool.c50
-rw-r--r--src/format/mangling/java_gram.y4
-rw-r--r--src/format/mangling/java_tok.l8
6 files changed, 143 insertions, 7 deletions
diff --git a/src/format/dex/dex-int.c b/src/format/dex/dex-int.c
index 025429f..8f5b408 100644
--- a/src/format/dex/dex-int.c
+++ b/src/format/dex/dex-int.c
@@ -354,6 +354,73 @@ bool read_dex_encoded_method(const GDexFormat *format, off_t *pos, encoded_metho
* pos = position de début de lecture. [OUT] *
* item = structure lue à retourner. [OUT] *
* *
+* Description : Procède à la lecture d'un type DEX. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool read_dex_type_item(const GDexFormat *format, off_t *pos, type_item *item)
+{
+ bool result; /* Bilan à retourner */
+ const bin_t *content; /* Contenu binaire à lire */
+ off_t length; /* Taille totale du contenu */
+
+ result = true;
+
+ content = G_BIN_FORMAT(format)->content;
+ length = G_BIN_FORMAT(format)->length;
+
+ result &= read_u16(&item->type_idx, content, pos, length, SRE_LITTLE);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* pos = position de début de lecture. [OUT] *
+* list = structure lue à retourner. [OUT] *
+* *
+* Description : Procède à la lecture d'une liste de types DEX. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool read_dex_type_list(const GDexFormat *format, off_t *pos, type_list *list)
+{
+ bool result; /* Bilan à retourner */
+ const bin_t *content; /* Contenu binaire à lire */
+ off_t length; /* Taille totale du contenu */
+
+ result = true;
+
+ content = G_BIN_FORMAT(format)->content;
+ length = G_BIN_FORMAT(format)->length;
+
+ result &= read_u32(&list->size, content, pos, length, SRE_LITTLE);
+
+ list->list = (type_item *)&content[*pos];
+ result &= ((*pos + list->size * sizeof(type_item)) <= length);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = informations chargées à consulter. *
+* pos = position de début de lecture. [OUT] *
+* item = structure lue à retourner. [OUT] *
+* *
* Description : Procède à la lecture d'un contenu de classe DEX. *
* *
* Retour : Bilan de l'opération. *
diff --git a/src/format/dex/dex-int.h b/src/format/dex/dex-int.h
index 2e3cc00..4b15c83 100755
--- a/src/format/dex/dex-int.h
+++ b/src/format/dex/dex-int.h
@@ -94,6 +94,12 @@ bool read_dex_encoded_field(const GDexFormat *, off_t *, encoded_field *);
/* Procède à la lecture d'une méthode quelconque DEX. */
bool read_dex_encoded_method(const GDexFormat *, off_t *, encoded_method *);
+/* Procède à la lecture d'un type DEX. */
+bool read_dex_type_item(const GDexFormat *, off_t *, type_item *);
+
+/* Procède à la lecture d'une liste de types DEX. */
+bool read_dex_type_list(const GDexFormat *, off_t *, type_list *);
+
/* Procède à la lecture d'un contenu de classe DEX. */
bool read_dex_class_data_item(const GDexFormat *, off_t *, class_data_item *);
diff --git a/src/format/dex/dex_def.h b/src/format/dex/dex_def.h
index 9faf050..3f6950d 100755
--- a/src/format/dex/dex_def.h
+++ b/src/format/dex/dex_def.h
@@ -117,6 +117,21 @@ typedef struct _encoded_method
} encoded_method;
+/* Type quelconque */
+typedef struct _type_item
+{
+ uint16_t type_idx; /* Indice dans la table adaptée*/
+
+} type_item;
+
+/* Liste de types */
+typedef struct _type_list
+{
+ uint32_t size; /* Nombre d'éléments présents */
+ type_item *list; /* Liste des éléments inscrits */
+
+} type_list;
+
/* Données de fonctionnement pour classe */
typedef struct _class_data_item
{
diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c
index b2ca105..d82144f 100644
--- a/src/format/dex/pool.c
+++ b/src/format/dex/pool.c
@@ -92,7 +92,7 @@ GOpenidaType *get_type_from_dex_pool(const GDexFormat *format, uint16_t index)
string_data_item str_data; /* Description de chaîne */
- //printf("Index :: 0x%04hx\n", index);
+ //printf("Tp Index :: %hd / %d\n", index, format->header.type_ids_size);
if (index >= format->header.type_ids_size)
@@ -255,6 +255,12 @@ GBinRoutine *get_routine_from_dex_pool(const GDexFormat *format, uint32_t index)
string_id_item str_id; /* Identifiant de chaîne */
string_data_item str_data; /* Description de chaîne */
+
+ proto_id_item proto_id; /* Information de prototypage */
+ type_list args; /* Liste des arguments */
+ uint32_t i; /* Boucle de parcours */
+ GBinVariable *arg; /* Argument reconstitué */
+
if (index >= format->header.method_ids_size)
return NULL;
@@ -302,8 +308,50 @@ GBinRoutine *get_routine_from_dex_pool(const GDexFormat *format, uint32_t index)
g_binary_routine_set_namespace(result, type);
+
+ /*
+ printf(" ####\n");
+ printf(" #### ROUTINE '%s'\n", g_binary_routine_to_string(result));
+ printf(" ####\n");
+ printf(" ####\n");
+ */
+
//printf("==>>> routine :: '%s'\n", g_binary_routine_to_string(result));
+
+
+
+
+
+
+ /* Retour de la routine */
+
+ pos = format->header.proto_ids_off + meth_id.proto_idx * sizeof(proto_id_item);
+
+ if (!read_dex_proto_id_item(format, &pos, &proto_id))
+ goto no_more_info;
+
+ type = get_type_from_dex_pool(format, proto_id.return_type_idx);
+
+ g_binary_routine_set_return_type(result, type);
+
+ /* Arguments de la routine */
+
+ pos = proto_id.parameters_off;
+
+ if (read_dex_type_list(format, &pos, &args))
+ for (i = 0; i < args.size; i++)
+ {
+ type = get_type_from_dex_pool(format, args.list[i].type_idx);
+ if (type == NULL) continue;
+
+ arg = g_binary_variable_new(type);
+ g_binary_routine_add_arg(result, arg);
+
+ }
+
+ no_more_info:
+
return result;
}
diff --git a/src/format/mangling/java_gram.y b/src/format/mangling/java_gram.y
index 3522b01..859dce4 100644
--- a/src/format/mangling/java_gram.y
+++ b/src/format/mangling/java_gram.y
@@ -98,7 +98,7 @@ input:
;
type_descriptor:
- 'V' { $$ = g_basic_type_new(BTP_VOID); }
+ V { $$ = g_basic_type_new(BTP_VOID); }
| field_type_descriptor { $$ = $1; }
;
@@ -227,7 +227,7 @@ GDemanglingContext *g_java_dcontext_new(void)
* @param msg indications humaines sur l'événement.
* @return 0.
*/
-int java_error(/*const YYLTYPE *yyloc, bool hunt, char **ucode, unsigned char *index, */char *msg)
+int java_error(/*const YYLTYPE *yyloc, bool hunt, char **ucode, unsigned char *index, */GJavaDContext *context, char *msg)
{
diff --git a/src/format/mangling/java_tok.l b/src/format/mangling/java_tok.l
index 06777f9..c19cd04 100644
--- a/src/format/mangling/java_tok.l
+++ b/src/format/mangling/java_tok.l
@@ -23,11 +23,11 @@ I { return I; }
J { return J; }
F { return F; }
D { return D; }
-L { printf("Got 'L'\n"); BEGIN(string); return L; }
-<string>[/] { printf("Got '/'\n"); return SLASH; }
-<string>[$] { printf("Got '$'\n"); return DOLLAR; }
+L { BEGIN(string); return L; }
+<string>[/] { return SLASH; }
+<string>[$] { return DOLLAR; }
<string>[;] { BEGIN(INITIAL); return SEMICOLON; }
-<string>[A-Za-z0-9]* { java_lval.text = yytext; printf("Got text:'%s'\n", yytext); return TEXT; }
+<string>[A-Za-z0-9]* { java_lval.text = yytext; return TEXT; }
%%