From 0251f35c93e3f0e0a6853a50fb5bd82c1b9e4187 Mon Sep 17 00:00:00 2001 From: saturneric Date: Mon, 6 Nov 2023 17:17:47 +0800 Subject: refactor: clean up core's codes --- .../function/basic/SingletonStorageCollection.h | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/core/function/basic/SingletonStorageCollection.h (limited to 'src/core/function/basic/SingletonStorageCollection.h') diff --git a/src/core/function/basic/SingletonStorageCollection.h b/src/core/function/basic/SingletonStorageCollection.h new file mode 100644 index 00000000..16a72fd4 --- /dev/null +++ b/src/core/function/basic/SingletonStorageCollection.h @@ -0,0 +1,69 @@ +/** + * Copyright (C) 2021 Saturneric + * + * This file is part of GpgFrontend. + * + * GpgFrontend 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. + * + * GpgFrontend 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 GpgFrontend. If not, see . + * + * The initial version of the source code is inherited from + * the gpg4usb project, which is under GPL-3.0-or-later. + * + * All the source code of GpgFrontend was modified and released by + * Saturneric starting on May 12, 2021. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#pragma once + +namespace GpgFrontend { + +class SingletonStorage; + +class GPGFRONTEND_CORE_EXPORT SingletonStorageCollection { + public: + /** + * @brief Get the Instance object + * + * @return SingletonStorageCollection* + */ + static auto GetInstance(bool force_refresh) -> SingletonStorageCollection*; + + /** + * @brief Get the Singleton Storage object + * + * @param singleton_function_object + * @return SingletonStorage* + */ + auto GetSingletonStorage(const std::type_info&) -> SingletonStorage*; + + private: + class Impl; + std::unique_ptr p_; + + /** + * @brief + * + */ + SingletonStorageCollection() noexcept; + + /** + * @brief + * + */ + ~SingletonStorageCollection(); +}; + +} // namespace GpgFrontend \ No newline at end of file -- cgit v1.2.3 From ae2717c3787a34a2c60d6aeef2d0b8bb8e551a1e Mon Sep 17 00:00:00 2001 From: saturneric Date: Sun, 3 Dec 2023 04:27:47 -0800 Subject: feat: improve memory security of function framework --- src/core/function/basic/SingletonStorageCollection.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/core/function/basic/SingletonStorageCollection.h') diff --git a/src/core/function/basic/SingletonStorageCollection.h b/src/core/function/basic/SingletonStorageCollection.h index 16a72fd4..b96bff3d 100644 --- a/src/core/function/basic/SingletonStorageCollection.h +++ b/src/core/function/basic/SingletonStorageCollection.h @@ -28,10 +28,16 @@ #pragma once -namespace GpgFrontend { +#include + +#include "core/function/SecureMemoryAllocator.h" +namespace GpgFrontend { class SingletonStorage; +using SingletonStoragePtr = + std::unique_ptr>; + class GPGFRONTEND_CORE_EXPORT SingletonStorageCollection { public: /** -- cgit v1.2.3 From 054e6e28cca2517dda2319ef683314b3318c39a6 Mon Sep 17 00:00:00 2001 From: saturneric Date: Sun, 3 Dec 2023 12:25:21 -0800 Subject: feat: standarized and speed up app env loading process --- .../function/basic/SingletonStorageCollection.h | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/core/function/basic/SingletonStorageCollection.h') diff --git a/src/core/function/basic/SingletonStorageCollection.h b/src/core/function/basic/SingletonStorageCollection.h index b96bff3d..70b91cb9 100644 --- a/src/core/function/basic/SingletonStorageCollection.h +++ b/src/core/function/basic/SingletonStorageCollection.h @@ -28,8 +28,6 @@ #pragma once -#include - #include "core/function/SecureMemoryAllocator.h" namespace GpgFrontend { @@ -40,6 +38,18 @@ using SingletonStoragePtr = class GPGFRONTEND_CORE_EXPORT SingletonStorageCollection { public: + /** + * @brief + * + */ + SingletonStorageCollection() noexcept; + + /** + * @brief + * + */ + ~SingletonStorageCollection(); + /** * @brief Get the Instance object * @@ -47,6 +57,12 @@ class GPGFRONTEND_CORE_EXPORT SingletonStorageCollection { */ static auto GetInstance(bool force_refresh) -> SingletonStorageCollection*; + /** + * @brief + * + */ + static void Destroy(); + /** * @brief Get the Singleton Storage object * @@ -58,18 +74,6 @@ class GPGFRONTEND_CORE_EXPORT SingletonStorageCollection { private: class Impl; std::unique_ptr p_; - - /** - * @brief - * - */ - SingletonStorageCollection() noexcept; - - /** - * @brief - * - */ - ~SingletonStorageCollection(); }; } // namespace GpgFrontend \ No newline at end of file -- cgit v1.2.3 From c41074792f8c3b966b6d637c9e9b0ee10c5255e7 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 15 Dec 2023 21:12:25 -0800 Subject: fix: clean up envirnoment when app exits --- src/core/function/basic/SingletonStorageCollection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/function/basic/SingletonStorageCollection.h') diff --git a/src/core/function/basic/SingletonStorageCollection.h b/src/core/function/basic/SingletonStorageCollection.h index 70b91cb9..38ced83b 100644 --- a/src/core/function/basic/SingletonStorageCollection.h +++ b/src/core/function/basic/SingletonStorageCollection.h @@ -73,7 +73,7 @@ class GPGFRONTEND_CORE_EXPORT SingletonStorageCollection { private: class Impl; - std::unique_ptr p_; + SecureUniquePtr p_; }; } // namespace GpgFrontend \ No newline at end of file -- cgit v1.2.3