有没有办法以编程方式将我的iPhone恢复到出厂设置? [英] Is there a way to programatically restore my iphone to factory settings?

查看:204
本文介绍了有没有办法以编程方式将我的iPhone恢复到出厂设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个越狱应用程序,我不在乎它是否被应用商店拒绝。我找到了一种方法用这种方式完全消灭我的iphone 有没有办法以编程方式完全消灭iPhone数据?。这个方法存在问题但是,它使我的iphone毫无价值,我必须使用iTunes恢复它。
我只是想以编程方式恢复我的iphone。任何人都可以帮助我吗?

I am developing for a jailbroken app and I dont care if its rejected by the app store.I have found a way to completely wipe out my iphone using this way Is there a way to completely wipe out iPhone data programatically? .There is a problem with this method however.It makes my iphone worthless and I have to recover it using itunes. I just want to factory restore my iphone programatically.Can anybody help me ?

推荐答案

有一个私有API SBDataReset在SpringboardServices私有框架中。它会擦除所有数据。

There is a private API SBDataReset in SpringboardServices private framework. It wipes all data.

您可以查看以下代码,例如如何使用它。

You can check the following code for example how to use it.

使用此API的应用程序应具有com.apple.springboard。 wipedevice工作的权利。

An application which uses this API should have "com.apple.springboard.wipedevice" entitlement to work.

BTW。另一种选择是使用MDM协议。它有一个擦除命令。但是,它需要更多的机器(MDM服务器,注册用户)。

BTW. One more alternative is to use MDM protocol. It has a wipe command. However, it requires way more machinery (MDM server, enroll a user).

它看起来像链接中的示例代码是日期。我查看了首选项以及其他一些使用SBDataReset的iOS软件,看起来新的参数被引入SBDataReset。

It looks like sample code in the link is out date. I looked into Preferences and couple of other pieces of iOS software which uses SBDataReset and it looks like new argument was introduced to SBDataReset.

尝试以下代码(对不起,我不知道)现在已经越狱了iOS设备,所以我不能自己尝试)

Try following code (sorry, I don't have jailbroken iOS device right now, so I can't try it on my own)

#import <UIKit/UIKit.h>
#import <UIKit/UIApplication.h>
#include <dlfcn.h>
#include <stdio.h>

// Framework Paths
#define SBSERVPATH "/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices"
#define UIKITPATH "/System/Library/Framework/UIKit.framework/UIKit"

#define WIPE_MODE_NORMAL 4

int main(int argc, char **argv)
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    // Fetch the SpringBoard server port
    mach_port_t *p;
    void *uikit = dlopen(UIKITPATH, RTLD_LAZY);
    int (*SBSSpringBoardServerPort)() = 
    dlsym(uikit, "SBSSpringBoardServerPort");
    p = SBSSpringBoardServerPort(); 
    dlclose(uikit);

    // Getting DataReset proc
    void *sbserv = dlopen(SBSERVPATH, RTLD_LAZY);
    int (*dataReset)(mach_port_t* port, int wipeMode) = dlsym(sbserv, "SBDataReset");
    dataReset(p, WIPE_MODE_NORMAL);
    dlclose(sbserv);

    [pool release];
}

请注意,SBDataReset函数有第二个参数。

Please notice, that there is second parameter for SBDataReset function.

看起来4是正常的擦除模式,6是砖块擦除模式。

It looks like 4 is normal wipe mode and 6 is brick wipe mode.

免责声明此代码按原样提供。我不知道如果在砖块模式下擦除设备将会发生什么。

DISCLAIMER This code is provided AS IS. I have no idea what will happen if device will be wiped in brick mode.

这篇关于有没有办法以编程方式将我的iPhone恢复到出厂设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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