Skip to content

Commit

Permalink
Fix code on non mac for arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
tashcan committed Nov 28, 2024
1 parent 025bc57 commit 9a88236
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ if(SPUD_AARCH64_SUPPORT)
target_compile_definitions(spud PUBLIC SPUD_AARCH64_SUPPORT=1)
endif()

target_compile_definitions(spud PRIVATE NOMINMAX=1)

if(NOT SPUD_NO_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported OUTPUT error)
Expand Down
14 changes: 10 additions & 4 deletions src/detour/aarch64/aarch64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include <mach/vm_map.h>
#endif

#if SPUD_OS_WIN
#include <Windows.h>
#endif

#include <algorithm>
#include <cstdint>
#include <cstring>
Expand Down Expand Up @@ -143,10 +147,10 @@ std::tuple<relocation_info, size_t> collect_relocations(uintptr_t address,
size_t jump_size) {

relocation_info relocation_info;

#if SPUD_OS_APPLE
csh handle;
cs_insn *insn;

#if SPUD_OS_APPLE
vm_size_t vmsize = 0;
vm_address_t addr = (vm_address_t)address;
vm_region_basic_info_data_64_t info;
Expand All @@ -158,10 +162,12 @@ std::tuple<relocation_info, size_t> collect_relocations(uintptr_t address,
(vm_region_info_t)&info, &info_count, &object);
#elif SPUD_OS_WIN
MEMORY_BASIC_INFORMATION memory_info;
VirtualQuery(address, &memory_info, sizeof(memory_info));
size_t vmsize = im.RegionSize;
VirtualQuery(reinterpret_cast<LPCVOID>(address), &memory_info, sizeof(memory_info));
size_t vmsize = memory_info.RegionSize;
uintptr_t addr = reinterpret_cast<uintptr_t>(memory_info.BaseAddress);
#else
size_t vmsize = 0xFF;
uintptr_t addr =address;
#endif // SPUD_OS_APPLE

cs_open(CS_ARCH_AARCH64, CS_MODE_LITTLE_ENDIAN, &handle);
Expand Down

0 comments on commit 9a88236

Please sign in to comment.