MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / ReadIvarList

Method ReadIvarList

objectivec/objc.cpp:917–969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

915}
916
917void ObjCProcessor::ReadIvarList(ObjCReader* reader, ClassBase& cls, std::string_view name, view_ptr_t start)
918{
919 reader->Seek(start);
920 ivar_list_t head;
921 head.entsizeAndFlags = reader->Read32();
922 head.count = reader->Read32();
923 auto addressSize = m_data->GetAddressSize();
924 DefineObjCSymbol(DataSymbol, m_typeNames.ivarList, "ivar_list_" + std::string(name), start, true);
925 for (unsigned i = 0; i < head.count; i++)
926 {
927 try
928 {
929 Ivar ivar;
930 ivar_t ivarStruct;
931 uint64_t cursor = start + (sizeof(ivar_list_t)) + (i * ((addressSize * 3) + 8));
932 reader->Seek(cursor);
933 ivarStruct.offset = ReadPointerAccountingForRelocations(reader);
934 ivarStruct.name = ReadPointerAccountingForRelocations(reader);
935 ivarStruct.type = ReadPointerAccountingForRelocations(reader);
936 ivarStruct.alignmentRaw = reader->Read32();
937 ivarStruct.size = reader->Read32();
938
939 if (ivarStruct.offset)
940 {
941 reader->Seek(ivarStruct.offset);
942 ivar.offset = reader->Read32();
943 }
944 else
945 {
946 // `offset` can be 0 if the ivar is an anonymous bitfield.
947 ivar.offset = 0;
948 }
949
950 reader->Seek(ivarStruct.name);
951 ivar.name = reader->ReadCString();
952 reader->Seek(ivarStruct.type);
953 ivar.type = reader->ReadCString();
954
955 DefineObjCSymbol(DataSymbol, m_typeNames.ivar, "ivar_" + ivar.name, cursor, true);
956 DefineObjCSymbol(DataSymbol, Type::ArrayType(Type::IntegerType(1, true), ivar.name.size() + 1),
957 "ivarName_" + ivar.name, ivarStruct.name, true);
958 DefineObjCSymbol(DataSymbol, Type::ArrayType(Type::IntegerType(1, true), ivar.type.size() + 1),
959 "ivarType_" + ivar.name, ivarStruct.type, true);
960
961 cls.ivarList[cursor] = ivar;
962 }
963 catch (...)
964 {
965 m_logger->LogError("Failed to process an ivar at offset 0x%llx",
966 start + (sizeof(ivar_list_t)) + (i * ((addressSize * 3) + 8)));
967 }
968 }
969}
970
971
972std::pair<QualifiedName, Ref<Type>> finalizeStructureBuilder(

Callers

nothing calls this directly

Calls 8

ArrayTypeClass · 0.85
IntegerTypeClass · 0.85
LogErrorMethod · 0.80
SeekMethod · 0.45
Read32Method · 0.45
GetAddressSizeMethod · 0.45
ReadCStringMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected