有没有地方我可以启动MobileSubstrate调整编程? [英] is there anywhere where I could start MobileSubstrate tweaks programming?

查看:119
本文介绍了有没有地方我可以启动MobileSubstrate调整编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里在论坛上搜索后,我发现了一个问题,它重定向了一个教程,给了一些基本的操作SpringBoard与CapitainHook的说明。



开始我想用正常的%钩子做。

解决方案

所以,因为我(希望我)远离一个noob与MobileSubstrate编程现在,并且看到这个问题很受欢迎,我决定创建一个答案,希望简要地介绍您需要了解的主题。



这个小小的介绍适用于任何人对Objective-C 了解很少,并且知道他在做什么。



注意:我会参考theos安装路径为 $ THEOS 。这可以是〜/ theos / var / theos / usr / theos ...是的。



最流行的创建MobileSubstrate扩展的方法也被称为 tweaks href =http://howett.net> Dustin Howett 的 theos构建套件 。详情如下:



什么是theos?



所以, :




  • 操作系统

  • 希腊神

  • 一个编译器



当然,

  • 创建调整,无需您考虑

  • 设置整个建筑环境和/或安装iOS SDK。



  • Theos是用于在不使用Xcode 的情况下管理,开发和部署iOS软件的平台开发工具套件:





    如何安装theos?





    如何使用theos?



    >非常提问,太模糊。由于theos是一整套开发工具,因此要询问如何使用它没有意义,但更具体地说,请问如何使用theos 创建软件。



    首先,请始终拥有 Theos Makefile参考手。它包含了创建一个theos Makefile的基本知识,包括解决你的链接问题,为项目添加框架或私有框架



    ,你可以从头创建自己的Makefile,创建你的小的theos clone / symlink并开始编码,但是theos使这一步更容易。你可以使用 nic.pl



    一个非常简单的运行NIC创建一个例子可以找到< a href =http://iphonedevwiki.net/index.php/Theos/Getting_Started#NIC_Example>此处。



    现在,我们开始回到主题。



    使用theos创建一个tweak



    首先,不要在内部运行NIC $ THEOS / bin 。 NIC将正确创建项目目录,并避免在 $ THEOS / bin 中创建任何项目。



    运行 $ THEOS / bin / nic.pl 并选择 iphone / tweak 模板。除了最后一个字段: MobileSubstrate包过滤器



    由于MobileSubstrate的很大一部分不仅仅是 hooker (用您的方法切换原始方法/函数的库),还有 loader 它让你的钩子被插入到某些进程),你必须提供这些基本信息给装载者知道在哪里加载你的调整。此字段只是要插入此项目的应用程序的绑定标识符。



    com.apple.springboard ,默认选项是SpringBoard的包标识符,应用程序是:




    • iOS主屏幕

    • 常用应用程序的启动器/显示器

    • iOS状态栏




    因此,有许多调整发生的地方,改变行为从一些微不足道的应用程序启动到像整个主屏幕UI



    使用Logos编程tweak



    现在,NIC生成的目录将包含:




    • Theos Makefile ,您将更改与编译相关的信息

    • 控制文件,您将在其中更改与包装相关的信息

    • 符号链接)到 $ THEOS 命名为 theos /

    • 主代码文件 Tweak.xm 。它已经添加到Makefile进行编译,所以你可以立即开始编码!



    在知道该怎么办



    现在,你没有SpringBoard的源代码,你不能猜到什么方法从无处挂钩。因此,您需要一个 SpringBoard标头集。为此,您需要使用一个名为 class-dump-z 的工具,并将其运行到 SpringBoard 是在iOS文件系统中)获取包含所有类声明及其在应用程序中的方法的头文件。



    从这一点(一个猜测和记录一个方法调用涉及)



    当然,如果你不挂钩SpringBoard,你可以使用 class-dump -z ,如在其他二进制文件中,例如 UIKit MobileSafari 等。



    请注意,当反转 App Store应用时,它们将被加密。你需要解密这些(我不幸的是不允许告诉你怎么办),然后只需在它们上运行 class-dump-z



    在获取私有头文件时



    像喜欢的bundle需要私有框架的头文件,在这种情况下,首选项框架的头。否则,你会得到无穷无尽的声明错误(我猜你可以假设)。



    获得他们具有相同的逻辑应用上一步。运行 class-dump-z ,在这种情况下,首选项 $ c> INCLUDEPATH INCLUDEPATH 是编译器将寻找包括 #include< stdio.h> 的头文件。是, stdio.h 位于构建编译器 INCLUDEPATH 的目录之一中。



    使用theos Makefile进行编译时, $ THEOS / include 计入 INCLUDEPATH



    (注意,类转储的头并不总是完美的,所以你'很可能有几个头相关的编译错误,可以很容易地修复与删除 #import 指令或更改它,或添加几个声明。)



    代码提示




    • 您无法链接到SpringBoard,需要使用SpringBoard中的类,您必须使用Logos %c 指令或 objc_getClass code>< objc / runtime.h> 来获取它。示例: [%c(SBUIController)sharedInstance] [objc_getClass(SBUIController)sharedInstance] 。 >
    • 当不知道什么是方法时,或者SpringBoard中有什么工作,请尝试用 IDA 或其他方法反汇编它。我使用 IDA Demo (< - noob!)进行反汇编。

    • 查看示例代码是非常有用的并找出在SpringBoard或其他(再次..)中的东西如何工作。 GitHub上的很多人都会看到这些项目: chpwn 方法更多。

    • 要了解SpringBoard和其他工作(...)的方法,请查看 iPhone Dev Wiki



    结语



    ,哪里是好的部分?我在哪里可以在 Tweak.xm ?中了解编码?



    开始MobileSubstrate调整编程?。您已经完成所有设置,希望所有的标题放置,准备输入 make 并看到您的项目用theos神奇编译。


    $ b $



    Logos参考包含如何钩和使用Logos的其他功能,以及关于devwiki的MobileSubstrate文章也是一个很好的阅读。



    祝你好运。如果有任何疑问,请随时加入 irc.saurik.com #theos IRC频道。这是一个讨论theos相关主题和提出问题的好方法。我大多在那里,连同其他很聪明的人;)


    After a search here on the forum I found a question like that, and it redirected me to a tutorial which gave em some basic instructions on manipulating SpringBoard with CapitainHook.

    To start I'd like to do it with normal %hooks only. Any hint where I could start?

    解决方案

    So, since I (hope I) am far away from a noob with MobileSubstrate programming now, and saw this question as quite popular, I decided to create an answer covering everything you need to know about the subject hopefully briefly.

    This little introduction is meant for whoever has a minimal knowledge on Objective-C and knows what he is doing.

    NOTE: I will refer to the theos install path as $THEOS. This could be ~/theos, /var/theos, /usr/theos... Yeah.

    The most popular way of creating MobileSubstrate extensions, also known as tweaks, is using Dustin Howett's theos build suite. Details follow:

    What is theos?

    So, we should start with what theos is not:

    • The Operating System
    • A Greek God
    • A compiler

    And of course, what theos doesn't do:

    • Teaches you how to code.
    • Creates tweaks without having you to think
    • Sets up a whole building environment and/or installs the iOS SDK.

    Theos is a cross-platform suite of development tools for managing, developing, and deploying iOS software without the use of Xcode, featuring:

    • A robust build system driven by GNU Make, which makes its Makefiles easily deployable through everywhere with theos installed too.

    • NIC, a project templating system which creates ready-to-build empty projects for varying purposes.

    • Logos, a built-in preprocessor-based library of directives designed to make MobileSubstrate extension development easy and with optimal code generation.

    • Automated packaging: Theos is capable of directly creating DEB packages for distribution in Cydia, the most popular mean of package distribution in the jailbreak scene.

    How to install theos?

    • On OSX: Have the iOS SDK installed and follow these instructions.
    • On iOS: Install the BigBoss Recommended Tools package from Cydia and run installtheos3.
    • On Linux: Find a mean to have the toolchain installed, and follow these instructions.
    • On Windows: Nothing is impossible, but if you actually manage to do so, please let me know. :P

    How to use theos?

    This is a very asked question and too vague. Since theos is a whole suite of development tools, it doesn't make sense to ask How to use it, but more specifically, to ask How to create software using theos.

    First of all, always have the Theos Makefile Reference in hand. It covers the basics of creating a theos Makefile, and that includes solving your linking issues adding a framework or private framework to the project.

    Now, you can either create your own Makefile from scratch, create your little theos clone/symlink and start coding, but theos makes this step easier. You can just use nic.pl.

    A very simple example of running NIC to create something can be found here. It's very straight-forward and sets you up right-away for programming.

    Now, here's where we start getting back to topic.

    Creating a tweak with theos

    First of all, do not run NIC when inside $THEOS/bin. NIC will create the project directory exactly where you're running it from, and it avoids any project being created in $THEOS/bin. Therefore, you'll end up with a simple error which can be avoided by creating the project directory somewhere decent.

    Run $THEOS/bin/nic.pl and choose the iphone/tweak template. You will be prompted by simple information which you may well know well how to answer, except for the last field: MobileSubstrate bundle filter.

    Since a big part of MobileSubstrate is not just the hooker (the library which switches original methods/functions with yours), but also the loader (the part which gets your hooking to be inserted into certain processes), you have to supply this basic information for the Loader to know where to load your tweak. This field is but the bundle identifier for the application where this project will be inserted.

    com.apple.springboard, the default option is the bundle identifier for SpringBoard, the application which is:

    • The iOS Homescreen
    • The launcher/displayer of common applications
    • The iOS Status Bar
    • Handler of some high-level essential background processes

    Therefore, there's where many tweaks take place, altering behavior from something as trivial as app launching to something like how the whole homescreen UI looks like.

    Programming a tweak with Logos

    Now, the directory generated by NIC will contain:

    • The Theos Makefile, where you'll change information related to compiling
    • The control file, where you'll change packaging-related information
    • A symbolic link (or shortcut) to $THEOS named theos/
    • The main code file, defaulted as Tweak.xm. It is already added to the Makefile for compiling, so you can start coding right-away with it!

    On knowing what to do

    Now, you don't have SpringBoard's source code laying around, and you can't guess what methods to hook from nowhere. Therefore, you need a SpringBoard header set. For that, you need to use a tool named class-dump-z and run it into the SpringBoard binary (which is inside the iOS filesystem) to obtain header files including all class declarations and its methods inside the application.

    From that (a deal of guessing and logging a method call is involved) you can start messing around with what you want in a tweak.

    Of course, if you are not hooking SpringBoard you can use class-dump-z as you would in other binaries, such as UIKit, MobileSafari, etc.

    Note that for when reversing App Store apps, they'll be encrypted. You'll need to decrypt those (I am unfortunately not allowed to tell you how-to), and then just run class-dump-z on them.

    On obtaining private headers

    Stuff like preference bundles require the headers for private frameworks, in that case the Preferences framework's headers. Else you'll get endless missing declaration errors (as I guess you could assume).

    Getting them has the same logic applied the previous step. Run class-dump-z on, at this case, the Preferences binary and throw the headers at your INCLUDEPATH. The INCLUDEPATH is where the compiler will go looking for headers you include like #include <stdio.h>. Yes, stdio.h is inside one of the directories which build a compiler's INCLUDEPATH!

    When compiling with a theos Makefile, $THEOS/include counts as part of your INCLUDEPATH, which means, you can just throw your dumped headers over there and include them later.

    (Note that class-dumped headers aren't always perfect, so you're likely to have a couple of header-related compilation errors which can be easily fixed with something like removing a #import directive or changing it, or adding a couple of declarations.)

    Code tips

    • You can't link against SpringBoard, so whenever you require a class from SpringBoard you have to use either the Logos %c directive or the objc_getClass function, as defined at <objc/runtime.h> to get it. Example: [%c(SBUIController) sharedInstance], [objc_getClass("SBUIController") sharedInstance].
    • When not knowing what a method does or how something works in SpringBoard, try disassembling it with IDA or others. I use IDA Demo (<- noob!) for my disassembling.
    • Looking at example code is amazingly helpful for both learning and figuring out how something works inside SpringBoard or others (again..). Great people at GitHub to have a projects looked at are rpetrich, chpwn, DHowett, EvilPenguin, and of course way more.
    • To also find about how SpringBoard and other works (...), have a look at a class's article at the iPhone Dev Wiki!

    Epilogue

    Wait, where's the good part? Where do I learn about coding in Tweak.xm?

    Well, the original question was actually How to start MobileSubstrate tweaks programming?. You're all setup, hopefully with all headers placed, ready to type in make and see your project magically compiled with theos.

    All you need to do is now to actually dig into your headers or your disassembly and go hooking, calling, etc.!

    Logos Reference contains exactly how to hook and use other features of Logos, and the MobileSubstrate article on the devwiki is also a great read.

    Good luck. And in case there is any doubt, don't hesitate joining the irc.saurik.com #theos IRC channel. It's a great way to discuss theos-related topics and ask questions. I'm mostly there, along with other greatly smart people ;)

    这篇关于有没有地方我可以启动MobileSubstrate调整编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