diff options
Diffstat (limited to 'plugins/dex')
| -rw-r--r-- | plugins/dex/core.c | 14 | ||||
| -rwxr-xr-x | plugins/dex/format.c | 63 | ||||
| -rwxr-xr-x | plugins/dex/format.h | 3 | ||||
| -rw-r--r-- | plugins/dex/python/format.c | 15 | 
4 files changed, 79 insertions, 16 deletions
| diff --git a/plugins/dex/core.c b/plugins/dex/core.c index 869ef4b..da0a540 100644 --- a/plugins/dex/core.c +++ b/plugins/dex/core.c @@ -54,10 +54,7 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)  {      bool result;                            /* Bilan à retourner           */ -    result = register_format_loader("dex", "Dalvik Executable format", g_dex_format_new); - -    if (result) -        result = add_format_dex_module_to_python_module(); +    result = add_format_dex_module_to_python_module();      return result; @@ -82,19 +79,12 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin)  G_MODULE_EXPORT void chrysalide_plugin_handle_binary_content(const GPluginModule *plugin, PluginAction action, GBinContent *content, gid_t gid, GtkStatusStack *status)  { -    vmpa2t addr;                            /* Tête de lecture initiale    */      bool test;                              /* Bilan des accès mémoire     */ -    char magic[DEX_FILE_MAGIC_LEN];         /* Idenfiant standard          */      GExeFormat *format;                     /* Format DEX reconnu          */      GLoadedContent *loaded;                 /* Représentation chargée      */      GContentResolver *resolver;             /* Resolveur de contenus       */ -    init_vmpa(&addr, 0, VMPA_NO_VIRTUAL); - -    test = g_binary_content_read_raw(content, &addr, DEX_FILE_MAGIC_LEN, (bin_t *)magic); - -    if (test) -        test = (memcmp(magic, DEX_FILE_MAGIC, DEX_FILE_MAGIC_LEN) == 0); +    test = check_dex_format(content);      if (test)      { diff --git a/plugins/dex/format.c b/plugins/dex/format.c index 1fa5a7d..b9b6ca9 100755 --- a/plugins/dex/format.c +++ b/plugins/dex/format.c @@ -55,6 +55,9 @@ static void g_dex_format_finalize(GDexFormat *);  /* Indique la désignation interne du format. */  static const char *g_dex_format_get_name(const GDexFormat *); +/* Fournit une description humaine du format. */ +static const 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 *); @@ -90,6 +93,39 @@ static void g_dex_format_decompile(const GDexFormat *, void/*GCodeBuffer*/ *, co + + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : content = contenu binaire à traiter.                         * +*                                                                             * +*  Description : Valide un contenu comme étant un format Dex.                 * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool check_dex_format(const GBinContent *content) +{ +    bool result;                            /* Bilan à faire remonter      */ +    vmpa2t addr;                            /* Tête de lecture initiale    */ +    char magic[DEX_FILE_MAGIC_LEN];         /* Idenfiant standard          */ + +    init_vmpa(&addr, 0, VMPA_NO_VIRTUAL); + +    result = g_binary_content_read_raw(content, &addr, DEX_FILE_MAGIC_LEN, (bin_t *)magic); + +    if (result) +        result = (memcmp(magic, DEX_FILE_MAGIC, DEX_FILE_MAGIC_LEN) == 0); + +    return result; + +} + +  /* Indique le type défini pour un format d'exécutable DEX. */  G_DEFINE_TYPE(GDexFormat, g_dex_format, G_TYPE_EXE_FORMAT); @@ -120,6 +156,7 @@ static void g_dex_format_class_init(GDexFormatClass *klass)      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; @@ -216,6 +253,9 @@ GExeFormat *g_dex_format_new(GBinContent *content)  {      GDexFormat *result;                     /* Structure à retourner       */ +    if (!check_dex_format(content)) +        return NULL; +      result = g_object_new(G_TYPE_DEX_FORMAT, NULL);      g_binary_format_set_content(G_BIN_FORMAT(result), content); @@ -250,6 +290,29 @@ static const char *g_dex_format_get_name(const GDexFormat *format)  /******************************************************************************  *                                                                             * +*  Paramètres  : format = description de l'exécutable à consulter.            * +*                                                                             * +*  Description : Fournit une description humaine du format.                   * +*                                                                             * +*  Retour      : Description du format.                                       * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static const char *g_dex_format_get_description(const GDexFormat *format) +{ +    const char *result;                     /* Désignation à retourner     */ + +    result = "Dalvik Executable format (version '035')"; + +    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.                   * diff --git a/plugins/dex/format.h b/plugins/dex/format.h index 6850ed1..1879da3 100755 --- a/plugins/dex/format.h +++ b/plugins/dex/format.h @@ -52,6 +52,9 @@ typedef struct _GDexFormat GDexFormat;  typedef struct _GDexFormatClass GDexFormatClass; +/* Valide un contenu comme étant un format Dex. */ +bool check_dex_format(const GBinContent *); +  /* Indique le type défini pour un format d'exécutable DEX. */  GType g_dex_format_get_type(void); diff --git a/plugins/dex/python/format.c b/plugins/dex/python/format.c index 81db02f..8bcd2fa 100644 --- a/plugins/dex/python/format.c +++ b/plugins/dex/python/format.c @@ -100,13 +100,20 @@ static PyObject *py_dex_format_new(PyTypeObject *type, PyObject *args, PyObject      content = G_BIN_CONTENT(pygobject_get(content_obj));      format = g_dex_format_new(content); -    assert(format != NULL); -    result = pygobject_new(G_OBJECT(format)); +    if (format == NULL) +    { +        result = Py_None; +        Py_INCREF(result); +    } -    g_object_unref(format); +    else +    { +        result = pygobject_new(G_OBJECT(format)); +        g_object_unref(format); +    } -    return (PyObject *)result; +    return result;  } | 
