Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSObject is defined incorrectly in builtin type libraries #6240

Open
WeiN76LQh opened this issue Dec 9, 2024 · 0 comments
Open

NSObject is defined incorrectly in builtin type libraries #6240

WeiN76LQh opened this issue Dec 9, 2024 · 0 comments

Comments

@WeiN76LQh
Copy link

WeiN76LQh commented Dec 9, 2024

Version and Platform (required):

  • Binary Ninja Version: 4.3.6541-dev (2a7e8df1)
  • OS: macOS
  • OS Version: 15.1.1
  • CPU Architecture: M1

Bug Description:
For a Mach-O binary NSObject has the following type definition in the ioscommon-aarch64 library:

typedef struct objc_class* NSObject;

While this is not entirely incorrect its not really the best way to define it.

When viewing DSC the type definition is actually incorrect but in a different way for some reason:

struct NSObject
{
    struct objc_class_t isa;
};

Additionally the size of the NSObject is 8 initially when viewing DSC, but if you go to change the type of its only field, isa, and then just provide the exact same type, NSObject becomes 0x28 in size. This is the correct size for that definition because objc_class_t is that size and the definition defines it as an inline struct field.

Expected Behavior:
The type definition is more accurately defined as:

struct NSObject
{
    struct objc_class_t *isa;
};

One of the benefits of this is it allows it to be used as a base class for other class/struct definitions.

@WeiN76LQh WeiN76LQh changed the title NSObject should be defined as a struct for Mach-O binaries NSObject is defined incorrectly in builtin type libraries Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant