Skip to content

Commit

Permalink
Bump version for 3.5.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
RLib committed Apr 1, 2018
1 parent f53276c commit 3124e32
Show file tree
Hide file tree
Showing 42 changed files with 1,478 additions and 663 deletions.
14 changes: 6 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="andhook.ui"
android:versionCode="1"
android:versionName="1.0">
package="andhook.test.app"
android:versionCode="3"
android:versionName="3.5.0">

<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="27" />
android:minSdkVersion="14"
android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name="andhook.ui.MainApplication"
android:allowBackup="true"
android:name="andhook.test.app.MainApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
Expand All @@ -20,7 +19,6 @@
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
32 changes: 0 additions & 32 deletions app/src/main/java/andhook/test/A.java

This file was deleted.

41 changes: 0 additions & 41 deletions app/src/main/java/andhook/test/AndTest.java
Original file line number Diff line number Diff line change
@@ -1,46 +1,5 @@
package andhook.test;

import android.content.ContentResolver;
import android.content.ContextWrapper;
import android.util.Log;

import andhook.lib.AndHook;

@SuppressWarnings({"all"})
public class AndTest {
public final static String LOG_TAG = "AndHook_Test";

public static void RunTest(final ContextWrapper context,
final ContentResolver resolver) {
Log.i(AndTest.LOG_TAG, "\nhook test started.\n--------------------------------");
// libAndHook.so must be loaded before libmyjnihook.so
AndHook.ensureNativeLibraryLoaded();

Log.i(AndTest.LOG_TAG, "\nhook in C/C++...\n--------------------------------");
try {
System.loadLibrary("myjnihook");
} catch (final UnsatisfiedLinkError e) {
Log.w(AndTest.LOG_TAG, "failed to load myjnihook!");
}

Log.i(AndTest.LOG_TAG, "\n--------------------------------");
Xposed.doHook();

Log.i(AndTest.LOG_TAG, "\n--------------------------------");
WideningConversion.doHook();

Log.i(AndTest.LOG_TAG, "\n--------------------------------");
Static.doHook();

Log.i(AndTest.LOG_TAG, "\n--------------------------------");
Constructor.doHook();

Log.i(AndTest.LOG_TAG, "\n--------------------------------");
Virtual.doHook();

Log.i(AndTest.LOG_TAG, "\n--------------------------------");
SystemClass.doHook(resolver);

Log.i(AndTest.LOG_TAG, "\n--------------------------------\nhook test done.\n");
}
}
42 changes: 0 additions & 42 deletions app/src/main/java/andhook/test/B.java

This file was deleted.

31 changes: 19 additions & 12 deletions app/src/main/java/andhook/test/Constructor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,36 @@

import andhook.lib.HookHelper;
import andhook.lib.HookHelper.Hook;
import andhook.ui.MainActivity;

import android.util.Log;

