Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
v2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vvb2060 committed Sep 21, 2021
1 parent 059d047 commit d28d113
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "io.github.vvb2060.nativedetector"
minSdkVersion 21
targetSdkVersion 31
versionCode 5
versionName "2.0"
versionCode 6
versionName "2.1"
}
externalNativeBuild {
ndkBuild {
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
tools:ignore="AllowBackup,MissingApplicationIcon"
tools:targetApi="m">

<activity
android:name="android.app.NativeActivity"
android:enabled="false" />

<activity-alias
android:name="zygisk"
android:exported="true"
android:label="Zygisk Detector">
android:label="Zygisk Detector"
android:targetActivity="android.app.NativeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -26,9 +32,9 @@
<meta-data
android:name="android.app.func_name"
android:value="zygisk" />
</activity>
</activity-alias>
<activity-alias
android:name="android"
android:name="riru"
android:exported="true"
android:label="Riru Detector"
android:targetActivity="android.app.NativeActivity">
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := vvb2060
LOCAL_SRC_FILES := elf_util.cpp bitmap.cpp activity.cpp solist.cpp
LOCAL_LDLIBS := -llog -landroid -ljnigraphics
LOCAL_MODULE := vvb2060
LOCAL_SRC_FILES := elf_util.cpp bitmap.cpp activity.cpp solist.cpp
LOCAL_LDLIBS := -llog -landroid -ljnigraphics
LOCAL_STATIC_LIBRARIES := cxx
include $(BUILD_SHARED_LIBRARY)

Expand Down
12 changes: 4 additions & 8 deletions app/src/main/jni/bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ jobject asBitmap(JNIEnv *env, float width, std::string_view str) {
jmethodID setTextSize = env->GetMethodID(classTextPaint, "setTextSize"_ienc .c_str(), "(F)V"_ienc .c_str());
jmethodID setAntiAlias = env->GetMethodID(classTextPaint, "setAntiAlias"_ienc .c_str(), "(Z)V"_ienc .c_str());
jclass classBitmap = env->FindClass("android/graphics/Bitmap"_ienc .c_str());
jmethodID createBitmap = env->GetStaticMethodID(classBitmap, "createBitmap"_ienc .c_str(),
"(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;"_ienc .c_str());
jmethodID createBitmap = env->GetStaticMethodID(classBitmap, "createBitmap"_ienc .c_str(), "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;"_ienc .c_str());
jclass classBitmap$Config = env->FindClass("android/graphics/Bitmap$Config"_ienc .c_str());
jfieldID field = env->GetStaticFieldID(classBitmap$Config, "ARGB_8888"_ienc .c_str(),
"Landroid/graphics/Bitmap$Config;"_ienc .c_str());
jfieldID field = env->GetStaticFieldID(classBitmap$Config, "ARGB_8888"_ienc .c_str(), "Landroid/graphics/Bitmap$Config;"_ienc .c_str());
jobject config = env->GetStaticObjectField(classBitmap$Config, field);
jclass classCanvas = env->FindClass("android/graphics/Canvas"_ienc .c_str());
jmethodID initCanvas = env->GetMethodID(classCanvas, "<init>"_ienc .c_str(), "(Landroid/graphics/Bitmap;)V"_ienc .c_str());
Expand All @@ -25,8 +23,7 @@ jobject asBitmap(JNIEnv *env, float width, std::string_view str) {
jclass classLayout = env->FindClass("android/text/StaticLayout"_ienc .c_str());
jmethodID getHeight = env->GetMethodID(classLayout, "getHeight"_ienc .c_str(), "()I"_ienc .c_str());
jmethodID draw = env->GetMethodID(classLayout, "draw"_ienc .c_str(), "(Landroid/graphics/Canvas;)V"_ienc .c_str());
jmethodID obtainLayout = env->GetStaticMethodID(classLayoutBuilder, "obtain"_ienc. c_str(),
"(Ljava/lang/CharSequence;IILandroid/text/TextPaint;I)Landroid/text/StaticLayout$Builder;"_ienc .c_str());
jmethodID obtainLayout = env->GetStaticMethodID(classLayoutBuilder, "obtain"_ienc. c_str(), "(Ljava/lang/CharSequence;IILandroid/text/TextPaint;I)Landroid/text/StaticLayout$Builder;"_ienc .c_str());

float textSize = 42.0f;
jobject textPaint = env->NewObject(classTextPaint, initTextPaint);
Expand All @@ -38,8 +35,7 @@ jobject asBitmap(JNIEnv *env, float width, std::string_view str) {
jobject layout = env->CallObjectMethod(builder, buildLayout);
jint height = env->CallIntMethod(layout, getHeight);

jobject bitmap = env->CallStaticObjectMethod(classBitmap, createBitmap, (jint)width,
height, config);
jobject bitmap = env->CallStaticObjectMethod(classBitmap, createBitmap, (jint)width, height, config);
jobject canvas = env->NewObject(classCanvas, initCanvas, bitmap);

env->CallVoidMethod(canvas, drawARGB, 0xff, 0x30, 0x30, 0x30);
Expand Down
19 changes: 8 additions & 11 deletions app/src/main/jni/solist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,18 @@ namespace Solist {

struct soinfo {
soinfo *next() {
return *(soinfo **) ((uintptr_t)
this + solist_next_offset);
return *(soinfo **) ((uintptr_t) this + solist_next_offset);
}

const char *get_realpath() {
return get_realpath_sym ? get_realpath_sym(this) :
((std::string * )((uintptr_t)
this + solist_realpath_offset))->c_str();
((std::string *) ((uintptr_t) this + solist_realpath_offset))->c_str();
}

const char *get_soname() {
return get_soname_sym ? get_soname_sym(this) :
*((const char **) ((uintptr_t)
this + solist_realpath_offset -
sizeof(void *)));
*((const char **) ((uintptr_t) this + solist_realpath_offset -
sizeof(void *)));
}

static bool setup(const SandHook::ElfImg &linker) {
Expand Down Expand Up @@ -80,14 +77,14 @@ namespace Solist {
SandHook::ElfImg linker("/linker"_ienc);
solist = getStaticPointer<soinfo>(linker, "__dl__ZL6solist"_ienc);
somain = getStaticPointer<soinfo>(linker, "__dl__ZL6somain"_ienc);
preloads = reinterpret_cast<std::vector<soinfo*>*>(linker.getSymbAddress(
preloads = reinterpret_cast<std::vector<soinfo *> *>(linker.getSymbAddress(
"__dl__ZL13g_ld_preloads"_ienc));
return soinfo::setup(linker) &&
solist != nullptr && somain != nullptr && preloads != nullptr;
}();

std::vector<soinfo *> linker_get_solist() {
std::vector < soinfo * > linker_solist{};
std::vector<soinfo *> linker_solist{};
for (auto *iter = solist; iter; iter = iter->next()) {
linker_solist.push_back(iter);
}
Expand All @@ -105,8 +102,8 @@ namespace Solist {
return "Zygisk not found but there's LD_PRELOAD"_ienc.c_str();
}

std::set <std::string_view> FindPathsFromSolist(std::string_view keyword) {
std::set <std::string_view> paths{};
std::set<std::string_view> FindPathsFromSolist(std::string_view keyword) {
std::set<std::string_view> paths{};
if (!initialized) {
LOGW("%s", "not initialized"_ienc.c_str());
return paths;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/jni/solist.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

namespace Solist {
std::set<std::string_view> FindPathsFromSolist(std::string_view keyword);

std::string FindZygiskFromPreloads();
}

0 comments on commit d28d113

Please sign in to comment.