首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何研究iDevice?

如何研究iDevice?
EN

Stack Overflow用户
提问于 2012-11-08 06:14:01
回答 1查看 3.5K关注 0票数 3

我正在尝试做一个应用程序,以重新启动和重启任何iDevice。我的代码在iOS模拟器中运行良好,但是在我的iDevice上什么也没有发生(是的,它被越狱了)。

下面是我的呼吸代码:

代码语言:javascript
复制
        if(system("killall SpringBoard"));

        if(system("killall -9 SpringBoard"));

        if (system([@ "reboot" UTF8String]));

        if ([[[UIDevice currentDevice] systemVersion] hasPrefix:@"2."])
            notify_post("com.apple.language.changed");

        if (system([@ "killall SpringBoard" UTF8String]));

下面是我的重启代码:

代码语言:javascript
复制
if (system([@ "reboot" UTF8String]));

respring只工作一次,然后停止工作:(

我的脚本:

代码语言:javascript
复制
#!/bin/sh

#  Script.sh
#  Respring
#
#  Created by David on 08.11.12.
#  Copyright (c) 2012 David. All rights reserved.

app binary - root:wheel 4755

script - root:wheel 0755

C=/${0}
C=${C%/*}
declare -a flags
[[ :${DYLD_INSERT_LIBRARIES}: == */MobileSubstrate.dylib: ]] && flags[${flags[@]}]=--substrate
exec "${C:-.}"/Respring "${flags[@]}" -- "$@" 2>>/tmp/Respring.log

这是我的alertView,用于在呼吸不起作用时使用BugReport重新启动和重新启动

代码语言:javascript
复制
//Respring

-(IBAction)respring {

    UIAlertView *respring=[[UIAlertView alloc]initWithTitle:@"Respring"
                                                     message:@"Do you want to respring your iDevice?"
                                                    delegate:self
                                           cancelButtonTitle:@"No"
                                           otherButtonTitles:@"Yes", nil];
    respring.tag = 1;       
    [respring show];
}


//AlertView   
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 1){            
        if (alertView.tag ==1) {            
            setuid(0); system("killall i5MMS_");                

            UIAlertView *respringerror=[[UIAlertView alloc]initWithTitle:@"Error"
                                                                message:@"Respring is not possible, please send me an Bug Report."
                                                               delegate:self
                                                      cancelButtonTitle:@"OK"
                                                      otherButtonTitles:@"Send Bug Report",nil];                
                respringerror.tag = 3;                
                [respringerror show];                
        }

        if (alertView.tag ==2) {                
            if (system([@ "reboot" UTF8String]));

            UIAlertView *respringerror=[[UIAlertView alloc]initWithTitle:@"Error"
                                                                 message:@"Rebooting is not possible, please send me an Bug Report."
                                                                delegate:self
                                                       cancelButtonTitle:@"OK"
                                                       otherButtonTitles:@"Send Bug Report", nil];

            respringerror.tag = 4;                
            [respringerror show];            
        }                

    if (alertView.tag ==3) {            
        iDevice.text = [UIDevice currentDevice]. model;            
        ios.text = [UIDevice currentDevice]. systemVersion;            
        MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];            
        [composer setMailComposeDelegate:self];            
        if ([MFMailComposeViewController canSendMail]) {                
            [composer setToRecipients:[NSArray arrayWithObjects:@"david.goelzhaeuser@me.com", nil]];                
            [composer setSubject:@"Bug Report"];                
            [composer setMessageBody: [NSString stringWithFormat: @"%@ \n%@ \n%@", ios.text,iDevice.text, jailbreakstatus.text]isHTML:NO];                
            [composer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];                
            [composer setModalPresentationStyle:UIModalPresentationFormSheet];                
            [self presentModalViewController:composer animated:YES];
        }

    }

    if (alertView.tag ==4) {

        iDevice.text = [UIDevice currentDevice]. model;            
        ios.text = [UIDevice currentDevice]. systemVersion;            
        MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];            
        [composer setMailComposeDelegate:self];    
        if ([MFMailComposeViewController canSendMail]) {                
            [composer setToRecipients:[NSArray arrayWithObjects:@"david.goelzhaeuser@me.com", nil]];                
            [composer setSubject:@"Bug Report"];
            [composer setMessageBody: [NSString stringWithFormat: @"%@ \n%@ \n%@", ios.text,iDevice.text, jailbreakstatus.text]isHTML:NO];                
            [composer setModalTransitionStyle:UIModalTransitionStyleCoverVertical];                
            [composer setModalPresentationStyle:UIModalPresentationFormSheet];                
            [self presentModalViewController:composer animated:YES];
        }


        }
    }
}


