I'm using ida 6.8 SDK and i have an problem with saving changed variables names,

I used many functions like set_reg_name(C++), setMemberName(in python), they change the name but not permanently, after pressing refresh , or reopening ida, the variables have old names.

What function is used when u press "N" Rename Iyvar, and were to get info on correct way of saving changed variable names ?

  • As far as I remember there was save_user_lvar_settings for hex rays variables in ida 6.8. I'd suggest to search this function on github - this will probably give you some examples. – w s Apr 22 '18 at 10:06
  • @ws seems a common problem ? the thing is that when i'm trying to use user_lvar_visitor_t ulv;( instead of old lvar_uservec_t lvinf; ) i get error that can't create example of abstract class . And i can't find any valid source, can u point me to correct sources ? – LighFusion Apr 22 '18 at 11:53
  • Unfortunately the only source I know about that should work is related to IDA 7.1 and resides here :github.com/IDArlingTeam/IDArling/blob/master/idarling/core/… – w s Apr 22 '18 at 12:55
  • @ws and that's for python ? i can't make lvinf = ida_hexrays.lvar_uservec_t() the same in C++ ; Also i have found this function - bool __fastcall hexapi rename_lvar(lvar_t *v, const char *name, bool is_user_name); in comments it says //This function permanently renames a local variable. , but how to access it ? i get error not found when i try to use it – LighFusion Apr 22 '18 at 13:06
  • @ws huh finnaly after 2 days of searching, thx to these github.com/REhints/HexRaysCodeXplorer/blob/… guys ! the solutions i to get pointer from pseudo code, and apply vu.rename_lvar(&lvars.at(i), "var_permaNamed", true); Ands thats it! it renames permamently, thanks anyway , – LighFusion Apr 22 '18 at 13:45

Solution is very simple:

  1. get pointer to pseudoview

    vdui_t * vuu= open_pseudocode(func->startEA, 0);

  2. Get Pointer to variables

    lvars_t& lvars = *pFunction->get_lvars();

  3. Simply rename variable

    vuu->rename_lvar(&lvars.at(i), "permanamed", true);

last bool flag in rename_lvar func, operate if renaming is permanent or not .

p.s. Its kind'a bad solution as it require opening pseudo view, but i didn't find any other way to do it permanently , or similiar, working function that set's flag like in rename_lvar func .

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.