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

Function group_structure

plugins/pdb-ng/src/struct_grouper.rs:305–375  ·  view source on GitHub ↗
(
    name: &String,
    members: &Vec<ParsedMember>,
    structure: &mut StructureBuilder,
)

Source from the content-addressed store, hash-verified

303}
304
305pub fn group_structure(
306 name: &String,
307 members: &Vec<ParsedMember>,
308 structure: &mut StructureBuilder,
309) -> Result<()> {
310 // SO
311 // PDBs handle trivial unions inside structures by just slamming all the fields together into
312 // one big overlappy happy family. We need to reverse this and create out union structures
313 // to properly represent the original source.
314
315 // IN VISUAL FORM (if you are a visual person, like me):
316 // struct {
317 // int foos[2];
318 // __offset(0):
319 // int foo1;
320 // int foo2;
321 // int bar;
322 // }
323 //
324 // Into
325 //
326 // struct {
327 // union {
328 // int foos[2];
329 // struct {
330 // int foo1;
331 // int foo2;
332 // }
333 // }
334 // int bar;
335 // }
336
337 // Into internal rep
338 let reps = members
339 .iter()
340 .enumerate()
341 .map(|(i, member)| MemberSize {
342 index: i,
343 offset: member.offset,
344 width: member.ty.contents.width(),
345 })
346 .collect::<Vec<_>>();
347
348 log(|| format!("{} {:#x?}", name, members));
349 log(|| format!("{} {:#x?}", name, reps));
350
351 // Group them
352 match resolve_struct_groups(reps) {
353 Ok(groups) => {
354 log(|| format!("{} {:#x?}", name, groups));
355
356 // Apply grouped members
357 apply_groups(members, structure, groups, 0);
358 }
359 Err(e) => {
360 warn!("{} Could not resolve structure groups: {}", name, e);
361 for member in members {
362 structure.insert(

Callers 1

Calls 8

resolve_struct_groupsFunction · 0.85
apply_groupsFunction · 0.85
mapMethod · 0.80
logFunction · 0.70
iterMethod · 0.45
widthMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected