diff --git a/source/proxy-dll/component/arxan.cpp b/source/proxy-dll/component/arxan.cpp index efa9aac..d4aa021 100644 --- a/source/proxy-dll/component/arxan.cpp +++ b/source/proxy-dll/component/arxan.cpp @@ -1,8 +1,8 @@ #include #include "loader/component_loader.hpp" -#include -#include +#include +#include namespace arxan @@ -15,7 +15,7 @@ namespace arxan { std::vector> texts{}; - const utils::nt::library game{}; + const utilities::nt::library game{}; for (const auto& section : game.get_section_headers()) { if (section->Characteristics & IMAGE_SCN_MEM_EXECUTE) @@ -95,7 +95,7 @@ namespace arxan if (!context) { - MessageBoxA(nullptr, utils::string::va("No frame offset for: %llX", handler_address), "Error", + MessageBoxA(nullptr, utilities::string::va("No frame offset for: %llX", handler_address), "Error", MB_ICONERROR); TerminateProcess(GetCurrentProcess(), 0xBAD); return current_checksum; @@ -125,11 +125,11 @@ namespace arxan if ((next_inst & 0xFF00FFFF) != 0xFF004583) { - throw std::runtime_error(utils::string::va("Unable to patch intact basic block: %llX", game_address)); + throw std::runtime_error(utilities::string::va("Unable to patch intact basic block: %llX", game_address)); } const auto other_frame_offset = static_cast(next_inst >> 16); - static const auto stub = utils::hook::assemble([](utils::hook::assembler& a) + static const auto stub = utilities::hook::assemble([](utilities::hook::assembler& a) { a.push(rax); @@ -164,8 +164,8 @@ namespace arxan }); // push other_frame_offset - utils::hook::set(game_address, static_cast(0x6A | (other_frame_offset << 8))); - utils::hook::call(game_address + 2, stub); + utilities::hook::set(game_address, static_cast(0x6A | (other_frame_offset << 8))); + utilities::hook::call(game_address + 2, stub); } void patch_split_basic_block_integrity_check(void* address) @@ -177,11 +177,11 @@ namespace arxan if (*reinterpret_cast(next_inst_addr) != 0xE9) { - throw std::runtime_error(utils::string::va("Unable to patch split basic block: %llX", game_address)); + throw std::runtime_error(utilities::string::va("Unable to patch split basic block: %llX", game_address)); } - const auto jump_target = utils::hook::extract(reinterpret_cast(next_inst_addr + 1)); - const auto stub = utils::hook::assemble([jump_target](utils::hook::assembler& a) + const auto jump_target = utilities::hook::extract(reinterpret_cast(next_inst_addr + 1)); + const auto stub = utilities::hook::assemble([jump_target](utilities::hook::assembler& a) { a.push(rax); @@ -209,7 +209,7 @@ namespace arxan a.jmp(jump_target); }); - utils::hook::call(game_address, stub); + utilities::hook::call(game_address, stub); } void search_and_patch_integrity_checks() @@ -235,7 +235,7 @@ namespace arxan void** get_tls_callbacks() { - const utils::nt::library game{}; + const utilities::nt::library game{}; const auto& entry = game.get_optional_header()->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS]; if (!entry.VirtualAddress || !entry.Size) { @@ -254,7 +254,7 @@ namespace arxan original_first_tls_callback = *tls_callbacks; } - utils::hook::set(tls_callbacks, nullptr); + utilities::hook::set(tls_callbacks, nullptr); } void restore_tls_callbacks() @@ -262,17 +262,17 @@ namespace arxan auto* tls_callbacks = get_tls_callbacks(); if (tls_callbacks) { - utils::hook::set(tls_callbacks, original_first_tls_callback); + utilities::hook::set(tls_callbacks, original_first_tls_callback); } } - utils::hook::detour create_thread_hook; + utilities::hook::detour create_thread_hook; HANDLE WINAPI create_thread_stub(const LPSECURITY_ATTRIBUTES thread_attributes, const SIZE_T stack_size, const LPTHREAD_START_ROUTINE start_address, const LPVOID parameter, const DWORD creation_flags, const LPDWORD thread_id) { - if (utils::nt::library::get_by_address(start_address) == utils::nt::library{}) + if (utilities::nt::library::get_by_address(start_address) == utilities::nt::library{}) { restore_tls_callbacks(); @@ -285,15 +285,15 @@ namespace arxan creation_flags, thread_id); } - utils::hook::detour get_thread_context_hook; + utilities::hook::detour get_thread_context_hook; BOOL WINAPI get_thread_context_stub(const HANDLE thread_handle, const LPCONTEXT context) { constexpr auto debug_registers_flag = (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64); if (context && (context->ContextFlags & debug_registers_flag)) { auto* source = _ReturnAddress(); - const auto game = utils::nt::library{}; - const auto source_module = utils::nt::library::get_by_address(source); + const auto game = utilities::nt::library{}; + const auto source_module = utilities::nt::library::get_by_address(source); if (source_module == game) { @@ -304,7 +304,7 @@ namespace arxan return get_thread_context_hook.invoke(thread_handle, context); } - utils::hook::detour create_mutex_ex_a_hook; + utilities::hook::detour create_mutex_ex_a_hook; HANDLE create_mutex_ex_a_stub(const LPSECURITY_ATTRIBUTES attributes, const LPCSTR name, const DWORD flags, const DWORD access) { @@ -405,7 +405,7 @@ namespace arxan return res; } - utils::hook::detour nt_query_system_information_hook; + utilities::hook::detour nt_query_system_information_hook; NTSTATUS NTAPI nt_query_system_information_stub(const SYSTEM_INFORMATION_CLASS system_information_class, const PVOID system_information, const ULONG system_information_length, @@ -416,7 +416,7 @@ namespace arxan if (NT_SUCCESS(status)) { - if (system_information_class == SystemProcessInformation && !utils::nt::is_shutdown_in_progress()) + if (system_information_class == SystemProcessInformation && !utilities::nt::is_shutdown_in_progress()) { auto addr = static_cast(system_information); while (true) @@ -437,7 +437,7 @@ namespace arxan return status; } - utils::hook::detour nt_query_information_process_hook; + utilities::hook::detour nt_query_information_process_hook; NTSTATUS WINAPI nt_query_information_process_stub(const HANDLE handle, const PROCESSINFOCLASS info_class, const PVOID info, const ULONG info_length, const PULONG ret_length) @@ -465,16 +465,16 @@ namespace arxan disable_tls_callbacks(); create_thread_hook.create(CreateThread, create_thread_stub); - auto* get_thread_context_func = utils::nt::library("kernelbase.dll").get_proc("GetThreadContext"); + auto* get_thread_context_func = utilities::nt::library("kernelbase.dll").get_proc("GetThreadContext"); get_thread_context_hook.create(get_thread_context_func, get_thread_context_stub); create_mutex_ex_a_hook.create(CreateMutexExA, create_mutex_ex_a_stub); - utils::hook::copy(this->window_text_buffer_, GetWindowTextA, sizeof(this->window_text_buffer_)); - utils::hook::jump(GetWindowTextA, get_window_text_a_stub, true, true); - utils::hook::move_hook(GetWindowTextA); + utilities::hook::copy(this->window_text_buffer_, GetWindowTextA, sizeof(this->window_text_buffer_)); + utilities::hook::jump(GetWindowTextA, get_window_text_a_stub, true, true); + utilities::hook::move_hook(GetWindowTextA); - const utils::nt::library ntdll("ntdll.dll"); + const utilities::nt::library ntdll("ntdll.dll"); const auto nt_query_information_process = ntdll.get_proc("NtQueryInformationProcess"); nt_query_information_process_hook.create(nt_query_information_process, diff --git a/source/proxy-dll/component/blackbox.cpp b/source/proxy-dll/component/blackbox.cpp index 11c08f6..24104f3 100644 --- a/source/proxy-dll/component/blackbox.cpp +++ b/source/proxy-dll/component/blackbox.cpp @@ -2,11 +2,11 @@ #include "definitions/game.hpp" #include "loader/component_loader.hpp" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace blackbox @@ -64,12 +64,12 @@ namespace blackbox void display_error_dialog() { - const std::string error_str = utils::string::va("Fatal error (0x%08X) at 0x%p (0x%p).\n" + const std::string error_str = utilities::string::va("Fatal error (0x%08X) at 0x%p (0x%p).\n" "A minidump has been written.\n", exception_data.code, exception_data.address, reverse_b(reinterpret_cast(exception_data.address))); - utils::thread::suspend_other_threads(); + utilities::thread::suspend_other_threads(); show_mouse_cursor(); MessageBoxA(nullptr, error_str.data(), "Project-BO4 ERROR", MB_ICONERROR); @@ -98,7 +98,7 @@ namespace blackbox size_t get_reset_state_stub() { - static auto* stub = utils::hook::assemble([](utils::hook::assembler& a) + static auto* stub = utilities::hook::assemble([](utilities::hook::assembler& a) { a.sub(rsp, 0x10); a.or_(rsp, 0x8); @@ -165,7 +165,7 @@ namespace blackbox const auto x64register = [®isters_scroll](const char* key, DWORD64 value) { - registers_scroll.append(utils::string::va("\t%s = 0x%llX\r\n", key, value)); + registers_scroll.append(utilities::string::va("\t%s = 0x%llX\r\n", key, value)); }; x64register("rax", ctx->Rax); @@ -205,7 +205,7 @@ namespace blackbox for (size_t i = exception_start_index; i < count; i++) { - const auto from = utils::nt::library::get_by_address(backtrace_stack[i]); + const auto from = utilities::nt::library::get_by_address(backtrace_stack[i]); size_t rva = reinterpret_cast(backtrace_stack[i]) - reinterpret_cast(from.get_ptr()); if (from.get_name() == "BlackOps4.exe"s) rva += 0x140000000; @@ -219,7 +219,7 @@ namespace blackbox std::string generate_crash_info(const LPEXCEPTION_POINTERS exceptioninfo) { const auto& build_info = game::version_string; - const auto main_module = utils::nt::library{}; + const auto main_module = utilities::nt::library{}; const auto rip_address = exceptioninfo->ExceptionRecord->ExceptionAddress; std::string info{}; @@ -231,16 +231,16 @@ namespace blackbox line(build_info + " Crash Report\r\n"); - line(utils::string::va("Exception Code: 0x%08X(%s)", exceptioninfo->ExceptionRecord->ExceptionCode, + line(utilities::string::va("Exception Code: 0x%08X(%s)", exceptioninfo->ExceptionRecord->ExceptionCode, get_exception_string(exceptioninfo->ExceptionRecord->ExceptionCode))); - line(utils::string::va("Exception Addr: 0x%llX[%s]", exceptioninfo->ExceptionRecord->ExceptionAddress, - utils::nt::library::get_by_address(exceptioninfo->ExceptionRecord->ExceptionAddress).get_name().c_str())); - line(utils::string::va("Main Module: %s[0x%llX]", main_module.get_name().c_str(), main_module.get_ptr())); - line(utils::string::va("Thread ID: %d(%s)", GetCurrentThreadId(), is_game_thread() ? "Main Thread" : "Auxiliary Threads")); + line(utilities::string::va("Exception Addr: 0x%llX[%s]", exceptioninfo->ExceptionRecord->ExceptionAddress, + utilities::nt::library::get_by_address(exceptioninfo->ExceptionRecord->ExceptionAddress).get_name().c_str())); + line(utilities::string::va("Main Module: %s[0x%llX]", main_module.get_name().c_str(), main_module.get_ptr())); + line(utilities::string::va("Thread ID: %d(%s)", GetCurrentThreadId(), is_game_thread() ? "Main Thread" : "Auxiliary Threads")); if (exceptioninfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { - line(utils::string::va("\r\nExtended Info: Attempted to %s 0x%012X", + line(utilities::string::va("\r\nExtended Info: Attempted to %s 0x%012X", exceptioninfo->ExceptionRecord->ExceptionInformation[0] == 1 ? "write to" : "read from", exceptioninfo->ExceptionRecord->ExceptionInformation[1])); } @@ -256,10 +256,10 @@ namespace blackbox void write_minidump(const LPEXCEPTION_POINTERS exceptioninfo) { - const std::string crash_name = utils::string::va("minidumps/shield-crash-%s.zip", + const std::string crash_name = utilities::string::va("minidumps/shield-crash-%s.zip", get_timestamp().data()); - utils::compression::zip::archive zip_file{}; + utilities::compression::zip::archive zip_file{}; zip_file.add("crash.dmp", exception::create_minidump(exceptioninfo)); zip_file.add("info.txt", generate_crash_info(exceptioninfo)); zip_file.write(crash_name, "Project-bo4 Crash Dump"); @@ -304,11 +304,11 @@ namespace blackbox void pre_start() override { - const utils::nt::library ntdll("ntdll.dll"); + const utilities::nt::library ntdll("ntdll.dll"); auto* set_filter = ntdll.get_proc("RtlSetUnhandledExceptionFilter"); set_filter(exception_filter); - utils::hook::jump(set_filter, set_unhandled_exception_filter_stub); + utilities::hook::jump(set_filter, set_unhandled_exception_filter_stub); } }; } diff --git a/source/proxy-dll/component/debugging.cpp b/source/proxy-dll/component/debugging.cpp index 0a832bc..fcb6b1d 100644 --- a/source/proxy-dll/component/debugging.cpp +++ b/source/proxy-dll/component/debugging.cpp @@ -3,7 +3,7 @@ #include "component/scheduler.hpp" #include "loader/component_loader.hpp" -#include +#include namespace debugging { @@ -29,7 +29,7 @@ namespace debugging connectionInfoString[42] = NULL; - return utils::string::va("%s", connectionInfoString); + return utilities::string::va("%s", connectionInfoString); } void draw_debug_info() diff --git a/source/proxy-dll/component/demonware.cpp b/source/proxy-dll/component/demonware.cpp index 14349ca..0022788 100644 --- a/source/proxy-dll/component/demonware.cpp +++ b/source/proxy-dll/component/demonware.cpp @@ -1,9 +1,9 @@ #include #include "loader/component_loader.hpp" -#include -#include -#include +#include +#include +#include #include "demonware/servers/lobby_server.hpp" #include "demonware/servers/auth3_server.hpp" @@ -31,8 +31,8 @@ namespace demonware { std::atomic_bool exit_server{ false }; std::thread server_thread{}; - utils::concurrency::container> blocking_sockets{}; - utils::concurrency::container> socket_map{}; + utilities::concurrency::container> blocking_sockets{}; + utilities::concurrency::container> socket_map{}; server_registry tcp_servers{}; server_registry udp_servers{}; std::unordered_map original_imports{}; @@ -153,8 +153,8 @@ namespace demonware return getaddrinfo(name, service, hints, res); } - const auto address = utils::memory::get_allocator()->allocate(); - const auto ai = utils::memory::get_allocator()->allocate(); + const auto address = utilities::memory::get_allocator()->allocate(); + const auto ai = utilities::memory::get_allocator()->allocate(); auto in_addr = reinterpret_cast(address); in_addr->sin_addr.s_addr = server->get_address(); @@ -176,13 +176,13 @@ namespace demonware void freeaddrinfo_stub(addrinfo* ai) { - if (!utils::memory::get_allocator()->find(ai)) + if (!utilities::memory::get_allocator()->find(ai)) { return freeaddrinfo(ai); } - utils::memory::get_allocator()->free(ai->ai_addr); - utils::memory::get_allocator()->free(ai); + utilities::memory::get_allocator()->free(ai->ai_addr); + utilities::memory::get_allocator()->free(ai); } int getpeername_stub(const SOCKET s, sockaddr* addr, socklen_t* addrlen) @@ -440,11 +440,11 @@ namespace demonware void register_hook(const std::string& process, void* stub) { - const utils::nt::library game_module{}; + const utilities::nt::library game_module{}; std::optional> result{}; - if (!result) result = utils::hook::iat(game_module, "wsock32.dll", process, stub); - if (!result) result = utils::hook::iat(game_module, "WS2_32.dll", process, stub); + if (!result) result = utilities::hook::iat(game_module, "wsock32.dll", process, stub); + if (!result) result = utilities::hook::iat(game_module, "WS2_32.dll", process, stub); if (!result) { @@ -456,7 +456,7 @@ namespace demonware void check_lpc_files() { - if (!utils::io::file_exists("LPC/.manifest") || !utils::io::file_exists("LPC/core_ffotd_tu23_639_cf92ecf4a75d3f79.ff") || !utils::io::file_exists("LPC/core_playlists_tu23_639_cf92ecf4a75d3f79.ff")) + if (!utilities::io::file_exists("LPC/.manifest") || !utilities::io::file_exists("LPC/core_ffotd_tu23_639_cf92ecf4a75d3f79.ff") || !utilities::io::file_exists("LPC/core_playlists_tu23_639_cf92ecf4a75d3f79.ff")) { MessageBoxA(nullptr, "some required LPC files seems to be missing. You need to get and place them manually since this emulator doesnt host and provide those files; read instructions in github documentation for more info.", "LPC Files Missing", MB_ICONERROR); @@ -500,18 +500,18 @@ namespace demonware void post_unpack() override { - server_thread = utils::thread::create_named_thread("Demonware", server_main); + server_thread = utilities::thread::create_named_thread("Demonware", server_main); - utils::hook::set(0x144508469_g, 0x0); // CURLOPT_SSL_VERIFYPEER - utils::hook::set(0x144508455_g, 0xAF); // CURLOPT_SSL_VERIFYHOST - utils::hook::set(0x144B28D98_g, 0x0); // HTTPS -> HTTP + utilities::hook::set(0x144508469_g, 0x0); // CURLOPT_SSL_VERIFYPEER + utilities::hook::set(0x144508455_g, 0xAF); // CURLOPT_SSL_VERIFYHOST + utilities::hook::set(0x144B28D98_g, 0x0); // HTTPS -> HTTP - utils::hook::copy_string(0x144A27C70_g, "http://prod.umbrella.demonware.net"); - utils::hook::copy_string(0x144A2BAA0_g, "http://prod.uno.demonware.net/v1.0"); - utils::hook::copy_string(0x144A29CB0_g, "http://%s:%d/auth/"); + utilities::hook::copy_string(0x144A27C70_g, "http://prod.umbrella.demonware.net"); + utilities::hook::copy_string(0x144A2BAA0_g, "http://prod.uno.demonware.net/v1.0"); + utilities::hook::copy_string(0x144A29CB0_g, "http://%s:%d/auth/"); - utils::hook::set(0x142DD0E10_g, 0xC301B0); // Live_Qos_Finished - utils::hook::set(0x1438C2C70_g, 0xC301B0); // Live_Contracts? related to bdUNK125 + utilities::hook::set(0x142DD0E10_g, 0xC301B0); // Live_Qos_Finished + utilities::hook::set(0x1438C2C70_g, 0xC301B0); // Live_Contracts? related to bdUNK125 } void pre_destroy() override @@ -524,7 +524,7 @@ namespace demonware for (const auto& import : original_imports) { - utils::hook::set(import.first, import.second); + utilities::hook::set(import.first, import.second); } } }; diff --git a/source/proxy-dll/component/dvars.cpp b/source/proxy-dll/component/dvars.cpp index ecc9e44..dacbcd1 100644 --- a/source/proxy-dll/component/dvars.cpp +++ b/source/proxy-dll/component/dvars.cpp @@ -5,7 +5,7 @@ #include "definitions/variables.hpp" #include "loader/component_loader.hpp" -#include +#include namespace dvars { @@ -25,22 +25,22 @@ namespace dvars { if (domain.vector.max == FLT_MAX) { - return utils::string::va("Domain is any %iD vector", components); + return utilities::string::va("Domain is any %iD vector", components); } else { - return utils::string::va("Domain is any %iD vector with components %g or smaller", components, + return utilities::string::va("Domain is any %iD vector with components %g or smaller", components, domain.vector.max); } } else if (domain.vector.max == FLT_MAX) { - return utils::string::va("Domain is any %iD vector with components %g or bigger", components, + return utilities::string::va("Domain is any %iD vector with components %g or bigger", components, domain.vector.min); } else { - return utils::string::va("Domain is any %iD vector with components from %g to %g", components, + return utilities::string::va("Domain is any %iD vector with components from %g to %g", components, domain.vector.min, domain.vector.max); } } @@ -64,16 +64,16 @@ namespace dvars } else { - return utils::string::va("Domain is any number %g or smaller", domain.value.max); + return utilities::string::va("Domain is any number %g or smaller", domain.value.max); } } else if (domain.value.max == FLT_MAX) { - return utils::string::va("Domain is any number %g or bigger", domain.value.min); + return utilities::string::va("Domain is any number %g or bigger", domain.value.min); } else { - return utils::string::va("Domain is any number from %g to %g", domain.value.min, domain.value.max); + return utilities::string::va("Domain is any number from %g to %g", domain.value.min, domain.value.max); } case game::DVAR_TYPE_FLOAT_2: @@ -97,16 +97,16 @@ namespace dvars } else { - return utils::string::va("Domain is any integer %i or smaller", domain.integer.max); + return utilities::string::va("Domain is any integer %i or smaller", domain.integer.max); } } else if (domain.integer.max == INT_MAX) { - return utils::string::va("Domain is any integer %i or bigger", domain.integer.min); + return utilities::string::va("Domain is any integer %i or bigger", domain.integer.min); } else { - return utils::string::va("Domain is any integer from %i to %i", domain.integer.min, domain.integer.max); + return utilities::string::va("Domain is any integer from %i to %i", domain.integer.min, domain.integer.max); } case game::DVAR_TYPE_ENUM: @@ -114,7 +114,7 @@ namespace dvars for (auto string_index = 0; string_index < domain.enumeration.stringCount; ++string_index) { - str += utils::string::va("\n %2i: %s", string_index, domain.enumeration.strings[string_index]); + str += utilities::string::va("\n %2i: %s", string_index, domain.enumeration.strings[string_index]); } return str; @@ -134,16 +134,16 @@ namespace dvars } else { - return utils::string::va("Domain is any integer %lli or smaller", domain.integer64.max); + return utilities::string::va("Domain is any integer %lli or smaller", domain.integer64.max); } } else if (domain.integer64.max == _I64_MAX) { - return utils::string::va("Domain is any integer %lli or bigger", domain.integer64.min); + return utilities::string::va("Domain is any integer %lli or bigger", domain.integer64.min); } else { - return utils::string::va("Domain is any integer from %lli to %lli", domain.integer64.min, domain.integer64.max); + return utilities::string::va("Domain is any integer from %lli to %lli", domain.integer64.min, domain.integer64.max); } case game::DVAR_TYPE_UINT64: @@ -151,12 +151,12 @@ namespace dvars { if (domain.unsignedInt64.max == _UI64_MAX) { - return utils::string::va("Domain is any unsigned integer %zu or bigger", domain.unsignedInt64.min); + return utilities::string::va("Domain is any unsigned integer %zu or bigger", domain.unsignedInt64.min); } else { - return utils::string::va("Domain is any unsigned integer from %zu to %zu", domain.unsignedInt64.min, domain.unsignedInt64.max); + return utilities::string::va("Domain is any unsigned integer from %zu to %zu", domain.unsignedInt64.min, domain.unsignedInt64.max); } } else if (domain.unsignedInt64.max == _UI64_MAX) @@ -165,11 +165,11 @@ namespace dvars } else { - return utils::string::va("Domain is any integer %zu or smaller", domain.unsignedInt64.max); + return utilities::string::va("Domain is any integer %zu or smaller", domain.unsignedInt64.max); } default: - return utils::string::va("unhandled dvar type '%i'", type); + return utilities::string::va("unhandled dvar type '%i'", type); } } @@ -265,7 +265,7 @@ namespace dvars game::dvar_t* find_dvar(const std::string& nameRef) { - auto it = std::find_if(variables::dvars_record.begin(), variables::dvars_record.end(), [&nameRef](variables::varEntry& i) { return utils::string::compare(i.name, nameRef); }); + auto it = std::find_if(variables::dvars_record.begin(), variables::dvars_record.end(), [&nameRef](variables::varEntry& i) { return utilities::string::compare(i.name, nameRef); }); if (it != variables::dvars_record.end() && it->pointer) { diff --git a/source/proxy-dll/component/game_console.cpp b/source/proxy-dll/component/game_console.cpp index 453b71d..e3c10e8 100644 --- a/source/proxy-dll/component/game_console.cpp +++ b/source/proxy-dll/component/game_console.cpp @@ -7,9 +7,9 @@ #include "component/dvars.hpp" #include "component/scheduler.hpp" -#include -#include -#include +#include +#include +#include #define R_DrawTextFont reinterpret_cast(game::sharedUiInfo->assets.bigFont) #define R_WhiteMaterial reinterpret_cast(game::sharedUiInfo->assets.whiteMaterial) @@ -53,7 +53,7 @@ namespace game_console bool output_visible{}; int display_line_offset{}; int total_line_count{}; - utils::concurrency::container output{}; + utilities::concurrency::container output{}; }; ingame_console con{}; @@ -186,7 +186,7 @@ namespace game_console for (const auto& dvar : variables::dvars_record) { - if (dvars::find_dvar(dvar.fnv1a) && utils::string::match(input, dvar.name) >= required_ratio) + if (dvars::find_dvar(dvar.fnv1a) && utilities::string::match(input, dvar.name) >= required_ratio) { suggestions.push_back(dvar); } @@ -204,7 +204,7 @@ namespace game_console for (const auto& cmd : variables::commands_record) { - if (utils::string::match(input, cmd.name) >= required_ratio) + if (utilities::string::match(input, cmd.name) >= required_ratio) { suggestions.push_back(cmd); } @@ -252,7 +252,7 @@ namespace game_console if (matches.size() <= con.max_suggestions) { std::sort(matches.begin(), matches.end(), [&input](suggestion_t& lhs, suggestion_t& rhs) { - return utils::string::match(input, lhs.name) > utils::string::match(input, rhs.name); + return utilities::string::match(input, lhs.name) > utilities::string::match(input, rhs.name); }); } @@ -266,7 +266,7 @@ namespace game_console if (matches.size() > con.max_suggestions) { draw_hint_box(1, con_inputHintBoxColor); - draw_hint_text(0, utils::string::va("%i matches (too many to show here)", matches.size()), con_inputDvarMatchColor); + draw_hint_text(0, utilities::string::va("%i matches (too many to show here)", matches.size()), con_inputDvarMatchColor); } else if (matches.size() == 1) { @@ -414,7 +414,7 @@ namespace game_console va_end(ap); const auto formatted = std::string(va_buffer); - const auto lines = utils::string::split(formatted, '\n'); + const auto lines = utilities::string::split(formatted, '\n'); for (const auto& line : lines) { @@ -424,7 +424,7 @@ namespace game_console void print(const std::string& data) { - const auto lines = utils::string::split(data, '\n'); + const auto lines = utilities::string::split(data, '\n'); for (const auto& line : lines) { print_internal(line); @@ -476,7 +476,7 @@ namespace game_console if (key == 'v' - 'a' + 1) // paste { - const auto clipboard = utils::string::get_clipboard_data(); + const auto clipboard = utilities::string::get_clipboard_data(); if (clipboard.empty()) { return false; @@ -646,7 +646,7 @@ namespace game_console if (key == game::keyNum_t::K_ENTER) { - //game::Cbuf_AddText(0, utils::string::va("%s \n", fixed_input.data())); + //game::Cbuf_AddText(0, utilities::string::va("%s \n", fixed_input.data())); if (history_index != -1) { @@ -661,7 +661,7 @@ namespace game_console history.push_front(con.buffer); print("]%s\n", con.buffer); - game::Cbuf_AddText(0, utils::string::va("%s \n", fixed_input.data())); + game::Cbuf_AddText(0, utilities::string::va("%s \n", fixed_input.data())); if (history.size() > 10) { @@ -678,7 +678,7 @@ namespace game_console return true; } - utils::hook::detour cl_key_event_hook; + utilities::hook::detour cl_key_event_hook; void cl_key_event_stub(int localClientNum, int key, bool down, unsigned int time) { if (!game_console::console_key_event(localClientNum, key, down)) @@ -689,7 +689,7 @@ namespace game_console cl_key_event_hook.invoke(localClientNum, key, down, time); } - utils::hook::detour cl_char_event_hook; + utilities::hook::detour cl_char_event_hook; void cl_char_event_stub(const int localClientNum, const int key, bool isRepeated) { if (!game_console::console_char_event(localClientNum, key)) diff --git a/source/proxy-dll/component/logger.cpp b/source/proxy-dll/component/logger.cpp index 57ff36d..67822bf 100644 --- a/source/proxy-dll/component/logger.cpp +++ b/source/proxy-dll/component/logger.cpp @@ -3,7 +3,7 @@ #include "game_console.hpp" #include "loader/component_loader.hpp" -#include +#include #define OUTPUT_DEBUG_API #define OUTPUT_GAME_CONSOLE @@ -64,11 +64,11 @@ namespace logger void pre_start() override { #ifdef REMOVE_PREVIOUS_LOG - utils::io::remove_file("project-bo4.log"); + utilities::io::remove_file("project-bo4.log"); #endif // REMOVE_PREVIOUS_LOG write(LOG_TYPE_INFO, "======================================================================================================="); - write(LOG_TYPE_INFO, " Project-BO4 Initializing ... %s[0x%llX]", utils::nt::library{}.get_name().c_str(), utils::nt::library{}.get_ptr()); + write(LOG_TYPE_INFO, " Project-BO4 Initializing ... %s[0x%llX]", utilities::nt::library{}.get_name().c_str(), utilities::nt::library{}.get_ptr()); write(LOG_TYPE_INFO, "======================================================================================================="); } diff --git a/source/proxy-dll/component/platform.cpp b/source/proxy-dll/component/platform.cpp index 731cf32..1b8c4c1 100644 --- a/source/proxy-dll/component/platform.cpp +++ b/source/proxy-dll/component/platform.cpp @@ -3,11 +3,11 @@ #include "definitions/game.hpp" #include "loader/component_loader.hpp" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace platform @@ -17,8 +17,8 @@ namespace platform static uint64_t userid = 0; if (!userid) { - uint32_t default_xuid = utils::cryptography::xxh32::compute(utils::identity::get_sys_username()); - userid = utils::json_config::ReadUnsignedInteger64("identity", "xuid", default_xuid); + uint32_t default_xuid = utilities::cryptography::xxh32::compute(utilities::identity::get_sys_username()); + userid = utilities::json_config::ReadUnsignedInteger64("identity", "xuid", default_xuid); } return userid; @@ -29,8 +29,8 @@ namespace platform static std::string username{}; if (username.empty()) { - std::string default_name = utils::identity::get_sys_username(); - username = utils::json_config::ReadString("identity", "name", default_name); + std::string default_name = utilities::identity::get_sys_username(); + username = utilities::json_config::ReadString("identity", "name", default_name); } return username.data(); @@ -43,7 +43,7 @@ namespace platform namespace { - utils::hook::detour PC_TextChat_Print_Hook; + utilities::hook::detour PC_TextChat_Print_Hook; void PC_TextChat_Print_Stub(const char* text) { #ifdef DEBUG @@ -76,22 +76,22 @@ namespace platform void post_unpack() override { - utils::hook::set(0x1423271D0_g, 0x01B0); // BattleNet_IsDisabled (patch to mov al,1) - utils::hook::set(0x1423271E0_g, 0x90C301B0); // BattleNet_IsConnected (patch to mov al,1 retn) + utilities::hook::set(0x1423271D0_g, 0x01B0); // BattleNet_IsDisabled (patch to mov al,1) + utilities::hook::set(0x1423271E0_g, 0x90C301B0); // BattleNet_IsConnected (patch to mov al,1 retn) - utils::hook::set(0x142325210_g, 0xC3); // patch#1 Annoying function crashing game; related to BattleNet (TODO : Needs Further Investigation) - utils::hook::set(0x142307B40_g, 0xC3); // patch#2 Annoying function crashing game; related to BattleNet (TODO : Needs Further Investigation) - utils::hook::set(0x143D08290_g, 0x90C301B0); // patch#3 BattleNet_IsModeAvailable? (patch to mov al,1 retn) + utilities::hook::set(0x142325210_g, 0xC3); // patch#1 Annoying function crashing game; related to BattleNet (TODO : Needs Further Investigation) + utilities::hook::set(0x142307B40_g, 0xC3); // patch#2 Annoying function crashing game; related to BattleNet (TODO : Needs Further Investigation) + utilities::hook::set(0x143D08290_g, 0x90C301B0); // patch#3 BattleNet_IsModeAvailable? (patch to mov al,1 retn) - utils::hook::nop(0x1437DA454_g, 13); // begin cross-auth even without platform being initialized [LiveConnect_BeginCrossAuthPlatform] - utils::hook::set(0x1444D2D60_g, 0xC301B0); // Auth3 Response RSA signature check [bdAuth::validateResponseSignature] - utils::hook::set(0x1444E34C0_g, 0xC301B0); // Auth3 Response platform extended data check [bdAuthPC::processPlatformData] + utilities::hook::nop(0x1437DA454_g, 13); // begin cross-auth even without platform being initialized [LiveConnect_BeginCrossAuthPlatform] + utilities::hook::set(0x1444D2D60_g, 0xC301B0); // Auth3 Response RSA signature check [bdAuth::validateResponseSignature] + utilities::hook::set(0x1444E34C0_g, 0xC301B0); // Auth3 Response platform extended data check [bdAuthPC::processPlatformData] - utils::hook::nop(0x1438994E9_g, 22); // get live name even without platform being initialized [Live_UserSignedIn] - utils::hook::nop(0x1438C3476_g, 22); // get live xuid even without platform being initialized [LiveUser_UserGetXuid] + utilities::hook::nop(0x1438994E9_g, 22); // get live name even without platform being initialized [Live_UserSignedIn] + utilities::hook::nop(0x1438C3476_g, 22); // get live xuid even without platform being initialized [LiveUser_UserGetXuid] - utils::hook::jump(0x142325C70_g, bnet_get_username); // detour battlenet username - utils::hook::jump(0x142325CA0_g, bnet_get_userid); // detour battlenet userid + utilities::hook::jump(0x142325C70_g, bnet_get_username); // detour battlenet username + utilities::hook::jump(0x142325CA0_g, bnet_get_userid); // detour battlenet userid //PC_TextChat_Print_Hook.create(0x1422D4A20_g, PC_TextChat_Print_Stub); // Disable useless system messages passed into chat box diff --git a/source/proxy-dll/component/scheduler.cpp b/source/proxy-dll/component/scheduler.cpp index 407506e..445aca8 100644 --- a/source/proxy-dll/component/scheduler.cpp +++ b/source/proxy-dll/component/scheduler.cpp @@ -3,9 +3,9 @@ #include "loader/component_loader.hpp" #include -#include -#include -#include +#include +#include +#include namespace scheduler { @@ -64,8 +64,8 @@ namespace scheduler } private: - utils::concurrency::container new_callbacks_; - utils::concurrency::container callbacks_; + utilities::concurrency::container new_callbacks_; + utilities::concurrency::container callbacks_; void merge_callbacks() { @@ -85,9 +85,9 @@ namespace scheduler std::thread thread; task_pipeline pipelines[pipeline::count]; - utils::hook::detour r_end_frame_hook; - utils::hook::detour g_run_frame_hook; - utils::hook::detour main_frame_hook; + utilities::hook::detour r_end_frame_hook; + utilities::hook::detour g_run_frame_hook; + utilities::hook::detour main_frame_hook; void execute(const pipeline type) { @@ -152,7 +152,7 @@ namespace scheduler public: void pre_start() override { - thread = utils::thread::create_named_thread("Async Scheduler", []() + thread = utilities::thread::create_named_thread("Async Scheduler", []() { while (!kill) { diff --git a/source/proxy-dll/component/splash.cpp b/source/proxy-dll/component/splash.cpp index 3cd99ec..4ae1999 100644 --- a/source/proxy-dll/component/splash.cpp +++ b/source/proxy-dll/component/splash.cpp @@ -4,30 +4,30 @@ #include "resource.hpp" -#include -#include +#include +#include namespace splash { namespace { HWND window{}; - utils::image::object image{}; + utilities::image::object image{}; std::thread window_thread{}; - utils::image::object load_splash_image() + utilities::image::object load_splash_image() { - //const auto self = utils::nt::library::get_by_address(load_splash_image); + //const auto self = utilities::nt::library::get_by_address(load_splash_image); //return LoadImageA(self, MAKEINTRESOURCE(IMAGE_SPLASH), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); - const auto res = utils::nt::load_resource(IMAGE_SPLASH); - const auto img = utils::image::load_image(res); - return utils::image::create_bitmap(img); + const auto res = utilities::nt::load_resource(IMAGE_SPLASH); + const auto img = utilities::image::load_image(res); + return utilities::image::create_bitmap(img); } void enable_dpi_awareness() { - const utils::nt::library user32{ "user32.dll" }; + const utilities::nt::library user32{ "user32.dll" }; const auto set_dpi = user32 ? user32.get_proc( "SetProcessDpiAwarenessContext") @@ -63,7 +63,7 @@ namespace splash { WNDCLASSA wnd_class; - const auto self = utils::nt::library::get_by_address(load_splash_image); + const auto self = utilities::nt::library::get_by_address(load_splash_image); wnd_class.style = CS_DROPSHADOW; wnd_class.cbClsExtra = 0; @@ -161,7 +161,7 @@ namespace splash } window = nullptr; - UnregisterClassA("Black Ops 4 Splash Screen", utils::nt::library{}); + UnregisterClassA("Black Ops 4 Splash Screen", utilities::nt::library{}); } } diff --git a/source/proxy-dll/component/unlockall.cpp b/source/proxy-dll/component/unlockall.cpp index 7012949..2ded32d 100644 --- a/source/proxy-dll/component/unlockall.cpp +++ b/source/proxy-dll/component/unlockall.cpp @@ -1,7 +1,7 @@ #include #include "loader/component_loader.hpp" -#include +#include namespace unlockall { @@ -103,7 +103,7 @@ namespace unlockall public: void post_unpack() override { - utils::hook::jump(0x1437F6ED0_g, liveinventory_getitemquantity); + utilities::hook::jump(0x1437F6ED0_g, liveinventory_getitemquantity); } }; } diff --git a/source/proxy-dll/definitions/discovery.cpp b/source/proxy-dll/definitions/discovery.cpp index 893205c..4b13267 100644 --- a/source/proxy-dll/definitions/discovery.cpp +++ b/source/proxy-dll/definitions/discovery.cpp @@ -2,8 +2,8 @@ #include "discovery.hpp" #include "loader/component_loader.hpp" -#include -#include +#include +#include std::unordered_map symbols_list; @@ -98,7 +98,7 @@ namespace discovery continue; } - utils::hook::signature::signature_result scan = utils::hook::signature(std::string(i.sig, strlen(i.sig))).process(); + utilities::hook::signature::signature_result scan = utilities::hook::signature(std::string(i.sig, strlen(i.sig))).process(); if (scan.size() == 0 || scan.size() > 1) { @@ -126,7 +126,7 @@ namespace discovery if (symbols_list.find("com_get_build_version") != symbols_list.end()) { - const char* build_version = utils::hook::invoke(symbols_list["com_get_build_version"]); + const char* build_version = utilities::hook::invoke(symbols_list["com_get_build_version"]); logger::write(logger::LOG_TYPE_DEBUG, "Address-List Discovery Results for BlackOps4 %s", build_version); } diff --git a/source/proxy-dll/demonware/byte_buffer.cpp b/source/proxy-dll/demonware/byte_buffer.cpp index ee1dbee..e926cc1 100644 --- a/source/proxy-dll/demonware/byte_buffer.cpp +++ b/source/proxy-dll/demonware/byte_buffer.cpp @@ -169,24 +169,28 @@ namespace demonware return type == expected; } - bool byte_buffer::read_array_header(const unsigned char expected, unsigned int* element_count, - unsigned int* element_size) + bool byte_buffer::read_array_header(const unsigned char expected + , unsigned int* element_count, unsigned int* element_size) { if (element_count) *element_count = 0; if (element_size) *element_size = 0; + const auto using_types = this->is_using_data_types(); + this->set_use_data_types(true); + if (!this->read_data_type(expected + 100)) return false; - uint32_t array_size, el_count; + uint32_t array_size, num_elements; if (!this->read_uint32(&array_size)) return false; this->set_use_data_types(false); - this->read_uint32(&el_count); + if (!this->read_uint32(&num_elements)) return false; this->set_use_data_types(true); - if (element_count) *element_count = el_count; - if (element_size) *element_size = array_size / el_count; + if (element_count) *element_count = num_elements; + if (element_size) *element_size = array_size / num_elements; + this->set_use_data_types(using_types); return true; } @@ -293,8 +297,8 @@ namespace demonware return this->write(length, data); } - bool byte_buffer::write_array_header(const unsigned char type, const unsigned int element_count, - const unsigned int element_size) + bool byte_buffer::write_array_header(const unsigned char type, + const unsigned int element_count, const unsigned int element_size) { const auto using_types = this->is_using_data_types(); this->set_use_data_types(false); diff --git a/source/proxy-dll/demonware/byte_buffer.hpp b/source/proxy-dll/demonware/byte_buffer.hpp index 17299af..50c4e22 100644 --- a/source/proxy-dll/demonware/byte_buffer.hpp +++ b/source/proxy-dll/demonware/byte_buffer.hpp @@ -30,8 +30,59 @@ namespace demonware bool read_struct(std::string* output); bool read_data_type(char expected); - bool read_array_header(unsigned char expected, unsigned int* element_count, - unsigned int* element_size = nullptr); + bool read_array_header(const unsigned char expected + , unsigned int* element_count, unsigned int* element_size); + + template + bool read_array(const unsigned char expected, std::vector* vec) + { + const auto using_types = this->is_using_data_types(); + this->set_use_data_types(false); + + uint32_t ItemCount, itemSize; + + if (!this->read_array_header(expected, &ItemCount, &itemSize)) return false; + if (itemSize != sizeof(T)) return false; + + for (size_t i = 0; i < ItemCount; i++) + { + T item{}; + + if (!this->read(sizeof(T), &item)) return false; + + vec->push_back(item); + } + + this->set_use_data_types(using_types); + return true; + } + + template + bool read_array(const unsigned char expected, std::map* map) + { + const auto using_types = this->is_using_data_types(); + this->set_use_data_types(false); + + uint32_t ItemCount, itemSize; + + if (!this->read_array_header(expected, &ItemCount, &itemSize)) return false; + if (itemSize != sizeof(T)) return false; + + for (size_t i = 0; i < ItemCount / 2; i++) + { + T key{}, value{}; + + if (!this->read(sizeof(T), &key) + || !this->read(sizeof(T), &value) + ) return false; + + map->insert({ key, value }); + } + + this->set_use_data_types(using_types); + return true; + } + bool write_bool(bool data); bool write_byte(char data); @@ -51,7 +102,44 @@ namespace demonware bool write_struct(const char* data, int length); bool write_struct(const std::string& data); - bool write_array_header(unsigned char type, unsigned int element_count, unsigned int element_size); + bool write_array_header(const unsigned char type, + const unsigned int element_count, const unsigned int element_size); + + template + bool write_array(const unsigned char type, const std::vector& vec) + { + const auto using_types = this->is_using_data_types(); + this->set_use_data_types(false); + + auto result = write_array_header(type, vec.size(), sizeof(T)); + + for (size_t i = 0; i < vec.size(); i++) + { + result &= this->write(sizeof(T), &vec[i]); + } + + this->set_use_data_types(using_types); + return result; + } + + template + bool write_array(const unsigned char type, const std::map& map) + { + const auto using_types = this->is_using_data_types(); + this->set_use_data_types(false); + + auto result = write_array_header(type, map.size() * 2, sizeof(T)); + + for (const auto& item : map) + { + result &= this->write(sizeof(T), &item.first); + result &= this->write(sizeof(T), &item.second); + } + + this->set_use_data_types(using_types); + return result; + } + bool read(int bytes, void* output); bool write(int bytes, const void* data); diff --git a/source/proxy-dll/demonware/data_types.hpp b/source/proxy-dll/demonware/data_types.hpp index 2e19229..7cfbaad 100644 --- a/source/proxy-dll/demonware/data_types.hpp +++ b/source/proxy-dll/demonware/data_types.hpp @@ -18,10 +18,58 @@ namespace demonware } }; + class bdStringResult final : public bdTaskResult + { + public: + std::string content = ""; + + void serialize(byte_buffer* buffer) override + { + buffer->write_string(this->content); + } + + void deserialize(byte_buffer* buffer) override + { + buffer->read_string(&this->content); + } + }; + + class bdUInt64Result final : public bdTaskResult + { + public: + uint64_t value = 0; + + void serialize(byte_buffer* buffer) override + { + buffer->write_uint64(this->value); + } + + void deserialize(byte_buffer* buffer) override + { + buffer->read_uint64(&this->value); + } + }; + + class bdBoolResult final : public bdTaskResult + { + public: + bool value = false; + + void serialize(byte_buffer* buffer) override + { + buffer->write_bool(this->value); + } + + void deserialize(byte_buffer* buffer) override + { + buffer->read_bool(&this->value); + } + }; + class bdTimeStamp final : public bdTaskResult { public: - uint32_t unix_time; + uint32_t unix_time = 0; void serialize(byte_buffer* buffer) override { @@ -37,14 +85,14 @@ namespace demonware class bdDMLInfo : public bdTaskResult { public: - std::string country_code; // Char [3] - std::string country; // Char [65] - std::string region; // Char [65] - std::string city; // Char [129] - float latitude; - float longitude; - uint32_t asn; // Autonomous System Number. - std::string timezone; + std::string country_code = ""; // Char [3] + std::string country = ""; // Char [65] + std::string region = ""; // Char [65] + std::string city = ""; // Char [129] + float latitude = 0.0f; + float longitude = 0; + uint32_t asn = 0; // Autonomous System Number. + std::string timezone = ""; void serialize(byte_buffer* buffer) override { @@ -74,11 +122,11 @@ namespace demonware class bdDMLHierarchicalInfo final : public bdDMLInfo { public: - uint32_t m_tier0; - uint32_t m_tier1; - uint32_t m_tier2; - uint32_t m_tier3; - uint32_t m_confidence; + uint32_t m_tier0 = 0; + uint32_t m_tier1 = 0; + uint32_t m_tier2 = 0; + uint32_t m_tier3 = 0; + uint32_t m_confidence = 0; void serialize(byte_buffer* buffer) override { @@ -103,74 +151,12 @@ namespace demonware } }; - class bdStructedDataBuffer final : public bdTaskResult - { - public: - std::string structed_data_protobuffer; - - void serialize(byte_buffer* buffer) override - { - buffer->write_struct(this->structed_data_protobuffer); - } - - void deserialize(byte_buffer* buffer) override - { - buffer->read_struct(&this->structed_data_protobuffer); - } - }; - - class bdMarketplaceInventory final : public bdTaskResult - { - public: - uint64_t m_userID; - std::string m_accountType; - uint32_t m_itemId; - uint32_t m_itemQuantity; - uint32_t m_itemXp; - std::string m_itemData; - uint32_t m_expireDateTime; - int64_t m_expiryDuration; - uint16_t m_collisionField; - uint32_t m_modDateTime; - uint32_t m_customSourceType; - - void serialize(byte_buffer* buffer) override - { - buffer->write_uint64(this->m_userID); - buffer->write_string(this->m_accountType); - buffer->write_uint32(this->m_itemId); - buffer->write_uint32(this->m_itemQuantity); - buffer->write_uint32(this->m_itemXp); - buffer->write_blob(this->m_itemData); - buffer->write_uint32(this->m_expireDateTime); - buffer->write_int64(this->m_expiryDuration); - buffer->write_uint16(this->m_collisionField); - buffer->write_uint32(this->m_modDateTime); - buffer->write_uint32(this->m_customSourceType); - } - - void deserialize(byte_buffer* buffer) override - { - buffer->read_uint64(&this->m_userID); - buffer->read_string(&this->m_accountType); - buffer->read_uint32(&this->m_itemId); - buffer->read_uint32(&this->m_itemQuantity); - buffer->read_uint32(&this->m_itemXp); - buffer->read_blob(&this->m_itemData); - buffer->read_uint32(&this->m_expireDateTime); - buffer->read_int64(&this->m_expiryDuration); - buffer->read_uint16(&this->m_collisionField); - buffer->read_uint32(&this->m_modDateTime); - buffer->read_uint32(&this->m_customSourceType); - } - }; - class bdPublicProfileInfo final : public bdTaskResult { public: - uint64_t m_entityID; - int32_t m_VERSION; - std::string m_ddl; + uint64_t m_entityID = 0; + int32_t m_VERSION = 0; + std::string m_ddl = ""; void serialize(byte_buffer* buffer) override { @@ -186,4 +172,84 @@ namespace demonware buffer->read_blob(&this->m_ddl); } }; + + class bdFileMetaData final : public bdTaskResult + { + public: + uint64_t m_fileID = 0; + uint32_t m_createTime = 0; + uint32_t m_modifedTime = 0; + uint32_t m_fileSize = 0; + uint64_t m_ownerID = 0; + std::string m_ownerName = ""; + uint16_t m_fileSlot = 0; + std::string m_fileName = ""; + std::string m_url = ""; + uint16_t m_category = 0; + std::string m_metaData = ""; + uint32_t m_summaryFileSize = 0; + std::map m_tags; + uint32_t m_numCopiesMade = 0; + uint64_t m_originID = 0; + + void serialize(byte_buffer* buffer) override + { + buffer->write_uint64(this->m_fileID); + buffer->write_uint32(this->m_createTime); + buffer->write_uint32(this->m_modifedTime); + buffer->write_uint32(this->m_fileSize); + buffer->write_uint64(this->m_ownerID); + buffer->write_string(this->m_ownerName); + buffer->write_uint16(this->m_fileSlot); + buffer->write_string(this->m_fileName); + buffer->write_string(this->m_url); + buffer->write_uint16(this->m_category); + buffer->write_blob(this->m_metaData); + buffer->write_uint32(this->m_summaryFileSize); + buffer->write_array(10, m_tags); + buffer->write_uint32(this->m_numCopiesMade); + buffer->write_uint64(this->m_originID); + } + }; + + class bdURL final : public bdTaskResult + { + public: + std::string m_url = ""; + uint16_t m_serverType = 0; + std::string m_serverIndex = ""; + uint64_t m_fileID = 0; + + void serialize(byte_buffer* buffer) override + { + buffer->write_string(this->m_url); + buffer->write_uint16(this->m_serverType); + buffer->write_string(this->m_serverIndex); + buffer->write_uint64(this->m_fileID); + } + + void deserialize(byte_buffer* buffer) override + { + buffer->read_string(&this->m_url); + buffer->read_uint16(&this->m_serverType); + buffer->read_string(&this->m_serverIndex); + buffer->read_uint64(&this->m_fileID); + } + }; + + class bdStructedDataBuffer final : public bdTaskResult + { + public: + std::string structed_data_protobuffer = ""; + + void serialize(byte_buffer* buffer) override + { + buffer->write_struct(this->structed_data_protobuffer); + } + + void deserialize(byte_buffer* buffer) override + { + buffer->read_struct(&this->structed_data_protobuffer); + } + }; } diff --git a/source/proxy-dll/demonware/keys.cpp b/source/proxy-dll/demonware/keys.cpp index 3f420c4..b279425 100644 --- a/source/proxy-dll/demonware/keys.cpp +++ b/source/proxy-dll/demonware/keys.cpp @@ -1,12 +1,12 @@ #include #include "keys.hpp" -#include -#include -#include +#include +#include +#include #include "resource.hpp" -#include +#include namespace demonware @@ -41,7 +41,7 @@ namespace demonware pos++; // calculate hmac - result = utils::cryptography::hmac_sha1::compute(std::string(buffer, pos), std::string(dataxx, data_size)); + result = utilities::cryptography::hmac_sha1::compute(std::string(buffer, pos), std::string(dataxx, data_size)); // save output std::memcpy(dest, result.data(), std::min(20u, (dest_size - out_offset))); @@ -69,7 +69,7 @@ namespace demonware pos++; // calculate hmac - result = utils::cryptography::hmac_sha1::compute(std::string(buffer, pos), std::string(dataxx, data_size)); + result = utilities::cryptography::hmac_sha1::compute(std::string(buffer, pos), std::string(dataxx, data_size)); // save output std::memcpy(dest + out_offset, result.data(), std::min(20u, (dest_size - out_offset))); @@ -79,14 +79,14 @@ namespace demonware void derive_keys_iw8() { - std::string BD_AUTH_TRAFFIC_SIGNING_KEY = utils::nt::load_resource(DW_AUTH_TRAFFIC_SIGNING_KEY); + std::string BD_AUTH_TRAFFIC_SIGNING_KEY = utilities::nt::load_resource(DW_AUTH_TRAFFIC_SIGNING_KEY); - const auto packet_hash = utils::cryptography::sha1::compute(packet_buffer); + const auto packet_hash = utilities::cryptography::sha1::compute(packet_buffer); char out_1[24]; calculate_hmacs(data.m_session_key, 24, BD_AUTH_TRAFFIC_SIGNING_KEY.data(), 294, out_1, 24); - auto data_3 = utils::cryptography::hmac_sha1::compute(std::string(out_1, 24), packet_hash); + auto data_3 = utilities::cryptography::hmac_sha1::compute(std::string(out_1, 24), packet_hash); char out_2[16]; calculate_hmacs(data_3.data(), 20, "CLIENTCHAL", 10, out_2, 16); @@ -101,10 +101,10 @@ namespace demonware std::memcpy(data.m_enc_key, &out_3[56], 16); #ifndef NDEBUG - logger::write(logger::LOG_TYPE_DEBUG, "[DW] Response id: %s", utils::string::dump_hex(std::string(&out_2[8], 8)).data()); - logger::write(logger::LOG_TYPE_DEBUG, "[DW] Hash verify: %s", utils::string::dump_hex(std::string(&out_3[20], 20)).data()); - logger::write(logger::LOG_TYPE_DEBUG, "[DW] AES dec key: %s", utils::string::dump_hex(std::string(&out_3[40], 16)).data()); - logger::write(logger::LOG_TYPE_DEBUG, "[DW] AES enc key: %s", utils::string::dump_hex(std::string(&out_3[56], 16)).data()); + logger::write(logger::LOG_TYPE_DEBUG, "[DW] Response id: %s", utilities::string::dump_hex(std::string(&out_2[8], 8)).data()); + logger::write(logger::LOG_TYPE_DEBUG, "[DW] Hash verify: %s", utilities::string::dump_hex(std::string(&out_3[20], 20)).data()); + logger::write(logger::LOG_TYPE_DEBUG, "[DW] AES dec key: %s", utilities::string::dump_hex(std::string(&out_3[40], 16)).data()); + logger::write(logger::LOG_TYPE_DEBUG, "[DW] AES enc key: %s", utilities::string::dump_hex(std::string(&out_3[56], 16)).data()); logger::write(logger::LOG_TYPE_DEBUG, "[DW] Bravo 6, going dark."); #endif } diff --git a/source/proxy-dll/demonware/objects.cpp b/source/proxy-dll/demonware/objects.cpp index 81f5e39..1ad0e78 100644 --- a/source/proxy-dll/demonware/objects.cpp +++ b/source/proxy-dll/demonware/objects.cpp @@ -4,10 +4,10 @@ #include "protobuf_helper.hpp" #include "resource.hpp" -#include -#include -#include -#include +#include +#include +#include +#include #include #define PUBLISHER_OBJECTS_ENUMERATE_LPC_DIR @@ -30,11 +30,11 @@ namespace demonware std::string get_publisher_file_checksum(std::string file) { std::string file_data; - if (!utils::io::read_file(file, &file_data)) return ""; + if (!utilities::io::read_file(file, &file_data)) return ""; - std::string checksum_md5 = utils::cryptography::md5::compute(file_data); + std::string checksum_md5 = utilities::cryptography::md5::compute(file_data); - return utils::cryptography::base64::encode(checksum_md5); + return utilities::cryptography::base64::encode(checksum_md5); } std::vector get_publisher_objects_list(const std::string& category) @@ -42,24 +42,24 @@ namespace demonware std::vector result; #ifdef PUBLISHER_OBJECTS_ENUMERATE_LPC_DIR - std::vector files = utils::io::list_files("LPC"); + std::vector files = utilities::io::list_files("LPC"); for (std::string file : files) { - if (!utils::string::ends_with(file, ".ff")) continue; + if (!utilities::string::ends_with(file, ".ff")) continue; int64_t timestamp = static_cast(time(nullptr)); - result.push_back({ "treyarch", utils::io::file_name(file), get_publisher_file_checksum(file), utils::io::file_size(file), timestamp, timestamp, "" }); + result.push_back({ "treyarch", utilities::io::file_name(file), get_publisher_file_checksum(file), utilities::io::file_size(file), timestamp, timestamp, "" }); } #else // PUBLISHER_OBJECTS_ENUMERATE_CSV_LIST - const auto objects_list_csv = utils::nt::load_resource(DW_PUBLISHER_OBJECTS_LIST); - std::vector items = utils::string::split(objects_list_csv, "\r\n"); // WTF!? + const auto objects_list_csv = utilities::nt::load_resource(DW_PUBLISHER_OBJECTS_LIST); + std::vector items = utilities::string::split(objects_list_csv, "\r\n"); // WTF!? for (std::string item : items) { - std::string checksum = utils::cryptography::base64::encode(HexStringToBinaryString(utils::string::split(item, ',')[2])); - std::string name = utils::string::split(item, ',')[0]; - uint64_t length = std::stoull(utils::string::split(item, ',')[1]); + std::string checksum = utilities::cryptography::base64::encode(HexStringToBinaryString(utilities::string::split(item, ',')[2])); + std::string name = utilities::string::split(item, ',')[0]; + uint64_t length = std::stoull(utilities::string::split(item, ',')[1]); int64_t timestamp = static_cast(time(nullptr)); result.push_back({ "treyarch", name, checksum, length, timestamp, timestamp, "" }); @@ -159,17 +159,17 @@ namespace demonware std::string get_user_file_checksum(std::string file_path) { std::string file_data; - if (!utils::io::read_file(file_path, &file_data)) return ""; + if (!utilities::io::read_file(file_path, &file_data)) return ""; - return std::to_string(utils::cryptography::xxh32::compute(file_data)); + return std::to_string(utilities::cryptography::xxh32::compute(file_data)); } std::string get_user_file_content(std::string file_path) { std::string file_data; - if (!utils::io::read_file(file_path, &file_data)) return ""; + if (!utilities::io::read_file(file_path, &file_data)) return ""; - return utils::cryptography::base64::encode(file_data); + return utilities::cryptography::base64::encode(file_data); } std::string deliver_user_objects_vectorized_json(std::vector requested_items) @@ -294,7 +294,7 @@ namespace demonware { std::string file_path = get_user_file_path(file.name); int64_t timestamp = static_cast(time(nullptr)); - files_metadata_list.push_back({ file.owner, file.name, get_user_file_checksum(file_path), utils::io::file_size(file_path), timestamp, timestamp, get_user_file_content(file_path) }); + files_metadata_list.push_back({ file.owner, file.name, get_user_file_checksum(file_path), utilities::io::file_size(file_path), timestamp, timestamp, get_user_file_content(file_path) }); } return deliver_user_objects_vectorized_json(files_metadata_list); @@ -318,9 +318,9 @@ namespace demonware std::string userdata_directory = platform::get_userdata_directory(); - if (utils::io::directory_exists(userdata_directory)) + if (utilities::io::directory_exists(userdata_directory)) { - std::vector user_objects = utils::io::list_files(userdata_directory); + std::vector user_objects = utilities::io::list_files(userdata_directory); for (std::string object : user_objects) { @@ -336,7 +336,7 @@ namespace demonware json_writer.Uint(0); json_writer.Key("name"); - json_writer.String(utils::io::file_name(object)); + json_writer.String(utilities::io::file_name(object)); json_writer.Key("checksum"); json_writer.String(get_user_file_checksum(object)); @@ -354,7 +354,7 @@ namespace demonware json_writer.Null(); json_writer.Key("contentLength"); - json_writer.Uint64(utils::io::file_size(object)); + json_writer.Uint64(utilities::io::file_size(object)); json_writer.Key("context"); json_writer.String("t8-bnet"); @@ -404,9 +404,9 @@ namespace demonware std::string userdata_directory = platform::get_userdata_directory(); int files_count = 0; - if (utils::io::directory_exists(userdata_directory)) + if (utilities::io::directory_exists(userdata_directory)) { - files_count = static_cast(utils::io::list_files(userdata_directory).size()); + files_count = static_cast(utilities::io::list_files(userdata_directory).size()); } @@ -467,7 +467,7 @@ namespace demonware json_writer.Null(); json_writer.Key("contentLength"); - json_writer.Uint64(utils::io::file_size(file_path)); + json_writer.Uint64(utilities::io::file_size(file_path)); json_writer.Key("context"); json_writer.String("t8-bnet"); @@ -599,7 +599,7 @@ namespace demonware { std::string file_path = get_user_file_path(file); int64_t timestamp = static_cast(time(nullptr)); - files_metadata_list.push_back({ std::format("bnet-{}", platform::bnet_get_userid()), file, get_user_file_checksum(file_path), utils::io::file_size(file_path), timestamp, timestamp, get_user_file_content(file_path) }); + files_metadata_list.push_back({ std::format("bnet-{}", platform::bnet_get_userid()), file, get_user_file_checksum(file_path), utilities::io::file_size(file_path), timestamp, timestamp, get_user_file_content(file_path) }); } return construct_vectorized_upload_list_json(files_metadata_list); @@ -609,7 +609,7 @@ namespace demonware { bdProtobufHelper header_1st; header_1st.writeString(1, "Content-Length", 16); - header_1st.writeString(2, utils::string::va("%u", payload.length()), 8); + header_1st.writeString(2, utilities::string::va("%u", payload.length()), 8); bdProtobufHelper header_2nd; header_2nd.writeString(1, "Authorization", 16); diff --git a/source/proxy-dll/demonware/reply.cpp b/source/proxy-dll/demonware/reply.cpp index f067095..f1bf040 100644 --- a/source/proxy-dll/demonware/reply.cpp +++ b/source/proxy-dll/demonware/reply.cpp @@ -3,7 +3,7 @@ #include "reply.hpp" #include "servers/service_server.hpp" -#include +#include namespace demonware { @@ -41,7 +41,7 @@ namespace demonware std::string seed("\x5E\xED\x5E\xED\x5E\xED\x5E\xED\x5E\xED\x5E\xED\x5E\xED\x5E\xED", 16); // encrypt - const auto enc_data = utils::cryptography::aes::encrypt(aligned_data, seed, demonware::get_encrypt_key()); + const auto enc_data = utilities::cryptography::aes::encrypt(aligned_data, seed, demonware::get_encrypt_key()); // header : encrypted service data : hash static auto msg_count = 0; @@ -58,7 +58,7 @@ namespace demonware response.write(enc_data); // hash entire packet and append end - auto hash_data = utils::cryptography::hmac_sha1::compute(response.get_buffer(), demonware::get_hmac_key()); + auto hash_data = utilities::cryptography::hmac_sha1::compute(response.get_buffer(), demonware::get_hmac_key()); hash_data.resize(8); response.write(8, hash_data.data()); diff --git a/source/proxy-dll/demonware/server_registry.hpp b/source/proxy-dll/demonware/server_registry.hpp index 725e24c..1bb8ea1 100644 --- a/source/proxy-dll/demonware/server_registry.hpp +++ b/source/proxy-dll/demonware/server_registry.hpp @@ -1,7 +1,7 @@ #pragma once #include "servers/base_server.hpp" -#include +#include namespace demonware { @@ -31,7 +31,7 @@ namespace demonware T* find(const std::string& name) { - const auto address = utils::cryptography::jenkins_one_at_a_time::compute(name); + const auto address = utilities::cryptography::jenkins_one_at_a_time::compute(name); return find(address); } diff --git a/source/proxy-dll/demonware/servers/auth3_server.cpp b/source/proxy-dll/demonware/servers/auth3_server.cpp index 12d62ab..3e18d37 100644 --- a/source/proxy-dll/demonware/servers/auth3_server.cpp +++ b/source/proxy-dll/demonware/servers/auth3_server.cpp @@ -3,8 +3,8 @@ #include "auth3_server.hpp" #include "../keys.hpp" -#include -#include +#include +#include namespace demonware { @@ -84,7 +84,7 @@ namespace demonware { auto& token_field = extra_data["account_token"]; std::string token_b64(token_field.GetString(), token_field.GetStringLength()); - account_token = utils::cryptography::base64::decode(token_b64); + account_token = utilities::cryptography::base64::decode(token_b64); } } @@ -104,13 +104,13 @@ namespace demonware strncpy_s(ticket.m_username, sizeof(ticket.m_username), session_token.data(), session_token.length()); std::memcpy(ticket.m_sessionKey, session_key.data(), 24); - const auto client_ticket_b64 = utils::cryptography::base64::encode(reinterpret_cast(&ticket), sizeof(ticket)); + const auto client_ticket_b64 = utilities::cryptography::base64::encode(reinterpret_cast(&ticket), sizeof(ticket)); // server_ticket uint8_t server_ticket[128]; std::memset(&server_ticket, 0, sizeof server_ticket); std::memcpy(server_ticket, session_key.data(), 24); - const auto server_ticket_b64 = utils::cryptography::base64::encode(server_ticket, 128); + const auto server_ticket_b64 = utilities::cryptography::base64::encode(server_ticket, 128); demonware::set_session_key(session_key); @@ -128,7 +128,7 @@ namespace demonware extra.AddMember("username", username, extra.GetAllocator()); extra.AddMember("time_to_live", 9999, extra.GetAllocator()); - const auto lul = utils::cryptography::base64::encode("lul"); + const auto lul = utilities::cryptography::base64::encode("lul"); extra.AddMember("extended_data", lul, extra.GetAllocator()); rapidjson::StringBuffer extra_buffer{}; @@ -170,8 +170,8 @@ namespace demonware result.append("HTTP/1.1 200 OK\r\n"); result.append("Server: TornadoServer/4.5.3\r\n"); result.append("Content-Type: application/json\r\n"); - result.append(utils::string::va("Date: %s GMT\r\n", date)); - result.append(utils::string::va("Content-Length: %d\r\n\r\n", buffer.GetLength())); + result.append(utilities::string::va("Date: %s GMT\r\n", date)); + result.append(utilities::string::va("Content-Length: %d\r\n\r\n", buffer.GetLength())); result.append(buffer.GetString(), buffer.GetLength()); raw_reply reply(result); diff --git a/source/proxy-dll/demonware/servers/base_server.cpp b/source/proxy-dll/demonware/servers/base_server.cpp index 727a36a..b0e49f6 100644 --- a/source/proxy-dll/demonware/servers/base_server.cpp +++ b/source/proxy-dll/demonware/servers/base_server.cpp @@ -1,13 +1,13 @@ #include #include "base_server.hpp" -#include +#include namespace demonware { base_server::base_server(std::string name): name_(std::move(name)) { - this->address_ = utils::cryptography::jenkins_one_at_a_time::compute(this->name_); + this->address_ = utilities::cryptography::jenkins_one_at_a_time::compute(this->name_); } const std::string& base_server::get_name() const diff --git a/source/proxy-dll/demonware/servers/lobby_server.cpp b/source/proxy-dll/demonware/servers/lobby_server.cpp index 9c4f0cb..78ea0c6 100644 --- a/source/proxy-dll/demonware/servers/lobby_server.cpp +++ b/source/proxy-dll/demonware/servers/lobby_server.cpp @@ -4,7 +4,7 @@ #include "../services.hpp" #include "../keys.hpp" -#include +#include namespace demonware { @@ -127,7 +127,7 @@ namespace demonware char hash[8]; std::memcpy(hash, &(enc.data()[enc.size() - 8]), 8); - std::string dec = utils::cryptography::aes::decrypt( + std::string dec = utilities::cryptography::aes::decrypt( std::string(enc.data(), enc.size() - 8), std::string(seed, 16), demonware::get_decrypt_key()); @@ -168,7 +168,7 @@ namespace demonware } else { - logger::write(logger::LOG_TYPE_DEBUG, "[DW]: [lobby]: missing service '%s'", utils::string::va("%d", id)); + logger::write(logger::LOG_TYPE_DEBUG, "[DW]: [lobby]: missing service '%s'", utilities::string::va("%d", id)); // return no error byte_buffer buffer(data); diff --git a/source/proxy-dll/demonware/servers/tcp_server.hpp b/source/proxy-dll/demonware/servers/tcp_server.hpp index 3f6967e..6c8be37 100644 --- a/source/proxy-dll/demonware/servers/tcp_server.hpp +++ b/source/proxy-dll/demonware/servers/tcp_server.hpp @@ -1,7 +1,7 @@ #pragma once #include "base_server.hpp" -#include +#include namespace demonware { @@ -21,7 +21,7 @@ namespace demonware void send(const std::string& data); private: - utils::concurrency::container in_queue_; - utils::concurrency::container out_queue_; + utilities::concurrency::container in_queue_; + utilities::concurrency::container out_queue_; }; } diff --git a/source/proxy-dll/demonware/servers/udp_server.hpp b/source/proxy-dll/demonware/servers/udp_server.hpp index 340c598..825ca89 100644 --- a/source/proxy-dll/demonware/servers/udp_server.hpp +++ b/source/proxy-dll/demonware/servers/udp_server.hpp @@ -1,7 +1,7 @@ #pragma once #include "base_server.hpp" -#include +#include namespace demonware { @@ -56,7 +56,7 @@ namespace demonware using out_queue = std::queue; using socket_queue_map = std::unordered_map; - utils::concurrency::container in_queue_; - utils::concurrency::container out_queue_; + utilities::concurrency::container in_queue_; + utilities::concurrency::container out_queue_; }; } diff --git a/source/proxy-dll/demonware/service.hpp b/source/proxy-dll/demonware/service.hpp index e030665..a1cc6c8 100644 --- a/source/proxy-dll/demonware/service.hpp +++ b/source/proxy-dll/demonware/service.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include "servers/service_server.hpp" namespace demonware diff --git a/source/proxy-dll/demonware/services/bdDML.cpp b/source/proxy-dll/demonware/services/bdDML.cpp index 19a4603..98942d7 100644 --- a/source/proxy-dll/demonware/services/bdDML.cpp +++ b/source/proxy-dll/demonware/services/bdDML.cpp @@ -1,7 +1,7 @@ #include #include "../services.hpp" -#include +#include namespace demonware { diff --git a/source/proxy-dll/demonware/services/bdObjectStore.cpp b/source/proxy-dll/demonware/services/bdObjectStore.cpp index 8638134..12a5dca 100644 --- a/source/proxy-dll/demonware/services/bdObjectStore.cpp +++ b/source/proxy-dll/demonware/services/bdObjectStore.cpp @@ -3,8 +3,8 @@ #include "../objects.hpp" #include -#include -#include +#include +#include #include namespace demonware @@ -109,10 +109,10 @@ namespace demonware std::string url = request_buffer.GetString(2); std::string data = request_buffer.GetString(3); - std::string file = utils::string::split(url, '/')[8]; + std::string file = utilities::string::split(url, '/')[8]; std::string path = get_user_file_path(file); - if (!utils::io::write_file(path, data)) + if (!utilities::io::write_file(path, data)) logger::write(logger::LOG_TYPE_DEBUG, "[bdObjectStore::uploadUserObject] error on writing '%s'", file.data()); else logger::write(logger::LOG_TYPE_DEBUG, "[bdObjectStore::uploadUserObject] saved user file '%s'", file.data()); @@ -147,12 +147,12 @@ namespace demonware const rapidjson::Value& name = objects[i]["metadata"]["name"]; const rapidjson::Value& checksum = objects[i]["metadata"]["checksum"]; - std::string data = utils::cryptography::base64::decode(content.GetString()); + std::string data = utilities::cryptography::base64::decode(content.GetString()); const auto path = std::format("{}/{}", platform::get_userdata_directory(), name.GetString()); uploaded_objects_list.push_back(name.GetString()); - if (!utils::io::write_file(path, data)) + if (!utilities::io::write_file(path, data)) logger::write(logger::LOG_TYPE_DEBUG, "[bdObjectStore::uploadUserObjectsVectorized] error on writing '%s'", name.GetString()); else logger::write(logger::LOG_TYPE_DEBUG, "[bdObjectStore::uploadUserObjectsVectorized] saved user file '%s'", name.GetString()); diff --git a/source/proxy-dll/demonware/services/bdProfiles.cpp b/source/proxy-dll/demonware/services/bdProfiles.cpp index bb535bb..e29f78f 100644 --- a/source/proxy-dll/demonware/services/bdProfiles.cpp +++ b/source/proxy-dll/demonware/services/bdProfiles.cpp @@ -1,7 +1,7 @@ #include #include "../services.hpp" -#include +#include #include namespace demonware @@ -27,7 +27,7 @@ namespace demonware result->m_entityID = entity_id; result->m_VERSION = 4; - if (utils::io::read_file(std::format("{}/profileInfo_{}", platform::get_userdata_directory(), entity_id), &result->m_ddl)) + if (utilities::io::read_file(std::format("{}/profileInfo_{}", platform::get_userdata_directory(), entity_id), &result->m_ddl)) { auto reply = server->create_reply(this->task_id()); reply->add(result); @@ -46,7 +46,7 @@ namespace demonware buffer->read_int32(&version); buffer->read_blob(&ddl); - utils::io::write_file(std::format("{}/profileInfo_{}", platform::get_userdata_directory(), platform::bnet_get_userid()), ddl); + utilities::io::write_file(std::format("{}/profileInfo_{}", platform::get_userdata_directory(), platform::bnet_get_userid()), ddl); auto reply = server->create_reply(this->task_id()); reply->send(); diff --git a/source/proxy-dll/loader/component_loader.cpp b/source/proxy-dll/loader/component_loader.cpp index 9db538d..c1ed4ac 100644 --- a/source/proxy-dll/loader/component_loader.cpp +++ b/source/proxy-dll/loader/component_loader.cpp @@ -1,7 +1,7 @@ #include #include "component_loader.hpp" -#include +#include void component_loader::register_component(std::unique_ptr&& component_) { diff --git a/source/proxy-dll/main.cpp b/source/proxy-dll/main.cpp index a549360..eccc02d 100644 --- a/source/proxy-dll/main.cpp +++ b/source/proxy-dll/main.cpp @@ -1,11 +1,11 @@ #include #include "loader/component_loader.hpp" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace { @@ -17,7 +17,7 @@ namespace std::pair patch_import(const std::string& lib, const std::string& func, void* function) { - static const utils::nt::library game{}; + static const utilities::nt::library game{}; const auto game_entry = game.get_iat_entry(lib, func); if (!game_entry) @@ -26,11 +26,11 @@ namespace } #ifdef DEBUG - logger::write(logger::LOG_TYPE_DEBUG, "[ IAT-HOOKS ]: Diverted %s::%s from %p to %p", utils::string::to_upper(lib).c_str(), func.c_str(), game_entry, function); + logger::write(logger::LOG_TYPE_DEBUG, "[ IAT-HOOKS ]: Diverted %s::%s from %p to %p", utilities::string::to_upper(lib).c_str(), func.c_str(), game_entry, function); #endif // DEBUG const auto original_import = game_entry; - utils::hook::set(game_entry, function); + utilities::hook::set(game_entry, function); return { game_entry, original_import }; } @@ -49,17 +49,17 @@ namespace { patch_import("user32.dll", "GetSystemMetrics", get_system_metrics); - //utils::hook::set(utils::nt::library{}.get_iat_entry("kernel32.dll", "ExitProcess"), exit_hook); + //utilities::hook::set(utilities::nt::library{}.get_iat_entry("kernel32.dll", "ExitProcess"), exit_hook); } void remove_crash_file() { - const utils::nt::library game{}; + const utilities::nt::library game{}; const auto game_file = game.get_path(); auto game_path = std::filesystem::path(game_file); game_path.replace_extension(".start"); - utils::io::remove_file(game_path.generic_string()); + utilities::io::remove_file(game_path.generic_string()); } bool run() @@ -68,7 +68,7 @@ namespace { auto premature_shutdown = true; - const auto _ = utils::finally([&premature_shutdown]() + const auto _ = utilities::finally([&premature_shutdown]() { if (premature_shutdown) { @@ -107,14 +107,14 @@ namespace : source_(source) { memcpy(this->data_, source, sizeof(this->data_)); - utils::hook::jump(this->source_, target, true, true); + utilities::hook::jump(this->source_, target, true, true); } ~patch() { if (source_) { - utils::hook::copy(this->source_, this->data_, sizeof(this->data_)); + utilities::hook::copy(this->source_, this->data_, sizeof(this->data_)); } } @@ -148,13 +148,13 @@ namespace uint8_t* get_entry_point() { - const utils::nt::library game{}; + const utilities::nt::library game{}; return game.get_ptr() + game.get_optional_header()->AddressOfEntryPoint; } std::vector get_tls_callbacks() { - const utils::nt::library game{}; + const utilities::nt::library game{}; const auto& entry = game.get_optional_header()->DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS]; if (!entry.VirtualAddress || !entry.Size) { @@ -222,7 +222,7 @@ HRESULT D3D11CreateDevice(void* adapter, const uint64_t driver_type, char dir[MAX_PATH]{ 0 }; GetSystemDirectoryA(dir, sizeof(dir)); - const auto d3d11 = utils::nt::library::load(dir + "/d3d11.dll"s); + const auto d3d11 = utilities::nt::library::load(dir + "/d3d11.dll"s); return d3d11.get_proc("D3D11CreateDevice"); }(); diff --git a/source/proxy-dll/spoofer/spoofcall.cpp b/source/proxy-dll/spoofer/spoofcall.cpp index 78ea55a..0521f07 100644 --- a/source/proxy-dll/spoofer/spoofcall.cpp +++ b/source/proxy-dll/spoofer/spoofcall.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include namespace spoofcall @@ -30,7 +30,7 @@ namespace spoofcall return res; } - void callstack_return_stub(utils::hook::assembler& a) + void callstack_return_stub(utilities::hook::assembler& a) { a.push(rax); a.pushad64(); @@ -49,14 +49,14 @@ namespace spoofcall { const auto placeholder = 0x1403CF1C6_g; - utils::hook::set(placeholder - 2, 0xFF); // fakes a call - utils::hook::nop(placeholder, 1); - utils::hook::jump(placeholder + 1, utils::hook::assemble(callstack_return_stub)); + utilities::hook::set(placeholder - 2, 0xFF); // fakes a call + utilities::hook::nop(placeholder, 1); + utilities::hook::jump(placeholder + 1, utilities::hook::assemble(callstack_return_stub)); return placeholder; } - void callstack_stub(utils::hook::assembler& a) + void callstack_stub(utilities::hook::assembler& a) { a.push(rax); @@ -83,7 +83,7 @@ namespace spoofcall static bool spoofer_initialized = false; if (!spoofer_initialized) { - callstack_proxy_addr = utils::hook::assemble(callstack_stub); + callstack_proxy_addr = utilities::hook::assemble(callstack_stub); } address_to_call = funcAddr; diff --git a/source/proxy-dll/std_include.cpp b/source/proxy-dll/std_include.cpp index 50c1cec..a7714bc 100644 --- a/source/proxy-dll/std_include.cpp +++ b/source/proxy-dll/std_include.cpp @@ -1,5 +1,5 @@ #include -#include +#include extern "C" { @@ -27,7 +27,7 @@ extern "C" size_t get_base() { - static auto base = size_t(utils::nt::library{}.get_ptr()); + static auto base = size_t(utilities::nt::library{}.get_ptr()); assert(base && "Failed to resolve base"); return base; } diff --git a/source/shared-code/exception/minidump.cpp b/source/shared-code/exception/minidump.cpp index a55d290..28eefec 100644 --- a/source/shared-code/exception/minidump.cpp +++ b/source/shared-code/exception/minidump.cpp @@ -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); } } diff --git a/source/shared-code/exception/minidump.hpp b/source/shared-code/exception/minidump.hpp index 42b3a46..f655fd1 100644 --- a/source/shared-code/exception/minidump.hpp +++ b/source/shared-code/exception/minidump.hpp @@ -1,6 +1,6 @@ #pragma once -#include "../utils/nt.hpp" +#include "../utilities/nt.hpp" namespace exception { diff --git a/source/shared-code/utils/binary_resource.cpp b/source/shared-code/utilities/binary_resource.cpp similarity index 98% rename from source/shared-code/utils/binary_resource.cpp rename to source/shared-code/utilities/binary_resource.cpp index eed83b0..c000db3 100644 --- a/source/shared-code/utils/binary_resource.cpp +++ b/source/shared-code/utilities/binary_resource.cpp @@ -4,7 +4,7 @@ #include "nt.hpp" #include "io.hpp" -namespace utils +namespace utilities { namespace { diff --git a/source/shared-code/utils/binary_resource.hpp b/source/shared-code/utilities/binary_resource.hpp similarity index 94% rename from source/shared-code/utils/binary_resource.hpp rename to source/shared-code/utilities/binary_resource.hpp index da19af1..b7c1767 100644 --- a/source/shared-code/utils/binary_resource.hpp +++ b/source/shared-code/utilities/binary_resource.hpp @@ -2,7 +2,7 @@ #include -namespace utils +namespace utilities { class binary_resource { diff --git a/source/shared-code/utils/com.cpp b/source/shared-code/utilities/com.cpp similarity index 99% rename from source/shared-code/utils/com.cpp rename to source/shared-code/utilities/com.cpp index efb1fe0..33e6aa8 100644 --- a/source/shared-code/utils/com.cpp +++ b/source/shared-code/utilities/com.cpp @@ -8,7 +8,7 @@ #include -namespace utils::com +namespace utilities::com { namespace { diff --git a/source/shared-code/utils/com.hpp b/source/shared-code/utilities/com.hpp similarity index 91% rename from source/shared-code/utils/com.hpp rename to source/shared-code/utilities/com.hpp index adafdb4..4c9dfd3 100644 --- a/source/shared-code/utils/com.hpp +++ b/source/shared-code/utilities/com.hpp @@ -4,7 +4,7 @@ #include #include -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 create_progress_dialog(); diff --git a/source/shared-code/utils/compression.cpp b/source/shared-code/utilities/compression.cpp similarity index 99% rename from source/shared-code/utils/compression.cpp rename to source/shared-code/utilities/compression.cpp index d2a0d17..ed866fc 100644 --- a/source/shared-code/utils/compression.cpp +++ b/source/shared-code/utilities/compression.cpp @@ -8,7 +8,7 @@ #include "io.hpp" #include "finally.hpp" -namespace utils::compression +namespace utilities::compression { namespace zlib { diff --git a/source/shared-code/utils/compression.hpp b/source/shared-code/utilities/compression.hpp similarity index 94% rename from source/shared-code/utils/compression.hpp rename to source/shared-code/utilities/compression.hpp index ad79734..b903247 100644 --- a/source/shared-code/utils/compression.hpp +++ b/source/shared-code/utilities/compression.hpp @@ -5,7 +5,7 @@ #define CHUNK 16384u -namespace utils::compression +namespace utilities::compression { namespace zlib { diff --git a/source/shared-code/utils/concurrency.hpp b/source/shared-code/utilities/concurrency.hpp similarity index 96% rename from source/shared-code/utils/concurrency.hpp rename to source/shared-code/utilities/concurrency.hpp index 05c5d3a..52b71a9 100644 --- a/source/shared-code/utils/concurrency.hpp +++ b/source/shared-code/utilities/concurrency.hpp @@ -2,7 +2,7 @@ #include -namespace utils::concurrency +namespace utilities::concurrency { template class container diff --git a/source/shared-code/utils/cryptography.cpp b/source/shared-code/utilities/cryptography.cpp similarity index 99% rename from source/shared-code/utils/cryptography.cpp rename to source/shared-code/utilities/cryptography.cpp index 85347de..c81e396 100644 --- a/source/shared-code/utils/cryptography.cpp +++ b/source/shared-code/utilities/cryptography.cpp @@ -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 { diff --git a/source/shared-code/utils/cryptography.hpp b/source/shared-code/utilities/cryptography.hpp similarity index 98% rename from source/shared-code/utils/cryptography.hpp rename to source/shared-code/utilities/cryptography.hpp index a5d6776..a6617d7 100644 --- a/source/shared-code/utils/cryptography.hpp +++ b/source/shared-code/utilities/cryptography.hpp @@ -5,7 +5,7 @@ #include #include -namespace utils::cryptography +namespace utilities::cryptography { namespace ecc { diff --git a/source/shared-code/utils/finally.hpp b/source/shared-code/utilities/finally.hpp similarity index 98% rename from source/shared-code/utils/finally.hpp rename to source/shared-code/utilities/finally.hpp index 2e4b6ba..cf67ce5 100644 --- a/source/shared-code/utils/finally.hpp +++ b/source/shared-code/utilities/finally.hpp @@ -1,7 +1,7 @@ #pragma once #include -namespace utils +namespace utilities { /* * Copied from here: https://github.com/microsoft/GSL/blob/e0880931ae5885eb988d1a8a57acf8bc2b8dacda/include/gsl/util#L57 diff --git a/source/shared-code/utils/flags.cpp b/source/shared-code/utilities/flags.cpp similarity index 96% rename from source/shared-code/utils/flags.cpp rename to source/shared-code/utilities/flags.cpp index 09f1311..0911713 100644 --- a/source/shared-code/utils/flags.cpp +++ b/source/shared-code/utilities/flags.cpp @@ -4,7 +4,7 @@ #include -namespace utils::flags +namespace utilities::flags { void parse_flags(std::vector& flags) { diff --git a/source/shared-code/utils/flags.hpp b/source/shared-code/utilities/flags.hpp similarity index 74% rename from source/shared-code/utils/flags.hpp rename to source/shared-code/utilities/flags.hpp index cf304b2..60f6235 100644 --- a/source/shared-code/utils/flags.hpp +++ b/source/shared-code/utilities/flags.hpp @@ -2,7 +2,7 @@ #include -namespace utils::flags +namespace utilities::flags { bool has_flag(const std::string& flag); } diff --git a/source/shared-code/utils/hardware_breakpoint.cpp b/source/shared-code/utilities/hardware_breakpoint.cpp similarity index 98% rename from source/shared-code/utils/hardware_breakpoint.cpp rename to source/shared-code/utilities/hardware_breakpoint.cpp index 6a5e39f..3f3020d 100644 --- a/source/shared-code/utils/hardware_breakpoint.cpp +++ b/source/shared-code/utilities/hardware_breakpoint.cpp @@ -1,7 +1,7 @@ #include "hardware_breakpoint.hpp" #include "thread.hpp" -namespace utils::hardware_breakpoint +namespace utilities::hardware_breakpoint { namespace { diff --git a/source/shared-code/utils/hardware_breakpoint.hpp b/source/shared-code/utilities/hardware_breakpoint.hpp similarity index 94% rename from source/shared-code/utils/hardware_breakpoint.hpp rename to source/shared-code/utilities/hardware_breakpoint.hpp index e37fdea..79cf8fa 100644 --- a/source/shared-code/utils/hardware_breakpoint.hpp +++ b/source/shared-code/utilities/hardware_breakpoint.hpp @@ -2,7 +2,7 @@ #include #include "nt.hpp" -namespace utils::hardware_breakpoint +namespace utilities::hardware_breakpoint { enum condition { diff --git a/source/shared-code/utils/hook.cpp b/source/shared-code/utilities/hook.cpp similarity index 99% rename from source/shared-code/utils/hook.cpp rename to source/shared-code/utilities/hook.cpp index 38134d7..540ffa7 100644 --- a/source/shared-code/utils/hook.cpp +++ b/source/shared-code/utilities/hook.cpp @@ -15,7 +15,7 @@ #undef min #endif -namespace utils::hook +namespace utilities::hook { namespace { diff --git a/source/shared-code/utils/hook.hpp b/source/shared-code/utilities/hook.hpp similarity index 99% rename from source/shared-code/utils/hook.hpp rename to source/shared-code/utilities/hook.hpp index ade2fca..70aee7e 100644 --- a/source/shared-code/utils/hook.hpp +++ b/source/shared-code/utilities/hook.hpp @@ -6,7 +6,7 @@ using namespace asmjit::x86; -namespace utils::hook +namespace utilities::hook { namespace detail { diff --git a/source/shared-code/utils/http.cpp b/source/shared-code/utilities/http.cpp similarity index 96% rename from source/shared-code/utils/http.cpp rename to source/shared-code/utilities/http.cpp index 3cb5999..469ad6d 100644 --- a/source/shared-code/utils/http.cpp +++ b/source/shared-code/utilities/http.cpp @@ -2,7 +2,7 @@ #include "nt.hpp" #include -namespace utils::http +namespace utilities::http { std::optional get_data(const std::string& url) { diff --git a/source/shared-code/utils/http.hpp b/source/shared-code/utilities/http.hpp similarity index 89% rename from source/shared-code/utils/http.hpp rename to source/shared-code/utilities/http.hpp index 65628a9..488a4ed 100644 --- a/source/shared-code/utils/http.hpp +++ b/source/shared-code/utilities/http.hpp @@ -4,7 +4,7 @@ #include #include -namespace utils::http +namespace utilities::http { std::optional get_data(const std::string& url); std::future> get_data_async(const std::string& url); diff --git a/source/shared-code/utils/identity.cpp b/source/shared-code/utilities/identity.cpp similarity index 94% rename from source/shared-code/utils/identity.cpp rename to source/shared-code/utilities/identity.cpp index 5ba9495..70b9420 100644 --- a/source/shared-code/utils/identity.cpp +++ b/source/shared-code/utilities/identity.cpp @@ -6,7 +6,7 @@ #include #include -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 {}; } diff --git a/source/shared-code/utils/identity.hpp b/source/shared-code/utilities/identity.hpp similarity index 76% rename from source/shared-code/utils/identity.hpp rename to source/shared-code/utilities/identity.hpp index 6196aba..2b0f9ba 100644 --- a/source/shared-code/utils/identity.hpp +++ b/source/shared-code/utilities/identity.hpp @@ -2,7 +2,7 @@ #include -namespace utils::identity +namespace utilities::identity { std::string get_sys_username(); std::string get_sys_uuid(); diff --git a/source/shared-code/utils/image.cpp b/source/shared-code/utilities/image.cpp similarity index 97% rename from source/shared-code/utils/image.cpp rename to source/shared-code/utilities/image.cpp index 3f54018..fd36425 100644 --- a/source/shared-code/utils/image.cpp +++ b/source/shared-code/utilities/image.cpp @@ -10,7 +10,7 @@ #include "finally.hpp" -namespace utils::image +namespace utilities::image { image load_image(const std::string& data) { diff --git a/source/shared-code/utils/image.hpp b/source/shared-code/utilities/image.hpp similarity index 97% rename from source/shared-code/utils/image.hpp rename to source/shared-code/utilities/image.hpp index 2dea7b8..1e36bec 100644 --- a/source/shared-code/utils/image.hpp +++ b/source/shared-code/utilities/image.hpp @@ -3,7 +3,7 @@ #include #include "nt.hpp" -namespace utils::image +namespace utilities::image { struct image { diff --git a/source/shared-code/utils/info_string.cpp b/source/shared-code/utilities/info_string.cpp similarity index 98% rename from source/shared-code/utils/info_string.cpp rename to source/shared-code/utilities/info_string.cpp index 3b0287e..07c9f16 100644 --- a/source/shared-code/utils/info_string.cpp +++ b/source/shared-code/utilities/info_string.cpp @@ -1,7 +1,7 @@ #include "info_string.hpp" #include "string.hpp" -namespace utils +namespace utilities { info_string::info_string(const std::string& buffer) { diff --git a/source/shared-code/utils/info_string.hpp b/source/shared-code/utilities/info_string.hpp similarity index 95% rename from source/shared-code/utils/info_string.hpp rename to source/shared-code/utilities/info_string.hpp index 7391041..f30c4d1 100644 --- a/source/shared-code/utils/info_string.hpp +++ b/source/shared-code/utilities/info_string.hpp @@ -3,7 +3,7 @@ #include #include -namespace utils +namespace utilities { class info_string { diff --git a/source/shared-code/utils/io.cpp b/source/shared-code/utilities/io.cpp similarity index 90% rename from source/shared-code/utils/io.cpp rename to source/shared-code/utilities/io.cpp index e8eae30..eac3ad5 100644 --- a/source/shared-code/utils/io.cpp +++ b/source/shared-code/utilities/io.cpp @@ -2,7 +2,7 @@ #include "nt.hpp" #include -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)) diff --git a/source/shared-code/utils/io.hpp b/source/shared-code/utilities/io.hpp similarity index 87% rename from source/shared-code/utils/io.hpp rename to source/shared-code/utilities/io.hpp index c511085..4c5ad3a 100644 --- a/source/shared-code/utils/io.hpp +++ b/source/shared-code/utilities/io.hpp @@ -4,7 +4,7 @@ #include #include -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); diff --git a/source/shared-code/utils/json_config.cpp b/source/shared-code/utilities/json_config.cpp similarity index 99% rename from source/shared-code/utils/json_config.cpp rename to source/shared-code/utilities/json_config.cpp index 9007b6a..f5b730c 100644 --- a/source/shared-code/utils/json_config.cpp +++ b/source/shared-code/utilities/json_config.cpp @@ -5,7 +5,7 @@ #include #include -namespace utils::json_config +namespace utilities::json_config { rapidjson::Document json_doc{}; std::string file_name = "project-bo4.json"; diff --git a/source/shared-code/utils/json_config.hpp b/source/shared-code/utilities/json_config.hpp similarity index 97% rename from source/shared-code/utils/json_config.hpp rename to source/shared-code/utilities/json_config.hpp index 249ed4e..5a8b42b 100644 --- a/source/shared-code/utils/json_config.hpp +++ b/source/shared-code/utilities/json_config.hpp @@ -1,7 +1,7 @@ #pragma once #include -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); diff --git a/source/shared-code/utils/memory.cpp b/source/shared-code/utilities/memory.cpp similarity index 97% rename from source/shared-code/utils/memory.cpp rename to source/shared-code/utilities/memory.cpp index 99a0391..cec36fb 100644 --- a/source/shared-code/utils/memory.cpp +++ b/source/shared-code/utilities/memory.cpp @@ -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()) { diff --git a/source/shared-code/utils/memory.hpp b/source/shared-code/utilities/memory.hpp similarity index 98% rename from source/shared-code/utils/memory.hpp rename to source/shared-code/utilities/memory.hpp index 01f9554..7ed9246 100644 --- a/source/shared-code/utils/memory.hpp +++ b/source/shared-code/utilities/memory.hpp @@ -3,7 +3,7 @@ #include #include -namespace utils +namespace utilities { class memory final { diff --git a/source/shared-code/utils/nt.cpp b/source/shared-code/utilities/nt.cpp similarity index 99% rename from source/shared-code/utils/nt.cpp rename to source/shared-code/utilities/nt.cpp index 094e4c9..b85bf3c 100644 --- a/source/shared-code/utils/nt.cpp +++ b/source/shared-code/utilities/nt.cpp @@ -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; diff --git a/source/shared-code/utils/nt.hpp b/source/shared-code/utilities/nt.hpp similarity index 99% rename from source/shared-code/utils/nt.hpp rename to source/shared-code/utilities/nt.hpp index 27b7df8..fae4850 100644 --- a/source/shared-code/utils/nt.hpp +++ b/source/shared-code/utilities/nt.hpp @@ -16,7 +16,7 @@ #include #include -namespace utils::nt +namespace utilities::nt { class library final { diff --git a/source/shared-code/utils/progress_ui.cpp b/source/shared-code/utilities/progress_ui.cpp similarity index 75% rename from source/shared-code/utils/progress_ui.cpp rename to source/shared-code/utilities/progress_ui.cpp index 5b43701..ea30809 100644 --- a/source/shared-code/utils/progress_ui.cpp +++ b/source/shared-code/utilities/progress_ui.cpp @@ -1,12 +1,12 @@ #include "progress_ui.hpp" -#include +#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 diff --git a/source/shared-code/utils/progress_ui.hpp b/source/shared-code/utilities/progress_ui.hpp similarity index 95% rename from source/shared-code/utils/progress_ui.hpp rename to source/shared-code/utilities/progress_ui.hpp index 944005b..37094fe 100644 --- a/source/shared-code/utils/progress_ui.hpp +++ b/source/shared-code/utilities/progress_ui.hpp @@ -2,7 +2,7 @@ #include "com.hpp" -namespace utils +namespace utilities { class progress_ui { diff --git a/source/shared-code/utils/signature.cpp b/source/shared-code/utilities/signature.cpp similarity index 93% rename from source/shared-code/utils/signature.cpp rename to source/shared-code/utilities/signature.cpp index b4c47c7..3773aad 100644 --- a/source/shared-code/utils/signature.cpp +++ b/source/shared-code/utilities/signature.cpp @@ -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(); } diff --git a/source/shared-code/utils/signature.hpp b/source/shared-code/utilities/signature.hpp similarity index 90% rename from source/shared-code/utils/signature.hpp rename to source/shared-code/utilities/signature.hpp index 054e6b4..4bd9f6f 100644 --- a/source/shared-code/utils/signature.hpp +++ b/source/shared-code/utilities/signature.hpp @@ -2,7 +2,7 @@ #include "nt.hpp" #include -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); diff --git a/source/shared-code/utils/string.cpp b/source/shared-code/utilities/string.cpp similarity index 91% rename from source/shared-code/utils/string.cpp rename to source/shared-code/utilities/string.cpp index 46e3fcb..96c2af8 100644 --- a/source/shared-code/utils/string.cpp +++ b/source/shared-code/utilities/string.cpp @@ -1,11 +1,11 @@ #include "string.hpp" -#include +#include #include #include #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; + } } diff --git a/source/shared-code/utils/string.hpp b/source/shared-code/utilities/string.hpp similarity index 94% rename from source/shared-code/utils/string.hpp rename to source/shared-code/utilities/string.hpp index 0da871a..6694875 100644 --- a/source/shared-code/utils/string.hpp +++ b/source/shared-code/utilities/string.hpp @@ -7,7 +7,7 @@ template size_t ARRAYSIZE(Type (&)[n]) { return n; } #endif -namespace utils::string +namespace utilities::string { template 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); } diff --git a/source/shared-code/utils/thread.cpp b/source/shared-code/utilities/thread.cpp similarity index 96% rename from source/shared-code/utils/thread.cpp rename to source/shared-code/utilities/thread.cpp index cb3eeac..3b37126 100644 --- a/source/shared-code/utils/thread.cpp +++ b/source/shared-code/utilities/thread.cpp @@ -4,7 +4,7 @@ #include -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); }); diff --git a/source/shared-code/utils/thread.hpp b/source/shared-code/utilities/thread.hpp similarity index 97% rename from source/shared-code/utils/thread.hpp rename to source/shared-code/utilities/thread.hpp index dfdf1d6..24ac5aa 100644 --- a/source/shared-code/utils/thread.hpp +++ b/source/shared-code/utilities/thread.hpp @@ -2,7 +2,7 @@ #include #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);