Query multiple pages at once with GetWriteWatch (#222)

* Query multiple pages at once with GetWriteWatch

* Allow multiple buffer types to share the same page, aways use the physical address as cache key

* Remove a variable that is no longer needed
This commit is contained in:
gdkchan 2018-07-08 16:55:15 -03:00 committed by GitHub
parent 0f8f40486d
commit 095db47e13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 145 additions and 103 deletions

View file

@ -49,7 +49,7 @@ namespace ChocolArm64.Memory
VirtualFree(Address, IntPtr.Zero, MEM_RELEASE);
}
public unsafe static long IsRegionModified(IntPtr Address, IntPtr Size, bool Reset)
public unsafe static int GetPageSize(IntPtr Address, IntPtr Size)
{
IntPtr[] Addresses = new IntPtr[1];
@ -57,17 +57,36 @@ namespace ChocolArm64.Memory
long Granularity;
int Flags = Reset ? WRITE_WATCH_FLAG_RESET : 0;
GetWriteWatch(
Flags,
0,
Address,
Size,
Addresses,
&Count,
&Granularity);
return Count != 0 ? Granularity : 0;
return (int)Granularity;
}
public unsafe static void IsRegionModified(
IntPtr Address,
IntPtr Size,
IntPtr[] Addresses,
out int AddrCount)
{
long Count = Addresses.Length;
long Granularity;
GetWriteWatch(
WRITE_WATCH_FLAG_RESET,
Address,
Size,
Addresses,
&Count,
&Granularity);
AddrCount = (int)Count;
}
}
}