-
-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
87 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "Options.h" | ||
#include <nlohmann/json.hpp> | ||
#include <spdlog/spdlog.h> | ||
#include <spdlog/sinks/rotating_file_sink.h> | ||
#include <fstream> | ||
|
||
Options::Options(HMODULE aModule) | ||
{ | ||
char path[2048 + 1] = { 0 }; | ||
GetModuleFileNameA(aModule, path, std::size(path) - 1); | ||
|
||
Path = path; | ||
Path = Path.parent_path().parent_path(); | ||
Path /= "performance_overhaul/"; | ||
|
||
std::error_code ec; | ||
create_directories(Path, ec); | ||
|
||
const auto rotatingLogger = std::make_shared<spdlog::sinks::rotating_file_sink_mt>((Path / "performance_overhaul.log").string(), 1048576 * 5, 3); | ||
|
||
const auto logger = std::make_shared<spdlog::logger>("", spdlog::sinks_init_list{ rotatingLogger }); | ||
set_default_logger(logger); | ||
|
||
const auto configPath = Path / "config.json"; | ||
|
||
std::ifstream configFile(configPath); | ||
if(configFile) | ||
{ | ||
auto config = nlohmann::json::parse(configFile); | ||
this->PatchAVX = config.value("avx", this->PatchAVX); | ||
this->PatchSMT = config.value("smt", this->PatchSMT); | ||
this->PatchSpectre = config.value("spectre", this->PatchSpectre); | ||
} | ||
else | ||
{ | ||
nlohmann::json config; | ||
config["avx"] = this->PatchAVX; | ||
config["smt"] = this->PatchSMT; | ||
config["spectre"] = this->PatchSpectre; | ||
|
||
std::ofstream o(configPath); | ||
o << config.dump(4) << std::endl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <windows.h> | ||
#include <filesystem> | ||
|
||
struct Image; | ||
struct Options | ||
{ | ||
Options(HMODULE aModule); | ||
|
||
bool PatchSpectre { true }; | ||
bool PatchSMT{ true }; | ||
bool PatchAVX{ false }; | ||
std::filesystem::path Path; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
set_languages("cxx17") | ||
|
||
add_requires("zlib", "spdlog") | ||
add_requires("zlib", "spdlog", "nlohmann_json") | ||
|
||
add_rules("mode.debug", "mode.release") | ||
add_cxflags("-flto") | ||
add_ldflags("-flto") | ||
|
||
set_optimize("fastest") | ||
|
||
|
||
target("performance_overhaul") | ||
set_kind("shared") | ||
add_files("src/**.cpp") | ||
add_includedirs("src/") | ||
add_syslinks("User32") | ||
add_packages("zlib", "spdlog") | ||
add_packages("zlib", "spdlog", "nlohmann_json") |