Liam0205 / liam0205.github.io

Deployment of my weblog.
https://liam0205.github.io
35 stars 5 forks source link

编写 iOS 越狱插件:从 NIC 中创建项目 | 始终 #400

Open Liam0205 opened 1 year ago

Liam0205 commented 1 year ago

https://liam.page/2023/01/20/Build-an-iOS-Jailbreak-Tweak-init-project-from-NIC/

虚室生白,吉祥止止

boboffv commented 1 year ago

大佬您好,有个越狱手机开发插件的问题想咨询您一下 我的开发环境是 macOS Montery 12.5.1 Xcode 13.4.1 ios sdk 15.0 使用Theos开发tweak插件 目前程序编译打包完成后在iphone12mini ios15.4.1 Dopamine 越狱环境下使用不生效 以下是代码请您给指导下是哪里出了问题感谢!! Tweak.xm

import <UIKit/UIKit.h>

import <CameraUI/CAMZoomControl.h>

import <CameraUI/CAMFullscreenViewfinder.h>

%hook CAMZoomControl -(void)viewDidAppear { %orig; [self _setZoomFactor:0.5 interactionType:0 shouldNotifyDelegate:true]; NSLog(@"hook start"); } %end

%hook CAMFullscreenViewfinder

-(id)initWithFrame:(CGRect)frame { id i=%orig(frame); self.hidden=true; NSLog(@"hook start"); return i; }

Makefile THEOS_PACKAGE_SCHEME=rootless

FINALPACKAGE=1 export DEBUG=0

export TARGET = iphone:clang:15.0 export ADDITIONAL_CFLAGS = -fobjc-arc

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = hookcamera widebydefault_FILES = Tweak.xm ARCHS =arm64 arm64e

include $(THEOS_MAKE_PATH)/tweak.mk

after-install:: install.exec "killall -9 SpringBoard" include $(THEOS_MAKE_PATH)/aggregate.mk

Liam0205 commented 1 year ago

woc……

你这个贴代码,好歹排版一下啊,贴出来乱七八糟的,没法看啊。

我看你 NSLog 打日志了。控制台看一下呗。

boboffv commented 1 year ago

控制台没有日志输出,我在%ctor 里面也尝试过打印日志控制台也没有输出 我最近才接触越狱开发 有点懵。

boboffv commented 1 year ago

重排了 不知道您看到的是否正常,在网站上看有排版的。

Tweak.xm

#import <UIKit/UIKit.h>
#import <CameraUI/CAMZoomControl.h>
#import <CameraUI/CAMFullscreenViewfinder.h>

%hook CAMZoomControl
-(void)viewDidAppear
{
  %orig;
  [self _setZoomFactor:0.5 interactionType:0 shouldNotifyDelegate:true];
  NSLog(@"hook start");
}
%end

%hook CAMFullscreenViewfinder

-(id)initWithFrame:(CGRect)frame
{
  id i=%orig(frame);
  self.hidden=true;
  NSLog(@"hook start");
  return i;
}

-(void)didMoveToSuperview
{
  %orig;
  self.hidden=true;
  NSLog(@"hook start");
}

-(void)didMoveToWindow
{
  %orig;
  self.hidden=true;
  NSLog(@"hook start");
}
%end

Makefile

THEOS_PACKAGE_SCHEME=rootless

FINALPACKAGE=1
export DEBUG=0

export TARGET = iphone:clang:15.0
export ADDITIONAL_CFLAGS = -fobjc-arc

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = hookcamera
widebydefault_FILES = Tweak.xm
ARCHS =arm64 arm64e

include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
install.exec "killall -9 SpringBoard"
include $(THEOS_MAKE_PATH)/aggregate.mk
Liam0205 commented 1 year ago

我给你改了,这样才有排版。

Liam0205 commented 1 year ago

光看代码没什么毛病。先从最简单的代码开始,至少在控制台能看到 Hello World! 吧。不然你没办法调试,都不知道哪里出错了。

boboffv commented 1 year ago

我是在xcode Window-Deivecs And Simulators-Open Console 控制台上查看设备输出日志不知道这样是否正确?

Liam0205 commented 1 year ago

你得 make package 打包之后,安装到越狱后的 i-Device 上。

然后手机通过 USB 和 mac 连接,再打开 macOS 上的「控制台.app」,选择你的 i-Device 设备,然后执行你的代码。正常的话,会在控制台上看到输出(如果很多,可以右上角 filter 过滤)。

boboffv commented 1 year ago

那操作应该是没有问题的 控制台是有很多系统应用的日志 但就是查找不到自己写的调试日志。我也尝试在%ctor 构造器里面输出日志但是控制台上还是没有打印 。我还尝试过修改dylib 二进制文件 启动相机会黑屏应该是有加载这个插件 可能是签名没有验过无法载入,我现在有点迷茫不知道怎么去查找问题了。