From 7ba1c495ae1c176d02f8679d5fe0d1857aac3483 Mon Sep 17 00:00:00 2001 From: jam1garner Date: Thu, 23 Apr 2020 13:23:56 -0400 Subject: [PATCH] Fix issues with page-alignment of RW/RX page sizes --- source/skyline/inlinehook/controlledpages.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/skyline/inlinehook/controlledpages.cpp b/source/skyline/inlinehook/controlledpages.cpp index 309ff1f..b31ee95 100755 --- a/source/skyline/inlinehook/controlledpages.cpp +++ b/source/skyline/inlinehook/controlledpages.cpp @@ -157,7 +157,7 @@ namespace skyline::inlinehook { if(!isClaimed) { // get actual pages u64 alignedSrc = ALIGN_DOWN((u64)rx, PAGE_SIZE); - size_t alignedSize = ALIGN_UP(size, PAGE_SIZE); + size_t alignedSize = ALIGN_UP((u64)rx + size, PAGE_SIZE) - alignedSrc; // reserve space for rw pages u64 dst; @@ -182,7 +182,7 @@ namespace skyline::inlinehook { // get actual pages u64 alignedSrc = ALIGN_DOWN((u64)rx, PAGE_SIZE); void* alignedDst = (void*) ALIGN_DOWN((u64)rw, PAGE_SIZE); - size_t alignedSize = ALIGN_UP(size, PAGE_SIZE); + size_t alignedSize = ALIGN_UP((u64)rx + size, PAGE_SIZE) - alignedSrc; // invalidate caches armDCacheFlush((void*)alignedDst, size); @@ -197,4 +197,4 @@ namespace skyline::inlinehook { } } -}; \ No newline at end of file +};