//Reboot

-(IBAction)reboot;{        
    UIAlertView *reboot=[[UIAlertView alloc]initWithTitle:@"Reboot"
                                                    message:@"Do you want to reboot your iDevice? If you have a tethered jailbreak you have to make a tethered boot after rebooting!"
                                                    delegate:self
                                                    cancelButtonTitle:@"No"
                                                    otherButtonTitles:@"Yes", nil];

    reboot.tag = 2;        
    [reboot show];        
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-08 13:10:20

示例

我将我的应用程序命名为Respring

在我的应用程序代码中,我有一个RespringViewController.hRespringViewController.m

ResringViewController.h中,我将添加一个按钮来调用我的respring操作。

代码语言:javascript
复制
#import <UIKit/UIKit.h>

@interface RespringViewController : UIViewController
//Creates the button
- (IBAction) respring:(id)sender;

@end

现在在RespringViewController.m内部

代码语言:javascript
复制
#import "RespringViewController.h"

@interface RespringViewController ()

@end

@implementation RespringViewController
//This calls the button created in RespringViewController.h
- (IBAction) respring: (id) sender {
setuid(0); system("killall SpringBoard");
}
//This makes the view for the button programmatically
UIButton *button9 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button9 addTarget:self
                action:@selector(respring:)
      forControlEvents:UIControlEventTouchUpInside];
    button9.frame = CGRectMake(96.0, 262.0, 130.0, 37.0);
    button9.adjustsImageWhenDisabled = YES;
    button9.adjustsImageWhenHighlighted = YES;
    button9.alpha = 1.000;
    button9.autoresizesSubviews = YES;
    button9.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
    button9.clearsContextBeforeDrawing = YES;
    button9.clipsToBounds = NO;
    button9.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    button9.contentMode = UIViewContentModeScaleToFill;
    button9.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
    button9.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    button9.enabled = YES;
    button9.hidden = NO;
    button9.highlighted = NO;
    button9.multipleTouchEnabled = NO;
    button9.opaque = NO;
    button9.reversesTitleShadowWhenHighlighted = NO;
    button9.selected = NO;
    button9.showsTouchWhenHighlighted = NO;
    button9.tag = 0;
    button9.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15.000];
    button9.titleLabel.lineBreakMode = UILineBreakModeMiddleTruncation;
    button9.titleLabel.shadowOffset = CGSizeMake(0.0, 0.0);
    button9.userInteractionEnabled = YES;
    [button9 setTitle:NSLocalizedString(@"APPLY SETTINGS", nil) forState:UIControlStateNormal];
    [button9 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button9 setTitleColor:[UIColor colorWithWhite:1.000 alpha:1.000] forState:UIControlStateHighlighted];
    [button9 setTitleShadowColor:[UIColor colorWithWhite:0.500 alpha:1.000] forState:UIControlStateNormal];

//Adds the button to the view
[view addSubview:button9];

现在,我继续构建它,并获得一个名为Respring.app的文件

例如,在Respring.app内部有以下文件

Info.plist

Icon.png

重新启动

我必须将Respring.app内部的Respring重命名为Respring_

现在我必须将下面的脚本上传到/path/to/Respring.app/

代码语言:javascript
复制
#!/bin/bash
C=/${0}
C=${C%/*}
declare -a flags
[[ :${DYLD_INSERT_LIBRARIES}: == */MobileSubstrate.dylib: ]] && flags[${#flags[@]}]=--substrate
exec "${C:-.}"/Respring_ "${flags[@]}" -- "$@" 2>>/tmp/Respring.log

并将其命名为Respring

现在,您需要使用工具ldid对二进制文件进行伪代码签名

你可以从here下载

在终端上使用以下命令

sudo ldid -S /path/to/Respring.app/Respring_

请确保对二进制文件而不是脚本进行签名

脚本必须具有正确的权限,才能以root用户身份从终端启动应用程序。您可以运行以下命令

sudo chown 0:0 /path/to/Respring.app/Respring*

sudo chmod 0755 /path/to/Respring.app/Respring

sudo chmod 4755 /path/to/Respring.app/Respring_

现在一切都设置好了,你可以启动应用程序了,任何日志都将存储在你设备的/tmp/Respring.log中,你可以使用按钮重新启动。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13279182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档