launchApplicationWithIdentifier

前言

正文

  • launchApplicationWithIdentifier
NSTimer *timer ;

%hook SpringBoard
//applicationDidFinishLaunching
-(void)applicationDidFinishLaunching: (id)application
{
        %orig;
//创建一个定时器,定时检测   
	timer = [NSTimer scheduledTimerWithTimeInterval:60*2 target:self selector:@selector(checkHeart) userInfo:nil repeats:YES];
}

%new
- (void)checkHeart
{
	//定时检测微信是否开启
    [[UIApplication sharedApplication] launchApplicationWithIdentifier:@"com.kntencent.xin" suspended:0];
}

%end

与其他的tweak 结合起来使用,合并到同一个deb 包中

  • 放到layout对应的目录
 5 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100755 Layout/Library/MobileSubstrate/DynamicLibraries/SBLockScreenViewController.dylib
 create mode 100644 Layout/Library/MobileSubstrate/DynamicLibraries/SBLockScreenViewController.plist
  • 方式二:在%ctor 中根据 processName 进行%init group

// # 必须放置于最后,否则找不到wxHook
%ctor
{
	if ([[[NSProcessInfo processInfo] processName] isEqualToString:@"knWeChat"])
		%init(wxHook);

	if ([[[NSProcessInfo processInfo] processName] isEqualToString:@"SpringBoard"])
		%init(sbHook);
}


<!-- tweak plist -->

{ Filter = { Bundles = ( "com.kntencent.xin","com.apple.springboard"  ); }; }


<!-- %ctor -->

1) tweak的constructor,完成初始化工作;如果不显示定义,Theos会自动生成一个%ctor,并在其中调用%init(_ungrouped)。

2) %ctor一般可以用来初始化%group,以及进行MSHookFunction等操作

<!-- %group -->

1) 该指令用于将%hook分组,便于代码管理及按条件初始化分组,必须以%end结尾。

2) 一个%group可以包含多个%hook,所有不属于某个自定义group的%hook会被隐式归类到%group_ungrouped中。

<!-- %init -->

1) 该指令用于初始化某个%group,必须在%hook或%ctor内调用;如果带参数,则初始化指定的group,如果不带参数,则初始化_ungrouped.

2) 注:切记,只有调用了%init,对应的%group才能起作用!


<!-- %property -->

这个属性是时候尝试应用下了,否则使用全局变量不太方便

1) Add a property to a %subclass just like you would with @property to a normal Objective-C subclass as well as adding new properties to existing classes within %hook.

2) %property (nonatomic|assign|retain|copy|weak|strong|getter|setter) Type name;


<!-- %subclass -->
1) Subclass block - the class is created at runtime and populated with methods. ivars are not yet supported (use associated objects).

2)  The %new specifier is needed for a method that doesn't exist in the superclass. To instantiate an object of the new class, you can use the %c operator.

3) Can be inside a %group block.

see also

转载请注明: > launchApplicationWithIdentifier

在操作过程或者文章有问题的话欢迎在 原文 里提问或指正。

赞赏支持

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少
最近的文章

KSSystemInfoJailBreakHelperWtloginPlatformInfo

前言 KSSystemInfo 、JailBreakHelper、 WtloginPlatformInfo JailBreakHelperKSSystemInfoWtloginPlatformInfoSafeDeviceData<!-- [SafeDeviceData uuid](void * self, void * _cmd) { -->OpenUDID<!-- [OpenUDID _generateFreshOpenUDID]( -->see al...…

iOSre继续阅读
更早的文章

NSFileHandle

前言 NSFileManager 类主要对文件的操作(删除、修改、移动、复制等等) NSFileHandle 类主要对文件内容进行读取和写入操作 NSString stringWithContentsOfFile 从txt 读取数据的例子 NSString *sandboxPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) f...…

ios继续阅读
更多