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.

  • does it have to be programmatically? You can use "Create struct from data..." in the UI. – Igor Skochinsky Mar 7 at 21:29
  • @IgorSkochinsky Well yeah - either way it's so slow. I was able to write a program that does it - I thought it would be faster. – rec Mar 7 at 22:47
  • What’s your goal with this? It sounds like a pretty strange thing to do. – Igor Skochinsky Mar 7 at 22:48
  • @IgorSkochinsky I want to be able to compile back the output of the decompiler. Obviously some unknown data may actually need to be present in the output since it may be indirectly referenced by some function. A structure is the most obvious way to tackle this problem. – rec Mar 7 at 22:51
  • you may fix this by doing some work around for a specific program. But it is very hard, almost impossible to recompile decompiled output automatically. check this question if you really want to do this - reverseengineering.stackexchange.com/questions/2603/… – R4444 Mar 7 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.