Coder Social home page Coder Social logo

silverfruity / ocrunner Goto Github PK

View Code? Open in Web Editor NEW
659.0 17.0 149.0 4.39 MB

Execute Objective-C code as script. AST Interpreter. iOS hotfix SDK.

License: MIT License

Objective-C 64.64% C 17.35% Swift 10.03% Ruby 0.50% Assembly 1.46% Objective-C++ 6.02%
hotfix objective-c libffi arm64 objc-runtime ios interpreter

ocrunner's Introduction

Hi 👏

I'm Ke Ming Jiang, an iOS developer and unreliable crawler engineer.

  • 🔭 I’m currently working on iOS, Reverse engineering, Crawler and other more.
  • 🌱 I’m currently learning compiler and virtual machine.
  • 😄 I'm loving motorcycle riding, coding, travel.
  • ⚡ Fun fact: Road is underfoot - 。-
  • 👋 My personal blog site

SilverFruity's github stats

🎯 Now I'm focusing :

ocrunner oc2mango

ocrunner's People

Contributors

fabcz avatar jiangh10086 avatar moliya avatar silverfruity avatar weijwwww avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ocrunner's Issues

无法生成二进制文件

OCRunner version: 最新版

description: 写了要修复的代码后,编译了一下,没有生成二进制文件

example: xxxxx
搜索patchgenerator只搜到
截屏2022-07-14 18 14 57

方法参数大于3个传参丢失

比如一个方法有4个参数

  • (void)funcWithS1:(NSString*)s1 s2:(NSString *)s2 s3:(NSString *)s3 s4:(NSString *)s4;
    调用方法时参数对应关系错乱或者丢失

计算错误

double value = 22.23;
value = value < 10 ? 10 : value;
NSLog(@"%f", value);

输出:0.000000

NSRunner 加载 Framework

我想实现用NSRunner 加载 从服务器下发的 framework这个功能,我想知道是我framework打包的有问题,还是我NSRunner使用有问题

1.framework使用swift打包静态库

运行时发现如下错误
Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/Users/xuechen/Library/Developer/CoreSimulator/Devices/0FA624E9-ABC6-49AA-8123-B5D6DF709536/data/Containers/Data/Application/8D827040-88BB-4B27-9291-428273A7E516/Documents/ToolFramework.framework/ToolFramework): no suitable image found. Did find:
/Users/xuechen/Library/Developer/CoreSimulator/Devices/0FA624E9-ABC6-49AA-8123-B5D6DF709536/data/Containers/Data/Application/8D827040-88BB-4B27-9291-428273A7E516/Documents/ToolFramework.framework/ToolFramework: unknown file type, first eight bytes: 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Users/xuechen/Library/Developer/CoreSimulator/Devices/0FA624E9-ABC6-49AA-8123-B5D6DF709536/data/Containers/Data/Application/8D827040-88BB-4B27-9291-428273A7E516/Documents/ToolFramework.framework/ToolFramework, NSDebugDescription=dlopen_preflight(/Users/xuechen/Library/Developer/CoreSimulator/Devices/0FA624E9-ABC6-49AA-8123-B5D6DF709536/data/Containers/Data/Application/8D827040-88BB-4B27-9291-428273A7E516/Documents/ToolFramework.framework/ToolFramework): no suitable image found. Did find:
/Users/xuechen/Library/Developer/CoreSimulator/Devices/0FA624E9-ABC6-49AA-8123-B5D6DF709536/data/Containers/Data/Application/8D827040-88BB-4B27-9291-428273A7E516/Documents/ToolFramework.framework/ToolFramework: unknown file type, first eight bytes: 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A, NSBundlePath=/Users/xuechen/Library/Developer/CoreSimulator/Devices/0FA624E9-ABC6-49AA-8123-B5D6DF709536/data/Containers/Data/Application/8D827040-88BB-4B27-9291-428273A7E516/Documents/ToolFramework.framework, NSLocalizedDescription=The bundle “ToolFramework” couldn’t be loaded because it is damaged or missing necessary resources.}

runtime方式调用类方法时,无法传参的问题。

OCRunner version: 1.2.6

description: 当使用runtim动态调用类方法的时候,被调用的类方法可以被ocrunner替换,也能调到原来的方法,但是参数一直为nil,没能传递过来。

example: 使用method_getImplementation这个方式获取到imp指针,利用runtime方式调用类方法。

目前我只能排查到ORCoreImp.m文件内,methodIMP方法里,第23到27行这儿,sel和target都可以正常获取到,但是第25行获取方法签名就为nil了,所以后面的循环也直接没有跑,导致参数没有被添加到argValues数组中,后续就无法获取到参数了。
经测试,正常调用是可以获取到的,只有runtime这种方式调用的时候,获取不到参数。

麻烦大佬看一下。

有强转的计算表达式,计算结果错误

截屏2023-05-27 10 59 46

这个代码,在OCRunner里面运行,输出结果是:3.000000
正常原生代码运行,输出结果是:3.666667

猜测:
原生的逻辑是先执行参数强转,再执行表达式的计算。
OCRunner的逻辑是先执行表达式计算,再对结果进行强转?

热更代码创建基类,BaseViewController、热更代码创建ViewController3继承于BaseViewController,会导致崩溃

OCRunner version: 1.2.5

description: 热更代码创建基类,BaseViewController、热更代码创建ViewController3继承于BaseViewController,会导致崩溃

@interface HotBaseController : UIViewController
@EnD

@implementation HotBaseController

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSLog(@"----BaseController");
    }

@interface ViewController3 : HotBaseController
@EnD

