structural changes

This commit is contained in:
project-bo4
2023-11-10 13:52:20 -08:00
parent 55553a4099
commit e584075243
74 changed files with 604 additions and 411 deletions

View File

@ -79,7 +79,7 @@ namespace exception
std::string create_minidump(const LPEXCEPTION_POINTERS exceptioninfo)
{
const utils::nt::handle file_handle = write_dump_to_temp_file(exceptioninfo);
const utilities::nt::handle file_handle = write_dump_to_temp_file(exceptioninfo);
return read_file(file_handle);
}
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "../utils/nt.hpp"
#include "../utilities/nt.hpp"
namespace exception
{

View File

@ -4,7 +4,7 @@
#include "nt.hpp"
#include "io.hpp"
namespace utils
namespace utilities
{
namespace
{

View File

@ -2,7 +2,7 @@
#include <string>
namespace utils
namespace utilities
{
class binary_resource
{

View File

@ -8,7 +8,7 @@
#include <ShlObj.h>
namespace utils::com
namespace utilities::com
{
namespace
{

View File

@ -4,7 +4,7 @@
#include <ShlObj.h>
#include <atlbase.h>
namespace utils::com
namespace utilities::com
{
bool select_folder(std::string& out_folder, const std::string& title = "Select a Folder", const std::string& selected_folder = {});
CComPtr<IProgressDialog> create_progress_dialog();

View File

@ -8,7 +8,7 @@
#include "io.hpp"
#include "finally.hpp"
namespace utils::compression
namespace utilities::compression
{
namespace zlib
{

View File

@ -5,7 +5,7 @@
#define CHUNK 16384u
namespace utils::compression
namespace utilities::compression
{
namespace zlib
{

View File

@ -2,7 +2,7 @@
#include <mutex>
namespace utils::concurrency
namespace utilities::concurrency
{
template <typename T, typename MutexType = std::mutex>
class container

View File

@ -8,7 +8,7 @@ using namespace std::string_literals;
/// http://www.opensource.apple.com/source/CommonCrypto/CommonCrypto-55010/Source/libtomcrypt/doc/libTomCryptDoc.pdf
namespace utils::cryptography
namespace utilities::cryptography
{
namespace
{

View File

@ -5,7 +5,7 @@
#include <xxhash32.h>
#include <xxhash64.h>
namespace utils::cryptography
namespace utilities::cryptography
{
namespace ecc
{

View File

@ -1,7 +1,7 @@
#pragma once
#include <type_traits>
namespace utils
namespace utilities
{
/*
* Copied from here: https://github.com/microsoft/GSL/blob/e0880931ae5885eb988d1a8a57acf8bc2b8dacda/include/gsl/util#L57

View File

@ -4,7 +4,7 @@
#include <shellapi.h>
namespace utils::flags
namespace utilities::flags
{
void parse_flags(std::vector<std::string>& flags)
{

View File

@ -2,7 +2,7 @@
#include <string>
namespace utils::flags
namespace utilities::flags
{
bool has_flag(const std::string& flag);
}

View File

@ -1,7 +1,7 @@
#include "hardware_breakpoint.hpp"
#include "thread.hpp"
namespace utils::hardware_breakpoint
namespace utilities::hardware_breakpoint
{
namespace
{

View File

@ -2,7 +2,7 @@
#include <thread>
#include "nt.hpp"
namespace utils::hardware_breakpoint
namespace utilities::hardware_breakpoint
{
enum condition
{

View File

@ -15,7 +15,7 @@
#undef min
#endif
namespace utils::hook
namespace utilities::hook
{
namespace
{

View File

@ -6,7 +6,7 @@
using namespace asmjit::x86;
namespace utils::hook
namespace utilities::hook
{
namespace detail
{

View File

@ -2,7 +2,7 @@
#include "nt.hpp"
#include <atlcomcli.h>
namespace utils::http
namespace utilities::http
{
std::optional<std::string> get_data(const std::string& url)
{

View File

@ -4,7 +4,7 @@
#include <optional>
#include <future>
namespace utils::http
namespace utilities::http
{
std::optional<std::string> get_data(const std::string& url);
std::future<std::optional<std::string>> get_data_async(const std::string& url);

View File

@ -6,7 +6,7 @@
#include <intrin.h>
#include <lmcons.h>
namespace utils::identity
namespace utilities::identity
{
namespace
{
@ -44,7 +44,7 @@ namespace utils::identity
std::string parse_uuid(const uint8_t* data)
{
if (utils::memory::is_set(data, 0, 16) || utils::memory::is_set(data, -1, 16))
if (utilities::memory::is_set(data, 0, 16) || utilities::memory::is_set(data, -1, 16))
{
return {};
}

View File

@ -2,7 +2,7 @@
#include <string>
namespace utils::identity
namespace utilities::identity
{
std::string get_sys_username();
std::string get_sys_uuid();

View File

@ -10,7 +10,7 @@
#include "finally.hpp"
namespace utils::image
namespace utilities::image
{
image load_image(const std::string& data)
{

View File

@ -3,7 +3,7 @@
#include <string>
#include "nt.hpp"
namespace utils::image
namespace utilities::image
{
struct image
{

View File

@ -1,7 +1,7 @@
#include "info_string.hpp"
#include "string.hpp"
namespace utils
namespace utilities
{
info_string::info_string(const std::string& buffer)
{

View File

@ -3,7 +3,7 @@
#include <string>
#include <unordered_map>
namespace utils
namespace utilities
{
class info_string
{

View File

@ -2,7 +2,7 @@
#include "nt.hpp"
#include <fstream>
namespace utils::io
namespace utilities::io
{
bool remove_file(const std::string& file)
{
@ -86,6 +86,20 @@ namespace utils::io
return path.substr(pos + 1);
}
std::string file_stem(const std::string& path)
{
std::filesystem::path fsp(path);
return fsp.stem().generic_string();
}
std::string file_extension(const std::string& path)
{
const auto pos = path.find_last_of('.');
if (pos == std::string::npos) return "";
return path.substr(pos + 1);
}
size_t file_size(const std::string& file)
{
if (file_exists(file))

View File

@ -4,7 +4,7 @@
#include <vector>
#include <filesystem>
namespace utils::io
namespace utilities::io
{
bool remove_file(const std::string& file);
bool move_file(const std::string& src, const std::string& target);
@ -13,6 +13,8 @@ namespace utils::io
bool read_file(const std::string& file, std::string* data);
std::string read_file(const std::string& file);
std::string file_name(const std::string& path);
std::string file_stem(const std::string& path);
std::string file_extension(const std::string& path);
size_t file_size(const std::string& file);
time_t file_timestamp(const std::string& file);
bool create_directory(const std::string& directory);

View File

@ -5,7 +5,7 @@
#include <rapidjson/stringbuffer.h>
#include <rapidjson/prettywriter.h>
namespace utils::json_config
namespace utilities::json_config
{
rapidjson::Document json_doc{};
std::string file_name = "project-bo4.json";

View File

@ -1,7 +1,7 @@
#pragma once
#include <string>
namespace utils::json_config
namespace utilities::json_config
{
bool ReadBoolean(const char* szSection, const char* szKey, bool bolDefaultValue);
void WriteBoolean(const char* szSection, const char* szKey, bool bolValue);

View File

@ -1,7 +1,7 @@
#include "memory.hpp"
#include "nt.hpp"
namespace utils
namespace utilities
{
memory::allocator memory::mem_allocator_;
@ -144,7 +144,7 @@ namespace utils
bool memory::is_rdata_ptr(void* pointer)
{
const std::string rdata = ".rdata";
const auto pointer_lib = utils::nt::library::get_by_address(pointer);
const auto pointer_lib = utilities::nt::library::get_by_address(pointer);
for (const auto& section : pointer_lib.get_section_headers())
{

View File

@ -3,7 +3,7 @@
#include <mutex>
#include <vector>
namespace utils
namespace utilities
{
class memory final
{

View File

@ -1,6 +1,6 @@
#include "nt.hpp"
namespace utils::nt
namespace utilities::nt
{
library library::load(const char* name)
{
@ -251,7 +251,7 @@ namespace utils::nt
void relaunch_self()
{
const utils::nt::library self;
const utilities::nt::library self;
STARTUPINFOA startup_info;
PROCESS_INFORMATION process_info;

View File

@ -16,7 +16,7 @@
#include <functional>
#include <filesystem>
namespace utils::nt
namespace utilities::nt
{
class library final
{

View File

@ -1,12 +1,12 @@
#include "progress_ui.hpp"
#include <utils/string.hpp>
#include "string.hpp"
namespace utils
namespace utilities
{
progress_ui::progress_ui()
{
this->dialog_ = utils::com::create_progress_dialog();
this->dialog_ = utilities::com::create_progress_dialog();
if (!this->dialog_)
{
throw std::runtime_error{"Failed to create dialog"};
@ -30,12 +30,12 @@ namespace utils
void progress_ui::set_line(const int line, const std::string& text) const
{
this->dialog_->SetLine(line, utils::string::convert(text).data(), false, nullptr);
this->dialog_->SetLine(line, utilities::string::convert(text).data(), false, nullptr);
}
void progress_ui::set_title(const std::string& title) const
{
this->dialog_->SetTitle(utils::string::convert(title).data());
this->dialog_->SetTitle(utilities::string::convert(title).data());
}
bool progress_ui::is_cancelled() const

View File

@ -2,7 +2,7 @@
#include "com.hpp"
namespace utils
namespace utilities
{
class progress_ui
{

View File

@ -13,7 +13,7 @@
#undef min
#endif
namespace utils::hook
namespace utilities::hook
{
void signature::load_pattern(const std::string& pattern)
{
@ -143,7 +143,7 @@ namespace utils::hook
signature::signature_result signature::process() const
{
//MessageBoxA(nullptr, utils::string::va("%llX(%llX)%llX", *this->start_ , this->start_, this->length_), "signature::process", MB_OK | MB_ICONINFORMATION);
//MessageBoxA(nullptr, utilities::string::va("%llX(%llX)%llX", *this->start_ , this->start_, this->length_), "signature::process", MB_OK | MB_ICONINFORMATION);
const auto range = this->length_ - this->mask_.size();
const auto cores = std::max(1u, std::thread::hardware_concurrency());
@ -217,7 +217,7 @@ namespace utils::hook
}
}
utils::hook::signature::signature_result operator"" _sig(const char* str, const size_t len)
utilities::hook::signature::signature_result operator"" _sig(const char* str, const size_t len)
{
return utils::hook::signature(std::string(str, len)).process();
return utilities::hook::signature(std::string(str, len)).process();
}

View File

@ -2,7 +2,7 @@
#include "nt.hpp"
#include <cstdint>
namespace utils::hook
namespace utilities::hook
{
class signature final
{
@ -46,4 +46,4 @@ namespace utils::hook
};
}
utils::hook::signature::signature_result operator"" _sig(const char* str, size_t len);
utilities::hook::signature::signature_result operator"" _sig(const char* str, size_t len);

View File

@ -1,11 +1,11 @@
#include "string.hpp"
#include <sstream>
#include <regex>
#include <cstdarg>
#include <algorithm>
#include "nt.hpp"
namespace utils::string
namespace utilities::string
{
const char* va(const char* fmt, ...)
{
@ -71,6 +71,10 @@ namespace utils::string
return text;
}
bool is_integer(const std::string& str) {
return std::regex_match(str, std::regex("[(-|+)|][0-9]+"));
}
bool starts_with(const std::string& text, const std::string& substring)
{
return text.find(substring) == 0;
@ -213,4 +217,15 @@ namespace utils::string
if (!sensetive && (to_lower(s1) == to_lower(s2))) return true;
return false;
}
bool contains(std::string text, std::string substr, bool sensetive)
{
if (!sensetive) {
text = to_lower(text);
substr = to_lower(substr);
}
if (text.find(substr) != std::string::npos) return true;
return false;
}
}

View File

@ -7,7 +7,7 @@ template <class Type, size_t n>
size_t ARRAYSIZE(Type (&)[n]) { return n; }
#endif
namespace utils::string
namespace utilities::string
{
template <size_t Buffers, size_t MinBufferSize>
class va_provider final
@ -85,6 +85,9 @@ namespace utils::string
std::string to_lower(std::string text);
std::string to_upper(std::string text);
bool is_integer(const std::string& str);
bool starts_with(const std::string& text, const std::string& substring);
bool ends_with(const std::string& text, const std::string& substring);
@ -101,4 +104,5 @@ namespace utils::string
double match(const std::string& input, const std::string& text);
bool compare(const std::string& s1, const std::string& s2, bool sensetive = false);
bool contains(std::string text, std::string substr, bool sensetive = false);
}

View File

@ -4,7 +4,7 @@
#include <TlHelp32.h>
namespace utils::thread
namespace utilities::thread
{
bool set_name(const HANDLE t, const std::string& name)
{
@ -28,7 +28,7 @@ namespace utils::thread
auto* const t = OpenThread(THREAD_SET_LIMITED_INFORMATION, FALSE, id);
if (!t) return false;
const auto _ = utils::finally([t]()
const auto _ = utilities::finally([t]()
{
CloseHandle(t);
});

View File

@ -2,7 +2,7 @@
#include <thread>
#include "nt.hpp"
namespace utils::thread
namespace utilities::thread
{
bool set_name(HANDLE t, const std::string& name);
bool set_name(DWORD id, const std::string& name);