Remove Security system as it is useless
This commit is contained in:
parent
a9600f8d02
commit
62d37d227d
@ -29,6 +29,7 @@
|
||||
- Add LinearAllocator (for std)
|
||||
- Fix Crash in FilsSystem
|
||||
- Implement basic Theme System
|
||||
- Remove 0.9.4 Security
|
||||
## 0.9.4
|
||||
- Implement new Security System To prevent from crashes
|
||||
- Implement Functiontrace for better Timing Tests
|
||||
|
@ -1,69 +0,0 @@
|
||||
/**
|
||||
* This file is part of RenderD7
|
||||
* Copyright (C) 2021-2024 NPI-D7, tobid7
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <3ds.h>
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Init {
|
||||
void Security();
|
||||
}
|
||||
|
||||
class Security {
|
||||
public:
|
||||
/// @brief Security Levels
|
||||
enum Level {
|
||||
NONE, ///< Do Completly Nothing (excludes FrameEnd Security)
|
||||
FULL, ///< Display Every Reports even Success
|
||||
ERRORS, ///< Display Only Errors
|
||||
WARNINGS, ///< Display Errors and Warnings
|
||||
LOG, ///< Log Every Error with Detailed Information
|
||||
};
|
||||
|
||||
Security();
|
||||
~Security();
|
||||
/// @brief Set the Security Level
|
||||
/// @param level Level to use
|
||||
void SetLevel(Level level);
|
||||
/// @brief Get Current Security Level
|
||||
/// @return Security Level
|
||||
Level GetLevel();
|
||||
/// @brief Call a Function at Program Crash/Exit
|
||||
/// @param exit_func Function to Call
|
||||
void SafeExit(void (*exit_func)());
|
||||
/// @brief SaveInit a Function and define a Exit Func
|
||||
/// @param init_func Init Function
|
||||
/// @param exit_func Exit Function
|
||||
void SafeInit(void (*init_func)(), void (*exit_func)());
|
||||
/// @brief SaveInit a Function and define a Exit Func
|
||||
/// @param init_func Init Function
|
||||
/// @param exit_func Exit Function
|
||||
void SafeInit(Result (*init_func)(), void (*exit_func)());
|
||||
/// @brief SaveInit a Function and define a Exit Func
|
||||
/// @param init_func Init Function
|
||||
/// @param exit_func Exit Function
|
||||
void SafeInit(void (*init_func)(), Result (*exit_func)());
|
||||
/// @brief SaveInit a Function and define a Exit Func
|
||||
/// @param init_func Init Function
|
||||
/// @param exit_func Exit Function
|
||||
void SafeInit(Result (*init_func)(), Result (*exit_func)());
|
||||
};
|
||||
} // namespace RenderD7
|
||||
|
||||
/// @brief RenderD7 Security Object
|
||||
extern RenderD7::Security *rd7_security;
|
@ -31,8 +31,8 @@ class Font {
|
||||
Font(const std::string& path) { Load(path); };
|
||||
~Font() { Unload(); }
|
||||
using Ref = std::shared_ptr<Font>;
|
||||
template<typename ...args>
|
||||
inline static Ref New(args &&...a) {
|
||||
template <typename... args>
|
||||
inline static Ref New(args&&... a) {
|
||||
return std::make_shared<Font>(std::forward<args>(a)...);
|
||||
}
|
||||
void Load(const std::string& path) {
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <renderd7/ResultDecoder.hpp>
|
||||
#include <renderd7/Screen.hpp>
|
||||
#include <renderd7/Security.hpp>
|
||||
#include <renderd7/Sheet.hpp>
|
||||
#include <renderd7/Sprite.hpp>
|
||||
#include <renderd7/SpriteAnimation.hpp>
|
||||
|
@ -29,7 +29,7 @@ int main() {
|
||||
auto fnt = RD7::Font::New("romfs:/roboto_bold.bcfnt");
|
||||
RD7::TextFont(fnt);
|
||||
// IdbServer();
|
||||
//RD7::Init::NdspFirm();
|
||||
// RD7::Init::NdspFirm();
|
||||
RD7::Scene::Load(std::make_unique<Sample>());
|
||||
RD7::Ftrace::End("app", "app_init");
|
||||
while (RD7::MainLoop()) {
|
||||
|
@ -17,21 +17,20 @@
|
||||
*/
|
||||
|
||||
#include <renderd7/Hardware.hpp>
|
||||
#include <renderd7/Security.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
// Os Specific includes
|
||||
#include <3ds.h>
|
||||
|
||||
// RenderD7 Security
|
||||
extern bool isndspinit;
|
||||
|
||||
void RenderD7::Hardware::Initialisize() {
|
||||
rd7_security->SafeInit(mcuHwcInit, &mcuHwcExit);
|
||||
rd7_security->SafeInit(ptmuInit, &ptmuExit);
|
||||
mcuHwcInit();
|
||||
atexit(mcuHwcExit);
|
||||
ptmuInit();
|
||||
atexit(ptmuExit);
|
||||
}
|
||||
|
||||
bool RenderD7::Hardware::IsHeadphones() {
|
||||
if (isndspinit) {
|
||||
if (rd7i_is_ndsp) {
|
||||
bool inserted;
|
||||
DSP_GetHeadphoneStatus(&inserted);
|
||||
return inserted;
|
||||
|
@ -1,69 +0,0 @@
|
||||
/**
|
||||
* This file is part of RenderD7
|
||||
* Copyright (C) 2021-2024 NPI-D7, tobid7
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <renderd7/Security.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
RenderD7::Security *rd7_security;
|
||||
|
||||
bool *running_addr = NULL;
|
||||
RenderD7::Security::Level rd7i_slvl = RenderD7::Security::Level::NONE;
|
||||
|
||||
RenderD7::Security::Level RenderD7::Security::GetLevel() { return rd7i_slvl; }
|
||||
|
||||
void RenderD7::Security::SetLevel(RenderD7::Security::Level level) {
|
||||
rd7i_slvl = level;
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
Security::Security() { running_addr = &rd7i_running; }
|
||||
|
||||
Security::~Security() { *running_addr = false; }
|
||||
void Security::SafeExit(void (*exit_func)()) { atexit(exit_func); }
|
||||
|
||||
void Security::SafeInit(void (*init_func)(), void (*exit_func)()) {
|
||||
init_func();
|
||||
atexit(exit_func);
|
||||
}
|
||||
|
||||
void Security::SafeInit(Result (*init_func)(), void (*exit_func)()) {
|
||||
init_func();
|
||||
atexit(exit_func);
|
||||
}
|
||||
|
||||
void Security::SafeInit(void (*init_func)(), Result (*exit_func)()) {
|
||||
init_func();
|
||||
atexit(reinterpret_cast<void (*)()>(exit_func));
|
||||
}
|
||||
|
||||
void Security::SafeInit(Result (*init_func)(), Result (*exit_func)()) {
|
||||
init_func();
|
||||
atexit(reinterpret_cast<void (*)()>(exit_func));
|
||||
}
|
||||
} // namespace RenderD7
|
||||
namespace RenderD7 {
|
||||
namespace Init {
|
||||
void Security() {
|
||||
rd7_security = new RenderD7::Security(); // Load and Init the Security System
|
||||
}
|
||||
} // namespace Init
|
||||
} // namespace RenderD7
|
@ -230,7 +230,7 @@ void ServerThread(RenderD7::Parameter param) {
|
||||
return;
|
||||
}
|
||||
rd7i_idb_running = true;
|
||||
rd7_security->SafeExit(KillIdbServer);
|
||||
atexit(KillIdbServer);
|
||||
tcp_server server("0.0.0.0", 4727);
|
||||
int cmd = 0;
|
||||
while (true && !rd7i_idb_fp) {
|
||||
|
@ -36,6 +36,7 @@
|
||||
static void RD7i_ExitHook() {
|
||||
C2D_TextBufDelete(rd7i_text_buffer);
|
||||
C2D_TextBufDelete(rd7i_d2_dimbuf);
|
||||
romfsExit();
|
||||
}
|
||||
|
||||
std::vector<std::string> string_to_lines(std::string input_str) {
|
||||
@ -231,7 +232,8 @@ bool RenderD7::DrawImageFromSheet(RenderD7::Sheet *sheet, size_t index, float x,
|
||||
}
|
||||
void RenderD7::Init::NdspFirm() {
|
||||
if (access("sdmc:/3ds/dspfirm.cdc", F_OK) != -1) {
|
||||
rd7_security->SafeInit(ndspInit, ndspExit);
|
||||
ndspInit();
|
||||
atexit(ndspExit);
|
||||
rd7i_is_ndsp = true;
|
||||
} else {
|
||||
RenderD7::PushMessage(RenderD7::Message(
|
||||
@ -336,24 +338,26 @@ Result RenderD7::Init::Main(std::string app_name) {
|
||||
rd7i_app_name = app_name;
|
||||
/// The only func that can be executed before Security
|
||||
RenderD7::Ftrace::Beg("rd7-core", f2s(RenderD7::Init::Main));
|
||||
RenderD7::Init::Security();
|
||||
|
||||
rd7_security->SafeInit(gfxInitDefault, gfxExit);
|
||||
gfxInitDefault();
|
||||
atexit(gfxExit);
|
||||
// Speedup
|
||||
osSetSpeedupEnable(true);
|
||||
// consoleInit(GFX_TOP, NULL);
|
||||
rd7_security->SafeInit(cfguInit, cfguExit);
|
||||
cfguInit();
|
||||
atexit(cfguExit);
|
||||
CFGU_SecureInfoGetRegion(&rd7i_system_region);
|
||||
CFGU_GetSystemModel(&rd7i_console_model);
|
||||
|
||||
rd7_security->SafeInit(aptInit, aptExit);
|
||||
rd7_security->SafeInit(romfsInit, romfsExit);
|
||||
aptInit();
|
||||
atexit(aptExit);
|
||||
romfsInit();
|
||||
|
||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||
rd7_security->SafeExit(C3D_Fini);
|
||||
atexit(C3D_Fini);
|
||||
C2D_Init((size_t)rd7_max_objects);
|
||||
rd7_security->SafeExit(C2D_Fini);
|
||||
rd7_security->SafeExit(RD7i_ExitHook);
|
||||
atexit(C2D_Fini);
|
||||
atexit(RD7i_ExitHook);
|
||||
C2D_Prepare();
|
||||
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
|
||||
@ -372,7 +376,7 @@ Result RenderD7::Init::Main(std::string app_name) {
|
||||
rd7i_init_input();
|
||||
rd7i_init_theme();
|
||||
UI7::Init();
|
||||
rd7_security->SafeExit(UI7::Deinit);
|
||||
atexit(UI7::Deinit);
|
||||
RenderD7::Ftrace::End("rd7-core", f2s(RenderD7::Init::Main));
|
||||
rd7i_running = true;
|
||||
return 0;
|
||||
@ -380,17 +384,17 @@ Result RenderD7::Init::Main(std::string app_name) {
|
||||
|
||||
Result RenderD7::Init::Minimal(std::string app_name) {
|
||||
rd7i_app_name = app_name;
|
||||
RenderD7::Init::Security();
|
||||
|
||||
rd7_security->SafeInit(gfxInitDefault, gfxExit);
|
||||
rd7_security->SafeInit(romfsInit, romfsExit);
|
||||
gfxInitDefault();
|
||||
atexit(gfxExit);
|
||||
romfsInit();
|
||||
|
||||
osSetSpeedupEnable(true);
|
||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||
rd7_security->SafeExit(C3D_Fini);
|
||||
atexit(C3D_Fini);
|
||||
C2D_Init((size_t)rd7_max_objects);
|
||||
rd7_security->SafeExit(C2D_Fini);
|
||||
rd7_security->SafeExit(RD7i_ExitHook);
|
||||
atexit(C2D_Fini);
|
||||
atexit(RD7i_ExitHook);
|
||||
C2D_Prepare();
|
||||
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
|
||||
@ -410,7 +414,7 @@ Result RenderD7::Init::Minimal(std::string app_name) {
|
||||
rd7i_init_input();
|
||||
rd7i_init_theme();
|
||||
UI7::Init();
|
||||
rd7_security->SafeExit(UI7::Deinit);
|
||||
atexit(UI7::Deinit);
|
||||
rd7i_running = true;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user