function bytesToString(arr) {
var str = '';
arr = new Uint8Array(arr);
for (var i in arr) {
str += String.fromCharCode(arr[i]);
}
return str;
}
var Color = {
RESET: "\x1b[39;49;00m", Black: "0;01", Blue: "4;01", Cyan: "6;01", Gray: "7;11", Green: "2;01", Purple: "5;01", Red: "1;01", Yellow: "3;01",
Light: {
Black: "0;11", Blue: "4;11", Cyan: "6;11", Gray: "7;01", Green: "2;11", Purple: "5;11", Red: "1;11", Yellow: "3;11"
}
};
var LOG = function (input, kwargs) {
kwargs = kwargs || {};
var logLevel = kwargs['l'] || 'log', colorPrefix = '\x1b[3', colorSuffix = 'm';
if (typeof input === 'object')
input = JSON.stringify(input, null, kwargs['i'] ? 2 : null);
if (kwargs['c'])
input = colorPrefix + kwargs['c'] + colorSuffix + input + Color.RESET;
console[logLevel](input);
};
var printStack = function () {
Java.perform(function() {
var android_util_Log = Java.use('android.util.Log'), java_lang_Exception = Java.use('java.lang.Exception');
// getting stacktrace by throwing an exception
LOG(android_util_Log.getStackTraceString(java_lang_Exception.$new()), { c: Color.Gray });
});
};
function getFieldValue(obj, fieldName) {
var cls = obj.getClass();
var field = cls.getDeclaredField(fieldName);
field.setAccessible(true);
var name = field.getName();
var value = field.get(obj);
// console.log("field: " + field + "\tname:" + name + "\tvalue:" + value);
return value;
}
function getReflectFields(val1) {
var clazz = Java.use("java.lang.Class");
var parametersTest = Java.cast(val1.getClass(),clazz);
//getDeclaredFields()获取所有字段
var fields = parametersTest.getDeclaredFields();
fields.forEach(function (field) {//依次打印字段的类型、名称、值
var type =field.getType();
var name =field.getName();
var value =field.get(val1);
console.log(`name:${name},value:${value}`)
})
}
function arrayListToString(arrayList) {
for (var i = 0; i < arrayList.size(); i++) {
var item = arrayList.get(i);
getReflectFields(item)
}
}
let RichMediaServiceImpl = Java.use("com.tencent.qqnt.msg.api.impl.RichMediaServiceImpl");
RichMediaServiceImpl["downloadFileForFileInfo"].implementation = function (fileInfoList, savePath) {
printStack();
console.log(`RichMediaServiceImpl.downloadFileForFileInfo is called: fileInfoList1=${arrayListToString(Java.cast(fileInfoList, Java.use("java.util.ArrayList")))}, savePath=${savePath}`);
this["downloadFileForFileInfo"](fileInfoList, savePath);
};