【问题标题】:How to deal with custom type class in cydia java hooking?如何处理cydia java hooking中的自定义类型类?
【发布时间】:2015-01-26 08:08:52
【问题描述】:

我正在使用 cydia 基板来挂钩第三方应用程序中的方法,这意味着我无法访问它的源代码。我要挂钩的方法有一个自定义类型参数,如下所示:

methodToHook(com.thirdparty.app.CustomClass param1)

但是要钩住方法,我需要“告诉”cydia这个方法的参数类型,像这样:

MS.hookClassLoad("com.thirdparty.app.CustomClass",
                new MS.ClassLoadHook() {
                   @SuppressWarnings("unchecked")
                public void classLoaded(Class<?> CustomClass) {
                       Log.i("misty", "CustomClassclassLoaded");
                      Constructor constructor1;
                      try {
                          constructor1 = CustomClass.getMethod("CustomClass", CustomClass.class);

那么我怎样才能给它真正的“CustomClass.class”来完成钩子呢?

【问题讨论】:

标签: android hook cydia-substrate


【解决方案1】:

我认为你在 MS.hookClassLoad 调用中走得太深了。

试试这个

MS.hookClassLoad("com.thirdparty.app", new MS.ClassLoadHook() {
    public void classLoaded(Class<?> CustomClass) {
        Method getClass; try {
            getClass = CustomClass.getMethod("getClass", Integer.TYPE);

        } catch (NoSuchMethodException e) {
            getClass = null;
        }

        if (getClass != null) {
            final MS.MethodPointer old = new MS.MethodPointer();

            MS.hookMethod(CustomClass, getClass, new MS.MethodHook() {
                public Object invoked(Object CustomClass, Object... args)
                        throws Throwable
                {

                    int ModifiedValue = (Integer) old.invoke(CustomClass, args);
                    return ModifiedValue & ~0x0000ff00 | 0x00ff0000;
                }
            }, old);
        }
    }
});

com.thirdparty.app 是应用程序
CustomClass 是正在加载的类
getClass 是 CustomClass 中的内部方法。

【讨论】:

    猜你喜欢
    • 2021-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-31
    • 2014-04-09
    • 1970-01-01
    相关资源
    最近更新 更多