From 1b0d20fe51e8da6b7dc8b683a01ad5b096cd27dc Mon Sep 17 00:00:00 2001 From: bottiger1 <55270538+bottiger1@users.noreply.github.com> Date: Thu, 16 May 2024 11:32:12 -0700 Subject: [PATCH] Skip nearby alloc logic on 32 bits. --- src/allocator.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/allocator.cpp b/src/allocator.cpp index 4a46f1c..c0e3b80 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -178,6 +178,13 @@ void Allocator::combine_adjacent_freenodes(Memory& memory) { std::expected Allocator::allocate_nearby_memory( const std::vector& desired_addresses, size_t size, size_t max_distance) { +#if SAFETYHOOK_ARCH_X86_32 + if (auto result = vm_allocate(nullptr, size, VM_ACCESS_RWX)) { + return result.value(); + } + + return std::unexpected{Error::BAD_VIRTUAL_ALLOC}; +#else if (desired_addresses.empty()) { if (auto result = vm_allocate(nullptr, size, VM_ACCESS_RWX)) { return result.value(); @@ -256,6 +263,7 @@ std::expected Allocator::allocate_nearby_memory( } return std::unexpected{Error::NO_MEMORY_IN_RANGE}; +#endif } bool Allocator::in_range(uint8_t* address, const std::vector& desired_addresses, size_t max_distance) { @@ -268,4 +276,4 @@ bool Allocator::in_range(uint8_t* address, const std::vector& desired_ Allocator::Memory::~Memory() { vm_free(address); } -} // namespace safetyhook \ No newline at end of file +} // namespace safetyhook