summaryrefslogtreecommitdiff
path: root/Source/Core/Common/MemoryUtil.cpp
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2014-09-17 20:26:57 -0400
committercomex <comexk@gmail.com>2014-09-17 20:26:57 -0400
commit49a48a6057ad2fd189dd85ba0b38d541e8bac17d (patch)
tree997df90c6dbf680543a10ad47a3d09801237ccfd /Source/Core/Common/MemoryUtil.cpp
parent5fafcb66802c91052319556f7516992b2cad7b12 (diff)
parent7ad90275934b63dcc4726a7c49ee9a64758dda3b (diff)
Merge pull request #1025 from comex/blr-optimization
Opportunistically predict BLR destinations using RET.
Diffstat (limited to 'Source/Core/Common/MemoryUtil.cpp')
-rw-r--r--Source/Core/Common/MemoryUtil.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/Core/Common/MemoryUtil.cpp b/Source/Core/Common/MemoryUtil.cpp
index f7e1d7d902..a741deef4f 100644
--- a/Source/Core/Common/MemoryUtil.cpp
+++ b/Source/Core/Common/MemoryUtil.cpp
@@ -158,6 +158,25 @@ void FreeAlignedMemory(void* ptr)
}
}
+void ReadProtectMemory(void* ptr, size_t size)
+{
+ bool error_occurred = false;
+
+#ifdef _WIN32
+ DWORD oldValue;
+ if (!VirtualProtect(ptr, size, PAGE_NOACCESS, &oldValue))
+ error_occurred = true;
+#else
+ int retval = mprotect(ptr, size, PROT_NONE);
+
+ if (retval != 0)
+ error_occurred = true;
+#endif
+
+ if (error_occurred)
+ PanicAlert("ReadProtectMemory failed!\n%s", GetLastErrorMsg());
+}
+
void WriteProtectMemory(void* ptr, size_t size, bool allowExecute)
{
bool error_occurred = false;