aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Memory/MemoryManagementWindows.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ARMeilleure/Memory/MemoryManagementWindows.cs')
-rw-r--r--ARMeilleure/Memory/MemoryManagementWindows.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/ARMeilleure/Memory/MemoryManagementWindows.cs b/ARMeilleure/Memory/MemoryManagementWindows.cs
index ae64b5c6..a9455063 100644
--- a/ARMeilleure/Memory/MemoryManagementWindows.cs
+++ b/ARMeilleure/Memory/MemoryManagementWindows.cs
@@ -89,6 +89,15 @@ namespace ARMeilleure.Memory
return ptr;
}
+ public static bool Commit(IntPtr location, IntPtr size)
+ {
+ const AllocationType flags = AllocationType.Commit;
+
+ IntPtr ptr = VirtualAlloc(location, size, flags, MemoryProtection.ReadWrite);
+
+ return ptr != IntPtr.Zero;
+ }
+
public static bool Reprotect(IntPtr address, IntPtr size, Memory.MemoryProtection protection)
{
MemoryProtection prot = GetProtection(protection);
@@ -96,6 +105,20 @@ namespace ARMeilleure.Memory
return VirtualProtect(address, size, prot, out _);
}
+ public static IntPtr Reserve(IntPtr size)
+ {
+ const AllocationType flags = AllocationType.Reserve;
+
+ IntPtr ptr = VirtualAlloc(IntPtr.Zero, size, flags, MemoryProtection.ReadWrite);
+
+ if (ptr == IntPtr.Zero)
+ {
+ throw new OutOfMemoryException();
+ }
+
+ return ptr;
+ }
+
private static MemoryProtection GetProtection(Memory.MemoryProtection protection)
{
switch (protection)