def save(self): """ Function which allow to save the change made to the local variable inside the idb. This is necessary because by default the change made to a lvar using the IDA interface only change the object in memory and not its content. This function is called by default by the setters of this object if the ``_persistent`` property is at True (the default). It should not be necessary to call this directly. .. todo:: this should probably set the flags to ? flags are not directly accessible through the the lvar object from IDAPython rigth now... """ # object needed for containing the information to save about the lvar lsi = lvar_saved_info_t() # set everything which need to be save lsi.ll = self._lvar lsi.name = self.name lsi.type = self._lvar.tif lsi.size = self.size lsi.cmt = self.comment # create the object which is used for saving in the idb lvuv = lvar_uservec_t() # get the info from the previously modify lvar restore_user_lvar_settings(lvuv, self._hxcfunc.ea) if not lvuv.lvvec.add_unique(lsi): # adding this var to save # this is actually not an error but simply means the lvar # was already at the same state return # saving in the idb save_user_lvar_settings(self._hxcfunc.ea, lvuv)
def __call__(self): if len(self.lvar_settings) == 0: return lvinf = ida_hexrays.lvar_uservec_t() lvinf.lvvec = ida_hexrays.lvar_saved_infos_t() if "lvvec" in self.lvar_settings: for lv in self.lvar_settings["lvvec"]: lvinf.lvvec.push_back( UserLvarSettingsEvent._get_lvar_saved_info(lv)) lvinf.sizes = ida_pro.intvec_t() if "sizes" in self.lvar_settings: for i in self.lvar_settings["sizes"]: lvinf.sizes.push_back(i) lvinf.lmaps = ida_hexrays.lvar_mapping_t() if "lmaps" in self.lvar_settings: for key, val in self.lvar_settings["lmaps"]: key = UserLvarSettingsEvent._get_lvar_locator(key) val = UserLvarSettingsEvent._get_lvar_locator(val) ida_hexrays.lvar_mapping_insert(lvinf.lmaps, key, val) if "stkoff_delta" in self.lvar_settings: lvinf.stkoff_delta = self.lvar_settings["stkoff_delta"] if "ulv_flags" in self.lvar_settings: lvinf.ulv_flags = self.lvar_settings["ulv_flags"] ida_hexrays.save_user_lvar_settings(self.ea, lvinf) HexRaysEvent.refresh_pseudocode_view(self.ea)
def __call__(self): lvinf = ida_hexrays.lvar_uservec_t() lvinf.lvvec = ida_hexrays.lvar_saved_infos_t() for lv in self.lvar_settings['lvvec']: lvinf.lvvec.push_back( UserLvarSettingsEvent._get_lvar_saved_info(lv)) lvinf.sizes = ida_pro.intvec_t() for i in self.lvar_settings['sizes']: lvinf.sizes.push_back(i) lvinf.lmaps = ida_hexrays.lvar_mapping_t() for key, val in self.lvar_settings['lmaps']: key = UserLvarSettingsEvent._get_lvar_locator(key) val = UserLvarSettingsEvent._get_lvar_locator(val) ida_hexrays.lvar_mapping_insert(lvinf.lmaps, key, val) lvinf.stkoff_delta = self.lvar_settings['stkoff_delta'] lvinf.ulv_flags = self.lvar_settings['ulv_flags'] ida_hexrays.save_user_lvar_settings(self.ea, lvinf) HexRaysEvent.refresh_pseudocode_view()