mirror of
https://github.com/LSPosed/LSPlt.git
synced 2025-05-06 21:48:48 +08:00
Fix 16k page support
This commit is contained in:
parent
a674793be6
commit
7c8e54db1c
@ -101,6 +101,7 @@ android {
|
||||
"-DCMAKE_CXX_FLAGS_RELEASE=$configFlags",
|
||||
"-DCMAKE_C_FLAGS_RELEASE=$configFlags",
|
||||
"-DDEBUG_SYMBOLS_PATH=${project.buildDir.absolutePath}/symbols/$name",
|
||||
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
||||
)
|
||||
findInPath("ccache")?.let {
|
||||
println("Using ccache $it")
|
||||
|
@ -15,11 +15,13 @@
|
||||
#include "syscall.hpp"
|
||||
|
||||
namespace {
|
||||
const uintptr_t kPageSize = getpagesize();
|
||||
|
||||
inline auto PageStart(uintptr_t addr) { return reinterpret_cast<char *>(((addr)&PAGE_MASK)); }
|
||||
inline auto PageStart(uintptr_t addr) {
|
||||
return reinterpret_cast<char *>(addr / kPageSize * kPageSize); }
|
||||
|
||||
inline auto PageEnd(uintptr_t addr) {
|
||||
return reinterpret_cast<char *>(reinterpret_cast<uintptr_t>(PageStart(addr)) + PAGE_SIZE);
|
||||
return reinterpret_cast<char *>(reinterpret_cast<uintptr_t>(PageStart(addr)) + kPageSize);
|
||||
}
|
||||
|
||||
struct RegisterInfo {
|
||||
@ -113,7 +115,6 @@ public:
|
||||
}
|
||||
|
||||
bool DoHook(uintptr_t addr, uintptr_t callback, uintptr_t *backup) {
|
||||
using PAGE = std::array<char, PAGE_SIZE>;
|
||||
LOGV("Hooking %p", reinterpret_cast<void *>(addr));
|
||||
auto iter = lower_bound(addr);
|
||||
if (iter == end()) return false;
|
||||
@ -139,9 +140,8 @@ public:
|
||||
}
|
||||
for (uintptr_t src = reinterpret_cast<uintptr_t>(backup_addr), dest = info.start,
|
||||
end = info.start + len;
|
||||
dest < end; src += PAGE_SIZE, dest += PAGE_SIZE) {
|
||||
static_assert(sizeof(PAGE) == PAGE_SIZE);
|
||||
*reinterpret_cast<PAGE *>(dest) = *reinterpret_cast<PAGE *>(src);
|
||||
dest < end; src += kPageSize, dest += kPageSize) {
|
||||
memcpy(reinterpret_cast<void *>(dest), reinterpret_cast<void *>(src), kPageSize);
|
||||
}
|
||||
info.backup = reinterpret_cast<uintptr_t>(backup_addr);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user