diff options
Diffstat (limited to 'src/analysis/scan/conds/binop.c')
-rw-r--r-- | src/analysis/scan/conds/binop.c | 265 |
1 files changed, 0 insertions, 265 deletions
diff --git a/src/analysis/scan/conds/binop.c b/src/analysis/scan/conds/binop.c deleted file mode 100644 index 01e99d9..0000000 --- a/src/analysis/scan/conds/binop.c +++ /dev/null @@ -1,265 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * binop.c - opérations booléennes impliquant deux opérandes - * - * Copyright (C) 2022 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 "binop.h" - - -#include "binop-int.h" - - - -/* --------------------- INSTANCIATION D'UNE FORME DE CONDITION --------------------- */ - - -/* Initialise la classe des opérations booléennes. */ -static void g_binary_operation_class_init(GBinaryOperationClass *); - -/* Initialise une instance d'opération booléenne. */ -static void g_binary_operation_init(GBinaryOperation *); - -/* Supprime toutes les références externes. */ -static void g_binary_operation_dispose(GBinaryOperation *); - -/* Procède à la libération totale de la mémoire. */ -static void g_binary_operation_finalize(GBinaryOperation *); - - - -/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ - - -/* Indique le statut d'une condition de validation. */ -static bool g_binary_operation_resolve(const GBinaryOperation *); - -/* Lance l'analyse de contenu binaire selon un motif donné. */ -static void g_binary_operation_analyze(const GBinaryOperation *, const bin_t *, phys_t, phys_t, bool); - - - -/* ---------------------------------------------------------------------------------- */ -/* INSTANCIATION D'UNE FORME DE CONDITION */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini pour une opération booléenne de validation. */ -G_DEFINE_TYPE(GBinaryOperation, g_binary_operation, G_TYPE_MATCH_CONDITION); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des opérations booléennes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_operation_class_init(GBinaryOperationClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GMatchConditionClass *cond; /* Classe parente directe */ - - object = G_OBJECT_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_binary_operation_dispose; - object->finalize = (GObjectFinalizeFunc)g_binary_operation_finalize; - - cond = G_MATCH_CONDITION_CLASS(klass); - - cond->resolve = (resolve_cond_fc)g_binary_operation_resolve; - cond->analyze = (analyze_cond_fc)g_binary_operation_analyze; - -} - - -/****************************************************************************** -* * -* Paramètres : op = instance à initialiser. * -* * -* Description : Initialise une instance d'opération booléenne. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_operation_init(GBinaryOperation *op) -{ - op->conds[0] = NULL; - op->conds[1] = NULL; - - op->type = BOT_AND; - -} - - -/****************************************************************************** -* * -* Paramètres : op = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_operation_dispose(GBinaryOperation *op) -{ - g_clear_object(&op->conds[0]); - g_clear_object(&op->conds[1]); - - G_OBJECT_CLASS(g_binary_operation_parent_class)->dispose(G_OBJECT(op)); - -} - - -/****************************************************************************** -* * -* Paramètres : op = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_operation_finalize(GBinaryOperation *op) -{ - G_OBJECT_CLASS(g_binary_operation_parent_class)->finalize(G_OBJECT(op)); - -} - - -/****************************************************************************** -* * -* Paramètres : op1 = premier opérande à intégrer. * -* op2 = second opérande à intégrer. * -* type = type d'opération à prendre en compte. * -* * -* Description : Met en place une représentation d'opération booléenne. * -* * -* Retour : Condition mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GBinaryOperation *g_binary_operation_new(GMatchCondition *op1, GMatchCondition *op2, BinOpType type) -{ - GBinaryOperation *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_BINARY_OPERATION, NULL); - - result->conds[0] = op1; - g_object_ref(G_OBJECT(op1)); - - result->conds[1] = op2; - g_object_ref(G_OBJECT(op2)); - - result->type = type; - - return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : op = condition à consulter. * -* * -* Description : Indique le statut d'une condition de validation. * -* * -* Retour : Validation de la condition considérée. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static bool g_binary_operation_resolve(const GBinaryOperation *op) -{ - bool result; /* Bilan à retourner */ - - result = g_match_condition_resolve(op->conds[0]); - - switch (op->type) - { - case BOT_AND: - default: - if (result) - result = g_match_condition_resolve(op->conds[1]); - break; - - case BOT_OR: - if (!result) - result = g_match_condition_resolve(op->conds[1]); - break; - - case BOT_XOR: - result ^= g_match_condition_resolve(op->conds[1]); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : op = condition à considérer. * -* data = données binaires brutes à considérer. * -* size = quantité de ces données. * -* pos = position du point d'étude courant. * -* full = force une recherche pleine et entière. * -* * -* Description : Lance l'analyse de contenu binaire selon un motif donné. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_operation_analyze(const GBinaryOperation *op, const bin_t *data, phys_t size, phys_t pos, bool full) -{ - g_match_condition_analyze(op->conds[0], data, size, pos, full); - - if (full || !g_binary_operation_resolve(op)) - g_match_condition_analyze(op->conds[1], data, size, pos, full); - -} |