From ef920ff012ac794fc1f6abb8779e265f3e961f4d Mon Sep 17 00:00:00 2001 From: chiteroman <98092901+chiteroman@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:57:07 +0100 Subject: [PATCH] fix xiaomi.eu --- README.md | 1 - app/build.gradle.kts | 2 +- app/src/main/cpp/main.cpp | 20 ++++++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d9bb10e..b48a4d1 100644 --- a/README.md +++ b/README.md @@ -51,5 +51,4 @@ Their devs are already working on it: [click me](https://xiaomi.eu/community/thr If Xiaomi.eu devs drop support for your device and this module doesn't work you must change the ROM if you want to pass DEVICE verdict. ## Thanks to -- [libcxx-prefab](https://github.com/RikkaW/libcxx-prefab) - [Dobby](https://github.com/jmpews/Dobby) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index d1e589c..d583cfc 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -24,7 +24,7 @@ android { externalNativeBuild { cmake { arguments += "-DANDROID_STL=none" - arguments += "-DCMAKE_BUILD_TYPE=Release" + arguments += "-DCMAKE_BUILD_TYPE=MinSizeRel" cFlags += "-fvisibility=hidden" cFlags += "-fvisibility-inlines-hidden" diff --git a/app/src/main/cpp/main.cpp b/app/src/main/cpp/main.cpp index c17abfa..654e718 100644 --- a/app/src/main/cpp/main.cpp +++ b/app/src/main/cpp/main.cpp @@ -45,6 +45,11 @@ my_system_property_read_callback(const prop_info *pi, static void doHook() { void *handle = DobbySymbolResolver("libc.so", "__system_property_read_callback"); + if (handle == nullptr) { + LOGD("Couldn't find '__system_property_read_callback' handle. Report to @chiteroman"); + return; + } + LOGD("Found '__system_property_read_callback' handle at %p", handle); DobbyHook(handle, (void *) my_system_property_read_callback, (void **) &o_system_property_read_callback); } @@ -92,18 +97,17 @@ public: long size = 0; read(fd, &size, sizeof(size)); - if (size > 0) { - - char buffer[size]; - read(fd, buffer, size); - + if (size < 1) { close(fd); - - moduleDex.insert(moduleDex.end(), buffer, buffer + size); - + LOGD("Couldn't load classes.dex, does the file exist?"); return; } + char buffer[size]; + read(fd, buffer, size); + + moduleDex.insert(moduleDex.end(), buffer, buffer + size); + close(fd); }