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_CXX_FLAGS_RELEASE=$configFlags",
|
||||||
"-DCMAKE_C_FLAGS_RELEASE=$configFlags",
|
"-DCMAKE_C_FLAGS_RELEASE=$configFlags",
|
||||||
"-DDEBUG_SYMBOLS_PATH=${project.buildDir.absolutePath}/symbols/$name",
|
"-DDEBUG_SYMBOLS_PATH=${project.buildDir.absolutePath}/symbols/$name",
|
||||||
|
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
||||||
)
|
)
|
||||||
findInPath("ccache")?.let {
|
findInPath("ccache")?.let {
|
||||||
println("Using ccache $it")
|
println("Using ccache $it")
|
||||||
|
@ -15,11 +15,13 @@
|
|||||||
#include "syscall.hpp"
|
#include "syscall.hpp"
|
||||||
|
|
||||||
namespace {
|
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) {
|
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 {
|
struct RegisterInfo {
|
||||||
@ -113,7 +115,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DoHook(uintptr_t addr, uintptr_t callback, uintptr_t *backup) {
|
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));
|
LOGV("Hooking %p", reinterpret_cast<void *>(addr));
|
||||||
auto iter = lower_bound(addr);
|
auto iter = lower_bound(addr);
|
||||||
if (iter == end()) return false;
|
if (iter == end()) return false;
|
||||||
@ -139,9 +140,8 @@ public:
|
|||||||
}
|
}
|
||||||
for (uintptr_t src = reinterpret_cast<uintptr_t>(backup_addr), dest = info.start,
|
for (uintptr_t src = reinterpret_cast<uintptr_t>(backup_addr), dest = info.start,
|
||||||
end = info.start + len;
|
end = info.start + len;
|
||||||
dest < end; src += PAGE_SIZE, dest += PAGE_SIZE) {
|
dest < end; src += kPageSize, dest += kPageSize) {
|
||||||
static_assert(sizeof(PAGE) == PAGE_SIZE);
|
memcpy(reinterpret_cast<void *>(dest), reinterpret_cast<void *>(src), kPageSize);
|
||||||
*reinterpret_cast<PAGE *>(dest) = *reinterpret_cast<PAGE *>(src);
|
|
||||||
}
|
}
|
||||||
info.backup = reinterpret_cast<uintptr_t>(backup_addr);
|
info.backup = reinterpret_cast<uintptr_t>(backup_addr);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user