summaryrefslogtreecommitdiff
path: root/src/analysis/scan/patterns/modifiers
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/scan/patterns/modifiers')
-rw-r--r--src/analysis/scan/patterns/modifiers/Makefile.am23
-rw-r--r--src/analysis/scan/patterns/modifiers/hex.c296
-rw-r--r--src/analysis/scan/patterns/modifiers/hex.h58
-rw-r--r--src/analysis/scan/patterns/modifiers/list-int.h54
-rw-r--r--src/analysis/scan/patterns/modifiers/list.c438
-rw-r--r--src/analysis/scan/patterns/modifiers/list.h68
-rw-r--r--src/analysis/scan/patterns/modifiers/lower.c301
-rw-r--r--src/analysis/scan/patterns/modifiers/lower.h58
-rw-r--r--src/analysis/scan/patterns/modifiers/pipe-int.h54
-rw-r--r--src/analysis/scan/patterns/modifiers/pipe.c405
-rw-r--r--src/analysis/scan/patterns/modifiers/pipe.h68
-rw-r--r--src/analysis/scan/patterns/modifiers/plain.c289
-rw-r--r--src/analysis/scan/patterns/modifiers/plain.h58
-rw-r--r--src/analysis/scan/patterns/modifiers/rev.c291
-rw-r--r--src/analysis/scan/patterns/modifiers/rev.h58
-rw-r--r--src/analysis/scan/patterns/modifiers/upper.c301
-rw-r--r--src/analysis/scan/patterns/modifiers/upper.h58
-rw-r--r--src/analysis/scan/patterns/modifiers/wide.c291
-rw-r--r--src/analysis/scan/patterns/modifiers/wide.h58
-rw-r--r--src/analysis/scan/patterns/modifiers/xor.c438
-rw-r--r--src/analysis/scan/patterns/modifiers/xor.h58
21 files changed, 3723 insertions, 0 deletions
diff --git a/src/analysis/scan/patterns/modifiers/Makefile.am b/src/analysis/scan/patterns/modifiers/Makefile.am
new file mode 100644
index 0000000..da046b9
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/Makefile.am
@@ -0,0 +1,23 @@
+
+noinst_LTLIBRARIES = libanalysisscanpatternsmodifiers.la
+
+
+libanalysisscanpatternsmodifiers_la_SOURCES = \
+ hex.h hex.c \
+ list-int.h \
+ list.h list.c \
+ lower.h lower.c \
+ pipe-int.h \
+ pipe.h pipe.c \
+ plain.h plain.c \
+ rev.h rev.c \
+ upper.h upper.c \
+ wide.h wide.c \
+ xor.h xor.c
+
+libanalysisscanpatternsmodifiers_la_CFLAGS = $(LIBGOBJ_CFLAGS)
+
+
+devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%)
+
+dev_HEADERS = $(libanalysisscanpatternsmodifiers_la_SOURCES:%c=)
diff --git a/src/analysis/scan/patterns/modifiers/hex.c b/src/analysis/scan/patterns/modifiers/hex.c
new file mode 100644
index 0000000..4a41c7d
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/hex.c
@@ -0,0 +1,296 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * hex.c - transformation en version hexadécimale d'une séquence d'octets
+ *
+ * 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 "hex.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include "../modifier-int.h"
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transformations en hexadécimal. */
+static void g_scan_hex_modifier_class_init(GScanHexModifierClass *klass);
+
+/* Initialise une instance de transformation en hexadécimal. */
+static void g_scan_hex_modifier_init(GScanHexModifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_hex_modifier_dispose(GScanHexModifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_hex_modifier_finalize(GScanHexModifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_hex_modifier_get_name(const GScanHexModifier *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_hex_modifier_transform(const GScanHexModifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_hex_modifier_get_path(const GScanHexModifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transformation d'une séquence d'octets dans sa version hexadécimale. */
+G_DEFINE_TYPE(GScanHexModifier, g_scan_hex_modifier, G_TYPE_SCAN_TOKEN_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transformations en hexadécimal. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_hex_modifier_class_init(GScanHexModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_hex_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_hex_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_hex_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_hex_modifier_transform;
+ modifier->get_path = (get_modifier_path)g_scan_hex_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transformation en hexadécimal. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_hex_modifier_init(GScanHexModifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_hex_modifier_dispose(GScanHexModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_hex_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_hex_modifier_finalize(GScanHexModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_hex_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur fournistant une vue hexadécimale. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_hex_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_HEX_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_hex_modifier_get_name(const GScanHexModifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("hex");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_hex_modifier_transform(const GScanHexModifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ size_t k; /* Boucle de parcours #2 */
+
+ static char *alphabet = "0123456789abcdef";
+
+ result = true;
+
+ *dcount = scount;
+ *dest = malloc(*dcount * sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++, binary++)
+ {
+ _src = src + i;
+
+ binary->len = _src->len * 2;
+ binary->data = malloc(binary->len);
+
+ for (k = 0; k < _src->len; k++)
+ {
+ binary->data[k * 2 + 0] = alphabet[_src->data[k] >> 4];
+ binary->data[k * 2 + 1] = alphabet[_src->data[k] & 0xf];
+ }
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_hex_modifier_get_path(const GScanHexModifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+
+ if (*index > 0)
+ {
+ result = NULL;
+ (*index)--;
+ }
+
+ else
+ result = strdup("hex");
+
+ return result;
+
+}
diff --git a/src/analysis/scan/patterns/modifiers/hex.h b/src/analysis/scan/patterns/modifiers/hex.h
new file mode 100644
index 0000000..1a9b410
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/hex.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * hex.h - prototypes pour la transformation en version hexadécimale d'une séquence d'octets
+ *
+ * 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_PATTERNS_MODIFIERS_HEX_H
+#define _ANALYSIS_SCAN_PATTERNS_MODIFIERS_HEX_H
+
+
+#include <glib-object.h>
+
+
+#include "../modifier.h"
+
+
+
+#define G_TYPE_SCAN_HEX_MODIFIER g_scan_hex_modifier_get_type()
+#define G_SCAN_HEX_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_HEX_MODIFIER, GScanHexModifier))
+#define G_IS_SCAN_HEX_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_HEX_MODIFIER))
+#define G_SCAN_HEX_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_HEX_MODIFIER, GScanHexModifierClass))
+#define G_IS_SCAN_HEX_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_HEX_MODIFIER))
+#define G_SCAN_HEX_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_HEX_MODIFIER, GScanHexModifierClass))
+
+
+/* Transformation d'une séquence d'octets dans sa version hexadécimale (instance) */
+typedef GScanTokenModifier GScanHexModifier;
+
+/* Transformation d'une séquence d'octets dans sa version hexadécimale (classe) */
+typedef GScanTokenModifierClass GScanHexModifierClass;
+
+
+/* Indique le type défini pour une transformation d'une séquence d'octets dans sa version hexadécimale. */
+GType g_scan_hex_modifier_get_type(void);
+
+/* Construit un modificateur fournistant une vue hexadécimale. */
+GScanTokenModifier *g_scan_hex_modifier_new(void);
+
+
+
+#endif /* _ANALYSIS_SCAN_PATTERNS_MODIFIERS_HEX_H */
diff --git a/src/analysis/scan/patterns/modifiers/list-int.h b/src/analysis/scan/patterns/modifiers/list-int.h
new file mode 100644
index 0000000..3ba253e
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/list-int.h
@@ -0,0 +1,54 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * list-int.h - prototypes internes pour la gestion d'une liste de transformateurs
+ *
+ * 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_MODIFIERS_LIST_INT_H
+#define _ANALYSIS_SCAN_MODIFIERS_LIST_INT_H
+
+
+#include "list.h"
+
+
+#include "../modifier-int.h"
+
+
+
+/* Liste de transformations d'une séquence d'octets (instance) */
+struct _GScanModifierList
+{
+ GScanTokenModifier parent; /* A laisser en premier */
+
+ GScanTokenModifier **modifiers; /* Liste de transformateurs */
+ size_t count; /* Taille de cette liste */
+
+};
+
+/* Liste de transformations d'une séquence d'octets (classe) */
+struct _GScanModifierListClass
+{
+ GScanTokenModifierClass parent; /* A laisser en premier */
+
+};
+
+
+
+#endif /* _ANALYSIS_SCAN_MODIFIERS_LIST_INT_H */
diff --git a/src/analysis/scan/patterns/modifiers/list.c b/src/analysis/scan/patterns/modifiers/list.c
new file mode 100644
index 0000000..86fd19f
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/list.c
@@ -0,0 +1,438 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * list.c - gestion d'une liste de transformateurs
+ *
+ * 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 "list.h"
+
+
+#include <assert.h>
+#include <malloc.h>
+
+
+#include "list-int.h"
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des liste de transformations d'octets. */
+static void g_scan_modifier_list_class_init(GScanModifierListClass *);
+
+/* Initialise une instance de liste de transformations d'octets. */
+static void g_scan_modifier_list_init(GScanModifierList *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_modifier_list_dispose(GScanModifierList *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_modifier_list_finalize(GScanModifierList *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_modifier_list_get_name(const GScanModifierList *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_modifier_list_transform(const GScanModifierList *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_modifier_list_get_path(const GScanModifierList *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une série de transformations d'octets. */
+G_DEFINE_TYPE(GScanModifierList, g_scan_modifier_list, G_TYPE_SCAN_TOKEN_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des liste de transformations d'octets. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_modifier_list_class_init(GScanModifierListClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_modifier_list_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_modifier_list_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_modifier_list_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_modifier_list_transform;
+ modifier->get_path = (get_modifier_path)g_scan_modifier_list_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : list = instance à initialiser. *
+* *
+* Description : Initialise une instance de liste de transformations d'octets.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_modifier_list_init(GScanModifierList *list)
+{
+ list->modifiers = NULL;
+ list->count = 0;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : list = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_modifier_list_dispose(GScanModifierList *list)
+{
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < list->count; i++)
+ g_clear_object(&list->modifiers[i]);
+
+ G_OBJECT_CLASS(g_scan_modifier_list_parent_class)->dispose(G_OBJECT(list));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : list = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_modifier_list_finalize(GScanModifierList *list)
+{
+ if (list->modifiers != NULL)
+ free(list->modifiers);
+
+ G_OBJECT_CLASS(g_scan_modifier_list_parent_class)->finalize(G_OBJECT(list));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit une liste de modificateurs d'octets. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_modifier_list_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_MODIFIER_LIST, NULL);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : list = liste de modificateurs à étendre. *
+* modifier = modificateur à intégrer. *
+* *
+* Description : Intègre un nouveau transformateur dans une liste. *
+* *
+* Retour : Bilan de l'ajout : false si un élément similaire est déjà là.*
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_scan_modifier_list_add(GScanModifierList *list, GScanTokenModifier *modifier)
+{
+ bool result; /* Bilan à retourner */
+ char *name; /* Désignation du modificateur */
+ size_t i; /* Boucle de parcours */
+ char *other; /* Désignation de ses collègues*/
+
+ /* Recherche d'une redondance */
+
+ /**
+ * Note : deux listes identiques passent sans soucis.
+ * TODO : comparer les transformateurs ?
+ */
+
+ result = true;
+
+ if (!G_IS_SCAN_MODIFIER_LIST(modifier))
+ {
+ name = g_scan_token_modifier_get_name(modifier);
+
+ for (i = 0; i < list->count && result; i++)
+ {
+ if (G_IS_SCAN_MODIFIER_LIST(list->modifiers[i]))
+ continue;
+
+ other = g_scan_token_modifier_get_name(list->modifiers[i]);
+
+ result = (strcmp(name, other) != 0);
+
+ free(other);
+
+ }
+
+ free(name);
+
+ }
+
+ if (!result)
+ goto done;
+
+ /* Inclusion dans la liste */
+
+ list->modifiers = realloc(list->modifiers, ++list->count * sizeof(GScanTokenModifier *));
+
+ list->modifiers[list->count - 1] = modifier;
+ g_object_ref(G_OBJECT(modifier));
+
+ done:
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : list = série à consulter. *
+* *
+* Description : Indique le nombre de transformateurs intégrés dans la liste. *
+* *
+* Retour : Nombre de modificateurs représentés. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+size_t g_scan_modifier_list_count(const GScanModifierList *list)
+{
+ size_t result; /* Quantité à retourner */
+
+ result = list->count;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : list = série à consulter. *
+* index = indice du paramètre à retourner. *
+* *
+* Description : Fournit un transformateur donné de la liste. *
+* *
+* Retour : Modificateur inclus dans la liste ou NULL si mauvais indice. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_modifier_list_get(const GScanModifierList *list, size_t index)
+{
+ GScanTokenModifier *result; /* Instance à retourner */
+
+ assert(index < list->count);
+
+ if (index < list->count)
+ {
+ result = list->modifiers[index];
+ g_object_ref(G_OBJECT(result));
+ }
+
+ else
+ result = NULL;
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_modifier_list_get_name(const GScanModifierList *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("(list)");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_modifier_list_transform(const GScanModifierList *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ size_t i; /* Boucle de parcours #1 */
+ sized_binary_t *extra; /* Motifs supplémentaires */
+ size_t extra_count; /* Quantité de ces motifs */
+ sized_binary_t *new; /* Nouvel emplacement libre */
+ size_t k; /* Boucle de parcours #2 */
+
+ *dest = NULL;
+ *dcount = 0;
+
+ for (i = 0; i < modifier->count; i++)
+ {
+ result = g_scan_token_modifier_transform(modifier->modifiers[i], src, scount, &extra, &extra_count);
+ if (!result) goto exit;
+
+ *dcount += extra_count;
+ *dest = realloc(*dest, *dcount * sizeof(sized_binary_t));
+
+ new = (*dest) + *dcount - extra_count;
+
+ for (k = 0; k < extra_count; k++, new++)
+ copy_szstr(*new, extra[k]);
+
+ free(extra);
+
+ }
+
+ exit:
+
+ if (!result)
+ {
+ for (i = 0; i < *dcount; i++)
+ exit_szstr(dest[i]);
+
+ if (*dest != NULL)
+ free(*dest);
+
+ *dest = NULL;
+ *dcount = 0;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_modifier_list_get_path(const GScanModifierList *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+ size_t i; /* Boucle de parcours #1 */
+
+ result = NULL;
+
+ for (i = 0; i < modifier->count && result == NULL; i++)
+ result = g_scan_token_modifier_get_path(modifier->modifiers[i], index);
+
+ return result;
+
+}
diff --git a/src/analysis/scan/patterns/modifiers/list.h b/src/analysis/scan/patterns/modifiers/list.h
new file mode 100644
index 0000000..abd1eae
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/list.h
@@ -0,0 +1,68 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * list.h - prototypes pour la gestion d'une liste de transformateurs
+ *
+ * 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_MODIFIERS_LIST_H
+#define _ANALYSIS_SCAN_MODIFIERS_LIST_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+
+
+#include "../modifier.h"
+
+
+
+#define G_TYPE_SCAN_MODIFIER_LIST g_scan_modifier_list_get_type()
+#define G_SCAN_MODIFIER_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_MODIFIER_LIST, GScanModifierList))
+#define G_IS_SCAN_MODIFIER_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_MODIFIER_LIST))
+#define G_SCAN_MODIFIER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_MODIFIER_LIST, GScanModifierListClass))
+#define G_IS_SCAN_MODIFIER_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_MODIFIER_LIST))
+#define G_SCAN_MODIFIER_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_MODIFIER_LIST, GScanModifierListClass))
+
+
+/* Liste de transformations d'une séquence d'octets (instance) */
+typedef struct _GScanModifierList GScanModifierList;
+
+/* Liste de transformations d'une séquence d'octets (classe) */
+typedef struct _GScanModifierListClass GScanModifierListClass;
+
+
+/* Indique le type défini pour une série de transformations d'octets. */
+GType g_scan_modifier_list_get_type(void);
+
+/* Construit une liste de modificateurs d'octets. */
+GScanTokenModifier *g_scan_modifier_list_new(void);
+
+/* Intègre un nouveau transformateur dans une liste. */
+bool g_scan_modifier_list_add(GScanModifierList *, GScanTokenModifier *);
+
+/* Indique le nombre de transformateurs intégrés dans la liste. */
+size_t g_scan_modifier_list_count(const GScanModifierList *);
+
+/* Fournit un transformateur donné de la liste. */
+GScanTokenModifier *g_scan_modifier_list_get(const GScanModifierList *, size_t);
+
+
+
+#endif /* _ANALYSIS_SCAN_MODIFIERS_LIST_H */
diff --git a/src/analysis/scan/patterns/modifiers/lower.c b/src/analysis/scan/patterns/modifiers/lower.c
new file mode 100644
index 0000000..3904c52
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/lower.c
@@ -0,0 +1,301 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lower.c - transformation d'une séquence d'octets par passage en minuscules
+ *
+ * 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 "lower.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include "../modifier-int.h"
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transmissions en minuscules. */
+static void g_scan_lower_modifier_class_init(GScanLowerModifierClass *klass);
+
+/* Initialise une instance de transmission en minuscules. */
+static void g_scan_lower_modifier_init(GScanLowerModifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_lower_modifier_dispose(GScanLowerModifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_lower_modifier_finalize(GScanLowerModifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_lower_modifier_get_name(const GScanLowerModifier *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_lower_modifier_transform(const GScanLowerModifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_lower_modifier_get_path(const GScanLowerModifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transformation par bascule en minuscules. */
+G_DEFINE_TYPE(GScanLowerModifier, g_scan_lower_modifier, G_TYPE_SCAN_TOKEN_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transmissions en minuscules. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_lower_modifier_class_init(GScanLowerModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_lower_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_lower_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_lower_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_lower_modifier_transform;
+ modifier->get_path = (get_modifier_path)g_scan_lower_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transmission en minuscules. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_lower_modifier_init(GScanLowerModifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_lower_modifier_dispose(GScanLowerModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_lower_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_lower_modifier_finalize(GScanLowerModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_lower_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur livrant des octets en minuscules. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_lower_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_LOWER_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_lower_modifier_get_name(const GScanLowerModifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("lower");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_lower_modifier_transform(const GScanLowerModifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ size_t k; /* Boucle de parcours #2 */
+
+ result = true;
+
+ *dcount = scount;
+ *dest = malloc(*dcount * sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++, binary++)
+ {
+ _src = src + i;
+
+ binary->len = _src->len;
+ binary->data = malloc(binary->len);
+
+ for (k = 0; k < _src->len; k++)
+ switch (_src->data[k])
+ {
+ case 'A' ... 'Z':
+ binary->data[k] = _src->data[k] + 0x20;
+ break;
+
+ default:
+ binary->data[k] = _src->data[k];
+ break;
+
+ }
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_lower_modifier_get_path(const GScanLowerModifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+
+ if (*index > 0)
+ {
+ result = NULL;
+ (*index)--;
+ }
+
+ else
+ result = strdup("lower");
+
+ return result;
+
+}
diff --git a/src/analysis/scan/patterns/modifiers/lower.h b/src/analysis/scan/patterns/modifiers/lower.h
new file mode 100644
index 0000000..d361340
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/lower.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * lower.h - prototypes pour la transformation d'une séquence d'octets par passage en minuscules
+ *
+ * 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_PATTERNS_MODIFIERS_LOWER_H
+#define _ANALYSIS_SCAN_PATTERNS_MODIFIERS_LOWER_H
+
+
+#include <glib-object.h>
+
+
+#include "../modifier.h"
+
+
+
+#define G_TYPE_SCAN_LOWER_MODIFIER g_scan_lower_modifier_get_type()
+#define G_SCAN_LOWER_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_LOWER_MODIFIER, GScanLowerModifier))
+#define G_IS_SCAN_LOWER_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_LOWER_MODIFIER))
+#define G_SCAN_LOWER_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_LOWER_MODIFIER, GScanLowerModifierClass))
+#define G_IS_SCAN_LOWER_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_LOWER_MODIFIER))
+#define G_SCAN_LOWER_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_LOWER_MODIFIER, GScanLowerModifierClass))
+
+
+/* Transformation d'une séquence d'octets par passage en minuscules (instance) */
+typedef GScanTokenModifier GScanLowerModifier;
+
+/* Transformation d'une séquence d'octets par passage en minuscules (classe) */
+typedef GScanTokenModifierClass GScanLowerModifierClass;
+
+
+/* Indique le type défini pour une transformation par bascule en minuscules. */
+GType g_scan_lower_modifier_get_type(void);
+
+/* Construit un modificateur livrant des octets en minuscules. */
+GScanTokenModifier *g_scan_lower_modifier_new(void);
+
+
+
+#endif /* _ANALYSIS_SCAN_PATTERNS_MODIFIERS_LOWER_H */
diff --git a/src/analysis/scan/patterns/modifiers/pipe-int.h b/src/analysis/scan/patterns/modifiers/pipe-int.h
new file mode 100644
index 0000000..63c4d97
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/pipe-int.h
@@ -0,0 +1,54 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * pipe-int.h - prototypes internes pour la gestion de combinaisons de transformateurs
+ *
+ * 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_MODIFIERS_PIPE_INT_H
+#define _ANALYSIS_SCAN_MODIFIERS_PIPE_INT_H
+
+
+#include "pipe.h"
+
+
+#include "../modifier-int.h"
+
+
+
+/* Enchainement combinatoire de transformations d'octets (instance) */
+struct _GScanModifierPipe
+{
+ GScanTokenModifier parent; /* A laisser en premier */
+
+ GScanTokenModifier **modifiers; /* Pipee de transformateurs */
+ size_t count; /* Taille de cette pipee */
+
+};
+
+/* Enchainement combinatoire de transformations d'octets (classe) */
+struct _GScanModifierPipeClass
+{
+ GScanTokenModifierClass parent; /* A laisser en premier */
+
+};
+
+
+
+#endif /* _ANALYSIS_SCAN_MODIFIERS_PIPE_INT_H */
diff --git a/src/analysis/scan/patterns/modifiers/pipe.c b/src/analysis/scan/patterns/modifiers/pipe.c
new file mode 100644
index 0000000..7c659ea
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/pipe.c
@@ -0,0 +1,405 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * pipe.c - gestion de combinaisons de transformateurs
+ *
+ * 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 "pipe.h"
+
+
+#include <assert.h>
+#include <malloc.h>
+
+
+#include "pipe-int.h"
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des pipee de transformations d'octets. */
+static void g_scan_modifier_pipe_class_init(GScanModifierPipeClass *);
+
+/* Initialise une instance de pipee de transformations d'octets. */
+static void g_scan_modifier_pipe_init(GScanModifierPipe *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_modifier_pipe_dispose(GScanModifierPipe *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_modifier_pipe_finalize(GScanModifierPipe *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_modifier_pipe_get_name(const GScanModifierPipe *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_modifier_pipe_transform(const GScanModifierPipe *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_modifier_pipe_get_path(const GScanModifierPipe *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une série de transformations d'octets. */
+G_DEFINE_TYPE(GScanModifierPipe, g_scan_modifier_pipe, G_TYPE_SCAN_TOKEN_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des pipee de transformations d'octets. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_modifier_pipe_class_init(GScanModifierPipeClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_modifier_pipe_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_modifier_pipe_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_modifier_pipe_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_modifier_pipe_transform;
+ modifier->get_path = (get_modifier_path)g_scan_modifier_pipe_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pipe = instance à initialiser. *
+* *
+* Description : Initialise une instance de pipee de transformations d'octets.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_modifier_pipe_init(GScanModifierPipe *pipe)
+{
+ pipe->modifiers = NULL;
+ pipe->count = 0;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pipe = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_modifier_pipe_dispose(GScanModifierPipe *pipe)
+{
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < pipe->count; i++)
+ g_clear_object(&pipe->modifiers[i]);
+
+ G_OBJECT_CLASS(g_scan_modifier_pipe_parent_class)->dispose(G_OBJECT(pipe));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pipe = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_modifier_pipe_finalize(GScanModifierPipe *pipe)
+{
+ if (pipe->modifiers != NULL)
+ free(pipe->modifiers);
+
+ G_OBJECT_CLASS(g_scan_modifier_pipe_parent_class)->finalize(G_OBJECT(pipe));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit une pipee de modificateurs d'octets. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_modifier_pipe_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_MODIFIER_PIPE, NULL);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pipe = pipee de modificateurs à étendre. *
+* modifier = modificateur à intégrer. *
+* *
+* Description : Intègre un nouveau transformateur à enchaîner. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_scan_modifier_pipe_add(GScanModifierPipe *pipe, GScanTokenModifier *modifier)
+{
+ pipe->modifiers = realloc(pipe->modifiers, ++pipe->count * sizeof(GScanTokenModifier *));
+
+ pipe->modifiers[pipe->count - 1] = modifier;
+ g_object_ref(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pipe = série à consulter. *
+* *
+* Description : Indique le nombre de transformateurs intégrés dans la série. *
+* *
+* Retour : Nombre de modificateurs représentés. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+size_t g_scan_modifier_pipe_count(const GScanModifierPipe *pipe)
+{
+ size_t result; /* Quantité à retourner */
+
+ result = pipe->count;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pipe = série à consulter. *
+* index = indice du paramètre à retourner. *
+* *
+* Description : Fournit un transformateur donné de la série. *
+* *
+* Retour : Modificateur inclus dans la pipee ou NULL si mauvais indice. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_modifier_pipe_get(const GScanModifierPipe *pipe, size_t index)
+{
+ GScanTokenModifier *result; /* Instance à retourner */
+
+ assert(index < pipe->count);
+
+ if (index < pipe->count)
+ {
+ result = pipe->modifiers[index];
+ g_object_ref(G_OBJECT(result));
+ }
+
+ else
+ result = NULL;
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_modifier_pipe_get_name(const GScanModifierPipe *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("(pipe)");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_modifier_pipe_transform(const GScanModifierPipe *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ size_t i; /* Boucle de parcours #1 */
+ sized_binary_t *tmp_in; /* Motifs supplémentaires */
+ size_t tmp_in_count; /* Quantité de ces motifs */
+ sized_binary_t *tmp_out; /* Motifs supplémentaires */
+ size_t tmp_out_count; /* Quantité de ces motifs */
+ size_t k; /* Boucle de parcours #2 */
+
+ for (i = 0; i < modifier->count; i++)
+ {
+ if (i == 0)
+ result = g_scan_token_modifier_transform(modifier->modifiers[i],
+ src, scount, &tmp_out, &tmp_out_count);
+
+ else
+ {
+ tmp_in = tmp_out;
+ tmp_in_count = tmp_out_count;
+
+ result = g_scan_token_modifier_transform(modifier->modifiers[i],
+ tmp_in, tmp_in_count, &tmp_out, &tmp_out_count);
+
+ for (k = 0; k < tmp_in_count; k++)
+ exit_szstr(&tmp_in[k]);
+
+ if (tmp_in != NULL)
+ free(tmp_in);
+
+ }
+
+ if (!result)
+ break;
+
+ }
+
+ if (!result)
+ {
+ for (k = 0; k < tmp_out_count; k++)
+ exit_szstr(&tmp_out[k]);
+
+ if (tmp_out != NULL)
+ free(tmp_out);
+
+ *dest = NULL;
+ *dcount = 0;
+
+ }
+ else
+ {
+ *dcount += tmp_out_count;
+ *dest = tmp_out;
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_modifier_pipe_get_path(const GScanModifierPipe *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+ size_t i; /* Boucle de parcours #1 */
+
+ result = NULL;
+
+ for (i = 0; i < modifier->count && result == NULL; i++)
+ result = g_scan_token_modifier_get_path(modifier->modifiers[i], index);
+
+ return result;
+
+}
diff --git a/src/analysis/scan/patterns/modifiers/pipe.h b/src/analysis/scan/patterns/modifiers/pipe.h
new file mode 100644
index 0000000..8f9ca48
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/pipe.h
@@ -0,0 +1,68 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * pipe.h - prototypes pour la gestion de combinaisons de transformateurs
+ *
+ * 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_MODIFIERS_PIPE_H
+#define _ANALYSIS_SCAN_MODIFIERS_PIPE_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+
+
+#include "../modifier.h"
+
+
+
+#define G_TYPE_SCAN_MODIFIER_PIPE g_scan_modifier_pipe_get_type()
+#define G_SCAN_MODIFIER_PIPE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_MODIFIER_PIPE, GScanModifierPipe))
+#define G_IS_SCAN_MODIFIER_PIPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_MODIFIER_PIPE))
+#define G_SCAN_MODIFIER_PIPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_MODIFIER_PIPE, GScanModifierPipeClass))
+#define G_IS_SCAN_MODIFIER_PIPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_MODIFIER_PIPE))
+#define G_SCAN_MODIFIER_PIPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_MODIFIER_PIPE, GScanModifierPipeClass))
+
+
+/* Enchainement combinatoire de transformations d'octets (instance) */
+typedef struct _GScanModifierPipe GScanModifierPipe;
+
+/* Enchainement combinatoire de transformations d'octets (classe) */
+typedef struct _GScanModifierPipeClass GScanModifierPipeClass;
+
+
+/* Indique le type défini pour une série de transformations d'octets. */
+GType g_scan_modifier_pipe_get_type(void);
+
+/* Construit une pipee de modificateurs d'octets. */
+GScanTokenModifier *g_scan_modifier_pipe_new(void);
+
+/* Intègre un nouveau transformateur à enchaîner. */
+void g_scan_modifier_pipe_add(GScanModifierPipe *, GScanTokenModifier *);
+
+/* Indique le nombre de transformateurs intégrés dans la série. */
+size_t g_scan_modifier_pipe_count(const GScanModifierPipe *);
+
+/* Fournit un transformateur donné de la pipee. */
+GScanTokenModifier *g_scan_modifier_pipe_get(const GScanModifierPipe *, size_t);
+
+
+
+#endif /* _ANALYSIS_SCAN_MODIFIERS_PIPE_H */
diff --git a/src/analysis/scan/patterns/modifiers/plain.c b/src/analysis/scan/patterns/modifiers/plain.c
new file mode 100644
index 0000000..ad09129
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/plain.c
@@ -0,0 +1,289 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * plain.c - transmission à l'identique d'une séquence d'octets
+ *
+ * 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 "plain.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include "../modifier-int.h"
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transmissions à l'identique. */
+static void g_scan_plain_modifier_class_init(GScanPlainModifierClass *klass);
+
+/* Initialise une instance de transmission à l'identique. */
+static void g_scan_plain_modifier_init(GScanPlainModifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_plain_modifier_dispose(GScanPlainModifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_plain_modifier_finalize(GScanPlainModifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_plain_modifier_get_name(const GScanPlainModifier *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_plain_modifier_transform(const GScanPlainModifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_plain_modifier_get_path(const GScanPlainModifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transmission à l'identique d'une séquence d'octets. */
+G_DEFINE_TYPE(GScanPlainModifier, g_scan_plain_modifier, G_TYPE_SCAN_TOKEN_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transmissions à l'identique. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_plain_modifier_class_init(GScanPlainModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_plain_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_plain_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_plain_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_plain_modifier_transform;
+ modifier->get_path = (get_modifier_path)g_scan_plain_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transmission à l'identique. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_plain_modifier_init(GScanPlainModifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_plain_modifier_dispose(GScanPlainModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_plain_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_plain_modifier_finalize(GScanPlainModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_plain_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur livrant des octets à l'identique. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_plain_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_PLAIN_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_plain_modifier_get_name(const GScanPlainModifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("plain");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_plain_modifier_transform(const GScanPlainModifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours */
+ const sized_binary_t *_src; /* Source courante */
+
+ result = true;
+
+ *dcount = scount;
+ *dest = malloc(*dcount * sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++, binary++)
+ {
+ _src = src + i;
+
+ binary->len = _src->len;
+ binary->data = malloc(binary->len);
+
+ memcpy(binary->data, _src->data, _src->len);
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_plain_modifier_get_path(const GScanPlainModifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+
+ if (*index > 0)
+ {
+ result = NULL;
+ (*index)--;
+ }
+
+ else
+ result = strdup("plain");
+
+ return result;
+
+}
diff --git a/src/analysis/scan/patterns/modifiers/plain.h b/src/analysis/scan/patterns/modifiers/plain.h
new file mode 100644
index 0000000..ecabefd
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/plain.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * plain.h - prototypes pour la transmission à l'identique d'une séquence d'octets
+ *
+ * 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_PATTERNS_MODIFIERS_PLAIN_H
+#define _ANALYSIS_SCAN_PATTERNS_MODIFIERS_PLAIN_H
+
+
+#include <glib-object.h>
+
+
+#include "../modifier.h"
+
+
+
+#define G_TYPE_SCAN_PLAIN_MODIFIER g_scan_plain_modifier_get_type()
+#define G_SCAN_PLAIN_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_PLAIN_MODIFIER, GScanPlainModifier))
+#define G_IS_SCAN_PLAIN_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_PLAIN_MODIFIER))
+#define G_SCAN_PLAIN_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_PLAIN_MODIFIER, GScanPlainModifierClass))
+#define G_IS_SCAN_PLAIN_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_PLAIN_MODIFIER))
+#define G_SCAN_PLAIN_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_PLAIN_MODIFIER, GScanPlainModifierClass))
+
+
+/* Transmission à l'identique d'une séquence d'octets (instance) */
+typedef GScanTokenModifier GScanPlainModifier;
+
+/* Transmission à l'identique d'une séquence d'octets (classe) */
+typedef GScanTokenModifierClass GScanPlainModifierClass;
+
+
+/* Indique le type défini pour une transmission à l'identique d'une séquence d'octets. */
+GType g_scan_plain_modifier_get_type(void);
+
+/* Construit un modificateur livrant des octets à l'identique. */
+GScanTokenModifier *g_scan_plain_modifier_new(void);
+
+
+
+#endif /* _ANALYSIS_SCAN_PATTERNS_MODIFIERS_PLAIN_H */
diff --git a/src/analysis/scan/patterns/modifiers/rev.c b/src/analysis/scan/patterns/modifiers/rev.c
new file mode 100644
index 0000000..ef4d5fa
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/rev.c
@@ -0,0 +1,291 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * rev.c - transormation via inversement d'une séquence d'octets
+ *
+ * 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 "rev.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include "../modifier-int.h"
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transmissions via inversement. */
+static void g_scan_reverse_modifier_class_init(GScanReverseModifierClass *klass);
+
+/* Initialise une instance de transmission via inversement. */
+static void g_scan_reverse_modifier_init(GScanReverseModifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_reverse_modifier_dispose(GScanReverseModifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_reverse_modifier_finalize(GScanReverseModifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_reverse_modifier_get_name(const GScanReverseModifier *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_reverse_modifier_transform(const GScanReverseModifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_reverse_modifier_get_path(const GScanReverseModifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transormation via inversement d'une séquence d'octets. */
+G_DEFINE_TYPE(GScanReverseModifier, g_scan_reverse_modifier, G_TYPE_SCAN_TOKEN_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transmissions via inversement. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_reverse_modifier_class_init(GScanReverseModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_reverse_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_reverse_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_reverse_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_reverse_modifier_transform;
+ modifier->get_path = (get_modifier_path)g_scan_reverse_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transmission via inversement. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_reverse_modifier_init(GScanReverseModifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_reverse_modifier_dispose(GScanReverseModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_reverse_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_reverse_modifier_finalize(GScanReverseModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_reverse_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur livrant des octets inversés. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_reverse_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_REVERSE_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_reverse_modifier_get_name(const GScanReverseModifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("rev");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_reverse_modifier_transform(const GScanReverseModifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ size_t k; /* Boucle de parcours #2 */
+
+ result = true;
+
+ *dcount = scount;
+ *dest = malloc(*dcount * sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++, binary++)
+ {
+ _src = src + i;
+
+ binary->len = _src->len;
+ binary->data = malloc(binary->len);
+
+ for (k = 0; k < _src->len; k++)
+ binary->data[_src->len - k - 1] = _src->data[k];
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_reverse_modifier_get_path(const GScanReverseModifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+
+ if (*index > 0)
+ {
+ result = NULL;
+ (*index)--;
+ }
+
+ else
+ result = strdup("rev");
+
+ return result;
+
+}
diff --git a/src/analysis/scan/patterns/modifiers/rev.h b/src/analysis/scan/patterns/modifiers/rev.h
new file mode 100644
index 0000000..5b4e398
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/rev.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * rev.h - prototypes pour la transormation via inversement d'une séquence d'octets
+ *
+ * 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_PATTERNS_MODIFIERS_REV_H
+#define _ANALYSIS_SCAN_PATTERNS_MODIFIERS_REV_H
+
+
+#include <glib-object.h>
+
+
+#include "../modifier.h"
+
+
+
+#define G_TYPE_SCAN_REVERSE_MODIFIER g_scan_reverse_modifier_get_type()
+#define G_SCAN_REVERSE_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_REVERSE_MODIFIER, GScanReverseModifier))
+#define G_IS_SCAN_REVERSE_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_REVERSE_MODIFIER))
+#define G_SCAN_REVERSE_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_REVERSE_MODIFIER, GScanReverseModifierClass))
+#define G_IS_SCAN_REVERSE_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_REVERSE_MODIFIER))
+#define G_SCAN_REVERSE_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_REVERSE_MODIFIER, GScanReverseModifierClass))
+
+
+/* Transormation via inversement d'une séquence d'octets (instance) */
+typedef GScanTokenModifier GScanReverseModifier;
+
+/* Transormation via inversement d'une séquence d'octets (classe) */
+typedef GScanTokenModifierClass GScanReverseModifierClass;
+
+
+/* Indique le type défini pour une transormation via inversement d'une séquence d'octets. */
+GType g_scan_reverse_modifier_get_type(void);
+
+/* Construit un modificateur livrant des octets inversés. */
+GScanTokenModifier *g_scan_reverse_modifier_new(void);
+
+
+
+#endif /* _ANALYSIS_SCAN_PATTERNS_MODIFIERS_REV_H */
diff --git a/src/analysis/scan/patterns/modifiers/upper.c b/src/analysis/scan/patterns/modifiers/upper.c
new file mode 100644
index 0000000..9d1086b
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/upper.c
@@ -0,0 +1,301 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * upper.c - transformation d'une séquence d'octets par passage en majuscules
+ *
+ * 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 "upper.h"
+
+
+#include <malloc.h>
+#include <string.h>
+
+
+#include "../modifier-int.h"
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transmissions en majuscules. */
+static void g_scan_upper_modifier_class_init(GScanUpperModifierClass *klass);
+
+/* Initialise une instance de transmission en majuscules. */
+static void g_scan_upper_modifier_init(GScanUpperModifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_upper_modifier_dispose(GScanUpperModifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_upper_modifier_finalize(GScanUpperModifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_upper_modifier_get_name(const GScanUpperModifier *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_upper_modifier_transform(const GScanUpperModifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_upper_modifier_get_path(const GScanUpperModifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transformation par bascule en majuscules. */
+G_DEFINE_TYPE(GScanUpperModifier, g_scan_upper_modifier, G_TYPE_SCAN_TOKEN_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transmissions en majuscules. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_upper_modifier_class_init(GScanUpperModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_upper_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_upper_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_upper_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_upper_modifier_transform;
+ modifier->get_path = (get_modifier_path)g_scan_upper_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transmission en majuscules. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_upper_modifier_init(GScanUpperModifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_upper_modifier_dispose(GScanUpperModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_upper_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_upper_modifier_finalize(GScanUpperModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_upper_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur livrant des octets en majuscules. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_upper_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_UPPER_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_upper_modifier_get_name(const GScanUpperModifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("upper");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_upper_modifier_transform(const GScanUpperModifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ size_t k; /* Boucle de parcours #2 */
+
+ result = true;
+
+ *dcount = scount;
+ *dest = malloc(*dcount * sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++, binary++)
+ {
+ _src = src + i;
+
+ binary->len = _src->len;
+ binary->data = malloc(binary->len);
+
+ for (k = 0; k < _src->len; k++)
+ switch (_src->data[k])
+ {
+ case 'a' ... 'z':
+ binary->data[k] = _src->data[k] - 0x20;
+ break;
+
+ default:
+ binary->data[k] = _src->data[k];
+ break;
+
+ }
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_upper_modifier_get_path(const GScanUpperModifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+
+ if (*index > 0)
+ {
+ result = NULL;
+ (*index)--;
+ }
+
+ else
+ result = strdup("upper");
+
+ return result;
+
+}
diff --git a/src/analysis/scan/patterns/modifiers/upper.h b/src/analysis/scan/patterns/modifiers/upper.h
new file mode 100644
index 0000000..4666312
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/upper.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * upper.h - prototypes pour la transformation d'une séquence d'octets par passage en majuscules
+ *
+ * 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_PATTERNS_MODIFIERS_UPPER_H
+#define _ANALYSIS_SCAN_PATTERNS_MODIFIERS_UPPER_H
+
+
+#include <glib-object.h>
+
+
+#include "../modifier.h"
+
+
+
+#define G_TYPE_SCAN_UPPER_MODIFIER g_scan_upper_modifier_get_type()
+#define G_SCAN_UPPER_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_UPPER_MODIFIER, GScanUpperModifier))
+#define G_IS_SCAN_UPPER_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_UPPER_MODIFIER))
+#define G_SCAN_UPPER_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_UPPER_MODIFIER, GScanUpperModifierClass))
+#define G_IS_SCAN_UPPER_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_UPPER_MODIFIER))
+#define G_SCAN_UPPER_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_UPPER_MODIFIER, GScanUpperModifierClass))
+
+
+/* Transformation d'une séquence d'octets par passage en majuscules (instance) */
+typedef GScanTokenModifier GScanUpperModifier;
+
+/* Transformation d'une séquence d'octets par passage en majuscules (classe) */
+typedef GScanTokenModifierClass GScanUpperModifierClass;
+
+
+/* Indique le type défini pour une transformation par bascule en majuscules. */
+GType g_scan_upper_modifier_get_type(void);
+
+/* Construit un modificateur livrant des octets en majuscules. */
+GScanTokenModifier *g_scan_upper_modifier_new(void);
+
+
+
+#endif /* _ANALYSIS_SCAN_PATTERNS_MODIFIERS_UPPER_H */
diff --git a/src/analysis/scan/patterns/modifiers/wide.c b/src/analysis/scan/patterns/modifiers/wide.c
new file mode 100644
index 0000000..ef252d9
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/wide.c
@@ -0,0 +1,291 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * wide.c - transcription d'une séquence d'octets 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 <malloc.h>
+#include <string.h>
+
+
+#include "../modifier-int.h"
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transcriptions en UTF-16. */
+static void g_scan_wide_modifier_class_init(GScanWideModifierClass *klass);
+
+/* Initialise une instance de transcription en UTF-16. */
+static void g_scan_wide_modifier_init(GScanWideModifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_wide_modifier_dispose(GScanWideModifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_wide_modifier_finalize(GScanWideModifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_wide_modifier_get_name(const GScanWideModifier *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_wide_modifier_transform(const GScanWideModifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_wide_modifier_get_path(const GScanWideModifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transcription d'une séquence d'octets en UTF-16. */
+G_DEFINE_TYPE(GScanWideModifier, g_scan_wide_modifier, G_TYPE_SCAN_TOKEN_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transcriptions en UTF-16. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_wide_modifier_class_init(GScanWideModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_wide_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_wide_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_wide_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_wide_modifier_transform;
+ modifier->get_path = (get_modifier_path)g_scan_wide_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transcription en UTF-16. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_wide_modifier_init(GScanWideModifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_wide_modifier_dispose(GScanWideModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_wide_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_wide_modifier_finalize(GScanWideModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_wide_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur livrant des octets en UTF-16. *
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_wide_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_WIDE_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_wide_modifier_get_name(const GScanWideModifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("wide");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_wide_modifier_transform(const GScanWideModifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ size_t k; /* Boucle de parcours #2 */
+
+ result = true;
+
+ *dcount = scount;
+ *dest = malloc(*dcount * sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++, binary++)
+ {
+ _src = src + i;
+
+ binary->len = _src->len * 2;
+ binary->data = calloc(binary->len * 2, sizeof(bin_t));
+
+ for (k = 0; k < _src->len; k++)
+ binary->data[k * 2] = _src->data[k];
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_wide_modifier_get_path(const GScanWideModifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+
+ if (*index > 0)
+ {
+ result = NULL;
+ (*index)--;
+ }
+
+ else
+ result = strdup("wide");
+
+ return result;
+
+}
diff --git a/src/analysis/scan/patterns/modifiers/wide.h b/src/analysis/scan/patterns/modifiers/wide.h
new file mode 100644
index 0000000..deb92a4
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/wide.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * wide.h - prototypes pour la transcription d'une séquence d'octets 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_PATTERNS_MODIFIERS_WIDE_H
+#define _ANALYSIS_SCAN_PATTERNS_MODIFIERS_WIDE_H
+
+
+#include <glib-object.h>
+
+
+#include "../modifier.h"
+
+
+
+#define G_TYPE_SCAN_WIDE_MODIFIER g_scan_wide_modifier_get_type()
+#define G_SCAN_WIDE_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_WIDE_MODIFIER, GScanWideModifier))
+#define G_IS_SCAN_WIDE_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_WIDE_MODIFIER))
+#define G_SCAN_WIDE_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_WIDE_MODIFIER, GScanWideModifierClass))
+#define G_IS_SCAN_WIDE_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_WIDE_MODIFIER))
+#define G_SCAN_WIDE_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_WIDE_MODIFIER, GScanWideModifierClass))
+
+
+/* Transcription d'une séquence d'octets en UTF-16 (instance) */
+typedef GScanTokenModifier GScanWideModifier;
+
+/* Transcription d'une séquence d'octets en UTF-16 (classe) */
+typedef GScanTokenModifierClass GScanWideModifierClass;
+
+
+/* Indique le type défini pour une transcription d'une séquence d'octets en UTF-16. */
+GType g_scan_wide_modifier_get_type(void);
+
+/* Construit un modificateur livrant des octets en UTF-16. */
+GScanTokenModifier *g_scan_wide_modifier_new(void);
+
+
+
+#endif /* _ANALYSIS_SCAN_PATTERNS_MODIFIERS_WIDE_H */
diff --git a/src/analysis/scan/patterns/modifiers/xor.c b/src/analysis/scan/patterns/modifiers/xor.c
new file mode 100644
index 0000000..d932c82
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/xor.c
@@ -0,0 +1,438 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * xor.c - transormation via opération XOR
+ *
+ * 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 "xor.h"
+
+
+#include <assert.h>
+#include <malloc.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+
+#include "../modifier-int.h"
+
+
+
+/* ----------------------- RECHERCHE D'UN MOTIF DE TEXTE BRUT ----------------------- */
+
+
+/* Initialise la classe des transmissions via opération XOR. */
+static void g_scan_xor_modifier_class_init(GScanXorModifierClass *klass);
+
+/* Initialise une instance de transmission via opération XOR. */
+static void g_scan_xor_modifier_init(GScanXorModifier *);
+
+/* Supprime toutes les références externes. */
+static void g_scan_xor_modifier_dispose(GScanXorModifier *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_scan_xor_modifier_finalize(GScanXorModifier *);
+
+
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+
+
+/* Fournit le nom d'appel d'un modificateur pour motif. */
+static char *g_scan_xor_modifier_get_name(const GScanXorModifier *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_xor_modifier_transform(const GScanXorModifier *, const sized_binary_t *, size_t, sized_binary_t **, size_t *);
+
+/* Détermine si un argument est bien toléré par un modificateur. */
+static bool g_scan_xor_modifier_can_handle_arg(const GScanXorModifier *, const modifier_arg_t *);
+
+/* Transforme une séquence d'octets pour motif de recherche. */
+static bool g_scan_xor_modifier_transform_with_arg(const GScanXorModifier *, const sized_binary_t *, size_t, const modifier_arg_t *, sized_binary_t **, size_t *);
+
+/* Retrouve l'origine d'une correspondance à partir d'un indice. */
+static char *g_scan_xor_modifier_get_path(const GScanXorModifier *, size_t *);
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* RECHERCHE D'UN MOTIF DE TEXTE BRUT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Indique le type défini pour une transormation via une opération XOR. */
+G_DEFINE_TYPE(GScanXorModifier, g_scan_xor_modifier, G_TYPE_SCAN_TOKEN_MODIFIER);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des transmissions via opération XOR. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_xor_modifier_class_init(GScanXorModifierClass *klass)
+{
+ GObjectClass *object; /* Autre version de la classe */
+ GScanTokenModifierClass *modifier; /* Version de classe parente */
+
+ object = G_OBJECT_CLASS(klass);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_scan_xor_modifier_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_scan_xor_modifier_finalize;
+
+ modifier = G_SCAN_TOKEN_MODIFIER_CLASS(klass);
+
+ modifier->get_name = (get_scan_modifier_name_fc)g_scan_xor_modifier_get_name;
+
+ modifier->transform = (transform_scan_token_fc)g_scan_xor_modifier_transform;
+ modifier->can_handle = (can_token_modifier_handle_arg)g_scan_xor_modifier_can_handle_arg;
+ modifier->transform_with = (transform_scan_token_with_fc)g_scan_xor_modifier_transform_with_arg;
+ modifier->get_path = (get_modifier_path)g_scan_xor_modifier_get_path;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance à initialiser. *
+* *
+* Description : Initialise une instance de transmission via opération XOR. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_xor_modifier_init(GScanXorModifier *modifier)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_xor_modifier_dispose(GScanXorModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_xor_modifier_parent_class)->dispose(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_scan_xor_modifier_finalize(GScanXorModifier *modifier)
+{
+ G_OBJECT_CLASS(g_scan_xor_modifier_parent_class)->finalize(G_OBJECT(modifier));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Construit un modificateur livrant des octets traités par XOR.*
+* *
+* Retour : Mécanisme mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GScanTokenModifier *g_scan_xor_modifier_new(void)
+{
+ GScanTokenModifier *result; /* Structure à retourner */
+
+ result = g_object_new(G_TYPE_SCAN_XOR_MODIFIER, NULL);
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* *
+* Description : Fournit le nom d'appel d'un modificateur pour motif. *
+* *
+* Retour : Désignation humaine. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_xor_modifier_get_name(const GScanXorModifier *modifier)
+{
+ char *result; /* Désignation à retourner */
+
+ result = strdup("xor");
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_xor_modifier_transform(const GScanXorModifier *modifier, const sized_binary_t *src, size_t scount, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ long long x; /* Boucle de parcours #2 */
+ size_t k; /* Boucle de parcours #3 */
+
+ result = true;
+
+ *dcount = scount * 256;
+ *dest = malloc(*dcount * sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++)
+ {
+ _src = src + i;
+
+ for (x = 0; x <= 0xff; x++, binary++)
+ {
+ binary->len = _src->len;
+ binary->data = malloc(binary->len);
+
+ for (k = 0; k < _src->len; k++)
+ binary->data[k] = _src->data[k] ^ x;
+
+ }
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* arg = argument de personnalisation. *
+* *
+* Description : Détermine si un argument est bien toléré par un modificateur.*
+* *
+* Retour : Bilan de la consultation : support ou non. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_xor_modifier_can_handle_arg(const GScanXorModifier *modifier, const modifier_arg_t *arg)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+
+ switch (arg->type)
+ {
+ case MAT_UNSIGNED_INTEGER:
+ result = (arg->value.u_integer <= UINT8_MAX);
+ break;
+
+ case MAT_RANGE:
+ result = (INT8_MIN <= arg->value.range.start && arg->value.range.end <= INT8_MAX);
+ break;
+
+ default:
+ result = false;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à solliciter. *
+* src = séquences d'octets à traiter. *
+* scount = quantité de ces séquences. *
+* arg = argument de personnalisation. *
+* dest = nouvelle(s) séquence(s) d'octets obtenue(s) [OUT] *
+* dcount = quantité de ces séquences. *
+* *
+* Description : Transforme une séquence d'octets pour motif de recherche. *
+* *
+* Retour : Bilan de l'opération : succès ou échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool g_scan_xor_modifier_transform_with_arg(const GScanXorModifier *modifier, const sized_binary_t *src, size_t scount, const modifier_arg_t *arg, sized_binary_t **dest, size_t *dcount)
+{
+ bool result; /* Bilan d'opération à renvoyer*/
+ sized_binary_t *binary; /* Raccourci vers le stockage */
+ size_t i; /* Boucle de parcours #1 */
+ const sized_binary_t *_src; /* Source courante */
+ long long x; /* Boucle de parcours #2 */
+ size_t k; /* Boucle de parcours #3 */
+
+ result = true;
+
+ switch (arg->type)
+ {
+ case MAT_UNSIGNED_INTEGER:
+
+ *dcount = scount;
+ *dest = malloc(*dcount * sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++)
+ {
+ _src = src + i;
+
+ binary->len = _src->len;
+ binary->data = malloc(binary->len);
+
+ for (k = 0; k < _src->len; k++)
+ binary->data[k] = _src->data[k] ^ arg->value.u_integer;
+
+ }
+
+ break;
+
+ case MAT_RANGE:
+
+ *dcount = scount * (arg->value.range.end - arg->value.range.start + 1);
+ *dest = malloc(*dcount * sizeof(sized_binary_t));
+
+ binary = &(*dest)[0];
+
+ for (i = 0; i < scount; i++)
+ {
+ _src = src + i;
+
+ for (x = arg->value.range.start; x <= arg->value.range.end; x++, binary++)
+ {
+ binary->len = _src->len;
+ binary->data = malloc(binary->len);
+
+ for (k = 0; k < _src->len; k++)
+ binary->data[k] = _src->data[k] ^ x;
+
+ }
+
+ }
+
+ break;
+
+ default:
+ assert(false);
+ result = false;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : modifier = modificateur à consulter. *
+* index = indice de la combinaison ciblée. [OUT] *
+* *
+* Description : Retrouve l'origine d'une correspondance à partir d'un indice.*
+* *
+* Retour : Version humainement lisible de la combinaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *g_scan_xor_modifier_get_path(const GScanXorModifier *modifier, size_t *index)
+{
+ char *result; /* Combinaison à retourner */
+ int ret; /* Bilan intermédiaire */
+
+ if (*index > 255)
+ {
+ result = NULL;
+ (*index) -= 256;
+ }
+
+ else
+ {
+ ret = asprintf(&result, "xor(0x%02hhx)", (unsigned char)*index);
+
+ if (ret == -1)
+ result = strdup("xor(0x?)");
+
+ }
+
+ return result;
+
+}
diff --git a/src/analysis/scan/patterns/modifiers/xor.h b/src/analysis/scan/patterns/modifiers/xor.h
new file mode 100644
index 0000000..1a3e7e6
--- /dev/null
+++ b/src/analysis/scan/patterns/modifiers/xor.h
@@ -0,0 +1,58 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * xor.h - prototypes pour la transormation via opération XOR
+ *
+ * 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_PATTERNS_MODIFIERS_XOR_H
+#define _ANALYSIS_SCAN_PATTERNS_MODIFIERS_XOR_H
+
+
+#include <glib-object.h>
+
+
+#include "../modifier.h"
+
+
+
+#define G_TYPE_SCAN_XOR_MODIFIER g_scan_xor_modifier_get_type()
+#define G_SCAN_XOR_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_SCAN_XOR_MODIFIER, GScanXorModifier))
+#define G_IS_SCAN_XOR_MODIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_SCAN_XOR_MODIFIER))
+#define G_SCAN_XOR_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SCAN_XOR_MODIFIER, GScanXorModifierClass))
+#define G_IS_SCAN_XOR_MODIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SCAN_XOR_MODIFIER))
+#define G_SCAN_XOR_MODIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SCAN_XOR_MODIFIER, GScanXorModifierClass))
+
+
+/* Transormation via inversement d'une séquence d'octets (instance) */
+typedef GScanTokenModifier GScanXorModifier;
+
+/* Transormation via inversement d'une séquence d'octets (classe) */
+typedef GScanTokenModifierClass GScanXorModifierClass;
+
+
+/* Indique le type défini pour une transormation via une opération XOR. */
+GType g_scan_xor_modifier_get_type(void);
+
+/* Construit un modificateur livrant des octets traités par XOR. */
+GScanTokenModifier *g_scan_xor_modifier_new(void);
+
+
+
+#endif /* _ANALYSIS_SCAN_PATTERNS_MODIFIERS_XOR_H */