diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-03-11 21:57:05 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-03-11 21:57:05 (GMT) |
commit | 8088f1cbb4304c686ff41520099707a333084a4e (patch) | |
tree | 147411c3f90097dc1ae950ec390df2dfccf07ad7 /src/mangling/dex/shorty_gram.y | |
parent | a33dd28e763e3a8b04145fb549aca9320e100a4b (diff) |
Defined a new Dex demangler with MUTF-8 support as plugin.
Diffstat (limited to 'src/mangling/dex/shorty_gram.y')
-rw-r--r-- | src/mangling/dex/shorty_gram.y | 138 |
1 files changed, 0 insertions, 138 deletions
diff --git a/src/mangling/dex/shorty_gram.y b/src/mangling/dex/shorty_gram.y deleted file mode 100644 index b688896..0000000 --- a/src/mangling/dex/shorty_gram.y +++ /dev/null @@ -1,138 +0,0 @@ - -%{ - -#include <stdbool.h> - - -#include "context.h" -#include "../context-int.h" - - - -/* Affiche un message d'erreur concernant l'analyse. */ -static int shorty_error(GDexDemangler *, char *); - -/* Procède au décodage d'une chaîne de caractères. */ -bool demangle_dex_routine(GDexDemangler *, const char *); - - -%} - - -%code requires { - -#include "../../analysis/types/basic.h" -#include "../../analysis/types/cse.h" - -} - -%union { - - GDataType *type; /* Type reconstruit */ - -} - - -%parse-param { GDexDemangler *demangler } - -%token V Z B S C I J F D L - -%type <type> shorty_return_type shorty_field_type - - -%{ - -/* Déclarations issues de l'analyseur syntaxique... */ - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern YY_BUFFER_STATE shorty__scan_string(const char *); -extern void shorty__delete_buffer(YY_BUFFER_STATE); -extern int shorty_lex(void); - -%} - - -%% - - -shorty_descriptor: - shorty_return_type shorty_field_type_list { - GBinRoutine *routine; - routine = G_DEMANGLING_CONTEXT(demangler)->routine; - g_binary_routine_set_return_type(routine, $1); - } - -shorty_field_type_list: - /* empty */ - | shorty_field_type shorty_field_type_list { - GBinRoutine *routine; - GBinVariable *var; - routine = G_DEMANGLING_CONTEXT(demangler)->routine; - var = g_binary_variable_new($1); - g_binary_routine_add_arg(routine, var); - } - -shorty_return_type: - V { $$ = g_basic_type_new(BTP_VOID); } - | shorty_field_type { $$ = $1; } - -shorty_field_type: - Z { $$ = g_basic_type_new(BTP_BOOL); } - | B { $$ = g_basic_type_new(BTP_UCHAR); } - | S { $$ = g_basic_type_new(BTP_SHORT); } - | C { $$ = g_basic_type_new(BTP_CHAR); } - | I { $$ = g_basic_type_new(BTP_INT); } - | J { $$ = g_basic_type_new(BTP_LONG); } - | F { $$ = g_basic_type_new(BTP_FLOAT); } - | D { $$ = g_basic_type_new(BTP_DOUBLE); } - | L { $$ = g_class_enum_type_new(CET_CLASS, ""); } - - -%% - - -/****************************************************************************** -* * -* Paramètres : demangler = contexte associé à la procédure de décodage. * -* msg = indications humaines sur l'événement. * -* * -* Description : Affiche un message d'erreur concernant l'analyse. * -* * -* Retour : Valeur historique, ignorée. * -* * -* Remarques : - * -* * -******************************************************************************/ -static int shorty_error(GDexDemangler *demangler, char *msg) -{ - return -1; - -} - - -/****************************************************************************** -* * -* Paramètres : demangler = contexte de décodage à utiliser. * -* desc = chaîne de caractères à décoder. * -* * -* Description : Procède au décodage d'une chaîne de caractères. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool demangle_dex_routine(GDexDemangler *demangler, const char *desc) -{ - YY_BUFFER_STATE buffer; /* Tampon pour bison */ - int ret; /* Bilan de l'appel */ - - buffer = shorty__scan_string(desc); - ret = yyparse(demangler); - shorty__delete_buffer(buffer); - - return (ret == 0); - -} |