[英]How to respring iDevice?
我正在嘗試制作一個應用程序來重新啟動和重新啟動任何 iDevice。 我的代碼在 iOS 模擬器中運行良好,但在我的 iDevice 上沒有任何反應(是的,它已越獄)。
這是我的呼吸代碼:
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]));
這是我的重啟代碼:
if (system([@ "reboot" UTF8String]));
respring 只工作一次,然后停止工作:(
我的腳本:
#!/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
如果呼吸不起作用,這是我的警報視圖,用於重新啟動並使用 BugReport 重新啟動
//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];
}
例子
我將我的應用命名為 Respring
在我的應用程序代碼中,我有一個RespringViewController.h
和RespringViewController.m
在ResringViewController.h
我將添加一個按鈕來調用我的 respring 操作。
#import <UIKit/UIKit.h>
@interface RespringViewController : UIViewController
//Creates the button
- (IBAction) respring:(id)sender;
@end
現在在RespringViewController.m
里面
#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
里面有例如這些文件
信息表
圖標.png
重生
我必須將Respring
的Respring.app
重命名為Respring_
現在我必須將下面的腳本上傳到/path/to/Respring.app/
#!/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
對二進制文件進行偽代碼簽名
你可以 在這里下載
從終端使用以下命令
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
中,您可以使用按鈕重新啟動。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.