Удаление лишних комментариев /* loaded from: classes.dex */
This commit is contained in:
@@ -2,32 +2,82 @@
|
||||
#include <cstdio>
|
||||
#include <android/log.h>
|
||||
#include <jni.h>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "main.h"
|
||||
#include "util/util.h"
|
||||
#include <link.h>
|
||||
#include <unistd.h>
|
||||
#include <unwind.h>
|
||||
#include <dlfcn.h>
|
||||
#include <execinfo.h>
|
||||
#include <link.h>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "util/armhook.h"
|
||||
#include "util/armhooks.h"
|
||||
|
||||
// Callback для dl_iterate_phdr
|
||||
static int find_libapp_callback(struct dl_phdr_info *info, size_t size, void *data) {
|
||||
void* libapp_base = NULL;
|
||||
|
||||
static int find_lib_callback(struct dl_phdr_info* info, size_t size, void* data) {
|
||||
if (strstr(info->dlpi_name, "libapp.so")) {
|
||||
libapp = (void *) info->dlpi_addr;
|
||||
libapp_base = (void*)info->dlpi_addr;
|
||||
LOGD("Found libapp.so at base: 0x%08X", (uintptr_t)libapp_base);
|
||||
return 1; // Останавливаем перебор
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
// Ищем libapp.so
|
||||
dl_iterate_phdr(find_libapp_callback, NULL);
|
||||
bool get_libapp_base() {
|
||||
dl_iterate_phdr(find_lib_callback, NULL);
|
||||
if (!libapp_base) {
|
||||
Log("libapp.so not found in memory!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
int (*sub_4087CC)() = nullptr;
|
||||
int HOOK_sub_4087CC() {
|
||||
Log("Its hooked sub_4087CC()!");
|
||||
return sub_4087CC();
|
||||
}
|
||||
|
||||
if (libapp) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "MyLib", "libapp.so base: %p", libapp);
|
||||
} else {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "MyLib", "libapp.so not found!");
|
||||
return JNI_ERR;
|
||||
uintptr_t get_library_base(const char* lib_name) {
|
||||
FILE* maps = fopen("/proc/self/maps", "r");
|
||||
if (!maps) return 0;
|
||||
|
||||
char line[512];
|
||||
uintptr_t base = 0;
|
||||
|
||||
while (fgets(line, sizeof(line), maps)) {
|
||||
if (strstr(line, lib_name)) {
|
||||
base = (uintptr_t)strtoul(strtok(line, "-"), NULL, 16);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(maps);
|
||||
return base;
|
||||
}
|
||||
|
||||
bool is_address_executable(void* addr) {
|
||||
uintptr_t page = (uintptr_t)addr & ~(getpagesize() - 1);
|
||||
return msync((void*)page, getpagesize(), MS_ASYNC) == 0;
|
||||
}
|
||||
|
||||
bool is_memory_writable(void* addr, size_t size) {
|
||||
uintptr_t page_start = (uintptr_t)addr & ~(getpagesize() - 1);
|
||||
return mprotect((void*)page_start, size, PROT_READ | PROT_WRITE | PROT_EXEC) == 0;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
|
||||
get_libapp_base();
|
||||
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_nfs_mod_mpcore_MultiplayerCore_bumpBackTraceToLogcat(JNIEnv *env, jobject thiz) {
|
||||
//backtraceToLogcat();
|
||||
}
|
||||
Reference in New Issue
Block a user