@interface ViewController3 ()
@EnD
@implementation ViewController3

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    }
    @EnD

执行push时会崩溃
UIViewController *vc = [[NSClassFromString(@"ViewController3") alloc] init];
[self.navigationController pushViewController:vc animated:YES];
截屏

PS:如果要实现增量更新,这个问题不能忽略哦,作者阁下

不能识别UIView的bounds

不能识别UIView的bounds、center等属性

在 OCRunnerDemo 工程的 ViewController1.m 的 - (void)viewDidLoad {
方法中加入

UIView *frameView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 50, 50)];
frameView.backgroundColor = [UIColor redColor];
[self.view addSubview:frameView];

NSLog(@"----tapButton--11--:%@",self.view.subviews);
NSLog(@"----tapButton--22--:%@",NSStringFromCGRect(self.view.frame));
NSLog(@"----:%@",NSStringFromCGPoint(self.view.center));

CGRect rect = CGRectMake(100, 100, 100, 100);
NSLog(@"----:%@",NSStringFromCGRect(rect));

打印输出
2021-01-06 16:12:39.400790+0800 OCRunnerDemo[351:14130] ----tapButton--11--:(
"<_UILayoutGuide: 0x102d151d0; frame = (0 0; 0 0); hidden = YES; layer = <CALayer: 0x1c0036040>>",
"<_UILayoutGuide: 0x102d16020; frame = (0 0; 0 0); hidden = YES; layer = <CALayer: 0x1c0035d80>>",
"<UIView: 0x102d05660; frame = (100 100; 50 50); layer = <CALayer: 0x1c0036320>>"
)
2021-01-06 16:12:39.400884+0800 OCRunnerDemo[351:14130] ----tapButton--22--:(null)
2021-01-06 16:12:39.400950+0800 OCRunnerDemo[351:14130] ----:(null)
2021-01-06 16:12:39.401100+0800 OCRunnerDemo[351:14130] ----:(null)

作者有时间辛苦帮忙看看。

... initWithFrame:CGRectMake(100, 100, 50, 50)];
这里赋值的时候能够正常表现。

求助!求助!怎么设置在指定app版本下下热修复生效呢?没看到怎么设置的地方

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

结构体的内存对齐规则,有瑕疵,当存在嵌套结构体时,计算偏移量错误

OCRunner version: master分支

description:
嵌套结构体时,内部嵌套的结构体的偏移对齐值,不能按照它的尺寸来定义,而是由它的最大的基础变量的尺寸决定的

example:
`struct A {
int a1;
char a2;
};
struct B {
char b1;
struct A b2;
};

struct B s1 = {1,{2,3}};`

OCRunner 版本号: xxx

问题描述:
EFF67DC1-36D1-44BF-B15B-6A8902161190

计算结构体内部变量的偏移量时,当遇到structA这种,嵌套结构体时,它的size是8,但它的对齐偏移值应该是4,在structB中b2变量的offset应该是4,这里错误计算为8.

bug 示例代码:

可以热更swift吗 ?

OCRunner version: xxxxx

description: xxxxxx

example: xxxxx

OCRunner 版本号: xxx

问题描述: xxx

bug 示例代码: xxx

SIGSEGV crash

Hi, 大神
线上收集到一些crash记录,麻烦看一下呢。

iOS 14.4 iphoneXs, iphone11 Pro
iOS 14.3 iPhone 12 Pro Max

crash 栈记录:

#0 Thread

SIGSEGV

SEGV_ACCERR

0 libsystem_platform.dylib _platform_memmove + 84
1 _StringsNodeDeserialization (BinaryPatchHelper.m:210)
2 _PatchNodeGenerateCheckFile (BinaryPatchHelper.m:218)
3 +[ORPatchFile loadBinaryPatch:] (ORPatchFile.m:0)
4 +[ORInterpreter excuteBinaryPatchFile:] (ORInterpreter.m:0)

ocrunner 几处不兼容的地方

OCRunner 版本号: 1.2.0

OCRunner 目前几处不兼容的地方

  1. long double rotate = 0.0; 不支long double
  2. 不支持if (@available(iOS 10.0, *)) 写法
  3. 不支持@synthesize 写法;
  4. 带两个引号的写法不支持 包括属性和实例变量等。@property (nonatomic, assign) NSInteger selectIndex;;
  5. 协议内不能带空格,不支持
    @interface TargetObject ()
    <
    UITableViewDelegate,
    UITableViewDataSource
    >
    这种写法。
  6. .m 内方法后面不支持带 “;” 冒号写法
    7 不支持泛型
    @interface Target<NSObject> : Parent<NSObject>
    @end
    8 不支持 声明类写法 。例如 @class ClassA, ClassB;
    @protocol Prococol1, Prococol2;
  7. 偶尔将 #pragma mark - CustomMethodDescribtion 这种写法当做语法错误爆出

重写 super 的实例方法后,调用不到该方法

原始代码

@interface Car : NSObject

- (void)run;

@end

@interface BMW : Car

- (void)run;

@end

@interface MiniBMW : BMW

@end


#pragma mark - Car

@implementation Car

- (void)run
{
    NSLog(@"Car is running");
}

@end

#pragma mark - BMW

@implementation BMW

- (void)run
{
    NSLog(@"BMW is running");
}

@end

#pragma mark - MiniBMW

@implementation MiniBMW

@end

修复代码


@implementation BMW

- (void)run
{
    NSLog(@"running method by hook");
}

@end

调用代码

    MiniBWM *bmw = [[MiniBMW alloc] init];
    [bmw run];

此时,调用 run 没有任何输出。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.