-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
RLib
committed
Apr 1, 2018
1 parent
f53276c
commit 3124e32
Showing
42 changed files
with
1,478 additions
and
663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!"); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
Oops, something went wrong.