xposed开发8- hook微信聊天消息数据库插入操作

xposed开发8- hook微信聊天消息数据库插入操作

// hook微信聊天消息数据库插入操作
hookClass = "com.tencent.wcdb.database.SQLiteDatabase";
hookMethodName = "insertWithOnConflict";
XposedHelpers.findAndHookMethod(hookClass, lpparam.classLoader, hookMethodName, String.class, String.class, ContentValues.class, int.class, new XC_MethodHook() {
    @Override
    protected void afterHookedMethod(MethodHookParam param) throws Throwable {
        String tablename = (String) param.args[0];
        ContentValues contentValues = (ContentValues) param.args[2];
        if (tablename == null || tablename.length() == 0 || contentValues == null) {
            return;
        }
        // 过滤非聊天消息
        if (!tablename.equals("message")) {
            return;
        }
        // 打印日志
        printInsertLog(tablename, (String) param.args[1], contentValues, (Integer) param.args[3]);
    }
});


// 输出插入操作日志
private void printInsertLog(String tableName, String nullColumnHack, ContentValues contentValues, int conflickValue) {
    String[] arrayConflictValues = {
            "",
            " OR ROLLBACK ",
            " OR ABORT ",
            " OR FAIL ",
            " OR IGNORE ",
            " OR REPLACE "
    };
    if (conflickValue < 0 || conflickValue > 5) {
        return;
    }
    XposedBridge.log("hook数据库insert. table: " + tableName
            + "; nullColumnHack: " + nullColumnHack
            + "; conflick values: " + arrayConflictValues[conflickValue]
            + "; nullColumnHack: " + contentValues);
}

xposed开发8- hook微信聊天消息数据库插入操作_第1张图片

你可能感兴趣的:(xposed开发)