IOS越狱开发环境搭建

1:安装 mac ports

2:安装DPKG, 在终端输入sudo port -f install dpkg即可安装

 

3:安装theos

 

Theos是一个基于Make的编译环境,我们正是用它来编译生成deb文件的。

 

从该网站下载https://github.com/DHowett/theos,然后解压到你的保存目录下。

 

配置环境变量   export THEOS = /opt/theos 参考第5步的配置变量方法

 

4: 下载安装IOSOpenDev,

安装失败可以参考https://github.com/kokoabim/iOSOpenDev/wiki/Troubleshoot

 

5:还不能正常编译,你需要动态编译环境才能正常编译你的工程

可以参考这篇文章 https://github.com/kokoabim/iOSOpenDev/wiki/Setup-Explained

 

6:在你的手机设备安装OpenSSH

 

然后就可以建工程,

 

 

 

为了方便的调试,还要在工程里设置一些参数.这里介绍下这些参数的意义.首先打开程序设置TARGETS里的工程

 

  1. iOSOpenDevCopyOnBuild 布尔值YES/NO 默认是NO,是否把生成的可执行文件拷贝到/var/root/iOSOpenDevBuilds/[project name]/[executable name] 路径下.是为了方便那些远程SSH控制的程序,可能暂时用不到.
  2. iOSOpenDevDevice 设置你设备的IP.
  3. iOSOpenDevInstallOnProfiling 布尔值 默认为YES, 是否在build for profiling的时候直接远程安装到设备上.
  4. iOSOpenDevPath 不要修改此项,是iOSOpenDev的安装路径.
  5. iOSOpenDevRespringOnInstall 布尔值 默认为YES,是否在安装后重启SpringBoard.
  6. iOSOpenDev默认安装在/opt/iOSOpenDev里,在里面可以找到undocument api的头文件.

    编译的时候不能像正常的App点Run,点击Product->Build For->Build For Profiling.配置好上面的设备IP,程序会自动安装到设备里.

 

 

 

在privateFrameworks 下,苹果明确申明不能使用的API

 

class-dump可以从编译后的Objective-C的二进制文件中提取对应的数据结构及函数等声明

 

 

DumpFrameworks.pl是一个脚本,会在你的主目录下生成private的.h文件

 

DumpFrameworks.pl下载地址:http://ericasadun.com/HeaderDumpKit/

 

用法:
1 将下载好的 class-dump 放入usr/local/bin 下. 
2 将DumpFrameworks.pl 放入任意目录下.同样需要修改执行权限.
3. OK..现在所有的准备工作作好了. 我们在 terminal 的任意目录下 输入 : ./DumpFrameworks.pl
有一个Heards 文件夹在你的主目录下. 里面包含了 Frmeworks 和 privateFrameworks 下所有的私有 API

导出的时候注意一下SpringBoard的路径,这里导出ios5.0的如下:

class-dump -H /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/CoreServices/SpringBoard.app -o /Users/x/Desktop/SpringBoard

执行完命令之后就会生成.h文件了

然后把头文件拷贝到

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/include/SpringBoard/

并将substrate.h移动到/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/include/目录下

substrate.h文件的代码如下:

 

 1 #ifndef SUBSTRATE_H_
 2 #define SUBSTRATE_H_
 3 
 4 #ifdef __cplusplus
 5 extern "C" {
 6 #endif
 7 #include <mach-o/nlist.h>
 8 #ifdef __cplusplus
 9 }
10 #endif
11 
12 #include <objc/runtime.h>
13 //#include <objc/message.h>
14 #include <dlfcn.h>
15 
16 #ifdef __cplusplus
17 #define _default(value) = value
18 #else
19 #define _default(value)
20 #endif
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25     
26     void MSHookFunction(void *symbol, void *replace, void **result);
27     IMP MSHookMessage(Class _class, SEL sel, IMP imp, const char *prefix _default(NULL));
28     
29 #ifdef __cplusplus
30 }
31 #endif
32 
33 #ifdef __cplusplus
34 
35 template <typename Type_>
36 static inline Type_ *MSHookMessage(Class _class, SEL sel, Type_ *imp, const char *prefix = NULL) {
37     return reinterpret_cast<Type_ *>(MSHookMessage(_class, sel, reinterpret_cast<IMP>(imp), prefix));
38 }
39 
40 template <typename Type_>
41 static inline void MSHookFunction(Type_ *symbol, Type_ *replace, Type_ **result) {
42     return MSHookFunction(
43                           reinterpret_cast<void *>(symbol),
44                           reinterpret_cast<void *>(replace),
45                           reinterpret_cast<void **>(result)
46                           );
47 }
48 
49 template <typename Type_>
50 static inline void MSHookFunction(Type_ *symbol, Type_ *replace) {
51     return MSHookFunction(symbol, replace, reinterpret_cast<Type_ **>(NULL));
52 }
53 
54 template <typename Type_>
55 static inline void MSHookSymbol(Type_ *&value, const char *name, void *handle) {
56     value = reinterpret_cast<Type_ *>(dlsym(handle, name));
57 }
58 
59 template <typename Type_>
60 static inline Type_ &MSHookIvar(id self, const char *name) {
61     Ivar ivar(class_getInstanceVariable(object_getClass(self), name));
62     void *pointer(ivar == NULL ? NULL : reinterpret_cast<char *>(self) + ivar_getOffset(ivar));
63     return *reinterpret_cast<Type_ *>(pointer);
64 }
65 
66 #endif
67 
68 #define MSHook(type, name, args...) \
69 static type (*_ ## name)(args); \
70 static type $ ## name(args) \
71 
72 #define Foundation_f "/System/Library/Frameworks/Foundation.framework/Foundation"
73 #define UIKit_f "/System/Library/Frameworks/UIKit.framework/UIKit"
74 #define JavaScriptCore_f "/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore"
75 #define IOKit_f "/System/Library/Frameworks/IOKit.framework/IOKit"
76 
77 #endif//SUBSTRATE_H_

 

然后把网上下载的libsubstrate.dylib复制到:

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/

目录下。

导入完成,剩下的就是在工程中加入libsubstrate.dylib,引入头文件了。

 

posted @ 2013-12-08 10:45  wangzhenxiang  阅读(577)  评论(0编辑  收藏  举报