Skip to content

Commit

Permalink
feat: add signature error output
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Aug 25, 2024
1 parent cbfc430 commit 80dee58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src-test/server/TestNbt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,5 @@ LL_AUTO_TYPE_INSTANCE_HOOK(NbtTest, HookPriority::Normal, ServerInstance, &Serve
);

ll::getLogger().debug("signature {}", "48 8D 05 ? ? ? ? E8"_sig.toString(false, false));
}
ll::getLogger().debug("resolve {}", "48 8D 05 ? ? ? ? E8"_sig.resolve());
}
17 changes: 14 additions & 3 deletions src/ll/api/memory/Signature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
#include <execution>

#include "ll/api/utils/SystemUtils.h"
#include "ll/core/LeviLamina.h"

namespace ll::memory {

void* SignatureView::resolve() const { return resolve(sys_utils::getImageRange()); }

void* SignatureView::resolve(std::span<std::byte> range) const {
void* SignatureView::resolve(bool disableErrorOutput) const {
auto res = resolve(sys_utils::getImageRange(), true);
if (!res && !disableErrorOutput) {
getLogger().fatal("Couldn't find: {}", toString());
getLogger().fatal("In module: {}", sys_utils::getCallerModuleFileName());
}
return res;
}
void* SignatureView::resolve(std::span<std::byte> range, bool disableErrorOutput) const {
const auto firstByte = *elements.front();
const auto scanEnd = range.end() - elements.size() + 1;

Expand All @@ -21,6 +28,10 @@ void* SignatureView::resolve(std::span<std::byte> range) const {
return &*i;
}
}
if (!disableErrorOutput) {
getLogger().fatal("Couldn't find: {}", toString());
getLogger().fatal("In module: {}", sys_utils::getCallerModuleFileName());
}
return nullptr;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ll/api/memory/Signature.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class SignatureView {

[[nodiscard]] constexpr size_t size() const { return elements.size(); }

LLNDAPI void* resolve() const;
LLNDAPI void* resolve(std::span<std::byte> range) const;
LLNDAPI void* resolve(bool disableErrorOutput = false) const;
LLNDAPI void* resolve(std::span<std::byte> range, bool disableErrorOutput = false) const;

LLNDAPI std::string toString(bool alignWildcard = true, bool upperCase = true) const;
};
Expand Down

0 comments on commit 80dee58

Please sign in to comment.