mirror of
https://git.wownero.com/wownero/RandomWOW.git
synced 2024-12-22 07:48:54 +00:00
Query for LargePageMinimum on Windows
This commit is contained in:
parent
c1314dc2a2
commit
a78429202b
@ -88,7 +88,7 @@ void* allocExecutableMemory(std::size_t bytes) {
|
|||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr std::size_t align(std::size_t pos, uint32_t align) {
|
constexpr std::size_t align(std::size_t pos, std::size_t align) {
|
||||||
return ((pos - 1) / align + 1) * align;
|
return ((pos - 1) / align + 1) * align;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,11 @@ void* allocLargePagesMemory(std::size_t bytes) {
|
|||||||
void* mem;
|
void* mem;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
setPrivilege("SeLockMemoryPrivilege", 1);
|
setPrivilege("SeLockMemoryPrivilege", 1);
|
||||||
mem = VirtualAlloc(NULL, align(bytes, 2 * 1024 * 1024), MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE);
|
auto pageMinimum = GetLargePageMinimum();
|
||||||
|
if (pageMinimum > 0)
|
||||||
|
mem = VirtualAlloc(NULL, align(bytes, pageMinimum), MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE);
|
||||||
|
else
|
||||||
|
throw std::runtime_error("allocLargePagesMemory - Large pages are not supported");
|
||||||
if (mem == nullptr)
|
if (mem == nullptr)
|
||||||
throw std::runtime_error(getErrorMessage("allocLargePagesMemory - VirtualAlloc"));
|
throw std::runtime_error(getErrorMessage("allocLargePagesMemory - VirtualAlloc"));
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user