0

我正在使用 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”来完成钩子呢?

4

1 回答 1

0

我认为你在 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 中的内部方法。

于 2015-04-02T12:23:55.750 回答