Skip to content

Commit

Permalink
feat: add option to disable VirtualAlloc2
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Dec 25, 2023
1 parent 107b4ef commit b8abe1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ project(lime LANGUAGES CXX VERSION 2.3)
# Library options
# --------------------------------------------------------------------------------------------------------

option(lime_tests "Build tests" OFF)
option(lime_static_entrypoint "Use platform independent entrypoint implementation" OFF)
option(lime_tests "Build tests" OFF)
option(lime_no_alloc2 "Disables VirtualAlloc2 (may fix issues with wine)" OFF)
option(lime_static_entrypoint "Use platform independent entrypoint implementation" OFF)

# --------------------------------------------------------------------------------------------------------
# CMake options
Expand Down Expand Up @@ -107,13 +108,17 @@ endif()
target_sources(${PROJECT_NAME} PRIVATE ${src})

# --------------------------------------------------------------------------------------------------------
# Setup cross-platform entrypoint
# Setup compile definitions
# --------------------------------------------------------------------------------------------------------

if (lime_static_entrypoint)
target_compile_definitions(${PROJECT_NAME} PUBLIC LIME_STATIC_ENTRYPOINT)
endif()

if (lime_no_alloc2)
target_compile_definitions(${PROJECT_NAME} PUBLIC LIME_DISABLE_ALLOC2)
endif()

# --------------------------------------------------------------------------------------------------------
# Setup tests
# --------------------------------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions src/page.win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ namespace lime
std::shared_ptr<page> page::allocate<alloc_policy::nearby>(std::uintptr_t where, std::size_t size,
protection protection)
{
#ifdef LIME_DISABLE_ALLOC2
return nullptr;
#else
MEM_EXTENDED_PARAMETER param{};
MEM_ADDRESS_REQUIREMENTS requirements{};

Expand Down Expand Up @@ -253,5 +256,6 @@ namespace lime
}

return impl::from(alloc, size, protection);
#endif
}
} // namespace lime

0 comments on commit b8abe1c

Please sign in to comment.