码迷,mamicode.com
首页 > 其他好文 > 详细

Xposed hook实验小程序

时间:2014-11-27 16:13:16      阅读:1053      评论:0      收藏:0      [点我收藏+]

标签:des   android   style   blog   http   io   ar   color   os   

1、新建安卓工程;

2、libs文件夹下导入xposedbridge的jar包,并libs右键build path;

3、androidmanifest文件配置修改如下(添加几行即可):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.xposedtest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <meta-data
            android:name="xposedmodule"
            android:value="true"/>
        <meta-data
            android:name="xposeddescription"
            android:value="efdetyfdeuf"/>
        <meta-data
            android:name="xposedminversion"
            android:value="54"/>              
    </application>

</manifest>

4、在src文件夹下新建类,书写hook代码,如下:

package com.example.xposedtest;

import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import android.graphics.Color;
import android.widget.TextView;
import de.robv.android.xposed.*;
import de.robv.android.xposed.XC_MethodHook.MethodHookParam;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

public class HookSMS implements IXposedHookLoadPackage{

    @Override
    public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
        // TODO Auto-generated method stub
        if(!lpparam.packageName.equals("com.android.systemui"))
            return;
        findAndHookMethod("com.android.systemui.statusbar.policy.Clock",lpparam.classLoader,"updateClock",
                new XC_MethodHook()
        {

            @Override
            protected void beforeHookedMethod(MethodHookParam param)
                    throws Throwable {
                // TODO Auto-generated method stub
                super.beforeHookedMethod(param);
            }

            @Override
            protected void afterHookedMethod(MethodHookParam param)
                    throws Throwable {
                TextView tv=(TextView)param.thisObject;
                String text=tv.getText().toString();
                tv.setText(text+":)");
                tv.setTextColor(Color.RED);
                

            }
            
        }
                );
    }


}

注意:代码书写时候,接口内重写的函数,右键自动导入即可。

5、在assets文件夹下新建文件,文件内容是hook程序的路径,即com.example.xposedtest.HookSMS

6、总体配置截图如下:

bubuko.com,布布扣

-----------------------------------程序书写配置完毕----------------------------------

Xposed hook实验小程序

标签:des   android   style   blog   http   io   ar   color   os   

原文地址:http://www.cnblogs.com/Shawn1943/p/4126429.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!