TransWikia.com

How to replace a segment with a single structure consisting of the data in that segment - programmatically?

Reverse Engineering Asked by rec on March 20, 2021

So I have something like this (I copied this from my other plugin functionality which simply creates a copy paste structure from the frame containing stack variables, while deleting them and then recreating the stack frame as a single variable with the new struct type):

ea_t currea;

    for (auto i : ranges::iota_view{ (size_t)0, get_segm_qty() })
        if (auto segment = getnseg(i); segment->type & SEG_DATA) {
            currea = segment->start_ea;

            auto newstructid = add_struc(BADADDR, nullptr);

            auto newstruct = get_struc(newstructid);

            struc_error_t strucerr;

            do {
                strucerr = add_struc_member(newstruct, /*name*/, currea, /*flags*/, /*member info*/, /*size*/);
            } while ((currea = next_head(currea, segment->end_ea)) != BADADDR);
        }

Anyone can help me fill the blanks. I need to get information about the current head such as type and name.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP