summaryrefslogtreecommitdiff
path: root/Source/Core/Common/MemArenaWin.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-05-19 19:24:31 +0200
committerGitHub <noreply@github.com>2023-05-19 19:24:31 +0200
commit82ecbbe7953af9d07b8899e8a59e91aed409d93d (patch)
tree1e8754c5f0667cbcf2268ab305e725166acfccca /Source/Core/Common/MemArenaWin.cpp
parentb0d7fa9eb11676cf5ade0a0f5a9a3a07e3bd7224 (diff)
parent8342164dbdf6d862556de017f67ff28ecde0f0ec (diff)
Merge pull request #11822 from AdmiralCurtiss/win-large-memarena
Common/MemArenaWin: Improve file mapping logic.
Diffstat (limited to 'Source/Core/Common/MemArenaWin.cpp')
-rw-r--r--Source/Core/Common/MemArenaWin.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/Source/Core/Common/MemArenaWin.cpp b/Source/Core/Common/MemArenaWin.cpp
index 1e2de701c5..9d4a88d54a 100644
--- a/Source/Core/Common/MemArenaWin.cpp
+++ b/Source/Core/Common/MemArenaWin.cpp
@@ -8,6 +8,8 @@
#include <cstdlib>
#include <string>
+#include <fmt/format.h>
+
#include <windows.h>
#include "Common/Assert.h"
@@ -97,11 +99,22 @@ MemArena::~MemArena()
ReleaseSHMSegment();
}
-void MemArena::GrabSHMSegment(size_t size)
+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, std::string_view base_name)
{
- 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());
+ const std::string name = fmt::format("{}.{}", base_name, GetCurrentProcessId());
+ m_memory_handle =
+ CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, GetHighDWORD(size),
+ GetLowDWORD(size), UTF8ToTStr(name).c_str());
}
void MemArena::ReleaseSHMSegment()
@@ -114,8 +127,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)