作者:creantan 小葡萄爸爸
1、hook sysctlbyname底层函数,此种方法比较通用、可以修改任意App的设备信息的显示
实现代码如下:
int (*orig_sysctlbyname)(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
int mysysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen){
if (strcmp(name,"hw.machine") == 0) {
if (oldp != NULL) {
int ret = orig_sysctlbyname(name,oldp,oldlenp,newp,newlen);
const char* mechine = "iWatch Edition";
strncpy((char *)oldp,mechine,strlen(mechine));
return ret;
}else{
int ret = orig_sysctlbyname(name,oldp,oldlenp,newp,newlen);
return ret;
}
}else{
return orig_sysctlbyname(name,oldp,oldlenp,newp,newlen);
}
}
%ctor {
MSHookFunction((void *)MSFindSymbol(NULL,"_sysctlbyname"), (void *)mysysctlbyname, (void **)&orig_sysctlbyname);
}
2.NSUserDefaults值修改,只试用于QQ
cycript -p QQ_PID #使用cycript工具
[[NSUserDefaults standardUserDefaults] setObject:@"iWatch Edition" forKey:@"_QQ号_strDeviceName"]