4 Win32::SYSTEM_INFO Info;
6 return Info.dwPageSize;
10 if ((reinterpret_cast<unsigned long long>(AMemory) % APageSize) == 0)
12 return reinterpret_cast<void*
>(
reinterpret_cast<unsigned long long>(AMemory) + (APageSize - (reinterpret_cast<unsigned long long>(AMemory) % APageSize)));
16 if (ANumBytes >= 1024) {
17 void*
const Result(
Core().FModuleManager.Call<Modules::Kernel32::VirtualAlloc>(
nullptr, ANumBytes, Win32::DWORD(MEM_RESERVE), Win32::DWORD(PAGE_NOACCESS)));
18 if (Result !=
nullptr)
25 API::Assert::NotEqual<Win32::BOOL>(
Core().
FModuleManager.
Call<Modules::Kernel32::VirtualFree>(FReservation, 0U, Win32::DWORD(MEM_RELEASE)), FALSE);
29 if (ANumBytes > FCommitSize) {
30 if (ANumBytes <= FReservationSize) {
31 bool ThrowOccurred(
false);
33 Access(AccessLevel::READ_WRITE);
41 const void*
const Result(
Core().FModuleManager.Call<Modules::Kernel32::VirtualAlloc>(FReservation, ANumBytes, Win32::DWORD(MEM_COMMIT), Win32::DWORD(PAGE_READWRITE)));
42 if (Result ==
nullptr)
44 FCommitSize = ANumBytes;
52 Win32::MEMORY_BASIC_INFORMATION Info;
53 if (
Core().FModuleManager.Call<Modules::Kernel32::VirtualQuery>(FReservation, &Info,
sizeof(Win32::MEMORY_BASIC_INFORMATION)) == 0)
56 if (Info.State == MEM_COMMIT) {
59 if (
Core().FModuleManager.Call<Modules::Kernel32::VirtualProtect>(FReservation, Info.RegionSize, static_cast<Win32::DWORD>(
60 AAccessLevel == AccessLevel::READ_WRITE ?
62 (AAccessLevel == AccessLevel::NONE ?
63 PAGE_NOACCESS : PAGE_READONLY)),
74 if (!
Core().FModuleManager.Loaded<Modules::Kernel32Extended::DiscardVirtualMemory>())
78 if (ANumBytes < PageSize)
82 const auto Difference(reinterpret_cast<unsigned long long>(AlignedMemory) - reinterpret_cast<unsigned long long>(AMemory));
86 const auto BytesAvailableToDiscard(ANumBytes - Difference);
88 if (BytesAvailableToDiscard < PageSize)
91 const auto TrueDiscardSize(BytesAvailableToDiscard - (BytesAvailableToDiscard % PageSize));
93 Core().
FModuleManager.
Call<Modules::Kernel32Extended::DiscardVirtualMemory>(AlignedMemory, TrueDiscardSize);
Memory protection could not be set.
Platform::Modules::Manager FModuleManager
Loads and contains required modules.
const unsigned int FErrorCode
The assigned error code.
Memory could not be reserved.
Memory could not be commited from a reservation.
Precompiled header for inter-engine operations.
Engine::Core & Core(void) noexcept
Retrieve the Core singleton.
static void LessThanOrEqual(const AType &ALHS, const AType &ARHS) noexcept
Less than or equal assertion function. May not be evaluated.
Exceptions that are thrown internally in the engine that the should never see, these are a superset o...