0

I'm using cydia substrate to hook a method in a third party app, which means I have no access to the source code of it. The method I want to hook has a custom type parameter, like this :

methodToHook(com.thirdparty.app.CustomClass param1)

But to hook the method, I need to "tell" cydia the parameters' type of this method, like this:

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);

So how could I give it the real "CustomClass.class" to complete the hook?

Misty Zhu
  • 83
  • 2
  • 7

1 Answers1

0

I think you have gone one level too deep in your MS.hookClassLoad call.

Try this

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);
        }
    }
});

Where com.thirdparty.app is the Application
and CustomClass is the Class being loaded
and getClass is the internal Method within CustomClass.

guyver4mk
  • 609
  • 6
  • 11