hook的函数传入类

简单记录

比如要hook一个app包中一个类的private void c(dmp dmp1),其中dmp是个类,这种的处理的方式如下:

用cydiasubstrate hook框架

1.先通过hook 一个返回context对象的函数,比如SafeApplication类中的public static Context a()获取到context
public static Context a()
{
Invoke.print();
return g;
}

2.构造类dmp

3.Class<?> maClass = Class.forName("dmp", true, Application.cont.getClassLoader()); 


method = clazz.getDeclaredMethod("c", maClass);


Context c = createPackageContext("chroya.demo", Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
Class clazz = c.getClassLoader().loadClass("chroya.demo.Main");

或者Class<?> maClass = Class.forName("com.android.settings.ManageApplications", true, mmsCtx.getClassLoader());

 

http://www.cnblogs.com/Greenwood/archive/2011/04/02/2003803.html
http://blog.chinaunix.net/uid-27024249-id-3284292.html
http://wenku.baidu.com/view/12e5a340336c1eb91a375d9d.html

posted @ 2013-07-30 17:03  yarpee  阅读(340)  评论(0编辑  收藏  举报