From f884773e477dcb264d7af9093278b6869a084f45 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Fri, 13 Sep 2024 21:24:33 +0800 Subject: [PATCH] refactor: prepare for remove direct symbol resolve --- src-server/ll/core/plugin-abi/Memory.cpp | 9 ++ src-test/server/Packet_test.cpp | 5 +- src-test/server/TestNbt.cpp | 4 +- src/ll/api/base/FixedString.h | 11 ++- src/ll/api/command/Optional.h | 11 ++- src/ll/api/data/Version.h | 6 +- src/ll/api/memory/Hook.h | 9 +- src/ll/api/memory/Memory.cpp | 55 ++---------- src/ll/api/memory/Memory.h | 41 ++------- src/ll/api/memory/Signature.h | 35 +++++--- src/ll/api/memory/Symbol.cpp | 48 +++++++++++ src/ll/api/memory/Symbol.h | 88 ++++++++++++++++++++ src/ll/api/mod/ModManagerRegistry.cpp | 6 +- src/ll/api/reflection/Dispatcher.h | 5 +- src/ll/api/utils/StacktraceUtils.h | 1 - src/ll/api/utils/StacktraceUtils_win.cpp | 8 -- src/ll/core/mod/NativeModManager.cpp | 2 +- src/mc/deps/core/common/bedrock/typeid_t.cpp | 28 ++++--- 18 files changed, 227 insertions(+), 145 deletions(-) create mode 100644 src/ll/api/memory/Symbol.cpp create mode 100644 src/ll/api/memory/Symbol.h diff --git a/src-server/ll/core/plugin-abi/Memory.cpp b/src-server/ll/core/plugin-abi/Memory.cpp index 58dde93c96..584acbc6d1 100644 --- a/src-server/ll/core/plugin-abi/Memory.cpp +++ b/src-server/ll/core/plugin-abi/Memory.cpp @@ -27,4 +27,13 @@ LLNDAPI FuncPtr resolveSignature(std::string_view signature, std::span { }; std::string getVTableName(void* vtable) { - auto res = ll::memory::lookupSymbol(*((void**)vtable)); + auto res = ll::memory::Symbol::fromAddress(*((void**)vtable)); if (res.size() == 1) { - return res[0].substr(4, res[0].size() - 9); + auto str = res[0].view().raw(); + return std::string{str.substr(4, str.size() - 9)}; } else { throw std::runtime_error("cannot get symbol"); } diff --git a/src-test/server/TestNbt.cpp b/src-test/server/TestNbt.cpp index e2c29789e3..9e7b75786b 100644 --- a/src-test/server/TestNbt.cpp +++ b/src-test/server/TestNbt.cpp @@ -187,6 +187,6 @@ LL_AUTO_TYPE_INSTANCE_HOOK(NbtTest, HookPriority::Normal, ServerInstance, &Serve ->toSnbt(SnbtFormat::PrettyConsolePrint) ); - ll::getLogger().debug("signature {}", "48 8D 05 ? ? ? ? E8"_sig.toString(false, false)); - ll::getLogger().debug("resolve {}", "48 8D 05 ? ? ? ? E8"_sig.resolve()); + ll::getLogger().debug("signature {}", "48 8D 05 ? ? ? ? E8"_sigv.toString(false, false)); + ll::getLogger().debug("resolve {}", "48 8D 05 ? ? ? ? E8"_sigv.resolve()); } diff --git a/src/ll/api/base/FixedString.h b/src/ll/api/base/FixedString.h index ec49e3b329..fbd09cbc6b 100644 --- a/src/ll/api/base/FixedString.h +++ b/src/ll/api/base/FixedString.h @@ -9,13 +9,14 @@ template struct FixedString { char buf[N + 1]{}; consteval FixedString() = default; - // NOLINTBEGIN(google-explicit-constructor) consteval FixedString(std::string_view s) { std::copy_n(s.data(), s.size(), buf); } consteval FixedString(char const* s) { std::copy_n(s, N, buf); } consteval operator char const*() const { return buf; } consteval operator std::string_view() const { return buf; } constexpr operator std::string() const { return buf; } - // NOLINTEND(google-explicit-constructor) + + [[nodiscard]] constexpr char const& operator[](size_t idx) const { return buf[idx]; } + [[nodiscard]] constexpr char& operator[](size_t idx) { return buf[idx]; } template consteval auto operator+(const FixedString& other) { @@ -29,13 +30,11 @@ struct FixedString { struct StringView { char const* data; size_t size; - consteval StringView(std::string_view v) { // NOLINT + consteval StringView(std::string_view v) { data = v.data(); size = v.size(); } - consteval operator std::string_view() const { // NOLINT - return std::string_view{data, size}; - } + consteval operator std::string_view() const { return std::string_view{data, size}; } }; template diff --git a/src/ll/api/command/Optional.h b/src/ll/api/command/Optional.h index 1f7d03a086..f3fa0ed69c 100644 --- a/src/ll/api/command/Optional.h +++ b/src/ll/api/command/Optional.h @@ -86,14 +86,13 @@ class Optional { [[nodiscard]] constexpr T const* operator->() const { return &get(); } [[nodiscard]] constexpr T* operator->() { return &get(); } - // NOLINTNEXTLINE(google-explicit-constructor) [[nodiscard]] constexpr operator T const&&() const&& { return std::move(get()); } - [[nodiscard]] constexpr operator T&&() && { return std::move(get()); } // NOLINT(google-explicit-constructor) - [[nodiscard]] constexpr operator T const&() const& { return get(); } // NOLINT(google-explicit-constructor) - [[nodiscard]] constexpr operator T&() & { return get(); } // NOLINT(google-explicit-constructor) + [[nodiscard]] constexpr operator T&&() && { return std::move(get()); } + [[nodiscard]] constexpr operator T const&() const& { return get(); } + [[nodiscard]] constexpr operator T&() & { return get(); } - [[nodiscard]] constexpr operator T const*() const { return &get(); } // NOLINT(google-explicit-constructor) - [[nodiscard]] constexpr operator T*() { return &get(); } // NOLINT(google-explicit-constructor) + [[nodiscard]] constexpr operator T const*() const { return &get(); } + [[nodiscard]] constexpr operator T*() { return &get(); } template [[nodiscard]] constexpr T value_or(U&& right) const& { diff --git a/src/ll/api/data/Version.h b/src/ll/api/data/Version.h index 7e3a4b7e02..7f21b0ed36 100644 --- a/src/ll/api/data/Version.h +++ b/src/ll/api/data/Version.h @@ -25,10 +25,8 @@ namespace ll::data { namespace detail { struct from_chars_result : std::from_chars_result { - [[nodiscard]] constexpr operator bool() const noexcept { // NOLINT(google-explicit-constructor) - return ec == std::errc{}; - } - constexpr void value() const { + [[nodiscard]] constexpr operator bool() const noexcept { return ec == std::errc{}; } + constexpr void value() const { if (ec != std::errc{}) { throw std::system_error{std::make_error_code(ec)}; } diff --git a/src/ll/api/memory/Hook.h b/src/ll/api/memory/Hook.h index 1112605091..0d6003c293 100644 --- a/src/ll/api/memory/Hook.h +++ b/src/ll/api/memory/Hook.h @@ -66,7 +66,7 @@ constexpr FuncPtr resolveIdentifier(T identifier) { // TODO: remove in release template constexpr FuncPtr resolveIdentifier(std::string_view identifier) { - return resolveSymbol(identifier, false); + return SymbolView{identifier}.resolve(); } template @@ -74,6 +74,11 @@ constexpr FuncPtr resolveIdentifier(SignatureView identifier) { return identifier.resolve(); } +template +constexpr FuncPtr resolveIdentifier(SymbolView identifier) { + return identifier.resolve(); +} + template constexpr FuncPtr resolveIdentifier(uintptr_t address) { return toFuncPtr(address); @@ -176,7 +181,7 @@ struct LL_EBO Hook {}; \ static int hook(bool suspendThreads = true) { \ detector<_OriginFuncType>(); \ - _HookTarget = ::ll::memory::resolveIdentifier<_OriginFuncType>(IDENTIFIER); \ + if (!_HookTarget) _HookTarget = ::ll::memory::resolveIdentifier<_OriginFuncType>(IDENTIFIER); \ return ::ll::memory::hook( \ _HookTarget, \ ::ll::memory::toFuncPtr(&DEF_TYPE::detour), \ diff --git a/src/ll/api/memory/Memory.cpp b/src/ll/api/memory/Memory.cpp index 0859e0494d..f5a39b97f3 100644 --- a/src/ll/api/memory/Memory.cpp +++ b/src/ll/api/memory/Memory.cpp @@ -4,67 +4,24 @@ #include #include -#include "pl/SymbolProvider.h" - -#include "ll/api/io/Logger.h" -#include "ll/api/service/GamingStatus.h" -#include "ll/api/thread/GlobalThreadPauser.h" -#include "ll/api/utils/StringUtils.h" #include "ll/api/utils/SystemUtils.h" #include "ll/core/LeviLamina.h" #include "mc/deps/core/common/bedrock/IMemoryAllocator.h" -#include "demangler/Demangle.h" - namespace ll::memory { -std::string demangleSymbol(std::string_view symbol) { - std::string res; - if (demangler::nonMicrosoftDemangle(symbol, res)) return res; - else if (symbol.starts_with("_")) { // some platform's external symbol style... - demangler::nonMicrosoftDemangle(symbol.substr(1), res); - } else { - if (char* demangled = demangler::microsoftDemangle( - symbol, - nullptr, - nullptr, - (demangler::MSDemangleFlags)(demangler::MSDF_NoAccessSpecifier | demangler::MSDF_NoCallingConvention) - )) { - res = demangled; - std::free(demangled); - } else { - res = symbol; - } - } - return res; -} -FuncPtr resolveSymbol(char const* symbol) { - auto res = pl::symbol_provider::pl_resolve_symbol_silent(symbol); +LLAPI FuncPtr resolveSymbol(char const* symbol) { // for link + auto sym = SymbolView{ + {symbol, strlen(symbol)} + }; + auto res = sym.resolve(true); if (res == nullptr) { - getLogger().fatal("Couldn't find: {}", demangleSymbol(symbol)); + getLogger().fatal("Couldn't find: {}", sym.toString()); getLogger().fatal("In module: {}", sys_utils::getCallerModuleFileName()); } return res; } -FuncPtr resolveSymbol(std::string_view symbol, bool disableErrorOutput) { - auto res = pl::symbol_provider::pl_resolve_symbol_silent_n(symbol.data(), symbol.size()); - if (!disableErrorOutput && res == nullptr) { - getLogger().fatal("Couldn't find: {}", demangleSymbol(symbol)); - getLogger().fatal("In module: {}", sys_utils::getCallerModuleFileName()); - } - return res; -} -std::vector lookupSymbol(FuncPtr func) { - std::vector symbols; - size_t length; - auto result = pl::symbol_provider::pl_lookup_symbol(func, &length); - for (size_t i = 0; i < length; i++) { - symbols.emplace_back(result[i]); - } - if (result) pl::symbol_provider::pl_free_lookup_result(result); - return symbols; -} size_t getUsableSize(void* ptr) { return getDefaultAllocator().getUsableSize(ptr); } [[noreturn]] void throwMemoryException(size_t size) { diff --git a/src/ll/api/memory/Memory.h b/src/ll/api/memory/Memory.h index 7705034506..c82daee4b7 100644 --- a/src/ll/api/memory/Memory.h +++ b/src/ll/api/memory/Memory.h @@ -10,6 +10,7 @@ #include "ll/api/base/FixedString.h" #include "ll/api/base/Macro.h" #include "ll/api/memory/Signature.h" +#include "ll/api/memory/Symbol.h" namespace Bedrock::Memory { class IMemoryAllocator; @@ -53,24 +54,6 @@ template inline void memcpy_t(void* dst, void const* src) { memcpy(dst, src, sizeof(T)); } - -/** - * @brief resolve symbol to function pointer - * @param symbol Symbol - * @return function pointer - */ -LLNDAPI FuncPtr resolveSymbol(char const* symbol); - -LLNDAPI FuncPtr resolveSymbol(std::string_view symbol, bool disableErrorOutput); - -LLNDAPI std::string demangleSymbol(std::string_view symbol); -/** - * @brief lookup symbol name of a function address - * @param func Function address - * @return symbols - */ -LLNDAPI std::vector lookupSymbol(FuncPtr func); - /** * @brief make a region of memory writable and executable, then call the * callback, and finally restore the region. @@ -85,6 +68,11 @@ inline void modify(T& ref, std::function&)> const& f) { modify((void*)std::addressof(ref), sizeof(T), [&] { f((std::remove_cv_t&)(ref)); }); } +template +constexpr auto addressCall(void const* address, auto&&... args) -> RTN { + return ((RTN(*)(Args...))address)(std::forward(args)...); +} + template constexpr auto virtualCall(void const* self, ptrdiff_t vIndex, auto&&... args) -> RTN { return (*(RTN(**)(void const*, Args...))(*(uintptr_t**)self + vIndex))( @@ -201,21 +189,4 @@ class VirtualMemory { return reinterpret_cast(pointer); } }; - -template -inline FuncPtr symbolCache = resolveSymbol(symbol, false); - -template -inline FuncPtr signatureResultCache = signatureCache.view().resolve(); - } // namespace ll::memory - -#define LL_RESOLVE_SYMBOL(symbol) (ll::memory::symbolCache) - -#define LL_RESOLVE_SIGNATURE(signature) (ll::memory::signatureCache) - -#define LL_SYMBOL_CALL(symbol, Ret, ...) ((Ret(*)(__VA_ARGS__))(ll::memory::symbolCache)) - -#define LL_ADDRESS_CALL(address, Ret, ...) ((Ret(*)(__VA_ARGS__))(address)) - -#define LL_SIGNATURE_CALL(signature, Ret, ...) ((Ret(*)(__VA_ARGS__))(ll::memory::signatureCache)) diff --git a/src/ll/api/memory/Signature.h b/src/ll/api/memory/Signature.h index 76da0ea19b..083d9eb1a2 100644 --- a/src/ll/api/memory/Signature.h +++ b/src/ll/api/memory/Signature.h @@ -41,10 +41,16 @@ class SignatureElement { }; class SignatureView { - std::span const elements; + std::span elements; public: [[nodiscard]] constexpr SignatureView() = default; + + [[nodiscard]] constexpr SignatureView(SignatureView&&) noexcept = default; + LL_MAY_CONSTEXPR SignatureView& operator=(SignatureView&&) noexcept = default; + [[nodiscard]] constexpr SignatureView(SignatureView const&) noexcept = default; + LL_MAY_CONSTEXPR SignatureView& operator=(SignatureView const&) noexcept = default; + [[nodiscard]] constexpr SignatureView(std::span span) : elements(span) {} [[nodiscard]] constexpr SignatureView(Signature const& signature); @@ -66,7 +72,7 @@ class SignatureView { }; class Signature { - std::vector const elements; + std::vector elements; [[nodiscard]] constexpr Signature(std::vector vec) : elements(std::move(vec)) {} @@ -123,7 +129,11 @@ class FixedSignature { [[nodiscard]] constexpr SignatureView view() const { return {std::span{elements}}; } }; -template +template +[[nodiscard]] constexpr SignatureView::SignatureView(FixedSignature const& signature) +: SignatureView(signature.view()) {} + +template constexpr auto signatureCache = []() { constexpr size_t N = []() { size_t i = 0; @@ -132,24 +142,27 @@ constexpr auto signatureCache = []() { i++; return true; }, - str, + signature, " " ); return i; }(); - FixedSignature res{Signature::parse(str)}; + FixedSignature res{Signature::parse(signature)}; return res; }(); -template -[[nodiscard]] constexpr SignatureView::SignatureView(FixedSignature const& signature) -: SignatureView(signature.view()) {} +template +inline void* signatureAddressCache = signatureCache.view().resolve(); } // namespace ll::memory namespace ll::inline literals::inline memory_literals { -template -consteval memory::SignatureView operator""_sig() noexcept { - return memory::signatureCache.view(); +template +consteval memory::SignatureView operator""_sigv() noexcept { + return memory::signatureCache.view(); +} +template +constexpr void* operator""_sig() noexcept { + return memory::signatureAddressCache; } } // namespace ll::inline literals::inline memory_literals diff --git a/src/ll/api/memory/Symbol.cpp b/src/ll/api/memory/Symbol.cpp new file mode 100644 index 0000000000..7688a186d6 --- /dev/null +++ b/src/ll/api/memory/Symbol.cpp @@ -0,0 +1,48 @@ +#include "ll/api/memory/Symbol.h" + +#include "ll/api/utils/SystemUtils.h" +#include "ll/core/LeviLamina.h" + +#include "demangler/Demangle.h" +#include "pl/SymbolProvider.h" + +namespace ll::memory { +void* SymbolView::resolve(bool disableErrorOutput) const { + auto res = pl::symbol_provider::pl_resolve_symbol_silent_n(sym.data(), sym.size()); + if (!disableErrorOutput && res == nullptr) { + getLogger().fatal("Couldn't find: {}", toString()); + getLogger().fatal("In module: {}", sys_utils::getCallerModuleFileName()); + } + return res; +} +std::string SymbolView::toString() const { + std::string res; + if (demangler::nonMicrosoftDemangle(sym, res)) return res; + else if (sym.starts_with("_")) { // some platform's external sym style... + demangler::nonMicrosoftDemangle(sym.substr(1), res); + } else { + if (char* demangled = demangler::microsoftDemangle( + sym, + nullptr, + nullptr, + (demangler::MSDemangleFlags)(demangler::MSDF_NoAccessSpecifier | demangler::MSDF_NoCallingConvention) + )) { + res = demangled; + std::free(demangled); + } else { + res = sym; + } + } + return res; +} +std::vector Symbol::fromAddress(void* func) { + std::vector result; + size_t length{}; + auto symbols = pl::symbol_provider::pl_lookup_symbol(func, &length); + for (size_t i = 0; i < length; i++) { + result.emplace_back(symbols[i]); + } + if (symbols) pl::symbol_provider::pl_free_lookup_result(symbols); + return result; +} +} // namespace ll::memory diff --git a/src/ll/api/memory/Symbol.h b/src/ll/api/memory/Symbol.h new file mode 100644 index 0000000000..b3262c894d --- /dev/null +++ b/src/ll/api/memory/Symbol.h @@ -0,0 +1,88 @@ +#pragma once + +#include +#include +#include + +#include "ll/api/base/Macro.h" +#include "ll/api/base/StdInt.h" + +namespace ll::memory { +class Symbol; +template +class FixedSymbol; + +class SymbolView { + std::string_view sym; + +public: + [[nodiscard]] constexpr SymbolView() = default; + + [[nodiscard]] constexpr SymbolView(SymbolView&&) noexcept = default; + LL_MAY_CONSTEXPR SymbolView& operator=(SymbolView&&) noexcept = default; + [[nodiscard]] constexpr SymbolView(SymbolView const&) noexcept = default; + LL_MAY_CONSTEXPR SymbolView& operator=(SymbolView const&) noexcept = default; + + [[nodiscard]] constexpr explicit SymbolView(std::string_view symbol) : sym(symbol) {} + + [[nodiscard]] constexpr SymbolView(Symbol const& symbol); + template + [[nodiscard]] constexpr SymbolView(FixedSymbol const& symbol); + + [[nodiscard]] constexpr size_t size() const { return sym.size(); } + + LLNDAPI void* resolve(bool disableErrorOutput = false) const; + + [[nodiscard]] constexpr std::string_view raw() const { return sym; } + + LLNDAPI std::string toString() const; +}; + +class Symbol { + std::string sym; + +public: + [[nodiscard]] explicit constexpr Symbol(std::string symbol) : sym(std::move(symbol)) {} + + LLNDAPI static std::vector fromAddress(void*); + + [[nodiscard]] constexpr size_t size() const { return sym.size(); } + + [[nodiscard]] constexpr SymbolView view() const { return SymbolView{sym}; } +}; + +[[nodiscard]] constexpr SymbolView::SymbolView(Symbol const& symbol) : SymbolView(symbol.view()) {} + +template +class FixedSymbol { +public: + char sym[N + 1]{}; + + [[nodiscard]] consteval FixedSymbol(std::string_view symbol) { std::copy_n(symbol.data(), symbol.size(), sym); } + [[nodiscard]] consteval FixedSymbol(char const* symbol) { std::copy_n(symbol, N, sym); } + + [[nodiscard]] consteval size_t size() const { return N; } + + [[nodiscard]] constexpr SymbolView view() const { return SymbolView{std::string_view{sym}}; } +}; +template +FixedSymbol(char const (&)[N]) -> FixedSymbol; + +template +[[nodiscard]] constexpr SymbolView::SymbolView(FixedSymbol const& symbol) : SymbolView(symbol.view()) {} + +template +inline void* symbolAddressCache = symbol.view().resolve(); + +} // namespace ll::memory + +namespace ll::inline literals::inline memory_literals { +template +consteval memory::SymbolView operator""_symv() noexcept { + return symbol.view(); +} +template +constexpr void* operator""_sym() noexcept { + return memory::symbolAddressCache; +} +} // namespace ll::inline literals::inline memory_literals diff --git a/src/ll/api/mod/ModManagerRegistry.cpp b/src/ll/api/mod/ModManagerRegistry.cpp index 6e9089f9ce..219f52a209 100644 --- a/src/ll/api/mod/ModManagerRegistry.cpp +++ b/src/ll/api/mod/ModManagerRegistry.cpp @@ -164,15 +164,15 @@ std::shared_ptr ModManagerRegistry::getMod(std::string_view name) const { return getManagerForMod(name)->getMod(name); } -void ModManagerRegistry::executeOnModLoad(std::function&& fn) noexcept{ +void ModManagerRegistry::executeOnModLoad(std::function&& fn) noexcept { std::lock_guard lock(impl->fnMtx); impl->onModLoad.push_back(std::move(fn)); } -void ModManagerRegistry::executeOnModUnload(std::function&& fn)noexcept { +void ModManagerRegistry::executeOnModUnload(std::function&& fn) noexcept { std::lock_guard lock(impl->fnMtx); impl->onModUnload.push_back(std::move(fn)); } -void ModManagerRegistry::executeOnModEnable(std::function&& fn) noexcept{ +void ModManagerRegistry::executeOnModEnable(std::function&& fn) noexcept { std::lock_guard lock(impl->fnMtx); impl->onModEnable.push_back(std::move(fn)); } diff --git a/src/ll/api/reflection/Dispatcher.h b/src/ll/api/reflection/Dispatcher.h index 52f9bead57..809a5cbd47 100644 --- a/src/ll/api/reflection/Dispatcher.h +++ b/src/ll/api/reflection/Dispatcher.h @@ -15,9 +15,8 @@ class Dispatcher { void call() { listener.call(storage); } template - Dispatcher(Args&&... args) // NOLINT(google-explicit-constructor) - : storage(std::forward(args)...), - listener() { + Dispatcher(Args&&... args) : storage(std::forward(args)...), + listener() { if constexpr (CallInit) { call(); } diff --git a/src/ll/api/utils/StacktraceUtils.h b/src/ll/api/utils/StacktraceUtils.h index 48b7ead48d..1fa27ade11 100644 --- a/src/ll/api/utils/StacktraceUtils.h +++ b/src/ll/api/utils/StacktraceUtils.h @@ -72,7 +72,6 @@ struct StackTraceEntryInfo { std::string file; }; -LLNDAPI uintptr_t tryGetSymbolAddress(std::string_view); LLNDAPI StackTraceEntryInfo getInfo(StacktraceEntry const&); LLNDAPI std::string toString(StacktraceEntry const&); LLNDAPI std::string toString(Stacktrace const&); diff --git a/src/ll/api/utils/StacktraceUtils_win.cpp b/src/ll/api/utils/StacktraceUtils_win.cpp index 0bad93e508..5223cd92f5 100644 --- a/src/ll/api/utils/StacktraceUtils_win.cpp +++ b/src/ll/api/utils/StacktraceUtils_win.cpp @@ -211,14 +211,6 @@ SymbolLoader::~SymbolLoader() { } } -uintptr_t tryGetSymbolAddress(std::string_view symbol) { - DbgEngData data; - if (!data.tryInit()) { - return 0; - } - return data.getSymbol(symbol); -} - StackTraceEntryInfo getInfo(StacktraceEntry const& entry) { DbgEngData data; diff --git a/src/ll/core/mod/NativeModManager.cpp b/src/ll/core/mod/NativeModManager.cpp index 8c834df241..0277e2ea0d 100644 --- a/src/ll/core/mod/NativeModManager.cpp +++ b/src/ll/core/mod/NativeModManager.cpp @@ -56,7 +56,7 @@ formatDependencyError(pl::dependency_walker::DependencyIssueItem const& item, st for (const auto& [module, missingProcedure] : item.mMissingProcedure) { stream << indent << "|- " << module << '\n'; for (const auto& procedure : missingProcedure) { - stream << indent << "|---- " << memory::demangleSymbol(procedure) << '\n'; + stream << indent << "|---- " << memory::SymbolView(procedure).toString() << '\n'; } } } diff --git a/src/mc/deps/core/common/bedrock/typeid_t.cpp b/src/mc/deps/core/common/bedrock/typeid_t.cpp index de02e55155..f452d2bab7 100644 --- a/src/mc/deps/core/common/bedrock/typeid_t.cpp +++ b/src/mc/deps/core/common/bedrock/typeid_t.cpp @@ -3,24 +3,28 @@ #include "ll/api/base/Containers.h" +using namespace ll::literals; + template <> std::atomic_ushort& Bedrock::typeid_t::_getCounter() { - return *(std::atomic_ushort*)LL_RESOLVE_SYMBOL( - "?storage@?1??_getCounter@?$typeid_t@VCommandRegistry@@@Bedrock@@CAAEAU?$atomic@G@std@@XZ@4U45@A" - ); + return *(std::atomic_ushort*)"?storage@?1??_getCounter@?$typeid_t@VCommandRegistry@@@Bedrock@@CAAEAU?$atomic@G@std@" + "@XZ@4U45@A"_sym; } #define LL_TYPEID_STORAGE_SYMBOL(TYPE, SYMBOL) \ template <> \ Bedrock::typeid_t Bedrock::type_id() { \ - static auto* id = (Bedrock::typeid_t*)ll::memory::resolveSymbol( \ - "?id@?1???$type_id@VCommandRegistry@@" SYMBOL "@Bedrock@@YA?AV?$typeid_t@VCommandRegistry@@@1@XZ@4V21@A", \ - true \ - ); \ + static auto* id = \ + (Bedrock::typeid_t*)"?id@?1???$type_id@VCommandRegistry@@" SYMBOL \ + "@Bedrock@@YA?AV?$typeid_t@VCommandRegistry@@@1@XZ@4V21@A"_sigv \ + \ + \ + .resolve(true); \ if (!id) { \ - static auto* fn = (Bedrock::typeid_t(*)())ll::memory::resolveSymbol( \ - "??$type_id@VCommandRegistry@@" SYMBOL "@Bedrock@@YA?AV?$typeid_t@VCommandRegistry@@@0@XZ", \ - false \ - ); \ + static auto* fn = (Bedrock::typeid_t(*)() \ + ) "??$type_id@VCommandRegistry@@" SYMBOL "@Bedrock@@YA?AV?$typeid_t@VCommandRegistry@@@0@XZ"_sigv \ + \ + \ + .resolve(); \ if (fn) { \ return fn(); \ } \ @@ -44,4 +48,4 @@ ushort Bedrock::crtypidImpl(size_t type) { } ); return res; -} \ No newline at end of file +}