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

Method GetValueOfStructMember

examples/triage/headers.cpp:303–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301
302
303uint64_t PEHeaders::GetValueOfStructMember(
304 BinaryViewRef data, const std::string& structName, uint64_t structStart, const std::string& fieldName)
305{
306 TypeRef type = data->GetTypeByName(structName);
307 if (!type)
308 return 0;
309 if (type->GetClass() != StructureTypeClass)
310 return 0;
311 StructureRef s = type->GetStructure();
312 for (auto& member : s->GetMembers())
313 {
314 if (member.name == fieldName)
315 {
316 uint64_t offset = structStart + member.offset;
317 size_t width = member.type->GetWidth();
318 if (width > 8)
319 return 0;
320 uint64_t value = 0;
321 data->Read(&value, offset, width);
322 return value;
323 }
324 }
325 return 0;
326}
327
328
329uint64_t PEHeaders::GetAddressAfterStruct(BinaryViewRef data, const std::string& structName, uint64_t structStart)

Callers

nothing calls this directly

Calls 6

GetClassMethod · 0.80
GetStructureMethod · 0.80
GetMembersMethod · 0.80
GetTypeByNameMethod · 0.45
GetWidthMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected