Skip to content

Commit

Permalink
fix for older xposed version (lower than 54)
Browse files Browse the repository at this point in the history
  • Loading branch information
fkzhang committed Feb 10, 2016
1 parent 6ed2e59 commit 1b64c2c
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.fkzhang.wechatunrecalled"
minSdkVersion 14
targetSdkVersion 23
versionCode 18
versionName "1.4.6"
versionCode 19
versionName "1.4.61"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.fkzhang.wechatunrecalled.WechatPackageNames;

import java.io.File;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
Expand All @@ -38,7 +39,6 @@

import static de.robv.android.xposed.XposedHelpers.callMethod;
import static de.robv.android.xposed.XposedHelpers.callStaticMethod;
import static de.robv.android.xposed.XposedHelpers.findAndHookConstructor;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.findClass;
import static de.robv.android.xposed.XposedHelpers.getObjectField;
Expand Down Expand Up @@ -75,6 +75,26 @@ public WechatUnrecalledHook(WechatPackageNames packageNames) {
mNotificationHelper = new NotificationHelper(packageNames);
}

public static void findAndHookConstructor(String className, ClassLoader classLoader, Object... parameters) {
Class<?> cls = findClass(className, classLoader);
Class<?>[] parameterTypes = new Class[parameters.length - 1];
for (int i = 0; i < parameters.length - 1; i++) {
if (parameters[i] instanceof String) {
parameterTypes[i] = findClass((String) parameters[i], classLoader);
} else if (parameters[i] instanceof Class) {
parameterTypes[i] = (Class<?>) parameters[i];
}
}
try {
Constructor<?> constructor = cls.getDeclaredConstructor(parameterTypes);
constructor.setAccessible(true);
XC_MethodHook callback = (XC_MethodHook) parameters[parameters.length - 1];
XposedBridge.hookMethod(constructor, callback);
} catch (Throwable t) {
XposedBridge.log(t);
}
}

public void hook(final ClassLoader loader) {
try {
hookRecall(loader);
Expand Down Expand Up @@ -116,6 +136,7 @@ public void hook(final ClassLoader loader) {
} catch (Throwable t) {
XposedBridge.log(t);
}

}

protected void hookRecall(final ClassLoader loader) {
Expand Down Expand Up @@ -348,7 +369,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

protected void hookDbObject(final ClassLoader loader) {
// get database object
XposedHelpers.findAndHookConstructor(w.storageClass1, loader,
findAndHookConstructor(w.storageClass1, loader,
w.storageMethod1, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Expand Down Expand Up @@ -549,7 +570,6 @@ public void onComplete(Bitmap bitmap) {
cursor.close();
mDb.insertSystemMessage(talker, talkerId, replacemsg, createTime + 1);
updateMessageCount();

} catch (Throwable t) {
XposedBridge.log(t);
}
Expand Down Expand Up @@ -870,18 +890,6 @@ protected void init(ClassLoader loader) {

}


protected void unsetSnsDeleteFlag(ContentValues v) {
Object contentObject = mSnsDb.decodeBlob(mSnsContentClass, v.getAsByteArray("content"));
if (contentObject == null)
return;

String content = WechatSnsDBHelper.removeDeletedTag(mSnsDb.getSnsContent(contentObject));
setObjectField(contentObject, w.snsContentField, content);
v.put("content", WechatSnsDBHelper.encodeContentBlob(contentObject));
mSnsDb.update("SnsInfo", v, "snsId = ?", new String[]{v.getAsString("snsId")});
}

protected void setSnsDeleteFlag(ContentValues v) {
Object contentObject = mSnsDb.decodeBlob(mSnsContentClass, v.getAsByteArray("content"));
if (contentObject == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import static de.robv.android.xposed.XposedHelpers.callMethod;
import static de.robv.android.xposed.XposedHelpers.callStaticMethod;
import static de.robv.android.xposed.XposedHelpers.findAndHookConstructor;
import static de.robv.android.xposed.XposedHelpers.findConstructorExact;

/**
* Created by fkzhang on 1/16/2016.
Expand Down Expand Up @@ -89,21 +89,38 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}

protected void hookDbObject(final ClassLoader loader) {
findAndHookConstructor(w.storageClass1, loader, w.storageMethod1, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mStorageObject = param.thisObject;
init(loader);
if (mDb == null) {
try {
mDb = new WechatMainDBHelper(param.args[0]);
mNotificationHelper.setDB(mDb);
} catch (Throwable t) {
log(t);
XposedBridge.hookMethod(findConstructorExact(w.storageClass1, loader, w.storageMethod1),
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mStorageObject = param.thisObject;
init(loader);
if (mDb == null) {
try {
mDb = new WechatMainDBHelper(param.args[0]);
mNotificationHelper.setDB(mDb);
} catch (Throwable t) {
log(t);
}
}
}
}
}
});
});

// findAndHookConstructor(w.storageClass1, loader, w.storageMethod1, new XC_MethodHook() {
// @Override
// protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// mStorageObject = param.thisObject;
// init(loader);
// if (mDb == null) {
// try {
// mDb = new WechatMainDBHelper(param.args[0]);
// mNotificationHelper.setDB(mDb);
// } catch (Throwable t) {
// log(t);
// }
// }
// }
// });
}

protected void updateMessageCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import com.fkzhang.wechatunrecalled.WechatPackageNames;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;

import static de.robv.android.xposed.XposedHelpers.findAndHookConstructor;
import static de.robv.android.xposed.XposedHelpers.findConstructorExact;

/**
* Created by fkzhang on 1/16/2016.
Expand All @@ -17,8 +18,9 @@ public WechatUnrecalledHook602_58(WechatPackageNames packageNames) {
}

protected void hookDbObject(final ClassLoader loader) {
findAndHookConstructor(w.storageClass1, loader, w.storageMethod1,
w.packageName + ".storage.am", w.packageName + ".storage.an", new XC_MethodHook() {
XposedBridge.hookMethod(findConstructorExact(w.storageClass1, loader, w.storageMethod1,
w.packageName + ".storage.am", w.packageName + ".storage.an"),
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
mStorageObject = param.thisObject;
Expand All @@ -33,6 +35,23 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
}
});

// findAndHookConstructor(w.storageClass1, loader, w.storageMethod1,
// w.packageName + ".storage.am", w.packageName + ".storage.an", new XC_MethodHook() {
// @Override
// protected void afterHookedMethod(MethodHookParam param) throws Throwable {
// mStorageObject = param.thisObject;
// init(loader);
// if (mDb == null) {
// try {
// mDb = new WechatMainDBHelper(param.args[0]);
// mNotificationHelper.setDB(mDb);
// } catch (Throwable t) {
// log(t);
// }
// }
// }
// });
}

}
3 changes: 2 additions & 1 deletion app/src/main/res/layout-v17/item_support.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:paddingBottom="125dp" />

</LinearLayout>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_support.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:paddingBottom="125dp" />

</LinearLayout>

0 comments on commit 1b64c2c

Please sign in to comment.