diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-05-11 01:35:23 +0200 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-05-19 18:44:32 +0200 |
| commit | ff5bcba966372d5071c080234866e5fab23ae647 (patch) | |
| tree | 7709e2993134fe329c4ee00cf91dd4c68817afa6 /Source/Core/Common/MemArenaWin.cpp | |
| parent | b0d7fa9eb11676cf5ade0a0f5a9a3a07e3bd7224 (diff) | |
Common/MemArenaWin: Handle file mappings >= 4GB.
Diffstat (limited to 'Source/Core/Common/MemArenaWin.cpp')
| -rw-r--r-- | Source/Core/Common/MemArenaWin.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Source/Core/Common/MemArenaWin.cpp b/Source/Core/Common/MemArenaWin.cpp index 1e2de701c5..b055477a85 100644 --- a/Source/Core/Common/MemArenaWin.cpp +++ b/Source/Core/Common/MemArenaWin.cpp @@ -97,11 +97,22 @@ MemArena::~MemArena() ReleaseSHMSegment(); } +static DWORD GetHighDWORD(u64 value) +{ + return static_cast<DWORD>(value >> 32); +} + +static DWORD GetLowDWORD(u64 value) +{ + return static_cast<DWORD>(value); +} + void MemArena::GrabSHMSegment(size_t size) { const std::string name = "dolphin-emu." + std::to_string(GetCurrentProcessId()); - m_memory_handle = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, - static_cast<DWORD>(size), UTF8ToTStr(name).c_str()); + m_memory_handle = + CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, GetHighDWORD(size), + GetLowDWORD(size), UTF8ToTStr(name).c_str()); } void MemArena::ReleaseSHMSegment() @@ -114,8 +125,9 @@ void MemArena::ReleaseSHMSegment() void* MemArena::CreateView(s64 offset, size_t size) { - return MapViewOfFileEx(m_memory_handle, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, - nullptr); + const u64 off = static_cast<u64>(offset); + return MapViewOfFileEx(m_memory_handle, FILE_MAP_ALL_ACCESS, GetHighDWORD(off), GetLowDWORD(off), + size, nullptr); } void MemArena::ReleaseView(void* view, size_t size) |
