mirror of
				https://git.wownero.com/wownero/RandomWOW.git
				synced 2024-08-15 00:23:14 +00:00 
			
		
		
		
	Query for LargePageMinimum on Windows
This commit is contained in:
		
							parent
							
								
									c1314dc2a2
								
							
						
					
					
						commit
						a78429202b
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -88,7 +88,7 @@ void* allocExecutableMemory(std::size_t bytes) { | |||
| 	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; | ||||
| } | ||||
| 
 | ||||
|  | @ -96,7 +96,11 @@ void* allocLargePagesMemory(std::size_t bytes) { | |||
| 	void* mem; | ||||
| #ifdef _WIN32 | ||||
| 	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) | ||||
| 		throw std::runtime_error(getErrorMessage("allocLargePagesMemory - VirtualAlloc")); | ||||
| #else | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue