summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Makefile.am12
-rw-r--r--src/core/core.c101
-rw-r--r--src/core/core.h16
-rw-r--r--src/core/global.c190
-rw-r--r--src/core/global.h38
-rw-r--r--src/core/logs.h9
-rw-r--r--src/core/nox.c62
-rw-r--r--src/core/nox.h37
-rw-r--r--src/core/processors.c23
-rw-r--r--src/core/processors.h6
10 files changed, 427 insertions, 67 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 5bcb13a..15ed866 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -4,11 +4,8 @@ noinst_LTLIBRARIES = libcore4.la # libcore.la
libcore_la_SOURCES = \
collections.h collections.c \
columns.h \
- core.h core.c \
demanglers.h demanglers.c \
- global.h global.c \
logs.h logs.c \
- nproc.h nproc.c \
params.h params.c \
paths.h paths.c \
processors.h processors.c \
@@ -18,10 +15,15 @@ libcore_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS)
libcore4_la_SOURCES = \
+ core.h core.c \
+ global.h global.c \
logs.h logs.c \
- paths.h paths.c
+ nox.h nox.c \
+ nproc.h nproc.c \
+ paths.h paths.c \
+ processors.h processors.c
-libcore4_la_CFLAGS = $(TOOLKIT_CFLAGS)
+libcore4_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBSSL_CFLAGS)
devdir = $(includedir)/chrysalide/$(subdir:src/%=core/%)
diff --git a/src/core/core.c b/src/core/core.c
index f67e23d..c730fad 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -2,7 +2,7 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
* core.c - chargement et le déchargement du tronc commun
*
- * Copyright (C) 2014-2019 Cyrille Bagard
+ * Copyright (C) 2014-2024 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -24,6 +24,97 @@
#include "core.h"
+#include "global.h"
+#include "processors.h"
+
+
+
+/* Statuts de chargement */
+static AvailableCoreComponent __loaded = ACC_NONE;
+
+
+
+/******************************************************************************
+* *
+* Paramètres : flags = liste d'éléments à charger. *
+* *
+* Description : Charge une sélection d'éléments de base du programme. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool load_core_components(AvailableCoreComponent flags)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
+
+ if ((flags & ACC_GLOBAL_VARS) != 0 && (__loaded & ACC_GLOBAL_VARS) == 0)
+ {
+ set_secret_storage(g_secret_storage_new(NULL));
+
+ set_work_queue(g_work_queue_new());
+
+ __loaded |= ACC_GLOBAL_VARS;
+
+ }
+
+ if ((flags & ACC_CODE_ANALYSIS) != 0 && (__loaded & ACC_CODE_ANALYSIS) == 0)
+ {
+ register_arch_gtypes();
+
+ init_operands_factory();
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : flags = liste d'éléments à décharger. *
+* *
+* Description : Décharge une sélection d'éléments de base du programme. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void unload_core_components(AvailableCoreComponent flags)
+{
+ if ((flags & ACC_CODE_ANALYSIS) != 0 && (__loaded & ACC_CODE_ANALYSIS) == 0)
+ {
+ exit_operands_factory();
+
+ }
+
+ if ((flags & ACC_GLOBAL_VARS) != 0 && (__loaded & ACC_GLOBAL_VARS) == 0)
+ {
+ set_work_queue(NULL);
+
+ set_secret_storage(NULL);
+
+ __loaded &= ~ACC_GLOBAL_VARS;
+
+ }
+
+}
+
+
+
+
+
+
+
+#if 0
+
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
@@ -35,7 +126,6 @@
#include "demanglers.h"
#include "global.h"
#include "params.h"
-#include "processors.h"
#include "queue.h"
#include "../analysis/scan/core.h"
#ifdef INCLUDE_MAGIC_SUPPORT
@@ -119,9 +209,6 @@ bool load_all_core_components(bool cs)
if (result) result = init_segment_content_hash_table();
- register_arch_gtypes();
- init_operands_factory();
-
}
}
@@ -147,8 +234,6 @@ void unload_all_core_components(bool cs)
{
if (cs)
{
- exit_operands_factory();
-
exit_segment_content_hash_table();
unload_demanglers_definitions();
@@ -255,3 +340,5 @@ void unload_core_components(AvailableCoreComponent flags)
}
}
+
+#endif
diff --git a/src/core/core.h b/src/core/core.h
index def2813..640476a 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -2,7 +2,7 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
* core.h - prototypes pour le chargement et le déchargement du tronc commun
*
- * Copyright (C) 2014-2018 Cyrille Bagard
+ * Copyright (C) 2014-2024 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -29,17 +29,15 @@
-/* Charge les éléments de base du programme. */
-bool load_all_core_components(bool);
-
-/* Décharge les éléments de base du programme. */
-void unload_all_core_components(bool);
-
-
/* Eléments à (dé)charger disponibles */
typedef enum _AvailableCoreComponent
{
- ACC_SCAN_FEATURES = (1 << 0), /* Espace de noms pour scan */
+ ACC_NONE = (0 << 0), /* Statut initial */
+ ACC_GLOBAL_VARS = (1 << 0), /* Singletons globaux */
+ ACC_CODE_ANALYSIS = (1 << 1), /* Désassemblage de code */
+ ACC_SCAN_FEATURES = (1 << 2), /* Espace de noms pour scan */
+
+ ACC_ALL_COMPONENTS = (1 << 3) - 1
} AvailableCoreComponent;
diff --git a/src/core/global.c b/src/core/global.c
index c99d711..0275e09 100644
--- a/src/core/global.c
+++ b/src/core/global.c
@@ -2,7 +2,7 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
* global.c - conservation et accès aux variables globales
*
- * Copyright (C) 2017-2019 Cyrille Bagard
+ * Copyright (C) 2017-2024 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -24,38 +24,29 @@
#include "global.h"
-#include <assert.h>
+#include "../glibext/helpers.h"
-/* Mode de fonctionnement */
-static bool _batch_mode = false;
+/* Décompte des émissions et réceptions */
+static GMutex _network_mutex;
+static size_t _bytes_received = 0;
+static size_t _bytes_sent = 0;
/* Gestionnaire de tâches parallèles */
static GWorkQueue *_queue = NULL;
-/* Explorateur de contenus */
-static GContentExplorer *_explorer = NULL;
-
-/* Résolveur de contenus */
-static GContentResolver *_resolver = NULL;
-
-/* Espace de noms racine pour ROST */
-static GScanNamespace *_rost_root_ns = NULL;
-
-/* Projet global actif */
-static GStudyProject *_project = NULL;
-
-/* Avertisseur de changement de projet principal */
-static current_project_change_cb _project_notify = NULL;
+/* Gardien des secrets avec support des stockages */
+static GSecretStorage *_storage = NULL;
/******************************************************************************
* *
-* Paramètres : - *
+* Paramètres : received = quantité d'octets reçus jusqu'à présent. [OUT] *
+* sent = quantité d'octets émis jusqu'à présent. [OUT] *
* *
-* Description : Note un mode d'exécution sans interface. *
+* Description : Fournit les volumes d'octets échangés sur le réseau. *
* *
* Retour : - *
* *
@@ -63,28 +54,39 @@ static current_project_change_cb _project_notify = NULL;
* *
******************************************************************************/
-void set_batch_mode(void)
+void get_network_stats(size_t *received, size_t *sent)
{
- _batch_mode = true;
+ g_mutex_lock(&_network_mutex);
+
+ *received = _bytes_received;
+ *sent = _bytes_sent;
+
+ g_mutex_unlock(&_network_mutex);
}
/******************************************************************************
* *
-* Paramètres : - *
+* Paramètres : received = quantité d'octets reçus supplémentaire. *
+* sent = quantité d'octets émis supplémentaire. *
* *
-* Description : Indique le mode d'exécution courant du programme. *
+* Description : Augmente les volumes d'octets échangés sur le réseau. *
* *
-* Retour : true si le fonctionnement est sans interface. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-bool is_batch_mode(void)
+void update_network_stats(size_t received, size_t sent)
{
- return _batch_mode;
+ g_mutex_lock(&_network_mutex);
+
+ _bytes_received += received;
+ _bytes_sent += sent;
+
+ g_mutex_unlock(&_network_mutex);
}
@@ -101,9 +103,10 @@ bool is_batch_mode(void)
* *
******************************************************************************/
-void set_work_queue(GWorkQueue *queue)
+void set_work_queue(/* __steal */GWorkQueue *queue)
{
- assert(_queue == NULL);
+ if (_queue != NULL)
+ unref_object(_queue);
_queue = queue;
@@ -124,6 +127,8 @@ void set_work_queue(GWorkQueue *queue)
GWorkQueue *get_work_queue(void)
{
+ ref_object(_queue);
+
return _queue;
}
@@ -131,6 +136,131 @@ GWorkQueue *get_work_queue(void)
/******************************************************************************
* *
+* Paramètres : queue = nouveau stockage sécurisé à mémoriser ou NULL. *
+* *
+* Description : Définit le stockage sécurisé principal. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void set_secret_storage(/* __steal */GSecretStorage *storage)
+{
+ if (_storage != NULL)
+ unref_object(_storage);
+
+ _storage = storage;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit le stockage sécurisé principal. *
+* *
+* Retour : Gestionnaire de traitements parallèles courant. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GSecretStorage *get_secret_storage(void)
+{
+ ref_object(_storage);
+
+ return _storage;
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#if 0
+
+#include <assert.h>
+
+
+
+/* Mode de fonctionnement */
+static bool _batch_mode = false;
+
+/* Gestionnaire de tâches parallèles */
+//static GWorkQueue *_queue = NULL;
+
+/* Explorateur de contenus */
+static GContentExplorer *_explorer = NULL;
+
+/* Résolveur de contenus */
+static GContentResolver *_resolver = NULL;
+
+/* Espace de noms racine pour ROST */
+static GScanNamespace *_rost_root_ns = NULL;
+
+/* Projet global actif */
+static GStudyProject *_project = NULL;
+
+/* Avertisseur de changement de projet principal */
+static current_project_change_cb _project_notify = NULL;
+
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Note un mode d'exécution sans interface. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void set_batch_mode(void)
+{
+ _batch_mode = true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Indique le mode d'exécution courant du programme. *
+* *
+* Retour : true si le fonctionnement est sans interface. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool is_batch_mode(void)
+{
+ return _batch_mode;
+
+}
+
+
+
+
+/******************************************************************************
+* *
* Paramètres : explorer = éventuelle adresse du nouveau gestionnaire. *
* *
* Description : Définit l'adresse de l'explorateur de contenus courant. *
@@ -343,3 +473,5 @@ void register_project_change_notification(current_project_change_cb notify)
_project_notify = notify;
}
+
+#endif
diff --git a/src/core/global.h b/src/core/global.h
index 0a9172b..f5d8a62 100644
--- a/src/core/global.h
+++ b/src/core/global.h
@@ -2,7 +2,7 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
* global.h - prototypes pour la conservation et l'accès aux variables globales
*
- * Copyright (C) 2017-2018 Cyrille Bagard
+ * Copyright (C) 2017-2024 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -25,6 +25,35 @@
#define _CORE_GLOBAL_H
+#include "../glibext/secstorage.h"
+#include "../glibext/workqueue.h"
+
+
+
+/* Fournit les volumes d'octets échangés sur le réseau. */
+void get_network_stats(size_t *, size_t *);
+
+/* Augmente les volumes d'octets échangés sur le réseau. */
+void update_network_stats(size_t, size_t);
+
+/* Définit le gestionnaire de traitements parallèles courant. */
+void set_work_queue(/* __steal */GWorkQueue *);
+
+/* Fournit le gestionnaire de traitements parallèles courant. */
+GWorkQueue *get_work_queue(void);
+
+/* Définit le stockage sécurisé principal. */
+void set_secret_storage(/* __steal */GSecretStorage *);
+
+/* Fournit le stockage sécurisé principal. */
+GSecretStorage *get_secret_storage(void);
+
+
+
+
+
+#if 0
+
#include <stdbool.h>
@@ -42,10 +71,10 @@ void set_batch_mode(void);
bool is_batch_mode(void);
/* Définit le gestionnaire de traitements parallèles courant. */
-void set_work_queue(GWorkQueue *);
+//void set_work_queue(GWorkQueue *);
/* Fournit le gestionnaire de traitements parallèles courant. */
-GWorkQueue *get_work_queue(void);
+//GWorkQueue *get_work_queue(void);
/* Définit l'adresse de l'explorateur de contenus courant. */
void set_current_content_explorer(GContentExplorer *);
@@ -78,5 +107,8 @@ typedef void (* current_project_change_cb) (GStudyProject *, bool);
void register_project_change_notification(current_project_change_cb);
+#endif
+
+
#endif /* _CORE_GLOBAL_H */
diff --git a/src/core/logs.h b/src/core/logs.h
index e8df8bd..3719c6b 100644
--- a/src/core/logs.h
+++ b/src/core/logs.h
@@ -162,6 +162,15 @@ void log_variadic_message(LogMessageType, const char *, ...);
} \
while (0)
+#define LOG_ERROR_ZIP(func, err) \
+ do \
+ { \
+ const char *__msg; \
+ __msg = zip_error_strerror(err); \
+ log_variadic_message(LMT_EXT_ERROR, "[%s:%u] %s: %s", __FUNCTION__, __LINE__, func, __msg); \
+ } \
+ while (0)
+
#endif /* _CORE_LOGS_H */
diff --git a/src/core/nox.c b/src/core/nox.c
new file mode 100644
index 0000000..ccf9de2
--- /dev/null
+++ b/src/core/nox.c
@@ -0,0 +1,62 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * nox.c - indication de présence ou d'absence de support graphique
+ *
+ * Copyright (C) 2024 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "nox.h"
+
+
+#include <stddef.h>
+
+
+#include "../common/compiler.h"
+
+
+
+/* Indique la présence ou l'absence d'un affichage graphique. */
+__weak bool _run_in_nox_mode(void);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Indique la présence ou l'absence d'un affichage graphique. *
+* *
+* Retour : Statut à transmettre. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool run_in_nox_mode(void)
+{
+ bool result; /* Statut à retournr */
+
+ if (_run_in_nox_mode == NULL)
+ result = true;
+ else
+ result = _run_in_nox_mode();
+
+ return result;
+
+}
diff --git a/src/core/nox.h b/src/core/nox.h
new file mode 100644
index 0000000..c2c225d
--- /dev/null
+++ b/src/core/nox.h
@@ -0,0 +1,37 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * nox.h - prototypes pour l'indication de présence ou d'absence de support graphique
+ *
+ * Copyright (C) 2024 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 Chrysalide. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _CORE_NOX_H
+#define _CORE_NOX_H
+
+
+#include <stdbool.h>
+
+
+
+/* Indique la présence ou l'absence d'un affichage graphique. */
+bool run_in_nox_mode(void);
+
+
+
+#endif /* _CORE_NOX_H */
diff --git a/src/core/processors.c b/src/core/processors.c
index e4a558f..056fc23 100644
--- a/src/core/processors.c
+++ b/src/core/processors.c
@@ -2,7 +2,7 @@
/* Chrysalide - Outil d'analyse de fichiers binaires
* processors.c - enregistrement et fourniture des architectures supportées
*
- * Copyright (C) 2015-2020 Cyrille Bagard
+ * Copyright (C) 2015-2025 Cyrille Bagard
*
* This file is part of Chrysalide.
*
@@ -29,13 +29,13 @@
#include <pthread.h>
#include <string.h>
-
+#if 0
#include "../arch/instructions/raw.h"
#include "../arch/instructions/undefined.h"
#include "../arch/operands/immediate.h"
#include "../arch/operands/register.h"
#include "../arch/operands/target.h"
-
+#endif
/* Cache des singletons d'opérandes */
@@ -77,12 +77,12 @@ static proc_t *find_processor_by_key(const char *);
void register_arch_gtypes(void)
{
- g_type_ensure(G_TYPE_RAW_INSTRUCTION);
- g_type_ensure(G_TYPE_UNDEF_INSTRUCTION);
+ //g_type_ensure(G_TYPE_RAW_INSTRUCTION);
+ //g_type_ensure(G_TYPE_UNDEF_INSTRUCTION);
- g_type_ensure(G_TYPE_IMM_OPERAND);
- g_type_ensure(G_TYPE_REGISTER_OPERAND);
- g_type_ensure(G_TYPE_TARGET_OPERAND);
+ //g_type_ensure(G_TYPE_IMM_OPERAND);
+ //g_type_ensure(G_TYPE_REGISTER_OPERAND);
+ //g_type_ensure(G_TYPE_TARGET_OPERAND);
}
@@ -126,7 +126,7 @@ GSingletonFactory *get_operands_factory(void)
result = __operands_factory;
- g_object_ref(G_OBJECT(result));
+ ref_object(result);
return result;
@@ -154,7 +154,7 @@ void exit_operands_factory(void)
}
-
+#if 0
/******************************************************************************
* *
* Paramètres : type = type GLib représentant le type à instancier. *
@@ -206,7 +206,7 @@ bool register_processor_type(GType type)
done:
- g_object_unref(G_OBJECT(proc));
+ unref_object(proc);
return result;
@@ -341,3 +341,4 @@ GArchProcessor *get_arch_processor_for_key(const char *key)
return result;
}
+#endif
diff --git a/src/core/processors.h b/src/core/processors.h
index 6aa2d1e..b622305 100644
--- a/src/core/processors.h
+++ b/src/core/processors.h
@@ -29,7 +29,7 @@
#include <stdbool.h>
-#include "../arch/processor.h"
+//#include "../arch/processor.h"
#include "../glibext/singleton.h"
@@ -45,7 +45,7 @@ GSingletonFactory *get_operands_factory(void);
/* Supprime le fournisseur d'instances uniques d'opérandes. */
void exit_operands_factory(void);
-
+#if 0
/* Enregistre un processeur pour une architecture donnée. */
bool register_processor_type(GType);
@@ -57,7 +57,7 @@ char **get_all_processor_keys(size_t *);
/* Fournit le processeur d'architecture correspondant à un nom. */
GArchProcessor *get_arch_processor_for_key(const char *);
-
+#endif
#endif /* _CORE_PROCESSORS_H */