本帖最后由 tree_fly 于 2016-10-10 22:48 编辑
之前写的一篇帖子和Tweak,由于不能添加自定义小尾巴,没能让诸位装X的更彻底,闲暇时间更新了代码与大家分享。教你修改QQ手机型号为iPhone6Plushttps://www.chinapyg.com/thread-75886-1-1.html
*OS获取设备信息的函数之一 _sysctlbyname()
苹果官方文档这样写道:
https://developer.apple.com/lega ... sysctlbyname.3.html
The sysctlbyname() function accepts an ASCII representation of the name and internally looks up the
integer name vector. Apart from that, it behaves the same as the standard sysctl() function. For a
list of ASCII representations of commonly used sysctl names, please see sysctl(1).
The information is copied into the buffer specified by oldp. The size of the buffer is given by the
location specified by oldlenp before the call, and that location gives the amount of data copied after
a successful call and after a call that returns with the error code ENOMEM. If the amount of data
available is greater than the size of the buffer supplied, the call supplies as much data as fits in
the buffer provided and returns with the error code ENOMEM. If the old value is not desired, oldp and
oldlenp should be set to NULL.
The size of the available data can be determined by calling sysctl() with the NULL argument for oldp.
The size of the available data will be returned in the location pointed to by oldlenp.
基于文档提供的信息,更新下代码:
[Objective-C] 纯文本查看 复制代码 /*
* 修改手机类型为iPhone7 Plus
* 作者:tree_fly/P.Y.G
*/
#include "substrate.h"
int (*orig_sysctlbyname)(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
int my_sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen){
//skip
if (strcmp(name, "hw.machine") != 0)
return orig_sysctlbyname(name, oldp, oldlenp, newp, newlen);
int ret = orig_sysctlbyname(name, oldp, oldlenp, newp, newlen);
if (oldp == NULL) {
*oldlenp = 50;
// expand the buffer length, as normal is 10
return ret;
}else {
const char *machine = "iРhone7 Рlus 256g(亮黑色)";
strncpy((char *)oldp, machine, strlen(machine) + 1);
//modify the machine content
return ret;
}
}
%ctor {
//hook start
MSHookFunction((void *)MSFindSymbol(NULL,"_sysctlbyname"), (void *)my_sysctlbyname, (void **)&orig_sysctlbyname);
}
附上一张小图片:
|