diff options
Diffstat (limited to 'src/analysis/scan/items')
35 files changed, 1241 insertions, 107 deletions
diff --git a/src/analysis/scan/items/Makefile.am b/src/analysis/scan/items/Makefile.am index 89ae41e..9263c7b 100644 --- a/src/analysis/scan/items/Makefile.am +++ b/src/analysis/scan/items/Makefile.am @@ -14,6 +14,8 @@ endif libanalysisscanitems_la_SOURCES = \ count.h count.c \ datasize.h datasize.c \ + maxcommon.h maxcommon.c \ + modpath.h modpath.c \ uint-int.h \ uint.h uint.c diff --git a/src/analysis/scan/items/console/log.c b/src/analysis/scan/items/console/log.c index 02b6207..90e8f03 100644 --- a/src/analysis/scan/items/console/log.c +++ b/src/analysis/scan/items/console/log.c @@ -66,7 +66,7 @@ static bool g_scan_console_log_function_run_call(GScanConsoleLogFunction *, GSca /* Indique le type défini pour un afficheur de messages arbitraires. */ -G_DEFINE_TYPE(GScanConsoleLogFunction, g_scan_console_log_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanConsoleLogFunction, g_scan_console_log_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -84,14 +84,14 @@ G_DEFINE_TYPE(GScanConsoleLogFunction, g_scan_console_log_function, G_TYPE_REGIS static void g_scan_console_log_function_class_init(GScanConsoleLogFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_console_log_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_console_log_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_console_log_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_console_log_function_run_call; diff --git a/src/analysis/scan/items/console/log.h b/src/analysis/scan/items/console/log.h index 3e72ad8..95fc55f 100644 --- a/src/analysis/scan/items/console/log.h +++ b/src/analysis/scan/items/console/log.h @@ -41,10 +41,10 @@ /* Mesure de la quantité de données scannées (instance) */ -typedef GRegisteredItem GScanConsoleLogFunction; +typedef GScanRegisteredItem GScanConsoleLogFunction; /* Mesure de la quantité de données scannées (classe) */ -typedef GRegisteredItemClass GScanConsoleLogFunctionClass; +typedef GScanRegisteredItemClass GScanConsoleLogFunctionClass; /* Indique le type défini pour un afficheur de messages arbitraires. */ diff --git a/src/analysis/scan/items/count.c b/src/analysis/scan/items/count.c index 9040ec4..1d01867 100644 --- a/src/analysis/scan/items/count.c +++ b/src/analysis/scan/items/count.c @@ -64,7 +64,7 @@ static bool g_scan_count_function_run_call(GScanCountFunction *, GScanExpression /* Indique le type défini pour un décompte d'ensemble. */ -G_DEFINE_TYPE(GScanCountFunction, g_scan_count_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanCountFunction, g_scan_count_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -82,14 +82,14 @@ G_DEFINE_TYPE(GScanCountFunction, g_scan_count_function, G_TYPE_REGISTERED_ITEM) static void g_scan_count_function_class_init(GScanCountFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_count_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_count_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_count_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_count_function_run_call; @@ -165,9 +165,9 @@ static void g_scan_count_function_finalize(GScanCountFunction *func) * * ******************************************************************************/ -GRegisteredItem *g_scan_count_function_new(void) +GScanRegisteredItem *g_scan_count_function_new(void) { - GScanCountFunction *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_COUNT_FUNCTION, NULL); @@ -225,17 +225,24 @@ static char *g_scan_count_function_get_name(const GScanCountFunction *item) static bool g_scan_count_function_run_call(GScanCountFunction *item, GScanExpression **args, size_t count, GScanContext *ctx, GScanScope *scope, GObject **out) { bool result; /* Bilan à retourner */ + size_t sum; /* Somme des décomptes */ + size_t i; /* Boucle de parcours */ size_t value; /* Nouveau décompte */ - if (count != 1) - result = false; + result = (count > 0); - else + if (result) { - result = g_scan_expression_count_items(args[0], ctx, &value); + sum = 0; + + for (i = 0; i < count && result; i++) + { + result = g_scan_expression_count_items(args[i], ctx, &value); + sum += value; + } if (result) - *out = G_OBJECT(g_scan_literal_expression_new(LVT_UNSIGNED_INTEGER, (unsigned long long []){ value })); + *out = G_OBJECT(g_scan_literal_expression_new(LVT_UNSIGNED_INTEGER, (unsigned long long []){ sum })); } diff --git a/src/analysis/scan/items/count.h b/src/analysis/scan/items/count.h index 2429e40..d83714e 100644 --- a/src/analysis/scan/items/count.h +++ b/src/analysis/scan/items/count.h @@ -41,17 +41,17 @@ /* Mesure de la quantité de données scannées (instance) */ -typedef GRegisteredItem GScanCountFunction; +typedef GScanRegisteredItem GScanCountFunction; /* Mesure de la quantité de données scannées (classe) */ -typedef GRegisteredItemClass GScanCountFunctionClass; +typedef GScanRegisteredItemClass GScanCountFunctionClass; /* Indique le type défini pour un décompte d'ensemble. */ GType g_scan_count_function_get_type(void); /* Constitue une fonction de décompte d'éléments d'un ensemble. */ -GRegisteredItem *g_scan_count_function_new(void); +GScanRegisteredItem *g_scan_count_function_new(void); diff --git a/src/analysis/scan/items/datasize.c b/src/analysis/scan/items/datasize.c index 55e2d3b..11fe649 100644 --- a/src/analysis/scan/items/datasize.c +++ b/src/analysis/scan/items/datasize.c @@ -66,7 +66,7 @@ static bool g_scan_datasize_function_run_call(GScanDatasizeFunction *, GScanExpr /* Indique le type défini pour une mesure de quantité de données scannées. */ -G_DEFINE_TYPE(GScanDatasizeFunction, g_scan_datasize_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanDatasizeFunction, g_scan_datasize_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -84,14 +84,14 @@ G_DEFINE_TYPE(GScanDatasizeFunction, g_scan_datasize_function, G_TYPE_REGISTERED static void g_scan_datasize_function_class_init(GScanDatasizeFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_datasize_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_datasize_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_datasize_function_get_name; registered->reduce = (reduce_registered_item_fc)g_scan_datasize_function_reduce; @@ -168,9 +168,9 @@ static void g_scan_datasize_function_finalize(GScanDatasizeFunction *func) * * ******************************************************************************/ -GRegisteredItem *g_scan_datasize_function_new(void) +GScanRegisteredItem *g_scan_datasize_function_new(void) { - GScanDatasizeFunction *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_DATASIZE_FUNCTION, NULL); diff --git a/src/analysis/scan/items/datasize.h b/src/analysis/scan/items/datasize.h index 476df2d..daa71d1 100644 --- a/src/analysis/scan/items/datasize.h +++ b/src/analysis/scan/items/datasize.h @@ -41,17 +41,17 @@ /* Mesure de la quantité de données scannées (instance) */ -typedef GRegisteredItem GScanDatasizeFunction; +typedef GScanRegisteredItem GScanDatasizeFunction; /* Mesure de la quantité de données scannées (classe) */ -typedef GRegisteredItemClass GScanDatasizeFunctionClass; +typedef GScanRegisteredItemClass GScanDatasizeFunctionClass; /* Indique le type défini pour une mesure de quantité de données scannées. */ GType g_scan_datasize_function_get_type(void); /* Constitue une fonction de récupération de taille de données. */ -GRegisteredItem *g_scan_datasize_function_new(void); +GScanRegisteredItem *g_scan_datasize_function_new(void); diff --git a/src/analysis/scan/items/magic/mime-encoding.c b/src/analysis/scan/items/magic/mime-encoding.c index 935515d..aee23ff 100644 --- a/src/analysis/scan/items/magic/mime-encoding.c +++ b/src/analysis/scan/items/magic/mime-encoding.c @@ -64,7 +64,7 @@ static bool g_scan_mime_encoding_function_run_call(GScanMimeEncodingFunction *, /* Indique le type défini pour une reconnaissance d'encodages de contenus. */ -G_DEFINE_TYPE(GScanMimeEncodingFunction, g_scan_mime_encoding_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanMimeEncodingFunction, g_scan_mime_encoding_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -82,14 +82,14 @@ G_DEFINE_TYPE(GScanMimeEncodingFunction, g_scan_mime_encoding_function, G_TYPE_R static void g_scan_mime_encoding_function_class_init(GScanMimeEncodingFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_mime_encoding_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_mime_encoding_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_mime_encoding_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_mime_encoding_function_run_call; @@ -165,9 +165,9 @@ static void g_scan_mime_encoding_function_finalize(GScanMimeEncodingFunction *fu * * ******************************************************************************/ -GRegisteredItem *g_scan_mime_encoding_function_new(void) +GScanRegisteredItem *g_scan_mime_encoding_function_new(void) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_MIME_ENCODING_FUNCTION, NULL); diff --git a/src/analysis/scan/items/magic/mime-encoding.h b/src/analysis/scan/items/magic/mime-encoding.h index 9349d55..45ac241 100644 --- a/src/analysis/scan/items/magic/mime-encoding.h +++ b/src/analysis/scan/items/magic/mime-encoding.h @@ -41,17 +41,17 @@ /* Reconnaissance d'encodages de contenus (instance) */ -typedef GRegisteredItem GScanMimeEncodingFunction; +typedef GScanRegisteredItem GScanMimeEncodingFunction; /* Reconnaissance d'encodages de contenus (classe) */ -typedef GRegisteredItemClass GScanMimeEncodingFunctionClass; +typedef GScanRegisteredItemClass GScanMimeEncodingFunctionClass; /* Indique le type défini pour une reconnaissance d'encodages de contenus. */ GType g_scan_mime_encoding_function_get_type(void); /* Constitue une fonction de cernement d'encodages de contenus. */ -GRegisteredItem *g_scan_mime_encoding_function_new(void); +GScanRegisteredItem *g_scan_mime_encoding_function_new(void); diff --git a/src/analysis/scan/items/magic/mime-type.c b/src/analysis/scan/items/magic/mime-type.c index 95e441d..0635a33 100644 --- a/src/analysis/scan/items/magic/mime-type.c +++ b/src/analysis/scan/items/magic/mime-type.c @@ -64,7 +64,7 @@ static bool g_scan_mime_type_function_run_call(GScanMimeTypeFunction *, GScanExp /* Indique le type défini pour une reconnaissance de types de contenus. */ -G_DEFINE_TYPE(GScanMimeTypeFunction, g_scan_mime_type_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanMimeTypeFunction, g_scan_mime_type_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -82,14 +82,14 @@ G_DEFINE_TYPE(GScanMimeTypeFunction, g_scan_mime_type_function, G_TYPE_REGISTERE static void g_scan_mime_type_function_class_init(GScanMimeTypeFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_mime_type_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_mime_type_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_mime_type_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_mime_type_function_run_call; @@ -165,9 +165,9 @@ static void g_scan_mime_type_function_finalize(GScanMimeTypeFunction *func) * * ******************************************************************************/ -GRegisteredItem *g_scan_mime_type_function_new(void) +GScanRegisteredItem *g_scan_mime_type_function_new(void) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_MIME_TYPE_FUNCTION, NULL); diff --git a/src/analysis/scan/items/magic/mime-type.h b/src/analysis/scan/items/magic/mime-type.h index e02ce0f..f46cd15 100644 --- a/src/analysis/scan/items/magic/mime-type.h +++ b/src/analysis/scan/items/magic/mime-type.h @@ -41,17 +41,17 @@ /* Reconnaissance de types de contenus (instance) */ -typedef GRegisteredItem GScanMimeTypeFunction; +typedef GScanRegisteredItem GScanMimeTypeFunction; /* Reconnaissance de types de contenus (classe) */ -typedef GRegisteredItemClass GScanMimeTypeFunctionClass; +typedef GScanRegisteredItemClass GScanMimeTypeFunctionClass; /* Indique le type défini pour une reconnaissance de types de contenus. */ GType g_scan_mime_type_function_get_type(void); /* Constitue une fonction d'identification de types de contenus. */ -GRegisteredItem *g_scan_mime_type_function_new(void); +GScanRegisteredItem *g_scan_mime_type_function_new(void); diff --git a/src/analysis/scan/items/magic/type.c b/src/analysis/scan/items/magic/type.c index f87c34a..43b16ff 100644 --- a/src/analysis/scan/items/magic/type.c +++ b/src/analysis/scan/items/magic/type.c @@ -64,7 +64,7 @@ static bool g_scan_magic_type_function_run_call(GScanMagicTypeFunction *, GScanE /* Indique le type défini pour une reconnaissance de types de contenus. */ -G_DEFINE_TYPE(GScanMagicTypeFunction, g_scan_magic_type_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanMagicTypeFunction, g_scan_magic_type_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -82,14 +82,14 @@ G_DEFINE_TYPE(GScanMagicTypeFunction, g_scan_magic_type_function, G_TYPE_REGISTE static void g_scan_magic_type_function_class_init(GScanMagicTypeFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_magic_type_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_magic_type_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_magic_type_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_magic_type_function_run_call; @@ -165,9 +165,9 @@ static void g_scan_magic_type_function_finalize(GScanMagicTypeFunction *func) * * ******************************************************************************/ -GRegisteredItem *g_scan_magic_type_function_new(void) +GScanRegisteredItem *g_scan_magic_type_function_new(void) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_MAGIC_TYPE_FUNCTION, NULL); diff --git a/src/analysis/scan/items/magic/type.h b/src/analysis/scan/items/magic/type.h index bfad213..7a26da3 100644 --- a/src/analysis/scan/items/magic/type.h +++ b/src/analysis/scan/items/magic/type.h @@ -41,17 +41,17 @@ /* Reconnaissance de types de contenus (instance) */ -typedef GRegisteredItem GScanMagicTypeFunction; +typedef GScanRegisteredItem GScanMagicTypeFunction; /* Reconnaissance de types de contenus (classe) */ -typedef GRegisteredItemClass GScanMagicTypeFunctionClass; +typedef GScanRegisteredItemClass GScanMagicTypeFunctionClass; /* Indique le type défini pour une reconnaissance de types de contenus. */ GType g_scan_magic_type_function_get_type(void); /* Constitue une fonction d'identification de types de contenus. */ -GRegisteredItem *g_scan_magic_type_function_new(void); +GScanRegisteredItem *g_scan_magic_type_function_new(void); diff --git a/src/analysis/scan/items/math/to_string.c b/src/analysis/scan/items/math/to_string.c index 4bb8363..5debb61 100644 --- a/src/analysis/scan/items/math/to_string.c +++ b/src/analysis/scan/items/math/to_string.c @@ -70,7 +70,7 @@ static bool g_scan_math_to_string_function_run_call(GScanMathToStringFunction *, /* Indique le type défini pour une conversion d'entier en texte. */ -G_DEFINE_TYPE(GScanMathToStringFunction, g_scan_math_to_string_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanMathToStringFunction, g_scan_math_to_string_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -88,14 +88,14 @@ G_DEFINE_TYPE(GScanMathToStringFunction, g_scan_math_to_string_function, G_TYPE_ static void g_scan_math_to_string_function_class_init(GScanMathToStringFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_math_to_string_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_math_to_string_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_math_to_string_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_math_to_string_function_run_call; @@ -171,9 +171,9 @@ static void g_scan_math_to_string_function_finalize(GScanMathToStringFunction *f * * ******************************************************************************/ -GRegisteredItem *g_scan_math_to_string_function_new(void) +GScanRegisteredItem *g_scan_math_to_string_function_new(void) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_MATH_TO_STRING_FUNCTION, NULL); diff --git a/src/analysis/scan/items/math/to_string.h b/src/analysis/scan/items/math/to_string.h index 19f0020..b9213a9 100644 --- a/src/analysis/scan/items/math/to_string.h +++ b/src/analysis/scan/items/math/to_string.h @@ -41,17 +41,17 @@ /* Conversion d'une valeur entière en valeur textuelle (instance) */ -typedef GRegisteredItem GScanMathToStringFunction; +typedef GScanRegisteredItem GScanMathToStringFunction; /* Conversion d'une valeur entière en valeur textuelle (classe) */ -typedef GRegisteredItemClass GScanMathToStringFunctionClass; +typedef GScanRegisteredItemClass GScanMathToStringFunctionClass; /* Indique le type défini pour une conversion d'entier en texte. */ GType g_scan_math_to_string_function_get_type(void); /* Crée une fonction de conversion de valeur entière en texte. */ -GRegisteredItem *g_scan_math_to_string_function_new(void); +GScanRegisteredItem *g_scan_math_to_string_function_new(void); diff --git a/src/analysis/scan/items/maxcommon.c b/src/analysis/scan/items/maxcommon.c new file mode 100644 index 0000000..e8c4db3 --- /dev/null +++ b/src/analysis/scan/items/maxcommon.c @@ -0,0 +1,374 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * maxcommon.c - détermination de la plus grand occurrence au sein d'un ensemble d'éléments + * + * Copyright (C) 2023 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "maxcommon.h" + + +#include <assert.h> +#include <malloc.h> + + +#include "../item-int.h" +#include "../exprs/literal.h" +#include "../../../glibext/comparison-int.h" + + + +/* ---------------------- INTRODUCTION D'UNE NOUVELLE FONCTION ---------------------- */ + + +/* Initialise la classe des repérages de plus grande occurrence. */ +static void g_scan_maxcommon_function_class_init(GScanMaxcommonFunctionClass *); + +/* Initialise une instance de repérage d'occurrence maximake. */ +static void g_scan_maxcommon_function_init(GScanMaxcommonFunction *); + +/* Supprime toutes les références externes. */ +static void g_scan_maxcommon_function_dispose(GScanMaxcommonFunction *); + +/* Procède à la libération totale de la mémoire. */ +static void g_scan_maxcommon_function_finalize(GScanMaxcommonFunction *); + + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Indique le nom associé à une expression d'évaluation. */ +static char *g_scan_maxcommon_function_get_name(const GScanMaxcommonFunction *); + +/* Réduit une expression à une forme plus simple. */ +static bool g_scan_maxcommon_function_run_call(GScanMaxcommonFunction *, GScanExpression **, size_t, GScanContext *, GScanScope *, GObject **); + + + +/* ---------------------------------------------------------------------------------- */ +/* INTRODUCTION D'UNE NOUVELLE FONCTION */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini pour un décompte d'élément le plus représenté dans une série. */ +G_DEFINE_TYPE(GScanMaxcommonFunction, g_scan_maxcommon_function, G_TYPE_SCAN_REGISTERED_ITEM); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des repérages de plus grande occurrence.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_maxcommon_function_class_init(GScanMaxcommonFunctionClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_maxcommon_function_dispose; + object->finalize = (GObjectFinalizeFunc)g_scan_maxcommon_function_finalize; + + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); + + registered->get_name = (get_registered_item_name_fc)g_scan_maxcommon_function_get_name; + registered->run_call = (run_registered_item_call_fc)g_scan_maxcommon_function_run_call; + +} + + +/****************************************************************************** +* * +* Paramètres : func = instance à initialiser. * +* * +* Description : Initialise une instance de repérage d'occurrence maximake. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_maxcommon_function_init(GScanMaxcommonFunction *func) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : func = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_maxcommon_function_dispose(GScanMaxcommonFunction *func) +{ + G_OBJECT_CLASS(g_scan_maxcommon_function_parent_class)->dispose(G_OBJECT(func)); + +} + + +/****************************************************************************** +* * +* Paramètres : func = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_maxcommon_function_finalize(GScanMaxcommonFunction *func) +{ + G_OBJECT_CLASS(g_scan_maxcommon_function_parent_class)->finalize(G_OBJECT(func)); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Constitue une fonction de calcul de plus grande occurrence. * +* * +* Retour : Fonction mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GScanRegisteredItem *g_scan_maxcommon_function_new(void) +{ + GScanRegisteredItem *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_SCAN_MAXCOMMON_FUNCTION, NULL); + + return result; + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : item = élément d'appel à consulter. * +* * +* Description : Indique le nom associé à une expression d'évaluation. * +* * +* Retour : Désignation humaine de l'expression d'évaluation. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static char *g_scan_maxcommon_function_get_name(const GScanMaxcommonFunction *item) +{ + char *result; /* Désignation à retourner */ + + result = strdup("maxcommon"); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : item = élément d'appel à consulter. * +* args = liste d'éventuels arguments fournis. * +* count = taille de cette liste. * +* ctx = contexte de suivi de l'analyse courante. * +* scope = portée courante des variables locales. * +* out = zone d'enregistrement de la résolution opérée. [OUT] * +* * +* Description : Réduit une expression à une forme plus simple. * +* * +* Retour : Réduction correspondante, expression déjà réduite, ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_scan_maxcommon_function_run_call(GScanMaxcommonFunction *item, GScanExpression **args, size_t count, GScanContext *ctx, GScanScope *scope, GObject **out) +{ + bool result; /* Bilan à retourner */ + size_t used; /* Prochain emplacement libre */ + GScanExpression **collected; /* Représentants de groupes */ + size_t *scores; /* Taille de ces groupes */ + size_t i; /* Boucle de parcours #1 */ + size_t k; /* Boucle de parcours #2 */ + bool status; /* Bilan de la comparaison */ + bool equal; /* Egalité établie ? */ + size_t arg0_count; /* Taille de l'argument unique */ + GScanExpression *arg0_item; /* Elément de cet argument */ + size_t best; /* Meilleur score identifié */ + + result = (count > 0); + if (!result) goto exit; + + used = 0; + + /* Si la série à étudier est directement fournie */ + if (count > 1) + { + collected = malloc(count * sizeof(GScanExpression *)); + scores = malloc(count * sizeof(size_t)); + + for (i = 0; i < count; i++) + { + for (k = 0; k < used; k++) + { + status = g_comparable_item_compare_rich(G_COMPARABLE_ITEM(args[i]), + G_COMPARABLE_ITEM(collected[k]), + RCO_EQ, &equal); + + if (status && equal) + break; + + } + + if (k < used) + scores[k]++; + + else + { + collected[used] = args[i]; + g_object_ref(G_OBJECT(args[i])); + scores[used] = 1; + + used++; + + } + + } + + } + + /* Sinon on considère que l'arguement unique porte la liste (idéalement) */ + else + { + if (G_IS_SCAN_LITERAL_EXPRESSION(args[0]) || !g_scan_expression_handle_set_features(args[0])) + { + best = 1; + goto quick_unique; + } + +#ifndef NDEBUG + g_scan_expression_count_items(args[0], ctx, &arg0_count); +#else + status = g_scan_expression_count_items(args[0], ctx, &arg0_count); + assert(status); +#endif + + collected = malloc(arg0_count * sizeof(GScanExpression *)); + scores = malloc(arg0_count * sizeof(size_t)); + + if (arg0_count == 0) + { + best = 0; + goto quick_empty; + } + + for (i = 0; i < arg0_count; i++) + { +#ifndef NDEBUG + g_scan_expression_get_item(args[0], i, ctx, &arg0_item); +#else + status = g_scan_expression_get_item(args[0], i, ctx, &arg0_item); + assert(status); +#endif + + for (k = 0; k < used; k++) + { + status = g_comparable_item_compare_rich(G_COMPARABLE_ITEM(arg0_item), + G_COMPARABLE_ITEM(collected[k]), + RCO_EQ, &equal); + + if (status && equal) + break; + + } + + if (k < used) + { + g_object_unref(G_OBJECT(arg0_item)); + scores[k]++; + } + + else + { + collected[used] = arg0_item; + scores[used] = 1; + + used++; + + } + + } + + } + + /* Analyse des résultats */ + + best = 0; + + for (i = 0; i < used; i++) + if (scores[i] > best) + best = scores[i]; + + for (i = 0; i < used; i++) + g_object_unref(G_OBJECT(collected[i])); + + free(collected); + free(scores); + + quick_unique: + + assert(best > 0); + + quick_empty: + + *out = G_OBJECT(g_scan_literal_expression_new(LVT_UNSIGNED_INTEGER, (unsigned long long []){ best })); + + exit: + + return result; + +} diff --git a/src/analysis/scan/items/maxcommon.h b/src/analysis/scan/items/maxcommon.h new file mode 100644 index 0000000..a834c00 --- /dev/null +++ b/src/analysis/scan/items/maxcommon.h @@ -0,0 +1,58 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * maxcommon.h - prototypes pour la détermination de la plus grand occurrence au sein d'un ensemble d'éléments + * + * Copyright (C) 2023 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _ANALYSIS_SCAN_ITEMS_MAXCOMMON_H +#define _ANALYSIS_SCAN_ITEMS_MAXCOMMON_H + + +#include <glib-object.h> + + +#include "../item.h" + + + +#define G_TYPE_SCAN_MAXCOMMON_FUNCTION g_scan_maxcommon_function_get_type() +#define G_SCAN_MAXCOMMON_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_MAXCOMMON_FUNCTION, GScanMaxcommonFunction)) +#define G_IS_SCAN_MAXCOMMON_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_MAXCOMMON_FUNCTION)) +#define G_SCAN_MAXCOMMON_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_MAXCOMMON_FUNCTION, GScanMaxcommonFunctionClass)) +#define G_IS_SCAN_MAXCOMMON_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_MAXCOMMON_FUNCTION)) +#define G_SCAN_MAXCOMMON_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_MAXCOMMON_FUNCTION, GScanMaxcommonFunctionClass)) + + +/* Détermination de la plus grand occurrence au sein d'un ensemble (instance) */ +typedef GScanRegisteredItem GScanMaxcommonFunction; + +/* Détermination de la plus grand occurrence au sein d'un ensemble (classe) */ +typedef GScanRegisteredItemClass GScanMaxcommonFunctionClass; + + +/* Indique le type défini pour un décompte d'élément le plus représenté dans une série. */ +GType g_scan_maxcommon_function_get_type(void); + +/* Constitue une fonction de calcul de plus grande occurrence. */ +GScanRegisteredItem *g_scan_maxcommon_function_new(void); + + + +#endif /* _ANALYSIS_SCAN_ITEMS_MAXCOMMON_H */ diff --git a/src/analysis/scan/items/modpath.c b/src/analysis/scan/items/modpath.c new file mode 100644 index 0000000..62d3387 --- /dev/null +++ b/src/analysis/scan/items/modpath.c @@ -0,0 +1,306 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * modpath.c - récupération des combinaisons de modification de motifs + * + * Copyright (C) 2023 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "modpath.h" + + +#include "../item-int.h" + + +#include "../exprs/handler.h" +#include "../exprs/literal.h" +#include "../exprs/set.h" +#include "../matches/bytes.h" + + + +/* ---------------------- INTRODUCTION D'UNE NOUVELLE FONCTION ---------------------- */ + + +/* Initialise la classe des énumérations de formules de motifs. */ +static void g_scan_modpath_function_class_init(GScanModpathFunctionClass *); + +/* Initialise une instance d'énumération de formules de motifs. */ +static void g_scan_modpath_function_init(GScanModpathFunction *); + +/* Supprime toutes les références externes. */ +static void g_scan_modpath_function_dispose(GScanModpathFunction *); + +/* Procède à la libération totale de la mémoire. */ +static void g_scan_modpath_function_finalize(GScanModpathFunction *); + + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Indique le nom associé à une expression d'évaluation. */ +static char *g_scan_modpath_function_get_name(const GScanModpathFunction *); + +/* Réduit une expression à une forme plus simple. */ +static bool g_scan_modpath_function_run_call(GScanModpathFunction *, GScanExpression **, size_t, GScanContext *, GScanScope *, GObject **); + + + +/* ---------------------------------------------------------------------------------- */ +/* INTRODUCTION D'UNE NOUVELLE FONCTION */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini pour une énumération de formules créant des motifs. */ +G_DEFINE_TYPE(GScanModpathFunction, g_scan_modpath_function, G_TYPE_SCAN_REGISTERED_ITEM); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des énumérations de formules de motifs. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_modpath_function_class_init(GScanModpathFunctionClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_modpath_function_dispose; + object->finalize = (GObjectFinalizeFunc)g_scan_modpath_function_finalize; + + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); + + registered->get_name = (get_registered_item_name_fc)g_scan_modpath_function_get_name; + registered->run_call = (run_registered_item_call_fc)g_scan_modpath_function_run_call; + +} + + +/****************************************************************************** +* * +* Paramètres : func = instance à initialiser. * +* * +* Description : Initialise une instance d'énumération de formules de motifs. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_modpath_function_init(GScanModpathFunction *func) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : func = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_modpath_function_dispose(GScanModpathFunction *func) +{ + G_OBJECT_CLASS(g_scan_modpath_function_parent_class)->dispose(G_OBJECT(func)); + +} + + +/****************************************************************************** +* * +* Paramètres : func = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_modpath_function_finalize(GScanModpathFunction *func) +{ + G_OBJECT_CLASS(g_scan_modpath_function_parent_class)->finalize(G_OBJECT(func)); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Constitue une fonction d'énumération des formules de motifs. * +* * +* Retour : Fonction mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GScanRegisteredItem *g_scan_modpath_function_new(void) +{ + GScanRegisteredItem *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_SCAN_MODPATH_FUNCTION, NULL); + + return result; + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : item = élément d'appel à consulter. * +* * +* Description : Indique le nom associé à une expression d'évaluation. * +* * +* Retour : Désignation humaine de l'expression d'évaluation. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static char *g_scan_modpath_function_get_name(const GScanModpathFunction *item) +{ + char *result; /* Désignation à retourner */ + + result = strdup("modpath"); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : item = élément d'appel à consulter. * +* args = liste d'éventuels arguments fournis. * +* count = taille de cette liste. * +* ctx = contexte de suivi de l'analyse courante. * +* scope = portée courante des variables locales. * +* out = zone d'enregistrement de la résolution opérée. [OUT] * +* * +* Description : Réduit une expression à une forme plus simple. * +* * +* Retour : Réduction correspondante, expression déjà réduite, ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_scan_modpath_function_run_call(GScanModpathFunction *item, GScanExpression **args, size_t count, GScanContext *ctx, GScanScope *scope, GObject **out) +{ + + return false; + +#if 0 /* FIXME */ + + bool result; /* Bilan à retourner */ + size_t i; /* Boucle de parcours #1 */ + size_t mcount; /* Quantité de correspondances */ + GScanMatch **matches; /* Correspondances établies */ + size_t k; /* Boucle de parcours #2 */ + sized_string_t path; /* Combinaison à conserver */ + GScanExpression *subitem; /* Nouvel élément à transmettre*/ + + /* Validation préalable du type des arguments */ + + result = true; + + for (i = 0; i < count && result; i++) + result = G_IS_SCAN_PATTERN_HANDLER(args[i]); + + if (!result) + goto exit; + + /* Construction des chemins attendus */ + + *out = G_OBJECT(g_scan_generic_set_new()); + + for (i = 0; i < count; i++) + { + matches = g_scan_pattern_handler_get_all_matches(G_SCAN_PATTERN_HANDLER(args[i]), ctx, &mcount); + if (mcount == 0) continue; + + /** + * La série est à priori constituée d'éléments de même type, donc + * un test unique suffit. + */ + if (!G_IS_SCAN_BYTES_MATCH(matches[0])) + { + for (k = 0; k < mcount; k++) + g_object_unref(G_OBJECT(matches[k])); + } + + else + { + for (k = 0; k < mcount; k++) + { + path.data = g_scan_bytes_match_get_modifier_path(G_SCAN_BYTES_MATCH(matches[k])); + if (path.data == NULL) continue; + + path.len = strlen(path.data); + + subitem = g_scan_literal_expression_new(LVT_STRING, &path); + + g_scan_generic_set_add_item(G_SCAN_GENERIC_SET(*out), subitem); + + g_object_unref(G_OBJECT(subitem)); + + exit_szstr(&path); + + g_object_unref(G_OBJECT(matches[k])); + + } + + } + + free(matches); + + } + + exit: + + return result; + +#endif + +} diff --git a/src/analysis/scan/items/modpath.h b/src/analysis/scan/items/modpath.h new file mode 100644 index 0000000..3a78ef7 --- /dev/null +++ b/src/analysis/scan/items/modpath.h @@ -0,0 +1,58 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * modpath.h - prototypes pour la récupération des combinaisons de modification de motifs + * + * Copyright (C) 2023 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _ANALYSIS_SCAN_ITEMS_MODPATH_H +#define _ANALYSIS_SCAN_ITEMS_MODPATH_H + + +#include <glib-object.h> + + +#include "../item.h" + + + +#define G_TYPE_SCAN_MODPATH_FUNCTION g_scan_modpath_function_get_type() +#define G_SCAN_MODPATH_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_MODPATH_FUNCTION, GScanModpathFunction)) +#define G_IS_SCAN_MODPATH_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_MODPATH_FUNCTION)) +#define G_SCAN_MODPATH_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_MODPATH_FUNCTION, GScanModpathFunctionClass)) +#define G_IS_SCAN_MODPATH_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_MODPATH_FUNCTION)) +#define G_SCAN_MODPATH_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_MODPATH_FUNCTION, GScanModpathFunctionClass)) + + +/* Récupération de formules à l'origine de la construction de motifs (instance) */ +typedef GScanRegisteredItem GScanModpathFunction; + +/* Récupération de formules à l'origine de la construction de motifs (classe) */ +typedef GScanRegisteredItemClass GScanModpathFunctionClass; + + +/* Indique le type défini pour une énumération de formules créant des motifs. */ +GType g_scan_modpath_function_get_type(void); + +/* Constitue une fonction d'énumération des formules de motifs. */ +GScanRegisteredItem *g_scan_modpath_function_new(void); + + + +#endif /* _ANALYSIS_SCAN_ITEMS_MODPATH_H */ diff --git a/src/analysis/scan/items/string/Makefile.am b/src/analysis/scan/items/string/Makefile.am index c9ce6a3..6f8d6c5 100644 --- a/src/analysis/scan/items/string/Makefile.am +++ b/src/analysis/scan/items/string/Makefile.am @@ -5,7 +5,8 @@ noinst_LTLIBRARIES = libanalysisscanitemsstring.la libanalysisscanitemsstring_la_SOURCES = \ lower.h lower.c \ to_int.h to_int.c \ - upper.h upper.c + upper.h upper.c \ + wide.h wide.c libanalysisscanitemsstring_la_CFLAGS = $(LIBGOBJ_CFLAGS) diff --git a/src/analysis/scan/items/string/lower.c b/src/analysis/scan/items/string/lower.c index be8b133..241d87a 100644 --- a/src/analysis/scan/items/string/lower.c +++ b/src/analysis/scan/items/string/lower.c @@ -66,7 +66,7 @@ static bool g_scan_string_lower_function_run_call(GScanStringLowerFunction *, GS /* Indique le type défini pour une bascule de la casse d'une suite de caractères. */ -G_DEFINE_TYPE(GScanStringLowerFunction, g_scan_string_lower_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanStringLowerFunction, g_scan_string_lower_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -84,14 +84,14 @@ G_DEFINE_TYPE(GScanStringLowerFunction, g_scan_string_lower_function, G_TYPE_REG static void g_scan_string_lower_function_class_init(GScanStringLowerFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_string_lower_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_string_lower_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_string_lower_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_string_lower_function_run_call; @@ -167,9 +167,9 @@ static void g_scan_string_lower_function_finalize(GScanStringLowerFunction *func * * ******************************************************************************/ -GRegisteredItem *g_scan_string_lower_function_new(void) +GScanRegisteredItem *g_scan_string_lower_function_new(void) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_STRING_LOWER_FUNCTION, NULL); diff --git a/src/analysis/scan/items/string/lower.h b/src/analysis/scan/items/string/lower.h index f844a65..b9eb00a 100644 --- a/src/analysis/scan/items/string/lower.h +++ b/src/analysis/scan/items/string/lower.h @@ -41,17 +41,17 @@ /* Bascule d'une suite de caractères en minuscules (instance) */ -typedef GRegisteredItem GScanStringLowerFunction; +typedef GScanRegisteredItem GScanStringLowerFunction; /* Bascule d'une suite de caractères en minuscules (classe) */ -typedef GRegisteredItemClass GScanStringLowerFunctionClass; +typedef GScanRegisteredItemClass GScanStringLowerFunctionClass; /* Indique le type défini pour une bascule de la casse d'une suite de caractères. */ GType g_scan_string_lower_function_get_type(void); /* Constitue une fonction de bascule de lettres en minuscules. */ -GRegisteredItem *g_scan_string_lower_function_new(void); +GScanRegisteredItem *g_scan_string_lower_function_new(void); diff --git a/src/analysis/scan/items/string/to_int.c b/src/analysis/scan/items/string/to_int.c index 8031d4d..150fd06 100644 --- a/src/analysis/scan/items/string/to_int.c +++ b/src/analysis/scan/items/string/to_int.c @@ -66,7 +66,7 @@ static bool g_scan_string_to_int_function_run_call(GScanStringToIntFunction *, G /* Indique le type défini pour une conversion de texte en entier. */ -G_DEFINE_TYPE(GScanStringToIntFunction, g_scan_string_to_int_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanStringToIntFunction, g_scan_string_to_int_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -84,14 +84,14 @@ G_DEFINE_TYPE(GScanStringToIntFunction, g_scan_string_to_int_function, G_TYPE_RE static void g_scan_string_to_int_function_class_init(GScanStringToIntFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_string_to_int_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_string_to_int_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_string_to_int_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_string_to_int_function_run_call; @@ -167,9 +167,9 @@ static void g_scan_string_to_int_function_finalize(GScanStringToIntFunction *fun * * ******************************************************************************/ -GRegisteredItem *g_scan_string_to_int_function_new(void) +GScanRegisteredItem *g_scan_string_to_int_function_new(void) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_STRING_TO_INT_FUNCTION, NULL); diff --git a/src/analysis/scan/items/string/to_int.h b/src/analysis/scan/items/string/to_int.h index 143da44..ffd971b 100644 --- a/src/analysis/scan/items/string/to_int.h +++ b/src/analysis/scan/items/string/to_int.h @@ -41,17 +41,17 @@ /* Conversion d'une valeur textuelle en valeur entière (instance) */ -typedef GRegisteredItem GScanStringToIntFunction; +typedef GScanRegisteredItem GScanStringToIntFunction; /* Conversion d'une valeur textuelle en valeur entière (classe) */ -typedef GRegisteredItemClass GScanStringToIntFunctionClass; +typedef GScanRegisteredItemClass GScanStringToIntFunctionClass; /* Indique le type défini pour une conversion de texte en entier. */ GType g_scan_string_to_int_function_get_type(void); /* Crée une fonction de conversion de texte en valeur entière. */ -GRegisteredItem *g_scan_string_to_int_function_new(void); +GScanRegisteredItem *g_scan_string_to_int_function_new(void); diff --git a/src/analysis/scan/items/string/upper.c b/src/analysis/scan/items/string/upper.c index 2ddd0dc..d09ae00 100644 --- a/src/analysis/scan/items/string/upper.c +++ b/src/analysis/scan/items/string/upper.c @@ -66,7 +66,7 @@ static bool g_scan_string_upper_function_run_call(GScanStringUpperFunction *, GS /* Indique le type défini pour une bascule de la casse d'une suite de caractères. */ -G_DEFINE_TYPE(GScanStringUpperFunction, g_scan_string_upper_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanStringUpperFunction, g_scan_string_upper_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -84,14 +84,14 @@ G_DEFINE_TYPE(GScanStringUpperFunction, g_scan_string_upper_function, G_TYPE_REG static void g_scan_string_upper_function_class_init(GScanStringUpperFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_string_upper_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_string_upper_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_string_upper_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_string_upper_function_run_call; @@ -167,9 +167,9 @@ static void g_scan_string_upper_function_finalize(GScanStringUpperFunction *func * * ******************************************************************************/ -GRegisteredItem *g_scan_string_upper_function_new(void) +GScanRegisteredItem *g_scan_string_upper_function_new(void) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_STRING_UPPER_FUNCTION, NULL); diff --git a/src/analysis/scan/items/string/upper.h b/src/analysis/scan/items/string/upper.h index 4f6e4bc..4fdeb09 100644 --- a/src/analysis/scan/items/string/upper.h +++ b/src/analysis/scan/items/string/upper.h @@ -41,17 +41,17 @@ /* Bascule d'une suite de caractères en majuscules (instance) */ -typedef GRegisteredItem GScanStringUpperFunction; +typedef GScanRegisteredItem GScanStringUpperFunction; /* Bascule d'une suite de caractères en majuscules (classe) */ -typedef GRegisteredItemClass GScanStringUpperFunctionClass; +typedef GScanRegisteredItemClass GScanStringUpperFunctionClass; /* Indique le type défini pour une bascule de la casse d'une suite de caractères. */ GType g_scan_string_upper_function_get_type(void); /* Constitue une fonction de bascule de lettres en majuscules. */ -GRegisteredItem *g_scan_string_upper_function_new(void); +GScanRegisteredItem *g_scan_string_upper_function_new(void); diff --git a/src/analysis/scan/items/string/wide.c b/src/analysis/scan/items/string/wide.c new file mode 100644 index 0000000..378f21c --- /dev/null +++ b/src/analysis/scan/items/string/wide.c @@ -0,0 +1,270 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * wide.c - bascule de texte ASCII en UTF-16 + * + * Copyright (C) 2023 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "wide.h" + + +#include <ctype.h> + + +#include "../../item-int.h" +#include "../../exprs/literal.h" + + + +/* ---------------------- INTRODUCTION D'UNE NOUVELLE FONCTION ---------------------- */ + + +/* Initialise la classe des bascules de texte ASCII en UTF-16. */ +static void g_scan_string_wide_function_class_init(GScanStringWideFunctionClass *); + +/* Initialise une instance de bascule de texte ASCII en UTF-16. */ +static void g_scan_string_wide_function_init(GScanStringWideFunction *); + +/* Supprime toutes les références externes. */ +static void g_scan_string_wide_function_dispose(GScanStringWideFunction *); + +/* Procède à la libération totale de la mémoire. */ +static void g_scan_string_wide_function_finalize(GScanStringWideFunction *); + + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Indique le nom associé à une expression d'évaluation. */ +static char *g_scan_string_wide_function_get_name(const GScanStringWideFunction *); + +/* Réduit une expression à une forme plus simple. */ +static bool g_scan_string_wide_function_run_call(GScanStringWideFunction *, GScanExpression **, size_t, GScanContext *, GScanScope *, GObject **); + + + +/* ---------------------------------------------------------------------------------- */ +/* INTRODUCTION D'UNE NOUVELLE FONCTION */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini pour une bascule de texte ASCII en UTF-16. */ +G_DEFINE_TYPE(GScanStringWideFunction, g_scan_string_wide_function, G_TYPE_SCAN_REGISTERED_ITEM); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des bascules de texte ASCII en UTF-16. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_string_wide_function_class_init(GScanStringWideFunctionClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_string_wide_function_dispose; + object->finalize = (GObjectFinalizeFunc)g_scan_string_wide_function_finalize; + + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); + + registered->get_name = (get_registered_item_name_fc)g_scan_string_wide_function_get_name; + registered->run_call = (run_registered_item_call_fc)g_scan_string_wide_function_run_call; + +} + + +/****************************************************************************** +* * +* Paramètres : func = instance à initialiser. * +* * +* Description : Initialise une instance de bascule de texte ASCII en UTF-16. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_string_wide_function_init(GScanStringWideFunction *func) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : func = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_string_wide_function_dispose(GScanStringWideFunction *func) +{ + G_OBJECT_CLASS(g_scan_string_wide_function_parent_class)->dispose(G_OBJECT(func)); + +} + + +/****************************************************************************** +* * +* Paramètres : func = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_scan_string_wide_function_finalize(GScanStringWideFunction *func) +{ + G_OBJECT_CLASS(g_scan_string_wide_function_parent_class)->finalize(G_OBJECT(func)); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Constitue une fonction de bascule de texte ASCII en UTF-16. * +* * +* Retour : Fonction mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GScanRegisteredItem *g_scan_string_wide_function_new(void) +{ + GScanRegisteredItem *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_SCAN_STRING_WIDE_FUNCTION, NULL); + + return result; + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : item = élément d'appel à consulter. * +* * +* Description : Indique le nom associé à une expression d'évaluation. * +* * +* Retour : Désignation humaine de l'expression d'évaluation. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static char *g_scan_string_wide_function_get_name(const GScanStringWideFunction *item) +{ + char *result; /* Désignation à retourner */ + + result = strdup("wide"); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : item = élément d'appel à consulter. * +* args = liste d'éventuels arguments fournis. * +* count = taille de cette liste. * +* ctx = contexte de suivi de l'analyse courante. * +* scope = portée courante des variables locales. * +* out = zone d'enregistrement de la résolution opérée. [OUT] * +* * +* Description : Réduit une expression à une forme plus simple. * +* * +* Retour : Réduction correspondante, expression déjà réduite, ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_scan_string_wide_function_run_call(GScanStringWideFunction *item, GScanExpression **args, size_t count, GScanContext *ctx, GScanScope *scope, GObject **out) +{ + bool result; /* Bilan à retourner */ + GScanLiteralExpression *literal; /* Version plus accessible */ + LiteralValueType vtype; /* Type de valeur portée */ + const sized_string_t *string; /* Description du chaîne */ + sized_string_t new; /* Description transformée */ + size_t i; /* Boucle de parcours */ + + /* Validation des arguments */ + + result = (count == 1); + if (!result) goto exit; + + result = G_IS_SCAN_LITERAL_EXPRESSION(args[0]); + if (!result) goto exit; + + literal = G_SCAN_LITERAL_EXPRESSION(args[0]); + + vtype = g_scan_literal_expression_get_value_type(literal); + + result = (vtype == LVT_STRING); + if (!result) goto exit; + + result = g_scan_literal_expression_get_string_value(literal, &string); + if (!result) goto exit; + + /* Réalisation de l'opération attendue */ + + new.len = string->len * 2; + new.data = calloc(new.len, sizeof(bin_t)); + + for (i = 0; i < string->len; i++) + new.data[i * 2] = string->data[i]; + + *out = G_OBJECT(g_scan_literal_expression_new(LVT_STRING, &new)); + + exit_szstr(&new); + + exit: + + return result; + +} diff --git a/src/analysis/scan/items/string/wide.h b/src/analysis/scan/items/string/wide.h new file mode 100644 index 0000000..65195bd --- /dev/null +++ b/src/analysis/scan/items/string/wide.h @@ -0,0 +1,58 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * wide.h - prototypes pour la bascule de texte ASCII en UTF-16 + * + * Copyright (C) 2023 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _ANALYSIS_SCAN_ITEMS_STRING_WIDE_H +#define _ANALYSIS_SCAN_ITEMS_STRING_WIDE_H + + +#include <glib-object.h> + + +#include "../../item.h" + + + +#define G_TYPE_SCAN_STRING_WIDE_FUNCTION g_scan_string_wide_function_get_type() +#define G_SCAN_STRING_WIDE_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_STRING_WIDE_FUNCTION, GScanStringWideFunction)) +#define G_IS_SCAN_STRING_WIDE_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_STRING_WIDE_FUNCTION)) +#define G_SCAN_STRING_WIDE_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_STRING_WIDE_FUNCTION, GScanStringWideFunctionClass)) +#define G_IS_SCAN_STRING_WIDE_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_STRING_WIDE_FUNCTION)) +#define G_SCAN_STRING_WIDE_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_STRING_WIDE_FUNCTION, GScanStringWideFunctionClass)) + + +/* Bascule d'une suite de texte ASCII en UTF-16 (instance) */ +typedef GScanRegisteredItem GScanStringWideFunction; + +/* Bascule d'une suite de texte ASCII en UTF-16 (classe) */ +typedef GScanRegisteredItemClass GScanStringWideFunctionClass; + + +/* Indique le type défini pour une bascule de texte ASCII en UTF-16. */ +GType g_scan_string_wide_function_get_type(void); + +/* Constitue une fonction de bascule de texte ASCII en UTF-16. */ +GScanRegisteredItem *g_scan_string_wide_function_new(void); + + + +#endif /* _ANALYSIS_SCAN_ITEMS_STRING_WIDE_H */ diff --git a/src/analysis/scan/items/time/make.c b/src/analysis/scan/items/time/make.c index 477a77c..e7330a3 100644 --- a/src/analysis/scan/items/time/make.c +++ b/src/analysis/scan/items/time/make.c @@ -67,7 +67,7 @@ static bool g_scan_time_make_function_run_call(GScanTimeMakeFunction *, GScanExp /* Indique le type défini pour une conversion de date en nombre de secondes. */ -G_DEFINE_TYPE(GScanTimeMakeFunction, g_scan_time_make_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanTimeMakeFunction, g_scan_time_make_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -85,14 +85,14 @@ G_DEFINE_TYPE(GScanTimeMakeFunction, g_scan_time_make_function, G_TYPE_REGISTERE static void g_scan_time_make_function_class_init(GScanTimeMakeFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_time_make_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_time_make_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_time_make_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_time_make_function_run_call; @@ -168,9 +168,9 @@ static void g_scan_time_make_function_finalize(GScanTimeMakeFunction *func) * * ******************************************************************************/ -GRegisteredItem *g_scan_time_make_function_new(void) +GScanRegisteredItem *g_scan_time_make_function_new(void) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_TIME_MAKE_FUNCTION, NULL); diff --git a/src/analysis/scan/items/time/make.h b/src/analysis/scan/items/time/make.h index 958a392..f4be276 100644 --- a/src/analysis/scan/items/time/make.h +++ b/src/analysis/scan/items/time/make.h @@ -41,17 +41,17 @@ /* Convertisseur de date en nombre de secondes depuis le 01/01/1970 (instance) */ -typedef GRegisteredItem GScanTimeMakeFunction; +typedef GScanRegisteredItem GScanTimeMakeFunction; /* Convertisseur de date en nombre de secondes depuis le 01/01/1970 (classe) */ -typedef GRegisteredItemClass GScanTimeMakeFunctionClass; +typedef GScanRegisteredItemClass GScanTimeMakeFunctionClass; /* Indique le type défini pour une conversion de date en nombre de secondes. */ GType g_scan_time_make_function_get_type(void); /* Constitue une fonction de décompte du temps écoulé. */ -GRegisteredItem *g_scan_time_make_function_new(void); +GScanRegisteredItem *g_scan_time_make_function_new(void); diff --git a/src/analysis/scan/items/time/now.c b/src/analysis/scan/items/time/now.c index 16c4aef..7f8b627 100644 --- a/src/analysis/scan/items/time/now.c +++ b/src/analysis/scan/items/time/now.c @@ -66,7 +66,7 @@ static bool g_scan_time_now_function_run_call(GScanTimeNowFunction *, GScanExpre /* Indique le type défini pour un décompte de secondes écoulées depuis le 01/01/1970. */ -G_DEFINE_TYPE(GScanTimeNowFunction, g_scan_time_now_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanTimeNowFunction, g_scan_time_now_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -84,14 +84,14 @@ G_DEFINE_TYPE(GScanTimeNowFunction, g_scan_time_now_function, G_TYPE_REGISTERED_ static void g_scan_time_now_function_class_init(GScanTimeNowFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_time_now_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_time_now_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_time_now_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_time_now_function_run_call; @@ -167,9 +167,9 @@ static void g_scan_time_now_function_finalize(GScanTimeNowFunction *func) * * ******************************************************************************/ -GRegisteredItem *g_scan_time_now_function_new(void) +GScanRegisteredItem *g_scan_time_now_function_new(void) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_TIME_NOW_FUNCTION, NULL); diff --git a/src/analysis/scan/items/time/now.h b/src/analysis/scan/items/time/now.h index 6b3faa2..73ed52a 100644 --- a/src/analysis/scan/items/time/now.h +++ b/src/analysis/scan/items/time/now.h @@ -41,17 +41,17 @@ /* Décompte du nombre de seccondes écoulées depuis le 01/01/1970 (instance) */ -typedef GRegisteredItem GScanTimeNowFunction; +typedef GScanRegisteredItem GScanTimeNowFunction; /* Décompte du nombre de seccondes écoulées depuis le 01/01/1970 (classe) */ -typedef GRegisteredItemClass GScanTimeNowFunctionClass; +typedef GScanRegisteredItemClass GScanTimeNowFunctionClass; /* Indique le type défini pour un décompte de secondes écoulées depuis le 01/01/1970. */ GType g_scan_time_now_function_get_type(void); /* Constitue une fonction de décompte du temps écoulé. */ -GRegisteredItem *g_scan_time_now_function_new(void); +GScanRegisteredItem *g_scan_time_now_function_new(void); diff --git a/src/analysis/scan/items/uint-int.h b/src/analysis/scan/items/uint-int.h index 972d7a0..49050e6 100644 --- a/src/analysis/scan/items/uint-int.h +++ b/src/analysis/scan/items/uint-int.h @@ -35,7 +35,7 @@ /* Fonction conduisant à la lecture d'un mot (instance) */ struct _GScanUintFunction { - GRegisteredItem parent; /* A laisser en premier */ + GScanRegisteredItem parent; /* A laisser en premier */ MemoryDataSize size; /* Taille du mot à lire */ SourceEndian endian; /* Boutisme à respecter */ @@ -45,7 +45,7 @@ struct _GScanUintFunction /* Fonction conduisant à la lecture d'un mot (classe) */ struct _GScanUintFunctionClass { - GRegisteredItemClass parent; /* A laisser en premier */ + GScanRegisteredItemClass parent; /* A laisser en premier */ }; diff --git a/src/analysis/scan/items/uint.c b/src/analysis/scan/items/uint.c index 66c7fa9..8060aca 100644 --- a/src/analysis/scan/items/uint.c +++ b/src/analysis/scan/items/uint.c @@ -67,7 +67,7 @@ static bool g_scan_uint_function_run_call(GScanUintFunction *, GScanExpression * /* Indique le type défini pour une lecture de mot à partir de données binaires. */ -G_DEFINE_TYPE(GScanUintFunction, g_scan_uint_function, G_TYPE_REGISTERED_ITEM); +G_DEFINE_TYPE(GScanUintFunction, g_scan_uint_function, G_TYPE_SCAN_REGISTERED_ITEM); /****************************************************************************** @@ -85,14 +85,14 @@ G_DEFINE_TYPE(GScanUintFunction, g_scan_uint_function, G_TYPE_REGISTERED_ITEM); static void g_scan_uint_function_class_init(GScanUintFunctionClass *klass) { GObjectClass *object; /* Autre version de la classe */ - GRegisteredItemClass *registered; /* Version de classe parente */ + GScanRegisteredItemClass *registered; /* Version de classe parente */ object = G_OBJECT_CLASS(klass); object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_uint_function_dispose; object->finalize = (GObjectFinalizeFunc)g_scan_uint_function_finalize; - registered = G_REGISTERED_ITEM_CLASS(klass); + registered = G_SCAN_REGISTERED_ITEM_CLASS(klass); registered->get_name = (get_registered_item_name_fc)g_scan_uint_function_get_name; registered->run_call = (run_registered_item_call_fc)g_scan_uint_function_run_call; @@ -170,9 +170,9 @@ static void g_scan_uint_function_finalize(GScanUintFunction *func) * * ******************************************************************************/ -GRegisteredItem *g_scan_uint_function_new(MemoryDataSize size, SourceEndian endian) +GScanRegisteredItem *g_scan_uint_function_new(MemoryDataSize size, SourceEndian endian) { - GRegisteredItem *result; /* Structure à retourner */ + GScanRegisteredItem *result; /* Structure à retourner */ result = g_object_new(G_TYPE_SCAN_UINT_FUNCTION, NULL); diff --git a/src/analysis/scan/items/uint.h b/src/analysis/scan/items/uint.h index abc2231..d3dd3cb 100644 --- a/src/analysis/scan/items/uint.h +++ b/src/analysis/scan/items/uint.h @@ -52,7 +52,7 @@ typedef struct _GScanUintFunctionClass GScanUintFunctionClass; GType g_scan_uint_function_get_type(void); /* Constitue une fonction de lecture de valeur entière. */ -GRegisteredItem *g_scan_uint_function_new(MemoryDataSize, SourceEndian); +GScanRegisteredItem *g_scan_uint_function_new(MemoryDataSize, SourceEndian); |