@SuppressWarnings("all")
public final class Constructor {
public Constructor() {
Log.i(AndTest.LOG_TAG, "Original constructor hit, this is " + this);
private static boolean passed;

private Constructor() {
MainActivity.output("original constructor hit, this = " + this);
}

@SuppressWarnings("unused")
@Hook(clazz = Constructor.class, name = "<init>")
private static void FakeConstructor(final Object objConstructor) {
Log.i(AndTest.LOG_TAG, "Fake constructor hit, this is " + objConstructor);
private static void faked_Constructor(final Object objConstructor) {
MainActivity.output("faked constructor hit, this = " + objConstructor);
MainActivity.output(new RuntimeException("test"));
HookHelper.invokeVoidOrigin(objConstructor);
passed = true;
}

public static void doHook() {
// test call constructor
new Constructor();
public static void test() {
MainActivity.clear();
MainActivity.output("constructor hook test...");

// hook using HookHelper
HookHelper.applyHooks(Constructor.class);

// test call constructor
passed = false;
new Constructor();

if (passed)
MainActivity.info("constructor hook test passed");
else
MainActivity.alert("failed to hook constructor!");
}
}
31 changes: 31 additions & 0 deletions app/src/main/java/andhook/test/GC.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package andhook.test;

import andhook.ui.MainActivity;

public final class GC {
public static void test() {
MainActivity.clear();
MainActivity.output("GC test...");

try {
final Runtime run = Runtime.getRuntime();
MainActivity.output("maxMemory: " + run.maxMemory());
MainActivity.output("totalMemory: " + run.totalMemory());
MainActivity.output("freeMemory: " + run.freeMemory());

MainActivity.output(" ");

// System.gc();
run.gc();

MainActivity.output("maxMemory: " + run.maxMemory());
MainActivity.output("totalMemory: " + run.totalMemory());
MainActivity.output("freeMemory: " + run.freeMemory());
} catch (final Throwable t) {
MainActivity.alert(t);
return;
}

MainActivity.info("GC test passed");
}
}
97 changes: 97 additions & 0 deletions app/src/main/java/andhook/test/InnerException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package andhook.test;

import andhook.lib.xposed.XC_MethodHook;
import andhook.lib.xposed.XposedHelpers;
import andhook.ui.MainActivity;

public final class InnerException {
private static final class k {
static synchronized void a() {
MainActivity.output("k->a");
q.b();
}

static synchronized void e() {
MainActivity.output("k->e");
q.f();
}
}

private static final class q {
q() {
MainActivity.output("q->constructor");
}

static synchronized void a() {
MainActivity.output("q->a");
k.a();
}

static void b() {
MainActivity.output("q->b");
c();
new q();
}

static synchronized void c() {
MainActivity.output("q->c");
d();
}

static synchronized void d() {
MainActivity.output("q->d");
try {
e();
} catch (final Exception e) {
MainActivity.output("q->d exception");
throw new UnsupportedOperationException(e);
}
}

static void e() {
MainActivity.output("q->e");
k.e();
}

static void f() {
MainActivity.output("q->f");
throw new UnsupportedOperationException("test");
}
}

public static void test() {
MainActivity.clear();
MainActivity.output("inner exception test...");

XposedHelpers.findAndHookMethod(q.class, "b", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param)
throws Throwable {
super.beforeHookedMethod(param);
MainActivity.output("q->b before");
}
});
XposedHelpers.findAndHookMethod(q.class, "d", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(final MethodHookParam param)
throws Throwable {
super.beforeHookedMethod(param);
MainActivity.output("q->d before");
}
});

boolean passed = false;
try {
q.a();
} catch (final UnsupportedOperationException e) {
MainActivity.output(e);
passed = true;
}

if (passed)
MainActivity.info("inner exception test passed");
else
MainActivity.alert("inner exception test failed!");

}
}
45 changes: 45 additions & 0 deletions app/src/main/java/andhook/test/JNI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package andhook.test;

import andhook.lib.AndHook;
import andhook.ui.MainActivity;

public final class JNI {
private static native boolean java_hook();

private static native boolean native_hook();

public static void test() {
MainActivity.clear();
MainActivity.output("hook in C/C++...");

try {
// libAndHook.so must be loaded before libmyjnihook.so
AndHook.ensureNativeLibraryLoaded();
System.loadLibrary("myjnihook");
} catch (final Throwable t) {
MainActivity.alert(t);
MainActivity.alert("failed to load myjnihook!");
return;
}

boolean passed = false;
MainActivity.info("JNI->java_hook");
try {
passed = java_hook();
} catch (final Throwable t) {
MainActivity.alert(t);
}

MainActivity.info("JNI->native_hook");
try {
passed = native_hook() && passed;
} catch (final Throwable t) {
MainActivity.alert(t);
}

if (passed)
MainActivity.info("jni hook test passed");
else
MainActivity.alert("jni hook test failed");
}
}
Loading

0 comments on commit 3124e32

Please sign in to comment.