What is __CFString?

2019-08-17 05:09发布

问题:

I have arg1 which is an IMessage. IMessage is defined as:

struct IMessage {
    ...
    struct CFString _field2;
    ...
};

and CFString is defined as:

    struct CFString {
    void **_vptr$CFObject;
    struct __CFString *mCFRef;
    _Bool mIsMutable;
};

and __CFString is defined as:

struct __CFString;

My goal is to get a string of some sort be it NSString or CFStringRef from arg1, so how can i do it? Thanks.

Here is the error I get when I try to nslog mCFRef:

Thread 0 crashed:

#  1  0x97b41edb in _objc_msgSend + 0x0000001B (libobjc.A.dylib + 0x00005edb)
#  2  0x9610b5f2 in __CFStringAppendFormatAndArgumentsAux + 0x00000C42 (CoreFoundation + 0x0002c5f2)
#  3  0x9610a979 in __CFStringCreateWithFormatAndArgumentsAux + 0x00000069 (CoreFoundation + 0x0002b979)
#  4  0x961b3a3e in __CFLogvEx + 0x0000008E (CoreFoundation + 0x000d4a3e)
#  5  0x9415387c in _NSLogv + 0x0000008F (Foundation + 0x0009487c)
#  6  0x941537eb in _NSLog + 0x0000001B (Foundation + 0x000947eb)

回答1:

I don't know where you're getting this from, but CFStringRef is defined as struct __CFString *const, so you already have something that looks equivalent.