Skip to content

Commit

Permalink
Add Memory.GetProtection/SetProtection bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Oct 23, 2021
1 parent fc21fff commit a9e846e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Bindings/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@ namespace Dotx64Dbg::Native
return (int)bytesWritten;
}

static uint32_t GetProtection(duint addr)
static uint32_t GetProtection(System::UIntPtr addr, bool useCache)
{
return 0;
auto va = static_cast<duint>(addr.ToUInt64());

return Script::Memory::GetProtect(va, false, useCache);
}

static uint32_t SetProtection(duint addr, uint32_t prot)
static bool SetProtection(System::UIntPtr addr, uint32_t prot, int size)
{
return 0;
auto va = static_cast<duint>(addr.ToUInt64());

return Script::Memory::SetProtect(va, prot, (duint)size);
}

static System::UIntPtr GetBase(System::UIntPtr addr)
Expand Down
18 changes: 18 additions & 0 deletions src/Dotx64Managed/API/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,23 @@ public static nuint GetBase(ulong address)
{
return GetBase((nuint)address);
}

public static Protection GetProtection(nuint address, bool useCache)
{
return (Protection)Native.Memory.GetProtection(address, useCache);
}
public static Protection GetProtection(ulong address, bool useCache)
{
return GetProtection((nuint)address, useCache);
}

public static bool SetProtection(nuint address, Protection protect, int size)
{
return Native.Memory.SetProtection(address, (UInt32)protect, size);
}
public static bool SetProtection(ulong address, Protection protect, int size)
{
return SetProtection((nuint)address, protect, size);
}
};
}

0 comments on commit a9e846e

Please sign in to comment.