GithubHelp home page GithubHelp logo

Comments (7)

XjShi avatar XjShi commented on April 24, 2024

It may be a careless mistake. Try this:

Class _Nullable
my_object_setClass(id _Nullable obj, Class _Nonnull cls)
{
    return orig_object_setClass(obj, cls);
}

from fishhook.

623637646 avatar 623637646 commented on April 24, 2024

Hi @XjShi , I fix it. But still crash:
Screenshot 2019-11-20 at 8 00 49 PM

from fishhook.

XjShi avatar XjShi commented on April 24, 2024

Call object_setClass(@"", NSObject.class) can also cause crash without hook object_setClass.

from fishhook.

623637646 avatar 623637646 commented on April 24, 2024

@XjShi I tried. It doesn't crash without hooking.

#import "AppDelegate.h"
#import <UIKit/UIKit.h>
#import "fishhook.h"
#import <objc/runtime.h>

Class _Nullable
(*orig_object_setClass)(id _Nullable obj, Class _Nonnull cls);

Class _Nullable
my_object_setClass(id _Nullable obj, Class _Nonnull cls)
{
    return orig_object_setClass(obj, cls);
}


int main(int argc, char * argv[]) {
    @autoreleasepool {
//        rebind_symbols((struct rebinding[]){
//            {"object_setClass", my_object_setClass, (void *)&orig_object_setClass}
//        }, 1);
        
        object_setClass(@"", NSObject.class);
        
        [NSString stringWithFormat:@"%@", @""];
        
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

from fishhook.

XjShi avatar XjShi commented on April 24, 2024

It may be an 'undefined' behavior. I tried this in several different situation. Crash did happens in some situation.

I don't know anything deeper about object_class. 😒

from fishhook.

623637646 avatar 623637646 commented on April 24, 2024

Thanks @XjShi .

from fishhook.

623637646 avatar 623637646 commented on April 24, 2024

Found the answer: https://stackoverflow.com/a/62068020/9315497
Tagged Pointer Strings are special objects.

from fishhook.

Related Issues (20)

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.