Skip to content

Instantly share code, notes, and snippets.

@leptos-null
Last active December 15, 2018 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leptos-null/0ad4763ab56a7ce6cfaf6a69ce94f0d6 to your computer and use it in GitHub Desktop.
Save leptos-null/0ad4763ab56a7ce6cfaf6a69ce94f0d6 to your computer and use it in GitHub Desktop.
Odd encoding in YTIThumbnailDetails property list

YTIThumbnailDetails classdump notes

While class dumping YouTube Music, I ran into two problematic properties in a protobuf-generated class.

The property largestImageSource had the type encoding

{YTImageSource=@@{YTClientResource=@@{optional<unsigned int>=B(?={dummy_type=[4{empty_struct=}]}I)}}{optional<unsigned int>=B(?={dummy_type=[4{empty_struct=}]}I)}{optional<unsigned int>=B(?={dummy_type=[4{empty_struct=}]}I)}}

which I reconstructed with

struct optional_unsigned_int {
    BOOL optional;
    union {
        struct dummy_type {
            struct empty_struct {
            } empty[4];
        } blank;
        unsigned int type;
    } either;
};

struct YTImageSource {
    id objectAlpha;
    id objectBeta;
    struct YTClientResource {
        id objectAlpha;
        id objectBeta;
        struct optional_unsigned_int ouiAlpha;
    } resources;
    struct optional_unsigned_int ouiAlpha;
    struct optional_unsigned_int ouiBeta;
};

with the exception of the optional_unsigned_int struct name, which according to the original encoding is optional<unsigned int>, which can't be compiled in Objective-C. Looking over at C++17, there's a new class in the standard namespace called "optional", and allows std::optional<unsigned int>.

The propery imageSources had the type encoding

{vector<YTImageSource, std::__1::allocator<YTImageSource> >=^{YTImageSource}^{YTImageSource}{__compressed_pair<YTImageSource *, std::__1::allocator<YTImageSource> >=^{YTImageSource}}}

which is std::vector<struct YTImageSource> in C++ (requires a .mm file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment