diff --git a/CMakeLists.txt b/CMakeLists.txt index 6418c4a..0853c42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ elseif(UNIX) add_compile_definitions(SELAURA_LINUX) endif() -set(CLIENT_VERSION "0.11") +set(CLIENT_VERSION "0.20") if (CMAKE_BUILD_TYPE STREQUAL "Release") set(DEVELOPER_MODE "") @@ -118,6 +118,11 @@ FetchContent_Declare( GIT_REPOSITORY https://github.com/ocornut/imgui.git GIT_TAG features/shadows ) +FetchContent_Declare( + spdlog + GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.x +) if (MSVC) FetchContent_Declare( @@ -136,7 +141,7 @@ endif() set(DOBBY_DEBUG OFF) set(DOBBY_GENERATE_SHARED OFF) -FetchContent_MakeAvailable(fmt entt typesafe libhat magic_enum LuaBridge glm cpp-i18n) +FetchContent_MakeAvailable(fmt entt typesafe libhat magic_enum LuaBridge glm cpp-i18n spdlog) if (MSVC) FetchContent_MakeAvailable(minhook) else() @@ -159,9 +164,9 @@ if(NOT imgui_POPULATED) endif() if(MSVC) - target_link_libraries(Selaura PRIVATE fmt::fmt EnTT::EnTT type_safe libhat ImGui magic_enum LuaBridge glm cpp-i18n minhook) + target_link_libraries(Selaura PRIVATE fmt::fmt EnTT::EnTT type_safe libhat ImGui magic_enum LuaBridge glm cpp-i18n spdlog minhook) else() - target_link_libraries(Selaura PRIVATE fmt::fmt EnTT::EnTT type_safe libhat ImGui magic_enum LuaBridge glm cpp-i18n dobby_static) + target_link_libraries(Selaura PRIVATE fmt::fmt EnTT::EnTT type_safe libhat ImGui magic_enum LuaBridge glm cpp-i18n spdlog dobby_static) endif() if (ANDROID) diff --git a/src/client/event/event.hpp b/src/client/event/event.hpp deleted file mode 100644 index ed2a98e..0000000 --- a/src/client/event/event.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace selaura { - template - class dispatcher { - public: - static inline entt::sigh signal; - static inline entt::sink sink{ signal }; - - static void dispatch(T& ev) { - dispatcher::signal.publish(ev); - } - }; - - class listener { - public: - template void subscribe(this Self& self) { - selaura::dispatcher::sink.template connect(self); - } - - template void unsubscribe(this Self& self) { - selaura::dispatcher::sink.template disconnect(self); - } - - }; -} \ No newline at end of file diff --git a/src/client/feature/feature.cpp b/src/client/feature/feature.cpp deleted file mode 100644 index ee4432e..0000000 --- a/src/client/feature/feature.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "feature.hpp" - -namespace selaura { - feature::~feature() noexcept { - set_enabled(false); - on_disable(); - } - - void feature::set_enabled(bool enabled) { - this->enabled = enabled; - } - - bool feature::is_enabled() const { - return this->enabled; - } - - void feature::toggle() { - this->enabled = !this->enabled; - } - - void feature::set_hotkey(int hotkey) { - this->hotkey = hotkey; - } - - int feature::get_hotkey() const { - return this->hotkey; - } - - void feature::on_enable() {} - void feature::on_disable() {} - - void feature::set_feature_size(const glm::vec2& size) { - this->size = size; - } - void feature::set_feature_position(const glm::vec2& pos) { - this->pos = pos; - } - const glm::vec2& feature::get_feature_size() { - return this->size; - } - const glm::vec2& feature::get_feature_pos() { - return this->pos; - } -}; \ No newline at end of file diff --git a/src/client/feature/feature.hpp b/src/client/feature/feature.hpp deleted file mode 100644 index 94744ec..0000000 --- a/src/client/feature/feature.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#pragma once -#include -#include -#include -#include - -#include -#include -#include "../event/event.hpp" - -namespace selaura { - - using feature_setting_type = std::variant< - float, // slider - bool, // toggle - int, // enum index - glm::vec4 // color - >; - - struct feature_setting { - std::string name; - feature_setting_type value; - }; - - template - struct feature_traits { - static constexpr auto name = name_str; - static constexpr auto description = description_str; - }; - - #define DEFINE_FEATURE_TRAITS(name, description) using info = feature_traits; - - struct feature : public selaura::listener { - using info = feature_traits<>; - feature() = default; - virtual ~feature() noexcept; - - virtual void on_disable(); - virtual void on_enable(); - - void set_enabled(bool enabled = true); - bool is_enabled() const; - void toggle(); - - void set_hotkey(int hotkey = 0); - int get_hotkey() const; - - template - auto* add_settings(args_t... args) { - return settings.emplace_back(std::make_unique(std::forward(args)...)).get(); - } - - const std::vector>& get_settings() const { - return settings; - } - - virtual void set_feature_size(const glm::vec2& size); - virtual void set_feature_position(const glm::vec2& pos); - const glm::vec2& get_feature_size(); - const glm::vec2& get_feature_pos(); - - private: - bool enabled = false; - int hotkey; - glm::vec2 pos{}; - glm::vec2 size{}; - std::vector> settings; - }; -} \ No newline at end of file diff --git a/src/client/feature/feature_manager.hpp b/src/client/feature/feature_manager.hpp deleted file mode 100644 index 1e92d30..0000000 --- a/src/client/feature/feature_manager.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once -#include -#include - -#include "feature.hpp" - -namespace selaura { - template - struct feature_storage { - T mod; - feature_storage remaining; - - void for_each(auto callback) { - callback(mod); - remaining.for_each(callback); - } - }; - - template - struct feature_storage { - T mod; - void for_each(auto callback) { - callback(mod); - } - }; - - struct feature_manager { - using features_type = feature_storage; - - void for_each(auto callback) { - features.for_each(callback); - } - - void for_each(auto callback) const { - features.for_each(callback); - } - - template - T* get() { - T* result = nullptr; - features.for_each([&](features_type& feature) { - if (result != nullptr) return; - if (std::is_same_v) { - result = &feature; - } - }); - - return result; - } - - [[nodiscard]] auto* find(std::string_view name) { - feature* result = nullptr; - features.for_each([&](features_type & feature) { - if (result != nullptr) return; - if (features_type::info::name == name) { - result = &feature; - } - }); - - return result; - } - private: - features_type features; - }; -}; \ No newline at end of file diff --git a/src/client/hook/hook.cpp b/src/client/hook/hook.cpp deleted file mode 100644 index 1d91d22..0000000 --- a/src/client/hook/hook.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "hook.hpp" - -namespace selaura { - - bool hook_t::enable() { -#ifdef SELAURA_WINDOWS - return MH_EnableHook(target) == MH_OK; -#else - return true; -#endif - } - - bool hook_t::disable() { -#ifdef SELAURA_WINDOWS - return MH_DisableHook(target) == MH_OK; -#else - return DobbyDestroy(target) == 0; -#endif - } - - bool init_hooking() { -#ifdef SELAURA_WINDOWS - return MH_Initialize() == MH_OK; -#else - return true; -#endif - } - - void shutdown_hooking() { -#ifdef SELAURA_WINDOWS - MH_Uninitialize(); -#endif - } - - hook_t hook(void* target, void* detour) { - void** original_out; -#ifdef SELAURA_WINDOWS - MH_CreateHook(target, detour, original_out); -#else - DobbyHook(target, detour, original_out); -#endif - return { target, detour, *original_out }; - } -} diff --git a/src/client/hook/hook.hpp b/src/client/hook/hook.hpp deleted file mode 100644 index f59d93f..0000000 --- a/src/client/hook/hook.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#ifdef SELAURA_WINDOWS -#include -#include -#else -#include -#endif - -namespace selaura { - - struct hook_t { - void* target; - void* detour; - void* original; - - bool enable(); - bool disable(); - - template - T get_original() const { - return reinterpret_cast(original); - } - }; - - bool init_hooking(); - void shutdown_hooking(); - hook_t hook(void* target, void* detour); -} diff --git a/src/client/hook/hook_manager.hpp b/src/client/hook/hook_manager.hpp deleted file mode 100644 index 2f7e9f8..0000000 --- a/src/client/hook/hook_manager.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include -#include -#include - -#include "impl/visual_hooks.hpp" - -namespace selaura { - template - struct hook_storage { - T hook; - hook_storage remaining; - - void for_each(auto callback) { - callback(hook); - remaining.for_each(callback); - } - }; - - template - struct hook_storage { - T hook; - void for_each(auto callback) { - callback(hook); - } - }; - - struct hook_manager { - using hooks_type = hook_storage< - visual_hooks - >; - - void for_each(auto callback) { - hooks.for_each(callback); - } - - void for_each(auto callback) const { - hooks.for_each(callback); - } - - template - T* get() { - T* result = nullptr; - hooks.for_each([&](hooks_type & h) { - if (result != nullptr) return; - if (std::is_same_v) { - result = &h; - } - }); - return result; - } - private: - hooks_type hooks; - }; -} diff --git a/src/client/hook/impl/visual_hooks.cpp b/src/client/hook/impl/visual_hooks.cpp deleted file mode 100644 index db5b35b..0000000 --- a/src/client/hook/impl/visual_hooks.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "visual_hooks.hpp" - -//selaura::hook_t visual_hooks::setupandrender_hook; -selaura::hook_t visual_hooks::splashtext_hook; -/* -void visual_hooks::screenview_setupandrender(void* a1, bedrock::MinecraftUIRenderContext* mcuirc) { - auto ci = mcuirc->clientInstance; - auto guiData = ci->guiData; - - auto screenSize = guiData->mScreenSize; - static bedrock::Vec2 safeZone = { 0.f, 0.f }; - //ci->_updateScreenSizeVariables(&screenSize, &safeZone, 2); - - static bool once = false; - if (!once) { - //guiData->displayClientMessage("Selaura on Top!"); - once = true; - } - - setupandrender_hook.get_original()(a1, mcuirc); -} -*/ -std::vector* visual_hooks::splashtextrenderer_loadsplashes(void* a1, void* a2, void* a3, void* a4) { - auto original_func = splashtext_hook.get_original(); - std::vector* result = original_func(a1, a2, a3, a4); - - if (result) { - const static std::string splash_text = "\u00a76Selaura Client \u00a76on top!\u00a7r"; - *result = { splash_text }; - } - - return result; -} - -void visual_hooks::enable() { - //auto sig = GET_SIGNATURE("ScreenView::SetupandRender"); - //auto hook_test = selaura::hook((void*)sig.value(), (void*)screenview_setupandrender); - //hook_test.enable(); - - /*auto sig2 = GET_SIGNATURE("SplashTextRenderer::_loadSplashes"); - splashtext_hook = selaura::hook((void*)sig2.value(), (void*)splashtextrenderer_loadsplashes); - splashtext_hook.enable();*/ -} - -void visual_hooks::disable() { - //setupandrender_hook.disable(); - splashtext_hook.disable(); -} diff --git a/src/client/hook/impl/visual_hooks.hpp b/src/client/hook/impl/visual_hooks.hpp deleted file mode 100644 index 3ba791b..0000000 --- a/src/client/hook/impl/visual_hooks.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "../hook.hpp" -#include "../../io/io.hpp" -#include "../../symbol/map.hpp" -#include "../../../core/bedrock/client/renderer/minecraft_ui_render_context.hpp" -#include "../../../core/bedrock/core/math/vec2.hpp" - -class visual_hooks { -private: - //static selaura::hook_t setupandrender_hook; - static selaura::hook_t splashtext_hook; - - //static void screenview_setupandrender(void* a1, bedrock::MinecraftUIRenderContext* mcuirc); - static std::vector* splashtextrenderer_loadsplashes(void* a1, void* a2, void* a3, void* a4); -public: - void enable(); - void disable(); -}; diff --git a/src/client/instance.hpp b/src/client/instance.hpp deleted file mode 100644 index 1cc7c1f..0000000 --- a/src/client/instance.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include -#include -#include - -#include "event/event.hpp" -#include "io/io.hpp" -#include "feature/feature_manager.hpp" -#include "hook/hook_manager.hpp" - -#include "symbol/map.hpp" - -#ifdef SELAURA_WINDOWS -#include -#include -#include -#include -#endif - -namespace selaura { - class instance : public selaura::listener, public std::enable_shared_from_this { - public: - bool start(); - void init(); - void shutdown(); - - static std::shared_ptr get(); - private: - std::unique_ptr resolver; - std::unique_ptr io; - std::unique_ptr feature_manager; - std::unique_ptr hook_manager; - }; -}; \ No newline at end of file diff --git a/src/client/io/io.cpp b/src/client/io/io.cpp deleted file mode 100644 index 50e9760..0000000 --- a/src/client/io/io.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "io.hpp" - -namespace selaura { -} \ No newline at end of file diff --git a/src/client/io/io.hpp b/src/client/io/io.hpp deleted file mode 100644 index 3368707..0000000 --- a/src/client/io/io.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include - -namespace selaura { - class io { - public: - std::filesystem::path data_folder; - std::filesystem::path log_file; - std::ofstream log_stream; - - void init() { -#ifdef SELAURA_WINDOWS - char* localAppData = nullptr; - size_t size = 0; - _dupenv_s(&localAppData, &size, "APPDATA"); - if (localAppData) { - data_folder = std::filesystem::path(localAppData + std::string("\\..\\Local\\Packages\\Microsoft.MinecraftUWP_8wekyb3d8bbwe\\RoamingState\\Selaura")); - } -#elif defined(SELAURA_LINUX) - data_folder = "/data/data/com.mojang.minecraftpe/Selaura"; -#elif defined(SELAURA_ANDROID) - data_folder = "/data/data/com.selauraclient.launcher/Selaura"; -#endif - log_file = data_folder / "logs.txt"; - std::filesystem::create_directories(data_folder); - log_stream.open(log_file, std::ios::trunc); - } - - void shutdown() { - if (log_stream.is_open()) log_stream.close(); - } - - template - void info(std::format_string fmt, Args&&... args) { - log("INFO", std::format(fmt, std::forward(args)...)); - } - - template - void warn(std::format_string fmt, Args&&... args) { - log("WARN", std::format(fmt, std::forward(args)...)); - } - - template - void error(std::format_string fmt, Args&&... args) { - log("ERROR", std::format(fmt, std::forward(args)...)); - } - - private: - void log(const std::string& level, const std::string& msg) { - if (!log_stream.is_open()) return; - - auto now = std::chrono::system_clock::now(); - auto time_t_now = std::chrono::system_clock::to_time_t(now); - auto local_tm = std::localtime(&time_t_now); - - char timestamp[20]; - std::strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", local_tm); - - log_stream << std::format("[{}] [{}] {}\n", timestamp, level, msg); - log_stream.flush(); - } - }; -} diff --git a/src/client/scripting/script_lib.hpp b/src/client/scripting/script_lib.hpp deleted file mode 100644 index 5792211..0000000 --- a/src/client/scripting/script_lib.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace selaura { - template - concept StaticScriptLib = requires(lua_State * L) { - { T::init(L) } -> std::same_as; - }; - - template - concept DynamicScriptLib = requires(T t, lua_State * L) { - { t.init(L) } -> std::same_as; - }; - - class script_lib { - public: - script_lib() = default; - virtual ~script_lib() = default; - - virtual void init(lua_State* L) = 0; - - template - static void register_lib(lua_State* L) { - T::init(L); - } - - template - static void register_lib(lua_State* L) { - T{}.init(L); - } - }; -}; \ No newline at end of file diff --git a/src/client/symbol/map.cpp b/src/client/symbol/map.cpp deleted file mode 100644 index 8ad8efd..0000000 --- a/src/client/symbol/map.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "map.hpp" - -using namespace selaura::detail; - -namespace selaura::detail { - void register_memory() { - DEFINE_SIGNATURE("ScreenView::SetupandRender", platform::windows, "48 8B C4 48 89 58 18 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 98 FD"); - DEFINE_SIGNATURE("SplashTextRenderer::_loadSplashes", platform::windows, "48 89 5C 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 49 8B D9 49 8B F8 4C 89 44 24"); - DEFINE_SIGNATURE("ClientInstance::_updateScreenSizeVariables", platform::windows, "48 8B C4 48 89 58 18 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 C8 FE FF FF 48 81 EC 00 02 00 00 0F 29 70 B8 0F 29 78 A8 44 0F 29 40 98 44 0F 29 48 88 44 0F 29 90 78 FF FF FF 44 0F 29 A0"); - DEFINE_SIGNATURE("GuiData::displayClientMessage", platform::windows, "40 55 53 56 57 41 56 48 8D AC 24 A0 FE FF FF 48 81 EC 60 02 00 00 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 50 01 00 00 41"); - - DEFINE_SIGNATURE("ScreenView::SetupandRender", platform::arm64, "E8 0F 19 FC FD 7B 01 A9 FD 43 00 91 FC 6F 02 A9 FA 67 03 A9 F8 5F 04 A9 F6 57 05 A9 F4 4F 06 A9 FF 03 07 D1 48 D0 3B D5 F9"); - DEFINE_SIGNATURE("SplashTextRenderer::_loadSplashes", platform::arm64, "FD 7B BA A9 FC 6F 01 A9 FD 03 00 91 FA 67 02 A9 F8 5F 03 A9 F6 57 04 A9 F4 4F 05 A9 FF C3 06 D1 E1 13"); - DEFINE_SIGNATURE("ClientInstance::_updateScreenSizeVariables", platform::arm64, "48 8B C4 48 89 58 18 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 C8 FE FF FF 48 81 EC 00 02 00 00 0F 29 70 B8 0F 29 78 A8 44 0F 29 40 98 44 0F 29 48 88 44 0F 29 90 78 FF FF FF 44 0F 29 A0"); - DEFINE_SIGNATURE("GuiData::displayClientMessage", platform::arm64, "FF 83 07 D1 FD 7B 18 A9 FD 03 06 91 FC 6F 19 A9 FA 67 1A A9 F8 5F 1B A9 F6 57 1C A9 F4 4F 1D A9 E8 07"); - } -}; diff --git a/src/client/symbol/map.hpp b/src/client/symbol/map.hpp deleted file mode 100644 index b9fd7e9..0000000 --- a/src/client/symbol/map.hpp +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include "resolver.hpp" - -namespace selaura::detail { - void register_memory(); - - enum class platform { - windows = 0, - arm64 = 1, - android64 = 2, - count - }; - - using memory_array = std::array, static_cast(platform::count)>; - using string_array = std::array, static_cast(platform::count)>; - - struct sig_entry { - string_array signature_strings; - memory_array offsets; - }; - - class signature_map { - public: - static inline signature_map& inst() { - static signature_map map; - return map; - } - - void define_signature(const std::string& name, platform plat, const std::string& sig) { - entries[name].signature_strings[static_cast(plat)] = sig; - } - - void define_offset(const std::string& name, platform plat, uintptr_t offset) { - entries[name].offsets[static_cast(plat)] = offset; - } - - std::optional get_signature(const std::string& name, platform plat) const { - auto it = entries.find(name); - if (it != entries.end()) { - auto& sig = it->second.signature_strings[static_cast(plat)]; - if (sig.has_value()) { - return selaura::resolver::signature(sig.value()); - } - } - return std::nullopt; - } - - std::optional get_offset(const std::string& name, platform plat) const { - auto it = entries.find(name); - if (it != entries.end()) { - return it->second.offsets[static_cast(plat)]; - } - return std::nullopt; - } - - private: - std::unordered_map entries; - }; -}; - -#ifndef SELAURA_PLATFORM -#ifdef SELAURA_WINDOWS -#define SELAURA_PLATFORM selaura::detail::platform::windows -#elif defined(SELAURA_ANDROID) -#define SELAURA_PLATFORM selaura::detail::platform::arm64 -#elif defined(SELAURA_LINUX) -#define SELAURA_PLATFORM selaura::detail::platform::android64 -#endif -#endif - -#define DEFINE_SIGNATURE(name, platform, sig) \ - selaura::detail::signature_map::inst().define_signature(name, platform, sig) - -#define DEFINE_OFFSET(name, platform, offset) \ - selaura::detail::signature_map::inst().define_offset(name, platform, offset) - -#define GET_SIGNATURE(name) \ - selaura::detail::signature_map::inst().get_signature(name, SELAURA_PLATFORM) - -#define GET_OFFSET(name) \ - selaura::detail::signature_map::inst().get_offset(name, SELAURA_PLATFORM) diff --git a/src/client/symbol/resolver.cpp b/src/client/symbol/resolver.cpp deleted file mode 100644 index 03a91f8..0000000 --- a/src/client/symbol/resolver.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "resolver.hpp" - -namespace selaura { - std::optional resolver::signature(std::string_view sig) { - static selaura::detail::process_module game = selaura::detail::get_module_handle(); - - const auto parsed = hat::parse_signature(sig); - const auto result = hat::find_pattern(game.base, game.base + game.size, parsed.value()); - - if (!result.has_result()) return std::nullopt; - return reinterpret_cast(result.get()); - }; -}; \ No newline at end of file diff --git a/src/client/symbol/resolver.hpp b/src/client/symbol/resolver.hpp deleted file mode 100644 index 1fe7cdb..0000000 --- a/src/client/symbol/resolver.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include - -#include "module.hpp" - -namespace selaura { - class resolver { - public: - static std::optional signature(std::string_view sig); - }; -}; \ No newline at end of file diff --git a/src/client/types.hpp b/src/client/types.hpp deleted file mode 100644 index a06cc04..0000000 --- a/src/client/types.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include - -namespace selaura::detail { - struct version_format { - int max; - int min; - int build; - int revision; - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/client/client_instance.hpp b/src/core/bedrock/client/client_instance.hpp deleted file mode 100644 index b70a763..0000000 --- a/src/core/bedrock/client/client_instance.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "../../../client/symbol/resolver.hpp" -#include "../core/math/vec2.hpp" -#include -#include "gui_data.hpp" - -namespace bedrock { - class ClientInstance { - char _pad0[0x5B8]; - public: - bedrock::GuiData* guiData; - - void _updateScreenSizeVariables(Vec2* totalScreenSize, Vec2* safeZone, float guiScale) { - static auto sig = GET_SIGNATURE("ClientInstance::_updateScreenSizeVariables"); - auto fn = reinterpret_cast(sig.value()); - fn(this, totalScreenSize, safeZone, guiScale); - } - }; -} diff --git a/src/core/bedrock/client/client_instance_interface.hpp b/src/core/bedrock/client/client_instance_interface.hpp deleted file mode 100644 index b87d177..0000000 --- a/src/core/bedrock/client/client_instance_interface.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "../core/utility/enable_non_owner_references.hpp" - -#include -#include -#include -#include - -namespace bedrock { - class IClientInstance : public Bedrock::EnableNonOwnerReferences { - public: - - }; -} \ No newline at end of file diff --git a/src/core/bedrock/client/gui_data.hpp b/src/core/bedrock/client/gui_data.hpp deleted file mode 100644 index b0d1cb7..0000000 --- a/src/core/bedrock/client/gui_data.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "../core/math/vec2.hpp" - -namespace bedrock { - class GuiData { - private: - char pad[0x40]; - public: - Vec2 mScreenSize; - Vec2 mScreenSizeScaled; - private: - char pad2[0x4]; - public: - float mGuiScale; - - void displayClientMessage(const std::string& str) { - if (str.empty()) return; - static auto sig = GET_SIGNATURE("GuiData::displayClientMessage"); - char a3[0x28]{}; - - using func_t = void(*)(GuiData*, const std::string&, char*, bool); - static auto func = reinterpret_cast(sig.value()); - func(this, str, a3, true); - } - }; -} diff --git a/src/core/bedrock/client/renderer/minecraft_ui_render_context.hpp b/src/core/bedrock/client/renderer/minecraft_ui_render_context.hpp deleted file mode 100644 index e8c9dc1..0000000 --- a/src/core/bedrock/client/renderer/minecraft_ui_render_context.hpp +++ /dev/null @@ -1,98 +0,0 @@ -#pragma once - -#include "../client_instance.hpp" -#include "screen_context.hpp" -#include "../../core/utility/enable_non_owner_references.hpp" -#include "../../core/math/color.hpp" -#include "../../core/math/vec2.hpp" -#include - -#include -#include -#include - -namespace bedrock::mce { - class BedrockTexture; - class ClientTexture; -} - -namespace bedrock { - class ComponentRenderBatch {}; - struct BedrockTextureData { - mce::ClientTexture* clientTexture; - }; - class ResourceLocation { - public: - void* mFileSystem; // ResourceFileSystem - std::string mPath; - uint64_t mPathHash; - uint64_t mFullHash; - - ~ResourceLocation(); - ResourceLocation(); - ResourceLocation(const std::string& path); - ResourceLocation(const char* path); - private: - void _computeHashes(); - }; - - namespace cg { - class ImageBuffer {}; - } - - namespace mce { - class ClientTexture { - std::byte padding0[32]; - }; - class TextureGroup : public Bedrock::EnableNonOwnerReferences { - public: - std::byte padding48[352]; - std::map mLoadedTextures; - - BedrockTexture& uploadTexture(const ResourceLocation& resource, /*const mce::TextureContainer&*/ void* texture, std::optional debugName); - BedrockTexture& uploadTexture(const ResourceLocation& resource, cg::ImageBuffer imageBuffer); - void unloadAllTextures(); - }; - class TexturePtr { - public: - std::shared_ptr mClientTexture; - std::shared_ptr mResourceLocation; - }; - }; - class UIScene {}; - class Font {}; - struct RectangleArea { - float _x0; - float _x1; - float _y0; - float _y1; - }; - - enum TextAlignment : uint8_t { - Left = 0x0, - Right = 0x1, - Center = 0x2 - }; - - struct TextMeasureData { - float fontSize; - int linePadding; - bool renderShadow; - bool showColorSymbol; - bool hideHyphen; - }; - struct CaretMeasureData { - int position; - bool shouldRender; - }; - class MinecraftUIRenderContext { - private: - char pad0[0x8]; - public: - ClientInstance* clientInstance; - private: - char pad1[0x8]; - public: - ScreenContext* screenContext; - }; -} \ No newline at end of file diff --git a/src/core/bedrock/client/renderer/screen_context.hpp b/src/core/bedrock/client/renderer/screen_context.hpp deleted file mode 100644 index 4d95aee..0000000 --- a/src/core/bedrock/client/renderer/screen_context.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "tessellator.hpp" -#include - -namespace bedrock { - class ScreenContext /* : public UIScreenContext, public mce::MeshContent*/ { - public: - std::byte padding0[160]; - Tessellator* tessellator; // Tessellator& - - Tessellator* getTessellator() { - return hat::member_at(this, 0xC8); - } - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/client/renderer/tessellator.cpp b/src/core/bedrock/client/renderer/tessellator.cpp deleted file mode 100644 index 55f3ae7..0000000 --- a/src/core/bedrock/client/renderer/tessellator.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "tessellator.hpp" -#include "../../../../client/symbol/resolver.hpp" - -namespace bedrock { - void Tessellator::begin(mce::PrimitiveMode mode, int maxVertices) { - using func_t = void(*)(Tessellator*, mce::PrimitiveMode, int, bool); - static auto func = reinterpret_cast(selaura::resolver::signature("40 53 55 48 83 EC 28 80 B9").value()); - func(this, mode, maxVertices, false); - } - void Tessellator::vertex(float x, float y, float z) { - using func_t = void(*)(Tessellator*, float, float, float); - static auto func = reinterpret_cast(selaura::resolver::signature("40 57 48 81 EC ? ? ? ? 0F 29 7C ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 44 24 ? 8B 81").value()); - func(this, x, y, z); - } - void Tessellator::vertex(const Vec3& vec) { - this->vertex(vec.x, vec.y, vec.z); - } - void Tessellator::vertex(float x, float y) { - this->vertex(x, y, 0); - } - void Tessellator::vertex(const Vec2& vec) { - this->vertex(vec.x, vec.y, 0); - } - void Tessellator::vertexUV(float x, float y, float z, float uvX, float uvY) { - using func_t = void(*)(Tessellator*, float, float, float, float, float); - static auto func = reinterpret_cast(selaura::resolver::signature("48 83 EC ? 80 B9 ? ? ? ? ? 0F 57 E4").value()); - func(this, x, y, z, uvX, uvY); - } - void Tessellator::vertexUV(const Vec3& vec, float uvX, float uvY) { - this->vertexUV(vec.x, vec.y, vec.z, uvX, uvY); - } - mce::Mesh Tessellator::end(uint64_t a3, std::string_view debugName, int a5) { - using func_t = mce::Mesh(*)(Tessellator*, uint64_t, std::string_view, int); - static auto func = reinterpret_cast(selaura::resolver::signature("48 8B C4 48 89 58 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 0F 29 70 ? 0F 29 78 ? 44 0F 29 40 ? 44 0F 29 48 ? 44 0F 29 90 ? ? ? ? 44 0F 29 98 ? ? ? ? 44 0F 29 A0 ? ? ? ? 44 0F 29 A8 ? ? ? ? 44 0F 29 B0 ? ? ? ? 44 0F 29 B8 ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4D 8B F9").value()); - return func(this, a3, debugName, a5); - } - void Tessellator::setPostTransformOffset(float xo, float yo, float zo) { - this->postTransformOffset.x = xo; - this->postTransformOffset.y = yo; - this->postTransformOffset.z = zo; - } - - void Tessellator::setPosTransformOffset(Vec3 v) { - this->postTransformOffset = v; - } - - Vec3* Tessellator::getPostTransformOffset() { - return &this->postTransformOffset; - } - - void Tessellator::addPostTransformOffset(float x, float y, float z) { - this->postTransformOffset.x += x; - this->postTransformOffset.y += y; - this->postTransformOffset.z += z; - } - - void Tessellator::addPostTransformOffset(Vec3 v) { - this->postTransformOffset = this->postTransformOffset + v; - } - - void Tessellator::resetPostTransformScale() { - this->postTransformScale = Vec3(1.0f, 1.0f, 1.0f); - } - - void Tessellator::color(float r, float g, float b, float a) { - using func_t = void(*)(Tessellator*, float, float, float, float); - static auto func = reinterpret_cast(selaura::resolver::signature("80 B9 ? ? ? ? ? 4C 8B C1 75").value()); - func(this, r, g, b, a); - } - - void Tessellator::color(unsigned int rgba) { - float r = ((rgba >> 24) & 0xFF) / 255.0f; - float g = ((rgba >> 16) & 0xFF) / 255.0f; - float b = ((rgba >> 8) & 0xFF) / 255.0f; - float a = (rgba & 0xFF) / 255.0f; - this->color(r, g, b, a); - } - - void Tessellator::beginOverride() { - begin(mce::PrimitiveMode::QuadList, 0); - voidBeginEnd = true; - } - - //void Tessellator::clear() {} - - mce::Mesh Tessellator::endOverride(uint64_t a3, std::string_view debugName, int a5) { - voidBeginEnd = false; - return end(a3, debugName, a5); - } -}; \ No newline at end of file diff --git a/src/core/bedrock/client/renderer/tessellator.hpp b/src/core/bedrock/client/renderer/tessellator.hpp deleted file mode 100644 index de3a6b3..0000000 --- a/src/core/bedrock/client/renderer/tessellator.hpp +++ /dev/null @@ -1,98 +0,0 @@ -#pragma once -#include "../../core/math/vec2.hpp" -#include "../../core/math/vec3.hpp" -#include "../../../../client/symbol/resolver.hpp" -#include -#include -#include -#include -#include - -namespace bedrock { - namespace mce { - class TexturePtr; - class MeshContext {}; - class MaterialPtr {}; - class Mesh { - public: - void renderMesh(mce::MeshContext& mctx, const mce::MaterialPtr& mPtr, const mce::TexturePtr& texture) { - using func_t = void(*)(Mesh*, mce::MeshContext&, const mce::MaterialPtr&, const mce::TexturePtr&); - static uintptr_t val = selaura::resolver::signature("40 53 56 57 48 81 EC ? ? ? ? 48 8B D9 C6 44 24").value(); - static auto func = reinterpret_cast(val); - func(this, mctx, mPtr, texture); - } - }; - class MeshData { - public: - std::byte padding0[8]; - std::vector mPositions; - std::byte padding32[272 - 32]; - }; - - enum class PrimitiveMode : int { - None = 0, - QuadList = 1, - TriangleList = 2, - TriangleStrip = 3, - LineList = 4, - LineStrip = 5, - }; - } - - struct TessellatorQuadInfo { - public: - unsigned char facing; - unsigned char twoFace; - Vec3 centroid; - }; - - class Tessellator { - public: - bool isFormatFixed; - std::byte padding1[7]; - mce::MeshData meshData; - std::byte padding280[328 - 280]; - std::optional nextColor; - std::byte padding336[12]; - Vec3 postTransformOffset; - Vec3 postTransformScale; - std::byte padding372[4]; - std::vector quadInfoList; - std::byte padding400[16]; - bool applyTransform; - std::byte padding417[67]; - bool noColor; - bool voidBeginEnd; - std::byte padding486[46]; - bool tessellating; - std::byte padding533[19]; - unsigned int count; - std::byte padding556[5]; - bool buildFaceData; - public: - void begin(mce::PrimitiveMode mode = mce::PrimitiveMode::TriangleList, int maxVertices = 0); - void beginOverride(); - - void vertex(float x, float y, float z); - void vertex(const Vec3&); - void vertex(float x, float y); - void vertex(const Vec2&); - void vertexUV(float x, float y, float z, float uvX, float uvY); - void vertexUV(const Vec3&, float uvX, float uvY); - - void color(float r, float g, float b, float a); - void color(unsigned int rgba); - - void setPostTransformOffset(float xo, float yo, float zo); - void setPosTransformOffset(Vec3 v); - Vec3* getPostTransformOffset(); - void addPostTransformOffset(float x, float y, float z); - void addPostTransformOffset(Vec3 v); - - void resetPostTransformScale(); - - mce::Mesh end(uint64_t a3, std::string_view debugName, int a5); - void clear(); - mce::Mesh endOverride(uint64_t a3, std::string_view debugName, int a5); - }; -} \ No newline at end of file diff --git a/src/core/bedrock/common_types.hpp b/src/core/bedrock/common_types.hpp deleted file mode 100644 index b607766..0000000 --- a/src/core/bedrock/common_types.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "world/actor/actor.hpp" - -namespace bedrock { - using ActorList = std::vector; - - enum class SubClientId : std::uint8_t { - Server = 0, - PrimaryClient = 0, - Client2 = 1, - Client3 = 2, - Client4 = 3, - ExtraIdSlotStart = 100, - EditorUI = 101 - }; - - using BlockRuntimeId = std::uint32_t; - using BiomeIdType = std::uint16_t; -}; \ No newline at end of file diff --git a/src/core/bedrock/core/math/color.cpp b/src/core/bedrock/core/math/color.cpp deleted file mode 100644 index 91f5aca..0000000 --- a/src/core/bedrock/core/math/color.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "color.hpp" - -#include -#include -#include -#include - -namespace bedrock { - std::string mce::Color::toHexString() const - { - std::stringstream stream; - stream << "#" << std::setfill('0') << std::hex // - << std::setw(2) << static_cast(r * 255) // - << std::setw(2) << static_cast(g * 255) // - << std::setw(2) << static_cast(b * 255) // - << std::setw(2) << static_cast(a * 255); - return stream.str(); - } - - mce::Color mce::Color::fromHexString(const std::string& hex_string) - { - Color color{}; - if (hex_string.length() != 8) { - return color; - } - - const auto value = std::strtoul(hex_string.c_str(), nullptr, 16); - color.r = static_cast((value >> 24) & 0xFF) / 255.0F; - color.g = static_cast((value >> 16) & 0xFF) / 255.0F; - color.b = static_cast((value >> 8) & 0xFF) / 255.0F; - color.a = static_cast(value & 0xFF) / 255.0F; - return color; - } -} \ No newline at end of file diff --git a/src/core/bedrock/core/math/color.hpp b/src/core/bedrock/core/math/color.hpp deleted file mode 100644 index 416884d..0000000 --- a/src/core/bedrock/core/math/color.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace bedrock { - namespace mce { - class Color { - [[nodiscard]] std::string toHexString() const; - static Color fromHexString(const std::string& hex_string); - - float r; - float g; - float b; - float a; - }; - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/core/math/vec2.hpp b/src/core/bedrock/core/math/vec2.hpp deleted file mode 100644 index 7352d83..0000000 --- a/src/core/bedrock/core/math/vec2.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -namespace bedrock { - class Vec2 { - public: - float x; - float y; - - Vec2() : x(0), y(0) {} - Vec2(float x, float y) : x(x), y(y) {} - - Vec2 operator+(const Vec2& other) const { - return Vec2(x + other.x, y + other.y); - } - - Vec2& operator+=(const Vec2& other) { - x += other.x; - y += other.y; - return *this; - } - - Vec2 operator-(const Vec2& other) const { - return Vec2(x - other.x, y - other.y); - } - - Vec2& operator-=(const Vec2& other) { - x -= other.x; - y -= other.y; - return *this; - } - - Vec2 operator*(float scalar) const { - return Vec2(x * scalar, y * scalar); - } - - Vec2& operator*=(float scalar) { - x *= scalar; - y *= scalar; - return *this; - } - - Vec2 operator/(float scalar) const { - return Vec2(x / scalar, y / scalar); - } - - Vec2& operator/=(float scalar) { - x /= scalar; - y /= scalar; - return *this; - } - - bool operator==(const Vec2& other) const { - return x == other.x && y == other.y; - } - - bool operator!=(const Vec2& other) const { - return !(*this == other); - } - - Vec2 operator-() const { - return Vec2(-x, -y); - } - }; -} diff --git a/src/core/bedrock/core/math/vec3.hpp b/src/core/bedrock/core/math/vec3.hpp deleted file mode 100644 index 38f6ced..0000000 --- a/src/core/bedrock/core/math/vec3.hpp +++ /dev/null @@ -1,69 +0,0 @@ -#pragma once - -namespace bedrock { - class Vec3 { - public: - float x; - float y; - float z; - - Vec3() : x(0), y(0), z(0) {} - Vec3(float x, float y, float z) : x(x), y(y), z(z) {} - - Vec3 operator+(const Vec3& other) const { - return Vec3(x + other.x, y + other.y, z + other.z); - } - - Vec3& operator+=(const Vec3& other) { - x += other.x; - y += other.y; - z += other.z; - return *this; - } - - Vec3 operator-(const Vec3& other) const { - return Vec3(x - other.x, y - other.y, z - other.z); - } - - Vec3& operator-=(const Vec3& other) { - x -= other.x; - y -= other.y; - z -= other.z; - return *this; - } - - Vec3 operator*(float scalar) const { - return Vec3(x * scalar, y * scalar, z * scalar); - } - - Vec3& operator*=(float scalar) { - x *= scalar; - y *= scalar; - z *= scalar; - return *this; - } - - Vec3 operator/(float scalar) const { - return Vec3(x / scalar, y / scalar, z / scalar); - } - - Vec3& operator/=(float scalar) { - x /= scalar; - y /= scalar; - z /= scalar; - return *this; - } - - bool operator==(const Vec3& other) const { - return x == other.x && y == other.y && z == other.z; - } - - bool operator!=(const Vec3& other) const { - return !(*this == other); - } - - Vec3 operator-() const { - return Vec3(-x, -y, -z); - } - }; -} diff --git a/src/core/bedrock/core/utility/enable_non_owner_references.hpp b/src/core/bedrock/core/utility/enable_non_owner_references.hpp deleted file mode 100644 index d9bda95..0000000 --- a/src/core/bedrock/core/utility/enable_non_owner_references.hpp +++ /dev/null @@ -1,82 +0,0 @@ -#pragma once - -#include -#include - -namespace bedrock { - namespace Bedrock { - class EnableNonOwnerReferences { - public: - struct ControlBlock { - bool is_valid; - }; - EnableNonOwnerReferences() - { - control_block_ = std::make_shared(); - control_block_->is_valid = true; - } - virtual ~EnableNonOwnerReferences() - { - control_block_->is_valid = false; - } - - private: - template - friend class NonOwnerPointer; - - std::shared_ptr control_block_; - }; - - template - class NonOwnerPointer { - private: - std::shared_ptr controlBlock; - - public: - NonOwnerPointer() : controlBlock(nullptr) {} - - explicit NonOwnerPointer(T* ptr) : controlBlock(ptr->controlBlock) {} - - NonOwnerPointer(const NonOwnerPointer& other) : controlBlock(other.controlBlock) {} - - NonOwnerPointer& operator=(const NonOwnerPointer& other) - { - this->controlBlock = other.controlBlock; - return *this; - } - - NonOwnerPointer& operator=(T* ptr) - { - this->controlBlock = ptr->controlBlock; - return *this; - } - - T* operator->() const - { - return static_cast(this->controlBlock.get()->ptr); - } - - T& operator*() const - { - return *this->operator->(); - } - - bool operator==(void*) const - { - return this->controlBlock == nullptr; - } - - bool operator!=(void*) const - { - return this->controlBlock != nullptr; - } - - T* get() const - { - static_assert(std::is_base_of::value, "T must derive from EnableNonOwnerReferences"); - return static_cast(this->controlBlock ? this->controlBlock->ptr : nullptr); - } - }; - - } -}; \ No newline at end of file diff --git a/src/core/bedrock/entity/components/aabb_shape_component.hpp b/src/core/bedrock/entity/components/aabb_shape_component.hpp deleted file mode 100644 index bf773f9..0000000 --- a/src/core/bedrock/entity/components/aabb_shape_component.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "../../core/math/vec2.hpp" -#include "../../world/phys/aabb.hpp" - -namespace bedrock { - struct AABBShapeComponent { - AABB aabb; - Vec2 dim; - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/entity/components/state_vector_component.hpp b/src/core/bedrock/entity/components/state_vector_component.hpp deleted file mode 100644 index aed6912..0000000 --- a/src/core/bedrock/entity/components/state_vector_component.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "../../core/math/vec3.hpp" - -namespace bedrock { - struct StateVectorComponent { - Vec3 pos; - Vec3 pos_prev; - Vec3 pos_gamdelta; - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/entity/gamerefs_entity/entity_context.hpp b/src/core/bedrock/entity/gamerefs_entity/entity_context.hpp deleted file mode 100644 index aef015f..0000000 --- a/src/core/bedrock/entity/gamerefs_entity/entity_context.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "../../gamerefs/enable_get_weak_ref.hpp" - -namespace bedrock { - class EntityContext : public EnableGetWeakRef { - - }; -} \ No newline at end of file diff --git a/src/core/bedrock/gamerefs/enable_get_weak_ref.hpp b/src/core/bedrock/gamerefs/enable_get_weak_ref.hpp deleted file mode 100644 index ef79dbf..0000000 --- a/src/core/bedrock/gamerefs/enable_get_weak_ref.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -namespace bedrock { - template - class EnableGetWeakRef {}; -} \ No newline at end of file diff --git a/src/core/bedrock/network/network_identifier.hpp b/src/core/bedrock/network/network_identifier.hpp deleted file mode 100644 index 43a5dd8..0000000 --- a/src/core/bedrock/network/network_identifier.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include -#include - -namespace bedrock { - class NetworkIdentifier { - public: - enum class Type : std::uint32_t { - RakNet = 0, - Address = 1, - Address6 = 2, - NetherNet = 3, - Invalid = 4, - }; - - std::uint64_t nether_net_id; - /* - RakNet::RakNetGUID guid; // +8 - union { // - sockaddr_storage sa_stor; // - sockaddr_in6 addr6; // - sockaddr_in addr4; // - } sock; */ - Type type; - - [[nodiscard]] std::string getAddress() const; - [[nodiscard]] std::uint16_t getPort() const; - [[nodiscard]] Type getType() const; - bool operator==(const NetworkIdentifier& other) const; - bool operator!=(const NetworkIdentifier& other) const; - [[nodiscard]] bool equalsTypeData(const NetworkIdentifier& other) const; - }; - - struct NetworkIdentifierWithSubId { - NetworkIdentifier id; - SubClientId sub_client_id; - }; -} \ No newline at end of file diff --git a/src/core/bedrock/network/packet_sender.hpp b/src/core/bedrock/network/packet_sender.hpp deleted file mode 100644 index 8a083c2..0000000 --- a/src/core/bedrock/network/packet_sender.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include -#include "../core/utility/enable_non_owner_references.hpp" - -namespace bedrock { - class PacketSender : public Bedrock::EnableNonOwnerReferences { - - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/platform/uuid.cpp b/src/core/bedrock/platform/uuid.cpp deleted file mode 100644 index c02865d..0000000 --- a/src/core/bedrock/platform/uuid.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "uuid.hpp" -#include -#include - -namespace bedrock { - namespace mce { - UUID UUID::EMPTY{}; - - std::string UUID::asString() const - { - std::ostringstream oss; - oss << std::hex << std::setfill('0'); - oss << std::setw(8) << (data[0] >> 32 & 0xFFFFFFFF); - oss << '-'; - oss << std::setw(4) << (data[0] >> 16 & 0xFFFF); - oss << '-'; - oss << std::setw(4) << (data[0] & 0xFFFF); - oss << '-'; - oss << std::setw(4) << (data[1] >> 48 & 0xFFFF); - oss << '-'; - oss << std::setw(12) << (data[1] & 0xFFFFFFFFFFFF); - return oss.str(); - } - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/platform/uuid.hpp b/src/core/bedrock/platform/uuid.hpp deleted file mode 100644 index 5cb6230..0000000 --- a/src/core/bedrock/platform/uuid.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace bedrock { - namespace mce { - class UUID { - public: - static UUID EMPTY; - UUID() = default; - [[nodiscard]] std::string asString() const; - - std::int64_t data[2]{ 0, 0 }; - }; - } -}; \ No newline at end of file diff --git a/src/core/bedrock/world/actor/actor.hpp b/src/core/bedrock/world/actor/actor.hpp deleted file mode 100644 index d07fbe2..0000000 --- a/src/core/bedrock/world/actor/actor.hpp +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -namespace bedrock { - class Actor {}; -}; \ No newline at end of file diff --git a/src/core/bedrock/world/actor/mob.hpp b/src/core/bedrock/world/actor/mob.hpp deleted file mode 100644 index 5652601..0000000 --- a/src/core/bedrock/world/actor/mob.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include "actor.hpp" - -namespace bedrock { - class Mob : public Actor {}; -}; \ No newline at end of file diff --git a/src/core/bedrock/world/actor/player/localplayer.hpp b/src/core/bedrock/world/actor/player/localplayer.hpp deleted file mode 100644 index cf19432..0000000 --- a/src/core/bedrock/world/actor/player/localplayer.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "player.hpp" - -namespace bedrock { - class LocalPlayer : public Player {}; -} \ No newline at end of file diff --git a/src/core/bedrock/world/actor/player/player.hpp b/src/core/bedrock/world/actor/player/player.hpp deleted file mode 100644 index 09a2374..0000000 --- a/src/core/bedrock/world/actor/player/player.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include "../mob.hpp" -#include "../../level/level.hpp" -#include "../../level/game_type.hpp" -#include "../../../platform/uuid.hpp" -#include "../../../network/packet_sender.hpp" -#include "../../../network/network_identifier.hpp" -#include "../../../entity/gamerefs_entity/entity_context.hpp" -#include "../../../common_types.hpp" - -#include -#include - -namespace bedrock { - class Player : public Mob { - /* - Player( - class Level&, - class PacketSender& PacketSender, - enum GameType playerGameType, - bool isHostingPlayer, - const NetworkIdentifier& owner, - class SubClientId subid, - class mce::UUID uuid, - class std::string const& playFabId, - class std::string const& deviceId, - void* const& gameServerToken, - EntityContext& entityContext, - std::string const& platformId, - std::string const& platformOnlineId - ); - */ - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/world/level/game_type.hpp b/src/core/bedrock/world/level/game_type.hpp deleted file mode 100644 index db092e6..0000000 --- a/src/core/bedrock/world/level/game_type.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -namespace bedrock { - enum class GameType { - Undefined = -1, - Survival = 0, - Creative = 1, - Adventure = 2, - Default = 5, - Spectator = 6, - WorldDefault = Survival - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/world/level/level.hpp b/src/core/bedrock/world/level/level.hpp deleted file mode 100644 index 81e1896..0000000 --- a/src/core/bedrock/world/level/level.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "level_interface.hpp" - -namespace bedrock { - class Level : public ILevel { - - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/world/level/level_interface.hpp b/src/core/bedrock/world/level/level_interface.hpp deleted file mode 100644 index 36617be..0000000 --- a/src/core/bedrock/world/level/level_interface.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "../../core/utility/enable_non_owner_references.hpp" - -namespace bedrock { - class ILevel : Bedrock::EnableNonOwnerReferences { - public: - ~ILevel() override = default; - - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/world/level/level_seed.hpp b/src/core/bedrock/world/level/level_seed.hpp deleted file mode 100644 index a452b1c..0000000 --- a/src/core/bedrock/world/level/level_seed.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -namespace bedrock { - class LevelSeed64 { - using ValueType = uint64_t; - public: - LevelSeed64(); - LevelSeed64(ValueType value) : value(value) {}; - - ValueType value{ 0 }; - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/world/level/level_settings.hpp b/src/core/bedrock/world/level/level_settings.hpp deleted file mode 100644 index 201dd52..0000000 --- a/src/core/bedrock/world/level/level_settings.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "level_seed.hpp" - -namespace bedrock { - class LevelSettings { - public: - [[nodiscard]] LevelSeed64 getSeed() const - { - return seed_; - } - - void setRandomSeed(LevelSeed64 seed) - { - seed_ = seed; - } - - private: - LevelSeed64 seed_; - }; -}; \ No newline at end of file diff --git a/src/core/bedrock/world/phys/aabb.hpp b/src/core/bedrock/world/phys/aabb.hpp deleted file mode 100644 index 85690ad..0000000 --- a/src/core/bedrock/world/phys/aabb.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "../../core/math/vec3.hpp" - -namespace bedrock { - class AABB { - Vec3 min; - Vec3 max; - }; -}; \ No newline at end of file diff --git a/src/core/types/actor.hpp b/src/core/types/actor.hpp deleted file mode 100644 index b144b33..0000000 --- a/src/core/types/actor.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "../bedrock/world/actor/actor.hpp" - -namespace selaura::core { - class actor { - public: - // setSprinting(true) can call actor->setSprinting(true) but say this were to become a component - // i can change it here without having to change every single piece a code that uses this - // making it 10 times easier to update the client. - }; -}; \ No newline at end of file diff --git a/src/hook/hook_manager.cpp b/src/hook/hook_manager.cpp new file mode 100644 index 0000000..e0c73ff --- /dev/null +++ b/src/hook/hook_manager.cpp @@ -0,0 +1,17 @@ +#include "hook_manager.hpp" +#include + +#include "impl/visual_hooks.hpp" + +namespace selaura { + hook_group::hook_group(hook_manager& mgr) {}; + + void hook_manager::init() { +#ifdef SELAURA_WINDOWS + MH_Initialize(); +#endif + + register_hookgroup(); + + } +} \ No newline at end of file diff --git a/src/hook/hook_manager.hpp b/src/hook/hook_manager.hpp new file mode 100644 index 0000000..bfea2de --- /dev/null +++ b/src/hook/hook_manager.hpp @@ -0,0 +1,69 @@ +#pragma once +#include "../sdk/symbol.hpp" +#include "../sdk/signatures.hpp" + +#ifdef SELAURA_WINDOWS +#include +#else +#include +#endif + +#include +#include + +namespace selaura { + + struct hook_group; + + struct hook_manager { + hook_manager() = default; + void init(); + + template + void register_hook(symbol_t& symbol, auto callback) { + pass_callback(symbol.resolve(), callback); + } + + template + void register_hookgroup(args_t... args) { + hookGroups.emplace_back(std::make_unique(*this, std::forward(args)...)); + } + private: + std::vector> hookGroups{}; + + template + void pass_callback(void* addr, callback_t callback, typename std::enable_if>>::type* = 0) { + return resolve_callback(addr, callback); + } + + template + void pass_callback(void* addr, callback_t callback, typename std::enable_if>>::type* = 0) { + return resolve_callback(addr, callback, &callback_t::operator()); + } + + template + void resolve_callback(void* addr, auto callback, return_t(__thiscall lambda_t::*)(void*, args_t...) const) { + static uintptr_t ofunc = 0; + static auto cb = callback; + + static auto invoker = [](args_t... args) -> return_t { + return cb(std::bit_cast(ofunc), args...); + }; + + hook(addr, static_cast(invoker), (void**)&ofunc); + } + + void hook(void* target, void* trampoline, void** out) { +#ifdef SELAURA_WINDOWS + MH_CreateHook(target, trampoline, out); + MH_EnableHook(target); +#else + DobbyHook(target, trampoline, out); +#endif + } + }; + + struct hook_group { + explicit hook_group(hook_manager& mgr); + }; +} diff --git a/src/hook/impl/visual_hooks.cpp b/src/hook/impl/visual_hooks.cpp new file mode 100644 index 0000000..9ba7dda --- /dev/null +++ b/src/hook/impl/visual_hooks.cpp @@ -0,0 +1,17 @@ +#include "visual_hooks.hpp" + +namespace selaura { + visual_hooks::visual_hooks(hook_manager& mgr) : hook_group(mgr) { + mgr.register_hook(selaura::signatures::splashtextrenderer_loadsplashes, [](void* ofunc, void* a1, void* a2, void* a3, void* a4) { + using ofunc_t = selaura::signatures::splashtextrenderer_loadsplashes_t; + std::vector* result = std::bit_cast(ofunc)(a1, a2, a3, a4); + + if (result) { + const static std::string splash_text = "\u00a76Selaura Client \u00a76on top!\u00a7r"; + *result = { splash_text }; + } + + return result; + }); + }; +} \ No newline at end of file diff --git a/src/hook/impl/visual_hooks.hpp b/src/hook/impl/visual_hooks.hpp new file mode 100644 index 0000000..4494c8d --- /dev/null +++ b/src/hook/impl/visual_hooks.hpp @@ -0,0 +1,8 @@ +#pragma once +#include "../hook_manager.hpp" + +namespace selaura { + struct visual_hooks : public hook_group { + explicit visual_hooks(hook_manager& mgr); + }; +} \ No newline at end of file diff --git a/src/client/instance.cpp b/src/instance.cpp similarity index 54% rename from src/client/instance.cpp rename to src/instance.cpp index 7969e72..6f4e3aa 100644 --- a/src/client/instance.cpp +++ b/src/instance.cpp @@ -20,15 +20,19 @@ namespace selaura { void instance::init() { auto startTime = std::chrono::high_resolution_clock::now(); - io = std::make_unique(); - io->init(); + this->get_data_folder(); + auto log_file = this->data_folder / "logs.txt"; - selaura::detail::register_memory(); - selaura::init_hooking(); - this->hook_manager->for_each([&](auto& hook) { - hook.enable(); - }); + auto logger = spdlog::basic_logger_mt("selaura", log_file.string(), true); + logger->set_pattern("[%Y-%m-%d %H:%M:%S] [%^%l%$] %v"); + logger->set_level(spdlog::level::debug); + logger->flush_on(spdlog::level::debug); + + spdlog::set_default_logger(logger); + + get().init(); + #ifdef SELAURA_WINDOWS winrt::Windows::ApplicationModel::Core::CoreApplication::MainView().CoreWindow().Dispatcher().RunAsync(winrt::Windows::UI::Core::CoreDispatcherPriority::Normal, []() { @@ -39,6 +43,10 @@ namespace selaura { auto endTime = std::chrono::high_resolution_clock::now(); std::chrono::duration duration = endTime - startTime; +<<<<<<< HEAD:src/instance.cpp + spdlog::info("Successfully injected [{:.2f}s]", duration.count()); + +======= io->info("Successfully injected [{:.2f}s]", duration.count()); // refresh more /* @@ -47,26 +55,44 @@ namespace selaura { test ev( 1 ); selaura::dispatcher::dispatch(ev); */ +>>>>>>> 73d4408c2ba458c359e5865e47276d3c2e2518ea:src/client/instance.cpp } void instance::shutdown() { auto startTime = std::chrono::high_resolution_clock::now(); - io->info("Attempting to uninject"); + spdlog::info("Attempting to uninject"); - this->hook_manager->for_each([&](auto& hook) { - hook.disable(); - }); + //this->hook_manager->for_each([&](auto& hook) { + //hook.disable(); + //}); #ifdef SELAURA_WINDOWS winrt::Windows::ApplicationModel::Core::CoreApplication::MainView().CoreWindow().Dispatcher().RunAsync(winrt::Windows::UI::Core::CoreDispatcherPriority::Normal, []() { winrt::Windows::UI::ViewManagement::ApplicationView::GetForCurrentView().Title(winrt::to_hstring("")); }); #endif - selaura::shutdown_hooking(); auto endTime = std::chrono::high_resolution_clock::now(); std::chrono::duration duration = endTime - startTime; - io->info("Successfully uninjected [{:.2f}s]", duration.count()); + spdlog::info("Successfully uninjected [{:.2f}s]", duration.count()); + } + + const std::filesystem::path& instance::get_data_folder() { +#ifdef SELAURA_WINDOWS + char* localAppData = nullptr; + size_t size = 0; + _dupenv_s(&localAppData, &size, "APPDATA"); + if (localAppData) { + this->data_folder = std::filesystem::path(localAppData + std::string("\\..\\Local\\Packages\\Microsoft.MinecraftUWP_8wekyb3d8bbwe\\RoamingState\\Selaura")); + } +#elif defined(SELAURA_LINUX) + this->data_folder = "/data/data/com.mojang.minecraftpe/Selaura"; +#elif defined(SELAURA_ANDROID) + this->data_folder = "/data/data/com.selauraclient.launcher/Selaura"; +#endif + std::filesystem::create_directories(this->data_folder); + + return this->data_folder; } }; diff --git a/src/instance.hpp b/src/instance.hpp new file mode 100644 index 0000000..9cb4a6f --- /dev/null +++ b/src/instance.hpp @@ -0,0 +1,42 @@ +#pragma once +#include +#include +#include +#include + +#include +#include +#include + +#ifdef SELAURA_WINDOWS +#include +#include +#include +#include +#endif + +#include "sdk/signatures.hpp" +#include "hook/hook_manager.hpp" + +namespace selaura { + struct instance : public std::enable_shared_from_this { + using components_t = std::tuple< + hook_manager + >; + + bool start(); + void init(); + void shutdown(); + + template + constexpr auto& get() { + return std::get(components); + } + + const std::filesystem::path& get_data_folder(); + static std::shared_ptr get(); + private: + components_t components{}; + std::filesystem::path data_folder; + }; +} \ No newline at end of file diff --git a/src/load/main.hpp b/src/load/main.hpp index 8acfcc4..f5b5d05 100644 --- a/src/load/main.hpp +++ b/src/load/main.hpp @@ -1,6 +1,6 @@ #pragma once -#include "client/instance.hpp" +#include "../instance.hpp" #include void init(); diff --git a/src/sdk/mc/ClientInstance.cpp b/src/sdk/mc/ClientInstance.cpp new file mode 100644 index 0000000..4ab2f05 --- /dev/null +++ b/src/sdk/mc/ClientInstance.cpp @@ -0,0 +1 @@ +#include "ClientInstance.hpp" \ No newline at end of file diff --git a/src/sdk/mc/ClientInstance.hpp b/src/sdk/mc/ClientInstance.hpp new file mode 100644 index 0000000..6fa5e21 --- /dev/null +++ b/src/sdk/mc/ClientInstance.hpp @@ -0,0 +1,3 @@ +#pragma once + +struct ClientInstance { }; \ No newline at end of file diff --git a/src/client/symbol/module.cpp b/src/sdk/process.cpp similarity index 80% rename from src/client/symbol/module.cpp rename to src/sdk/process.cpp index f252c54..f286c31 100644 --- a/src/client/symbol/module.cpp +++ b/src/sdk/process.cpp @@ -1,16 +1,16 @@ -#include "resolver.hpp" +#include "process.hpp" -namespace selaura::detail { - std::byte* process_module::get_module_base() { +namespace selaura { + std::byte* process::get_process_base() { return this->base; } - std::size_t process_module::get_module_size() { + std::size_t process::get_process_size() { return this->size; } - process_module get_module_handle() { + process get_process_handle() { #ifdef SELAURA_WINDOWS std::string_view name = "Minecraft.Windows.exe"; - HMODULE hModule = GetModuleHandleW(std::wstring(name.begin(), name.end()).c_str()); + HMODULE hModule = GetModuleHandleW(std::wstring(name.begin(), name.end()).c_str()); if (!hModule) { throw std::runtime_error("Failed to get module handle."); } @@ -20,7 +20,7 @@ namespace selaura::detail { throw std::runtime_error("GetModuleInformation failed."); } - return { + return { reinterpret_cast(moduleInfo.lpBaseOfDll), moduleInfo.SizeOfImage, reinterpret_cast(hModule) @@ -32,7 +32,7 @@ namespace selaura::detail { throw std::runtime_error("dlopen failed."); } - process_module detail; + process detail; detail.native = handle; dl_iterate_phdr([](dl_phdr_info* info, size_t, void* data) -> int { @@ -43,7 +43,7 @@ namespace selaura::detail { return 1; } return 0; - }, &detail); + }, &detail); return { detail.base, @@ -51,5 +51,5 @@ namespace selaura::detail { detail.native }; #endif - } + } }; \ No newline at end of file diff --git a/src/client/symbol/module.hpp b/src/sdk/process.hpp similarity index 72% rename from src/client/symbol/module.hpp rename to src/sdk/process.hpp index 2111f8d..fc287d0 100644 --- a/src/client/symbol/module.hpp +++ b/src/sdk/process.hpp @@ -21,16 +21,16 @@ #include #endif -namespace selaura::detail { - struct process_module { +namespace selaura { + struct process { std::byte* base; std::size_t size; void* native; - std::byte* get_module_base(); - std::size_t get_module_size(); + std::byte* get_process_base(); + std::size_t get_process_size(); }; - process_module get_module_handle(); -} + process get_process_handle(); +} \ No newline at end of file diff --git a/src/sdk/signatures.hpp b/src/sdk/signatures.hpp new file mode 100644 index 0000000..3d567f1 --- /dev/null +++ b/src/sdk/signatures.hpp @@ -0,0 +1,17 @@ +#pragma once +#include "symbol.hpp" +#include +#include + +namespace selaura::signatures { + + using splashtextrenderer_loadsplashes_t = std::vector* (__thiscall*)(void*, void*, void*, void*); + inline signature_symbol splashtextrenderer_loadsplashes{ + "SplashTextRenderer::_loadSplashes", + { + { selaura::platform::windows, { "48 89 5C 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 49 8B D9 49 8B F8 4C 89 44 24" } }, + { selaura::platform::android, { "FD 7B BA A9 FC 6F 01 A9 FD 03 00 91 FA 67 02 A9 F8 5F 03 A9 F6 57 04 A9 F4 4F 05 A9 FF C3 06 D1 E1 13" } } + } + }; + +} \ No newline at end of file diff --git a/src/sdk/symbol.hpp b/src/sdk/symbol.hpp new file mode 100644 index 0000000..6ec9448 --- /dev/null +++ b/src/sdk/symbol.hpp @@ -0,0 +1,103 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "process.hpp" + +#include + +namespace selaura { + + enum class platform { + windows, + android, + linux + }; + +#if defined(SELAURA_WINDOWS) + constexpr platform current_platform = platform::windows; +#elif defined(SELAURA_ANDROID) + constexpr platform current_platform = platform::android; +#elif defined(SELAURA_LINUX) + constexpr platform current_platform = platform::linux; +#else +#error Unknown platform +#endif + + inline std::optional find_pattern(std::string_view pattern) { + const auto parsed = hat::parse_signature(pattern); + if (!parsed.has_value()) { + spdlog::error("Invalid signature! {:s}", pattern); + return std::nullopt; + } + + static auto process = selaura::get_process_handle(); + + const auto begin = process.get_process_base(); + const auto end = begin + process.get_process_size(); + const auto result = hat::find_pattern(begin, end, parsed.value()); + + if (!result.has_result()) { + return std::nullopt; + } + return reinterpret_cast(result.get()); + } + + template + struct base_symbol { + virtual void* resolve() const = 0; + virtual ~base_symbol() = default; + + using type = T; + }; + + template + struct signature_symbol : base_symbol { + struct signature_info { + std::string_view pattern; + std::ptrdiff_t offset = 0; + }; + + std::string_view name; + std::unordered_map platform_signatures; + mutable void* cached = nullptr; + + signature_symbol(std::string_view nm, std::unordered_map list) + : name(nm), platform_signatures(list) { + } + + void* resolve() const override { + auto it = platform_signatures.find(current_platform); + if (it == platform_signatures.end()) { + spdlog::error("No symbol for current platform: {}", name); + return nullptr; + } + + if (!cached) { + auto base = find_pattern(it->second.pattern); + if (!base.has_value()) { + spdlog::error("Signature not valid! {}", name); + return nullptr; + } + cached = reinterpret_cast(*base + it->second.offset); + } + return cached; + } + }; + + + template + struct direct_symbol : base_symbol { + void* direct_address; + + direct_symbol(void* addr) : direct_address(addr) {} + + void* resolve() const override { + return direct_address; + } + }; +}