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