1:引用原文代码:
XposedBridge.hookAllConstructors(File.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param)
throws Throwable {
// TODO Auto-generated method stub
super.beforeHookedMethod(param);
if (param.args.length == 1) {
if (param.args[0].equals("/proc/cpuinfo")) {
// 自定义文件的路径
param.args[0] = "/sdcard/Test/cpuinfo";
}
} else if (param.args.length == 2 && !File.class.isInstance(param.args[0])) {
String str = "";
while (i < 2) {
String stringBuilder;
if (param.args[i] != null) {
if (param.args[i].equals("/proc/cpuinfo")) {
param.args[i] = "/sdcard/Test/cpuinfo";
}
stringBuilder = new StringBuilder(String .valueOf(str)).append(param.args[i]) .append(":").toString();
} else {
stringBuilder = str;
}
i++;
str = stringBuilder;
}
}
}
});
File类有4个构造函数 你只能正确HOOK了其中1个 也就是public File(String path)
虽然你拦截了2个参数的构造方法 但是如果使用 new File("/proc/","cpuinfo");这种方式 你的方法根本检测不到 就更不用说其他几种参数类型的构造方法了
附:
public File(File dir, String name)
public File(String path)
public File(String dirPath, String name)
public File(URI uri)
上面的4个构造函数 你原文中的代码能拦截到几个?
2:引用原文代码:
//生成文件夹之后,再生成文件,不然会出错 Mnt.makeFilePath(filePath, fileName);
String strFilePath = filePath+fileName;
// 每次写入时,都换行写 String strContent = "Processor : ARMv7 Processor rev 0 (v7l)" + "\r\n";
String strContent2 = "processor : 0" + "\r\n";
String strContent3 = "BogoMIPS : 38.40";
String strContent4 = "" + "\r\n";
String strContent5 = "" + "\r\n";
String strContent6 = "processor : 1"+ "\r\n";
String strContent7 = "BogoMIPS : 38.40"+ "\r\n";
String strContent8 = ""+ "\r\n";
String strContent9 = "Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt"+ "\r\n";
String strContent10 = "CPU implementer : 0x51"+ "\r\n";
String strContent11 = "CPU architecture: 7"+ "\r\n";
String strContent12 = "CPU variant : 0x2"+ "\r\n";
String strContent13 = "CPU part : 0x06f"+ "\r\n";
String strContent14 = "CPU revision : 0"+ "\r\n";
String strContent15 = ""+ "\r\n";
String strContent16 = "Hardware :MT123 \n"; // 这型号自己随便定义 String strContent17 = "Revision : 000d"+ "\r\n";
String strContent18 = "Serial : 0000088900004e4b"+ "\r\n";
这个功能模块的应用场景不用我再提醒 既然要过检测 你的CPU的各个参数就不可能是写死的 因为大部分厂商对每个机型对应的CPU细节也必然是掌握的
提供给你100个手机对应的CPU型号拿去玩 见附录
4 你改的还不全 至少我依然有很多办法从java层获得CPUINFO 当然 没有人能把所有的检测都堵死 这是事实。但你应该在更底层的角度去考虑 例如11楼说的IoBridge 虽然我也是第一次听说这个比File更底层的方法 但是我敢于承认自己学习上的不足。
5 并不是只有008解决了这个问题 而且你肯定也不是全网唯一 虽然网络上大环境造就了很多标题党 但我建议在一个技术论坛里 无论说什么做什么一定要严谨。
另外 代码运行没问题 不代表没错 Windows Linux MAC 看起来运行也都很流畅 但补丁是永远打不完的 把自己心态放端正 有错误要及时的修正 并引以为戒避免下次出现相同的问题
附 100个机型对应的CPU型号
model,manufacturer,cpu
SM-J3110,samsung,Qualcomm Technologies, Inc MSM8916
SM-N9109W,samsung,Qualcomm APQ8084
GT-I9508,samsung,SAMSUNG JF
SM-N9200,samsung,SAMSUNG Exynos7420
SM-G9250,samsung,SAMSUNG Exynos7420
SM-G9208,samsung,SAMSUNG Exynos7420
Mi-4c,Xiaomi,Qualcomm Technologies, Inc MSM8992
MI NOTE Pro,Xiaomi,Qualcomm Technologies, Inc MSM8994
SM-G9280,samsung,SAMSUNG Exynos7420
MI 2SC,Xiaomi,MI 2
SM-G9198,samsung,Qualcomm Technologies, Inc MSM8992
Redmi Note 2,Xiaomi,MT6795M
SM-G9300,samsung,Qualcomm Technologies, Inc MSM8996
GT-I9507V,samsung,SAMSUNG JF
SM-N9009,samsung,Qualcomm MSM 8974 (Flattened Device Tree)
SM-N9100,samsung,Qualcomm APQ8084
SM-W2015,samsung,Qualcomm MSM8974PRO-AC
GT-I9300,samsung,SMDK4x12
SM-G8508S,samsung,Qualcomm MSM 8974 (Flattened Device Tree)
HM NOTE 1S,Xiaomi,Qualcomm Technologies, Inc MSM8916
Redmi Note 3,Xiaomi,Qualcomm Technologies, Inc MSM8956
2014813,Xiaomi,Qualcomm Technologies, Inc MSM8916
GT-I9152P,samsung,Qualcomm MSM 8226 (Flattened Device Tree)
GT-I9308,samsung,SMDK4x12
SM-N900V,samsung,Qualcomm MSM8974
2014501,Xiaomi,MT6582
2014811,Xiaomi,Qualcomm Technologies, Inc MSM8916
SM-A5000,samsung,Qualcomm Technologies, Inc MSM8916
HM NOTE 1LTE,Xiaomi,Qualcomm MSM 8226 (Flattened Device Tree)
Redmi 3,Xiaomi,Qualcomm Technologies, Inc MSM8939
SM-G5108Q,samsung,Qualcomm Technologies, Inc MSM8916
SM-G3502I,samsung,Qualcomm MSM 8610 (Flattened Device Tree)
SM-A3000,samsung,Qualcomm Technologies, Inc MSM8916
SM-N9108V,samsung,Qualcomm APQ8084
KNT-AL10,HUAWEI,Hisilicon Kirin 950
HUAWEI TAG-TL00,HUAWEI,MT6753T
SM-C101,samsung,SMDK4x12
FRD-AL00,HUAWEI,Hisilicon Kirin 950
EVA-AL10,HUAWEI,Hisilicon Kirin 955
SCL-TL00,HUAWEI,Qualcomm Technologies, Inc MSM8909
HUAWEI RIO-TL00,HUAWEI,Qualcomm MSM 8939 HUAWEI RIO-TL00
HUAWEI TIT-AL00,HUAWEI,MT6735
PLK-TL01H,HUAWEI,Hisilicon Kirin 935
SCH-I959,samsung,UNIVERSAL5410
HUAWEI GRA-CL00,HUAWEI,Hisilicon Kirin 930
HUAWEI GRA-CL10,HUAWEI,Hisilicon Kirin 935
SM-N7508V,samsung,Qualcomm MSM 8226 (Flattened Device Tree)
SM-A9100,samsung,Qualcomm Technologies, Inc MSM8976
SCL-AL00,HUAWEI,Qualcomm Technologies, Inc MSM8909
ATH-AL00,HUAWEI,Qualcomm MSM 8939 HUAWEI ATH-AL00
SM-G7106,samsung,Qualcomm MSM 8226 (Flattened Device Tree)
SM-G5306W,samsung,Qualcomm Technologies, Inc MSM8916
KIW-AL10,HUAWEI,Qualcomm MSM 8939 HUAWEI KIW-AL10
ATH-CL00,HUAWEI,Qualcomm MSM 8939 HUAWEI Athena CL
GT-N7102,samsung,SMDK4x12
SM-G7508Q,samsung,Qualcomm Technologies, Inc MSM8916
PLK-UL00,HUAWEI,Hisilicon Kirin 935
HUAWEI GRA-UL10,HUAWEI,Hisilicon Kirin 935
SM-A9000,samsung,Qualcomm Technologies, Inc MSM8976
SM-G9092,samsung,Qualcomm MSM 8974 (Flattened Device Tree)
SCH-P729,samsung,SAMSUNG MELIUS
HUAWEI RIO-AL00,HUAWEI,Qualcomm MSM 8939 HUAWEI RIO-AL00_VB
SM-A7000,samsung,Qualcomm Technologies, Inc MSM8939
SM-G5308W,samsung,Qualcomm Technologies, Inc MSM8916
HUAWEI GRA-UL00,HUAWEI,Hisilicon Kirin 930
SM-C5000,samsung,Qualcomm Technologies, Inc MSM8952
SM-G6000,samsung,Qualcomm Technologies, Inc MSM8916
GEM-703L,HUAWEI,unknown
SM-C7000,samsung,Qualcomm Technologies, Inc MSM8953
SM-J3109,samsung,Qualcomm Technologies, Inc MSM8916
HUAWEI RIO-UL00,HUAWEI,Qualcomm MSM 8939 HUAWEI RIO-TL00
SM-A5009,samsung,Qualcomm Technologies, Inc MSM8916
SM-G9350,samsung,Qualcomm Technologies, Inc MSM8996
HUAWEI CRR-CL00,HUAWEI,Hisilicon Kirin 935
HUAWEI CRR-UL00,HUAWEI,Hisilicon Kirin 935
ALE-UL00,HUAWEI,hi6210sft
HUAWEI P8max,HUAWEI,Hisilicon Kirin 935
SCL-TL00H,HUAWEI,Qualcomm Technologies, Inc MSM8909
HUAWEI NXT-DL00,HUAWEI,Hisilicon Kirin 950
HUAWEI TIT-TL00,HUAWEI,MT6735
HUAWEI CRR-UL20,HUAWEI,Hisilicon Kirin 935
HUAWEI RIO-CL00,HUAWEI,Qualcomm MSM 8939 HUAWEI RIO-CL00_VB
ATH-UL00,HUAWEI,Qualcomm MSM 8939 HUAWEI ATH-TL00
CHM-TL00,HUAWEI,hi6210sft
H60-L12,HUAWEI,Kirin920
CHM-UL00,HUAWEI,hi6210sft
HUAWEI MT7-UL00,HUAWEI,Kirin925
CHM-CL00,HUAWEI,Qualcomm Technologies, Inc MSM8939
H30-C00,HUAWEI,Qualcomm MSM 8x1x (Flattened Device Tree)
HONOR H30-L02,HUAWEI,hi6620oem
HUAWEI C199s,HUAWEI,Qualcomm Technologies, Inc MSM8939
PE-TL20,HUAWEI,Kirin925
HUAWEI ALE-CL00,HUAWEI,Qualcomm Technologies, Inc MSM8939
HUAWEI MT7-CL00,HUAWEI,Hisilicon Kirin 925
PE-TL10,HUAWEI,Kirin925
CHE-TL00,HUAWEI,hi6210sft
Che1-CL10,HUAWEI,Qualcomm Technologies, Inc MSM8916
HUAWEI MT7-TL00,HUAWEI,Kirin925
PE-CL00,HUAWEI,Kirin925
HUAWEI Y535-C00,HUAWEI,Qualcomm MSM 8610 (Flattened Device Tree)