tree_fly 发表于 2016-10-10 22:48:29

[Tweak]QQ小尾巴插件Tweak代码更新

本帖最后由 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.
基于文档提供的信息,更新下代码:
/*
* 修改手机类型为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);
}


附上一张小图片:


qinccckencn 发表于 2016-10-10 23:36:43

樹飛哥近來心情好好啊,那麽多産品,謝了

飘云 发表于 2016-10-11 00:28:00

学习了,膜iOS巨神!

orz 发表于 2016-10-11 09:03:56

膜拜。- -虽说I7己经满足不了装逼的需求了。

0xcb 发表于 2016-10-11 09:17:51

羡慕看的懂英文~ 赞一个

ZMZwise 发表于 2016-10-11 09:32:49

谢谢了,膜拜大神啊

cxqdly 发表于 2016-10-11 12:01:47

树飞版主 搞个Android的吧 一起装逼

ahappyboy 发表于 2016-10-11 19:19:25

大牛带我装逼带我飞

hu007 发表于 2016-10-12 07:48:49

谢谢分享了!

眷恋 发表于 2016-10-12 10:58:13

膜拜IOS牛
页: [1] 2
查看完整版本: [Tweak]QQ小尾巴插件Tweak代码更新