Skip to content

Commit

Permalink
Merge branch 'disasm-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed May 13, 2024
2 parents 19508d8 + 0cf1c1a commit 77ab455
Show file tree
Hide file tree
Showing 12 changed files with 371 additions and 289 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Compile
run: |
cmake -B build -Dlime_tests=ON
cmake -B build -Dlime_tests=ON
cmake --build build --config Debug
- name: Run Tests
Expand Down Expand Up @@ -57,14 +57,15 @@ jobs:
fail-fast: false
matrix:
language: ["cpp"]
arch: ["Win32", "x64"]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Compile
run: |
cmake -B build -Dlime_tests=ON -T ClangCL -A x64
cmake -B build -Dlime_tests=ON -T ClangCL -A ${{ matrix.arch }}
cmake --build build --config Debug
- name: Run Tests
Expand Down
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ include("cmake/cpm.cmake")

CPMAddPackage(
NAME Zydis
VERSION 4.0.0
VERSION 4.1.0
GIT_REPOSITORY "https://github.com/zyantific/zydis"
OPTIONS "ZYDIS_BUILD_TOOLS OFF"
"ZYDIS_BUILD_DOXYGEN OFF"
"ZYDIS_BUILD_EXAMPLES OFF"
)

CPMAddPackage(
Expand Down
2 changes: 2 additions & 0 deletions include/lime/hooks/hook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace lime
protect,
relocate,
bad_page,
bad_prot,
bad_func,
};

class hook_base
Expand Down
5 changes: 4 additions & 1 deletion include/lime/instruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ namespace lime
[[nodiscard]] std::optional<instruction> follow() const;
[[nodiscard]] std::optional<instruction> next(std::size_t mnemonic) const;

public:
[[nodiscard]] std::optional<std::uintptr_t> absolute() const;
[[nodiscard]] std::optional<std::uintptr_t> absolute(std::uintptr_t rip) const;

public:
[[nodiscard]] std::optional<instruction> operator-(std::size_t) const;
[[nodiscard]] std::optional<instruction> operator+(std::size_t) const;

public:
[[nodiscard]] operator std::uintptr_t() const;
[[nodiscard]] std::strong_ordering operator<=>(const instruction &) const;

public:
Expand Down
2 changes: 1 addition & 1 deletion private/disasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ namespace lime::disasm

disp displacement(std::uintptr_t);
std::vector<imm> immediates(std::uintptr_t);
std::optional<std::uintptr_t> follow(std::uintptr_t);
std::optional<std::uintptr_t> follow(std::uintptr_t address, std::optional<std::uintptr_t> = std::nullopt);
} // namespace lime::disasm
4 changes: 2 additions & 2 deletions src/disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace lime
return rtn;
}

std::optional<std::uintptr_t> disasm::follow(std::uintptr_t address)
std::optional<std::uintptr_t> disasm::follow(std::uintptr_t address, std::optional<std::uintptr_t> rip)
{
const auto decoder = get_decoder();
const auto *buffer = reinterpret_cast<void *>(address);
Expand All @@ -167,7 +167,7 @@ namespace lime
}

ZyanU64 result = 0;
ZydisCalcAbsoluteAddress(&inst, operands, address, &result);
ZydisCalcAbsoluteAddress(&inst, operands, rip.value_or(address), &result);

return result;
}
Expand Down
Loading

0 comments on commit 77ab455

Please sign in to comment.