-
Notifications
You must be signed in to change notification settings - Fork 638
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
BlackBox
committed
Feb 22, 2022
1 parent
e20be37
commit d5e6197
Showing
12 changed files
with
231 additions
and
24 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 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
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
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
89 changes: 89 additions & 0 deletions
89
Bcore/src/main/java/top/niunaijun/blackbox/fake/service/IActivityClientProxy.java
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,89 @@ | ||
package top.niunaijun.blackbox.fake.service; | ||
|
||
import android.os.IBinder; | ||
import android.os.IInterface; | ||
import android.util.Log; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import black.android.app.BRActivityClient; | ||
import black.android.util.BRSingleton; | ||
import black.android.util.SingletonContext; | ||
import top.niunaijun.blackbox.fake.frameworks.BActivityManager; | ||
import top.niunaijun.blackbox.fake.hook.ClassInvocationStub; | ||
import top.niunaijun.blackbox.fake.hook.MethodHook; | ||
import top.niunaijun.blackbox.fake.hook.ProxyMethod; | ||
|
||
/** | ||
* Created by BlackBox on 2022/2/22. | ||
*/ | ||
public class IActivityClientProxy extends ClassInvocationStub { | ||
public static final String TAG = "IActivityClientProxy"; | ||
private final Object who; | ||
|
||
public IActivityClientProxy(Object who) { | ||
this.who = who; | ||
} | ||
|
||
@Override | ||
protected Object getWho() { | ||
if (who != null) { | ||
return who; | ||
} | ||
Object instance = BRActivityClient.get().getInstance(); | ||
Object singleton = BRActivityClient.get(instance).INTERFACE_SINGLETON(); | ||
return BRSingleton.get(singleton).get(); | ||
} | ||
|
||
@Override | ||
protected void inject(Object baseInvocation, Object proxyInvocation) { | ||
Object instance = BRActivityClient.get().getInstance(); | ||
Object singleton = BRActivityClient.get(instance).INTERFACE_SINGLETON(); | ||
BRSingleton.get(singleton)._set_mInstance(proxyInvocation); | ||
} | ||
|
||
@Override | ||
public boolean isBadEnv() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Object getProxyInvocation() { | ||
return super.getProxyInvocation(); | ||
} | ||
|
||
@Override | ||
public void onlyProxy(boolean o) { | ||
super.onlyProxy(o); | ||
} | ||
|
||
@ProxyMethod(name = "finishActivity") | ||
public static class FinishActivity extends MethodHook { | ||
@Override | ||
protected Object hook(Object who, Method method, Object[] args) throws Throwable { | ||
IBinder token = (IBinder) args[0]; | ||
BActivityManager.get().onFinishActivity(token); | ||
return method.invoke(who, args); | ||
} | ||
} | ||
|
||
@ProxyMethod(name = "activityResumed") | ||
public static class ActivityResumed extends MethodHook { | ||
@Override | ||
protected Object hook(Object who, Method method, Object[] args) throws Throwable { | ||
IBinder token = (IBinder) args[0]; | ||
BActivityManager.get().onActivityResumed(token); | ||
return method.invoke(who, args); | ||
} | ||
} | ||
|
||
@ProxyMethod(name = "activityDestroyed") | ||
public static class ActivityDestroyed extends MethodHook { | ||
@Override | ||
protected Object hook(Object who, Method method, Object[] args) throws Throwable { | ||
IBinder token = (IBinder) args[0]; | ||
BActivityManager.get().onActivityDestroyed(token); | ||
return method.invoke(who, args); | ||
} | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
android-mirror/src/main/java/black/android/app/ActivityClient.java
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 black.android.app; | ||
|
||
import android.os.IInterface; | ||
|
||
import top.niunaijun.blackreflection.annotation.BClassName; | ||
import top.niunaijun.blackreflection.annotation.BField; | ||
import top.niunaijun.blackreflection.annotation.BStaticMethod; | ||
|
||
/** | ||
* Created by BlackBox on 2022/2/22. | ||
*/ | ||
@BClassName("android.app.ActivityClient") | ||
public interface ActivityClient { | ||
@BField | ||
Object INTERFACE_SINGLETON(); | ||
|
||
@BStaticMethod | ||
Object getInstance(); | ||
|
||
@BStaticMethod | ||
Object getActivityClientController(); | ||
|
||
@BStaticMethod | ||
Object setActivityClientController(Object iInterface); | ||
|
||
@BClassName("android.app.ActivityClient$ActivityClientControllerSingleton") | ||
interface ActivityClientControllerSingleton { | ||
@BField | ||
IInterface mKnownInstance(); | ||
} | ||
} |
Oops, something went wrong.