1
0
Fork 0

Refactor scripting API to use new accessors

This commit is contained in:
ζeh Matt 2021-10-22 14:27:28 +03:00
parent c6da82bf7b
commit 105aaa2ab7
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
2 changed files with 9 additions and 8 deletions

View File

@ -29,15 +29,15 @@ SCRIPT_EXPORT bool Script::Memory::RemoteFree(duint addr)
SCRIPT_EXPORT unsigned int Script::Memory::GetProtect(duint addr, bool reserved, bool cache)
{
if(!cache)
MemUpdateMap();
SHARED_ACQUIRE(LockMemoryPages);
auto found = memoryPages.find({ addr, addr });
if(found == memoryPages.end())
unsigned int prot = 0;
if(!MemGetProtect(addr, reserved, cache, &prot))
return 0;
if(!reserved && found->second.mbi.State == MEM_RESERVE) //check if the current page is reserved.
return 0;
return found->second.mbi.Protect;
return prot;
}
SCRIPT_EXPORT bool Script::Memory::SetProtect(duint addr, unsigned int protect)
{
return MemSetProtect(addr, protect);
}
SCRIPT_EXPORT duint Script::Memory::GetBase(duint addr, bool reserved, bool cache)

View File

@ -13,6 +13,7 @@ namespace Script
SCRIPT_EXPORT duint RemoteAlloc(duint addr, duint size);
SCRIPT_EXPORT bool RemoteFree(duint addr);
SCRIPT_EXPORT unsigned int GetProtect(duint addr, bool reserved = false, bool cache = true);
SCRIPT_EXPORT bool SetProtect(duint addr, unsigned int protect);
SCRIPT_EXPORT duint GetBase(duint addr, bool reserved = false, bool cache = true);
SCRIPT_EXPORT duint GetSize(duint addr, bool reserved = false, bool cache = true);