Java Code Examples for de.robv.android.xposed.XposedBridge#hookMethod()
The following examples show how to use
de.robv.android.xposed.XposedBridge#hookMethod() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedClock.java From AppTroy with Apache License 2.0 | 6 votes |
public void hookDebug() { try { Method start = Process.class.getMethod("start", String.class, String.class, Integer.TYPE, Integer.TYPE, int[].class, Integer.TYPE, Integer.TYPE, Integer.TYPE, String.class, String[].class); XposedBridge.hookMethod(start, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam methodHookParam) throws Throwable { int id = 5; int flags = (Integer) methodHookParam.args[id]; if ((flags & DEBUG_ENABLE_DEBUGGER) == 0) { flags |= DEBUG_ENABLE_DEBUGGER; } methodHookParam.args[id] = flags; if (BuildConfig.DEBUG) { XposedBridge.log("set debuggable flags to: " + flags); Log.d("cc", "set it debuggable"); } } }); } catch (NoSuchMethodException e) { e.printStackTrace(); } }
Example 2
Source File: $endGiftHook.java From QNotified with GNU General Public License v3.0 | 6 votes |
@Override public boolean init() { if (inited) return true; try { Method m = DexKit.doFindClass(DexKit.C_TROOP_GIFT_UTIL).getDeclaredMethod("a", Activity.class, String.class, String.class, load("com/tencent/mobileqq/app/QQAppInterface")); XposedBridge.hookMethod(m, new XC_MethodHook(47) { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (LicenseStatus.sDisableCommonHooks) return; try { ConfigManager cfg = ConfigManager.getDefaultConfig(); if (!cfg.getBooleanOrFalse(qn_disable_$end_gift)) return; } catch (Exception ignored) { } param.setResult(null); } }); inited = true; return true; } catch (Throwable e) { log(e); return false; } }
Example 3
Source File: MainActivity.java From JavaHooker with The Unlicense | 6 votes |
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); System.loadLibrary("javahooker"); System.loadLibrary("sbxa"); for (final Member method : Activity.class.getDeclaredMethods()) { if (!Modifier.isPublic(method.getModifiers())) continue; if (method.getName().startsWith("on")) continue; XposedBridge.hookMethod(method, new XC_MethodHook() { @Override protected void beforeHookedMethod(final MethodHookParam param) { XposedBridge.log(param.method.getName()); } }); } }
Example 4
Source File: CommonHook.java From WechatHook-Dusan with Apache License 2.0 | 5 votes |
public static void hook_methods(String className, String methodName, XC_MethodHook xmh) { try { Class<?> clazz = Class.forName(className); for (Method method : clazz.getDeclaredMethods()) if (method.getName().equals(methodName) && !Modifier.isAbstract(method.getModifiers()) && Modifier.isPublic(method.getModifiers())) { XposedBridge.hookMethod(method, xmh); } } catch (Exception e) { XposedBridge.log(e); } }
Example 5
Source File: InstrumentationManager.java From droidmon with GNU General Public License v3.0 | 5 votes |
private static void hook(final MethodHookImpl methodHook, ClassLoader classLoader) { try { // Create hook method XC_MethodHook xcMethodHook = methodHook; // Find hook class Class<?> hookClass = findClass(methodHook.getClassName(), classLoader); if (hookClass == null) { String message = String.format("Hook-Class not found: %s", methodHook.getClassName()); Logger.logError(message); return; } // Add hook if (methodHook.getMethodName() == null) { for (Constructor<?> constructor : hookClass.getDeclaredConstructors()){ XposedBridge.hookMethod(constructor, xcMethodHook); } } else{ for (Method method : hookClass.getDeclaredMethods()) if (method.getName().equals(methodHook.getMethodName())) XposedBridge.hookMethod(method, xcMethodHook); } } catch (Throwable ex) { } }
Example 6
Source File: WechatUnrecalledHook600.java From WechatUnrecalled with GNU General Public License v3.0 | 5 votes |
protected void hookDbObject(final ClassLoader loader) { XposedBridge.hookMethod(findConstructorExact(w.storageClass1, loader, w.storageMethod1), new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { mStorageObject = param.thisObject; init(loader); if (mDb == null) { try { mDb = new WechatMainDBHelper(param.args[0]); mNotificationHelper.setDB(mDb); } catch (Throwable t) { log(t); } } } }); // findAndHookConstructor(w.storageClass1, loader, w.storageMethod1, new XC_MethodHook() { // @Override // protected void afterHookedMethod(MethodHookParam param) throws Throwable { // mStorageObject = param.thisObject; // init(loader); // if (mDb == null) { // try { // mDb = new WechatMainDBHelper(param.args[0]); // mNotificationHelper.setDB(mDb); // } catch (Throwable t) { // log(t); // } // } // } // }); }
Example 7
Source File: DebugUtils.java From fuckView with GNU Affero General Public License v3.0 | 5 votes |
/** * Hook某个类的所有方法 */ public static void hookEveryMethods(Class<?> clz, XC_MethodHook methodHook) { Method[] methods = clz.getDeclaredMethods(); for (Method m : methods) { XposedBridge.hookMethod(m, methodHook); } }
Example 8
Source File: PackageManagerServiceHook.java From XposedSmsCode with GNU General Public License v3.0 | 5 votes |
private void hookGrantPermissionsLPw() { Class pmsClass = XposedWrapper.findClass(CLASS_PACKAGE_MANAGER_SERVICE, mClassLoader); Method method; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Android 5.0 + XLog.d("Hooking grantPermissionsLPw() for Android 21+"); method = XposedHelpers.findMethodExact(pmsClass, "grantPermissionsLPw", /* PackageParser.Package pkg */ CLASS_PACKAGE_PARSER_PACKAGE, /* boolean replace */ boolean.class, /* String packageOfInterest */ String.class); } else { // Android 4.4 + XLog.d("Hooking grantPermissionsLPw() for Android 19+"); method = XposedHelpers.findMethodExact(pmsClass, "grantPermissionsLPw", /* PackageParser.Package pkg */ CLASS_PACKAGE_PARSER_PACKAGE, /* boolean replace */ boolean.class); } XposedBridge.hookMethod(method, new MethodHookWrapper() { @Override protected void after(MethodHookParam param) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { grantPermissionsLPwSinceM(param); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { grantPermissionsLPwSinceK(param); } } }); }
Example 9
Source File: PermissionManagerServiceHook.java From XposedSmsCode with GNU General Public License v3.0 | 5 votes |
private void hookGrantPermissions() { XLog.d("Hooking grantPermissions() for Android 28+"); Method method = findTargetMethod(); XposedBridge.hookMethod(method, new MethodHookWrapper() { @Override protected void after(MethodHookParam param) throws Throwable { afterGrantPermissionsSinceP(param); } }); }
Example 10
Source File: HookLoader.java From wechatbot-xposed with Apache License 2.0 | 5 votes |
private void hook_methods(String className, String methodName, XC_MethodHook xmh){ try { Class<?> clazz = Class.forName(className); for (Method method : clazz.getDeclaredMethods()) if (method.getName().equals(methodName) && !Modifier.isAbstract(method.getModifiers()) && Modifier.isPublic(method.getModifiers())) { XposedBridge.hookMethod(method, xmh); } } catch (Exception e) { XposedBridge.log(e); } }
Example 11
Source File: RevokeMsgHook.java From QNotified with GNU General Public License v3.0 | 5 votes |
@Override public boolean init() { if (inited) return true; try { Method revokeMsg = null; for (Method m : _QQMessageFacade().getDeclaredMethods()) { if (m.getReturnType().equals(void.class)) { Class<?>[] argt = m.getParameterTypes(); if (argt.length == 2 && argt[0].equals(ArrayList.class) && argt[1].equals(boolean.class)) { revokeMsg = m; break; } } } XposedBridge.hookMethod(revokeMsg, new XC_MethodHook(-10086) { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { mQQMsgFacade = param.thisObject; if (LicenseStatus.sDisableCommonHooks) return; if (!isEnabled()) return; ArrayList list = (ArrayList) param.args[0]; param.setResult(null); if (list == null || list.isEmpty()) return; for (Object revokeMsgInfo : list) { try { onRevokeMsg(revokeMsgInfo); } catch (Throwable t) { log(t); } } list.clear(); } }); inited = true; return true; } catch (Throwable e) { log(e); return false; } }
Example 12
Source File: ShowPicGagHook.java From QNotified with GNU General Public License v3.0 | 5 votes |
@Override public boolean init() { if (inited) return true; try { Method showPicEffect = null; for (Method m : _TroopPicEffectsController().getDeclaredMethods()) { Class[] argt = m.getParameterTypes(); if (argt.length > 2 && argt[1].equals(Bitmap.class)) { showPicEffect = m; break; } } XposedBridge.hookMethod(showPicEffect, new XC_MethodHook(49) { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (LicenseStatus.sDisableCommonHooks) return; if (!isEnabled()) return; param.setResult(null); } }); inited = true; return true; } catch (Throwable e) { log(e); return false; } }
Example 13
Source File: DarkOverlayHook.java From QNotified with GNU General Public License v3.0 | 5 votes |
@Override public boolean init() { if (inited) return true; try { Method handleNightMask = DexKit.doFindMethod(DexKit.N_BASE_CHAT_PIE__handleNightMask); XposedBridge.hookMethod(handleNightMask, new XC_MethodHook(49) { Field fMask = null; @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { if (LicenseStatus.sDisableCommonHooks) return; if (!isEnabled()) return; if (fMask == null) { DexFieldDescriptor desc = FindNightMask.getNightMaskField(); if (desc == null) { loge("FindNightMask/E getNightMaskField return null"); return; } fMask = desc.getFieldInstance(Initiator.getHostClassLoader()); if (fMask != null) fMask.setAccessible(true); } if (fMask != null) { Object chatPie = param.thisObject; View mask = (View) fMask.get(chatPie); if (mask != null) mask.setVisibility(View.GONE); } } }); inited = true; return true; } catch (Throwable e) { log(e); return false; } }
Example 14
Source File: FakeVipHook.java From QNotified with GNU General Public License v3.0 | 5 votes |
@Override public boolean init() { if (inited) return true; try { Class clz = DexKit.doFindClass(DexKit.C_VIP_UTILS); Method getPrivilegeFlags = null; for (Method m : clz.getDeclaredMethods()) { if (m.getReturnType().equals(int.class)) { Class<?>[] argt = m.getParameterTypes(); if (argt.length == 2 && argt[0].equals(load("mqq/app/AppRuntime")) && argt[1].equals(String.class)) { getPrivilegeFlags = m; break; } } } XposedBridge.hookMethod(getPrivilegeFlags, new XC_MethodHook(-52) { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { int ret; //null is self if (param.args[1] == null) { ret = (int) param.getResult(); param.setResult(4 | ret);//svip } } }); inited = true; return true; } catch (Throwable e) { log(e); return false; } }
Example 15
Source File: PreUpgradeHook.java From QNotified with GNU General Public License v3.0 | 5 votes |
@Override public boolean init() { if (inited) return true; try { for (Method m : _UpgradeController().getDeclaredMethods()) { if (m.getParameterTypes().length != 0) continue; if (Modifier.isStatic(m.getModifiers())) continue; if (!m.getName().equals("a")) continue; if (m.getReturnType().getName().contains("UpgradeDetailWrapper")) { XposedBridge.hookMethod(m, new XC_MethodHook(43) { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { param.setResult(null); } }); break; } } /*Method method1 = getMethod(_BannerManager(), "n", View.class); if (method1 != null) { XposedBridge.hookMethod(method1, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { param.setResult(null); } }); }*/ inited = true; return true; } catch (Throwable e) { log(e); return false; } }
Example 16
Source File: SimpleCheckInHook.java From QNotified with GNU General Public License v3.0 | 4 votes |
@Override public boolean init() { if (inited) return true; try { Method getMsgType = null; for (Method m : DexKit.doFindClass(DexKit.C_ITEM_BUILDER_FAC).getMethods()) { if (m.getReturnType().equals(int.class)) { Class[] argt = m.getParameterTypes(); if (argt.length > 0 && argt[argt.length - 1].equals(load("com.tencent.mobileqq.data.ChatMessage"))) { getMsgType = m; break; } } } XposedBridge.hookMethod(getMsgType, new XC_MethodHook(39) { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { if (LicenseStatus.sDisableCommonHooks) return; try { ConfigManager cfg = ConfigManager.getDefaultConfig(); if (!cfg.getBooleanOrFalse(qn_sign_in_as_text)) return; } catch (Exception ignored) { } int result = (int) param.getResult(); if (result == 71 || result == 84) { param.setResult(-1); } else if (result == 47) { String json = (String) invoke_virtual(iget_object_or_null(param.args[param.args.length - 1], "ark_app_message"), "toAppXml", new Object[0]); if (json.contains("com.tencent.qq.checkin")) { param.setResult(-1); } } } }); inited = true; return true; } catch (Throwable e) { log(e); return false; } }
Example 17
Source File: XposeHookHelperImpl.java From ZjDroid with Apache License 2.0 | 4 votes |
@Override public void hookMethod(Member method, MethodHookCallBack callback) { // TODO Auto-generated method stub XposedBridge.hookMethod(method, callback); }
Example 18
Source File: XposeHookHelperImpl.java From zjdroid with Apache License 2.0 | 4 votes |
@Override public void hookMethod(Member method, MethodHookCallBack callback) { // TODO Auto-generated method stub XposedBridge.hookMethod(method, callback); }
Example 19
Source File: XposeHookHelperImpl.java From HeyGirl with Apache License 2.0 | 4 votes |
@Override public void hookMethod(Member method, MethodHookCallBack callback) { // TODO Auto-generated method stub if(method !=null) XposedBridge.hookMethod(method, callback); }
Example 20
Source File: MuteQZoneThumbsUp.java From QNotified with GNU General Public License v3.0 | 4 votes |
@Override public boolean init() { if (inited) return true; try { Class clz = DexKit.doFindClass(DexKit.C_QZONE_MSG_NOTIFY); Method showQZoneMsgNotification = null; for (Method m : clz.getDeclaredMethods()) { if (m.getReturnType().equals(void.class)) { if (showQZoneMsgNotification == null || m.getParameterTypes().length > showQZoneMsgNotification.getParameterTypes().length) { showQZoneMsgNotification = m; } } } XposedBridge.hookMethod(showQZoneMsgNotification, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (LicenseStatus.sDisableCommonHooks) return; if (!isEnabled()) return; if (MSG_INFO_OFFSET < 0) { Class<?>[] argt = ((Method) param.method).getParameterTypes(); int hit = 0; for (int i = 0; i < argt.length; i++) { if (argt[i].equals(String.class)) { if (hit == 1) { MSG_INFO_OFFSET = i; break; } else { hit++; } } } } String desc = (String) param.args[MSG_INFO_OFFSET]; if (desc != null && (desc.endsWith("赞了你的说说") || desc.endsWith("赞了你的分享"))) { param.setResult(null); } } }); inited = true; return true; } catch (Throwable e) { log(e); return false; } }