From ef78906ff97e8b7ffc077d8d2456667752f5af26 Mon Sep 17 00:00:00 2001 From: OEOTYAN Date: Wed, 2 Oct 2024 09:46:55 +0800 Subject: [PATCH] fix: fix libhat compile --- src/ll/api/memory/win/Signature.cpp | 22 +++++----------------- xmake.lua | 5 +++++ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/ll/api/memory/win/Signature.cpp b/src/ll/api/memory/win/Signature.cpp index 5ad66f086e..b9953bb869 100644 --- a/src/ll/api/memory/win/Signature.cpp +++ b/src/ll/api/memory/win/Signature.cpp @@ -5,27 +5,15 @@ #include "ll/api/utils/SystemUtils.h" #include "ll/core/LeviLamina.h" +#include "libhat.hpp" + namespace ll::memory { void* SignatureView::resolve(std::span range, bool disableErrorOutput) const { - - // TODO: fix libhat compile - - const auto firstByte = *elements.front(); - const auto scanEnd = range.end() - elements.size() + 1; - - for (auto i = range.begin(); i != scanEnd; i++) { - i = std::find(std::execution::unseq, i, scanEnd, firstByte); - if (i == scanEnd) [[unlikely]] { - break; - } - if (std::equal(elements.begin() + 1, elements.end(), i + 1, std::equal_to<>{})) [[unlikely]] { - return &*i; - } - } - if (!disableErrorOutput) { + auto result = hat::find_pattern(range.begin(), range.end(), *(hat::signature_view*)&elements); + if (result.has_result() && !disableErrorOutput) { getLogger().fatal("Couldn't find: {}", toString()); getLogger().fatal("In module: {}", sys_utils::getCallerModuleFileName()); } - return nullptr; + return (void*)result.get(); } } // namespace ll::memory diff --git a/xmake.lua b/xmake.lua index 3f807d694a..46d2be7b7c 100644 --- a/xmake.lua +++ b/xmake.lua @@ -35,6 +35,10 @@ add_requires("levibuildscript 0.2.0") add_requires("preloader v1.9.0") add_requires("symbolprovider v1.2.0") +if is_windows then +add_requires("libhat 2024.9.22") +end + if is_linux then set_toolchains("clang") end @@ -148,6 +152,7 @@ target("LeviLamina") end if is_windows then + add_packages("libhat") add_syslinks("Version", "DbgHelp", "dwrite") add_defines( "_AMD64_",