diff --git a/examples/index.html b/examples/index.html index 6f90121..c30da1f 100644 --- a/examples/index.html +++ b/examples/index.html @@ -3993,14 +3993,14 @@ IDA, with a custom widget.
  • APIs used
  • diff --git a/examples/index.md b/examples/index.md index dc02ddc..efe96d4 100644 --- a/examples/index.md +++ b/examples/index.md @@ -3327,14 +3327,14 @@ IDA, with a custom widget. chooser functions #### Uses -* Choose -* Choose.ALL_CHANGED -* Choose.CHCOL_HEX -* Choose.CHCOL_PLAIN -* Choose.NOTHING_CHANGED +* ida_funcs.get_func_name +* ida_kernwin.Choose +* ida_kernwin.Choose.ALL_CHANGED +* ida_kernwin.Choose.CHCOL_FNAME +* ida_kernwin.Choose.CHCOL_HEX +* ida_kernwin.Choose.CHCOL_PLAIN * idautils.Functions * idc.del_func -* idc.jumpto #### See also * [choose](#choose) diff --git a/examples/widgets/tabular_views/custom/func_chooser.py b/examples/widgets/tabular_views/custom/func_chooser.py index 75f95f1..e94ce3b 100644 --- a/examples/widgets/tabular_views/custom/func_chooser.py +++ b/examples/widgets/tabular_views/custom/func_chooser.py @@ -13,21 +13,22 @@ see_also: choose, choose_multi, chooser_with_folders from __future__ import print_function import idautils import idc -from ida_kernwin import Choose +import ida_funcs +import ida_kernwin -class MyChoose(Choose): +class my_funcs_t(ida_kernwin.Choose): def __init__(self, title): - Choose.__init__( + ida_kernwin.Choose.__init__( self, title, - [ ["Address", 10 | Choose.CHCOL_HEX], - ["Name", 30 | Choose.CHCOL_PLAIN] ]) + [ ["Address", 10 | ida_kernwin.Choose.CHCOL_HEX], + ["Name", 30 | ida_kernwin.Choose.CHCOL_PLAIN | ida_kernwin.Choose.CHCOL_FNAME] ]) self.items = [] self.icon = 41 def OnInit(self): - self.items = [ [hex(x), get_func_name(x), x] + self.items = [ [hex(x), ida_funcs.get_func_name(x), x] for x in idautils.Functions() ] return True @@ -40,19 +41,24 @@ class MyChoose(Choose): def OnDeleteLine(self, n): ea = self.items[n][2] idc.del_func(ea) - return (Choose.ALL_CHANGED, n) + return (ida_kernwin.Choose.ALL_CHANGED, n) - def OnSelectLine(self, n): - idc.jumpto(self.items[n][2]) - return (Choose.NOTHING_CHANGED, ) + def OnGetEA(self, n): + return self.items[n][2] def OnRefresh(self, n): self.OnInit() # try to preserve the cursor - return [Choose.ALL_CHANGED] + self.adjust_last_item(n) + return [ida_kernwin.Choose.ALL_CHANGED] + self.adjust_last_item(n) def OnClose(self): print("closed ", self.title) -c = MyChoose("My functions list") -c.Show() + +def show_my_funcs_t(modal=False): + c = my_funcs_t("My functions list") + c.Show(modal=modal) + +if __name__ == "__main__": + show_my_funcs_t() + diff --git a/out_of_tree/parsed_notifications.zip b/out_of_tree/parsed_notifications.zip index e7c9f00..8e232b3 100644 Binary files a/out_of_tree/parsed_notifications.zip and b/out_of_tree/parsed_notifications.zip differ diff --git a/pydoc_injections_pro3.txt b/pydoc_injections_pro3.txt index 704c6ba..d865d26 100644 --- a/pydoc_injections_pro3.txt +++ b/pydoc_injections_pro3.txt @@ -56920,6 +56920,20 @@ class Choose(builtins.object) | | @return: the dirtree_t, or None | + | OnGetEA(self, n) + | Get the address of an element + | + | When this function returns valid addresses: + | * If any column has the `CHCOL_FNAME` flag, rows will + | be colored according to the attributes of the functions + | who own those addresses (extern, library function, + | Lumina, ... - similar to what the "Functions" widget does) + | * When a selection is present and the user presses `` + | (`` if the chooser is modal), IDA will jump + | to that address (through jumpto()) + | @param n: element number (0-based) + | @return: the effective address, ida_idaapi.BADADDR if the element has no address + | | OnGetIcon(self, n) | Get an icon to associate with the first cell of an element | @@ -59420,8 +59434,12 @@ class chooser_base_t(builtins.object) | | get_ea(self, *args) -> 'ea_t' | get_ea(self, arg2) -> ea_t - | get an address of an element. Used to set breakpoint in any chooser which - | implements this callback. + | get the address of an element. When this function returns valid addresses: * If + | any column has the `CHCOL_FNAME` flag, rows will be colored according to the + | attributes of the functions who own those addresses (extern, library function, + | Lumina, ... - similar to what the "Functions" widget does) * When a selection is + | present and the user presses `` (`` if the chooser is + | modal), IDA will jump to that address (through jumpto()) | | @param arg2: size_t | @return: the effective address, BADADDR if the element has no address @@ -108495,9 +108513,10 @@ Documentation on variable CHCOL_EA in module ida_kernwin: Documentation on variable CHCOL_FNAME in module ida_kernwin: - function name. If a chooser column has this flag set, its background color will - be automatically set to match the navigator's "Library function", "Lumina - function" and "External symbol" colors + function name. If a chooser column has this flag set and implements + chooser_base_t::get_ea(), rows background colors will be automatically set to + match the navigator's "Library function", "Lumina function" and "External + symbol" colors Documentation on variable CHCOL_FORMAT in module ida_kernwin: diff --git a/pywraps.hpp b/pywraps.hpp index b713c68..4eaf77a 100644 --- a/pywraps.hpp +++ b/pywraps.hpp @@ -110,6 +110,7 @@ static const char S_ON_GET_ICON[] = "OnGetIcon"; static const char S_ON_GET_LINE_ATTR[] = "OnGetLineAttr"; static const char S_ON_GET_SIZE[] = "OnGetSize"; static const char S_ON_GETTEXT[] = "OnGetText"; +static const char S_ON_GET_EA[] = "OnGetEA"; static const char S_ON_GET_DIRTREE[] = "OnGetDirTree"; static const char S_ON_INDEX_TO_INODE[] = "OnIndexToInode"; static const char S_ON_INDEX_TO_DIFFPOS[] = "OnIndexToDiffpos"; diff --git a/pywraps/py_kernwin_choose.hpp b/pywraps/py_kernwin_choose.hpp index 62eacea..c2badeb 100644 --- a/pywraps/py_kernwin_choose.hpp +++ b/pywraps/py_kernwin_choose.hpp @@ -25,10 +25,11 @@ enum feature_t CFEAT_SELECT = 0x0100, CFEAT_ONCLOSE = 0x0200, CFEAT_EMBEDDED = 0x0400, - CFEAT_GETDIRTREE = 0x0800, - CFEAT_INDEX2INODE = 0x1000, - CFEAT_INDEX2DIFFPOS = 0x2000, - CFEAT_LAZYLOADDIR = 0x4000, + CFEAT_GETEA = 0x0800, + CFEAT_GETDIRTREE = 0x1000, + CFEAT_INDEX2INODE = 0x2000, + CFEAT_INDEX2DIFFPOS = 0x4000, + CFEAT_LAZYLOADDIR = 0x8000, }; //------------------------------------------------------------------------ @@ -62,6 +63,10 @@ enum feature_t { \ mixin_closed(this); \ } \ + virtual ea_t idaapi get_ea(size_t n) const override \ + { \ + return mixin_get_ea(n); \ + } \ virtual dirtree_t *idaapi get_dirtree() override \ { \ return mixin_get_dirtree(this); \ @@ -294,6 +299,7 @@ bool py_chooser_props_t::do_extract_from_pyobject( { S_ON_REFRESH, CFEAT_REFRESH, CH_CAN_REFRESH, 0 }, { S_ON_SELECTION_CHANGE, CFEAT_SELECT, 0, 0 }, { S_ON_CLOSE, CFEAT_ONCLOSE, 0, 0 }, + { S_ON_GET_EA, CFEAT_GETEA, 0, 0 }, { S_ON_GET_DIRTREE, CFEAT_GETDIRTREE, CH_HAS_DIRTREE, 0 }, { S_ON_INDEX_TO_INODE, CFEAT_INDEX2INODE, CH_HAS_DIRTREE, 0 }, { S_ON_INDEX_TO_DIFFPOS, CFEAT_INDEX2DIFFPOS, CH_HAS_DIFF, 0 }, @@ -375,6 +381,7 @@ protected: size_t n, const chooser_base_t *chobj) const; void mixin_closed(chooser_base_t *chobj); + ea_t mixin_get_ea(size_t n) const; dirtree_t *mixin_get_dirtree(const chooser_base_t *chobj); inode_t mixin_index_to_inode(size_t n) const; diffpos_t mixin_index_to_diffpos(size_t n) const; @@ -519,6 +526,24 @@ void py_chooser_mixin_t::mixin_closed(chooser_base_t *chobj) } } +//------------------------------------------------------------------------- +ea_t py_chooser_mixin_t::mixin_get_ea(size_t n) const +{ + ea_t ea = BADADDR; + if ( has_feature(CFEAT_GETEA) ) + { + PYW_GIL_GET; + pycall_res_t pyres(PyObject_CallMethod(self.o, (char *) S_ON_GET_EA, PY_BV_SZ, Py_ssize_t(n))); + if ( pyres.result != nullptr ) + { + uint64 u64; + if ( PyW_GetNumber(pyres.result.o, &u64) ) + ea = ea_t(u64); + } + } + return ea; +} + //------------------------------------------------------------------------- dirtree_t *py_chooser_mixin_t::mixin_get_dirtree(const chooser_base_t * /*chobj*/) { diff --git a/pywraps/py_kernwin_choose.py b/pywraps/py_kernwin_choose.py index fdc9a25..381040d 100644 --- a/pywraps/py_kernwin_choose.py +++ b/pywraps/py_kernwin_choose.py @@ -385,6 +385,23 @@ class Choose(object): """ pass + def OnGetEA(self, n): + """ + Get the address of an element + + When this function returns valid addresses: + * If any column has the `CHCOL_FNAME` flag, rows will + be colored according to the attributes of the functions + who own those addresses (extern, library function, + Lumina, ... - similar to what the "Functions" widget does) + * When a selection is present and the user presses `` + (`` if the chooser is modal), IDA will jump + to that address (through jumpto()) + @param n element number (0-based) + @return the effective address, ida_idaapi.BADADDR if the element has no address + """ + pass + def OnGetDirTree(self): """ Get the dirtree_t that will be used to present a tree-like diff --git a/release_pydoc_injections3.txt b/release_pydoc_injections3.txt index 615bc46..403c8ac 100644 --- a/release_pydoc_injections3.txt +++ b/release_pydoc_injections3.txt @@ -56982,6 +56982,20 @@ class Choose(builtins.object) | | @return: the dirtree_t, or None | + | OnGetEA(self, n) + | Get the address of an element + | + | When this function returns valid addresses: + | * If any column has the `CHCOL_FNAME` flag, rows will + | be colored according to the attributes of the functions + | who own those addresses (extern, library function, + | Lumina, ... - similar to what the "Functions" widget does) + | * When a selection is present and the user presses `` + | (`` if the chooser is modal), IDA will jump + | to that address (through jumpto()) + | @param n: element number (0-based) + | @return: the effective address, ida_idaapi.BADADDR if the element has no address + | | OnGetIcon(self, n) | Get an icon to associate with the first cell of an element | @@ -59462,8 +59476,12 @@ class chooser_base_t(builtins.object) | | get_ea(self, *args) -> 'ea_t' | get_ea(self, arg2) -> ea_t - | get an address of an element. Used to set breakpoint in any chooser which - | implements this callback. + | get the address of an element. When this function returns valid addresses: * If + | any column has the `CHCOL_FNAME` flag, rows will be colored according to the + | attributes of the functions who own those addresses (extern, library function, + | Lumina, ... - similar to what the "Functions" widget does) * When a selection is + | present and the user presses `` (`` if the chooser is + | modal), IDA will jump to that address (through jumpto()) | | @param arg2: size_t | @return: the effective address, BADADDR if the element has no address @@ -105578,7 +105596,10 @@ Documentation on variable CHCOL_EA in module ida_kernwin: Documentation on variable CHCOL_FNAME in module ida_kernwin: - function name + function name. If a chooser column has this flag set and implements + chooser_base_t::get_ea(), rows background colors will be automatically set to + match the navigator's "Library function", "Lumina function" and "External + symbol" colors Documentation on variable CHCOL_FORMAT in module ida_kernwin: diff --git a/release_pydoc_injections_pro3.txt b/release_pydoc_injections_pro3.txt index d2707f9..61d529c 100644 --- a/release_pydoc_injections_pro3.txt +++ b/release_pydoc_injections_pro3.txt @@ -56802,6 +56802,20 @@ class Choose(builtins.object) | | @return: the dirtree_t, or None | + | OnGetEA(self, n) + | Get the address of an element + | + | When this function returns valid addresses: + | * If any column has the `CHCOL_FNAME` flag, rows will + | be colored according to the attributes of the functions + | who own those addresses (extern, library function, + | Lumina, ... - similar to what the "Functions" widget does) + | * When a selection is present and the user presses `` + | (`` if the chooser is modal), IDA will jump + | to that address (through jumpto()) + | @param n: element number (0-based) + | @return: the effective address, ida_idaapi.BADADDR if the element has no address + | | OnGetIcon(self, n) | Get an icon to associate with the first cell of an element | @@ -59282,8 +59296,12 @@ class chooser_base_t(builtins.object) | | get_ea(self, *args) -> 'ea_t' | get_ea(self, arg2) -> ea_t - | get an address of an element. Used to set breakpoint in any chooser which - | implements this callback. + | get the address of an element. When this function returns valid addresses: * If + | any column has the `CHCOL_FNAME` flag, rows will be colored according to the + | attributes of the functions who own those addresses (extern, library function, + | Lumina, ... - similar to what the "Functions" widget does) * When a selection is + | present and the user presses `` (`` if the chooser is + | modal), IDA will jump to that address (through jumpto()) | | @param arg2: size_t | @return: the effective address, BADADDR if the element has no address @@ -104559,7 +104577,10 @@ Documentation on variable CHCOL_EA in module ida_kernwin: Documentation on variable CHCOL_FNAME in module ida_kernwin: - function name + function name. If a chooser column has this flag set and implements + chooser_base_t::get_ea(), rows background colors will be automatically set to + match the navigator's "Library function", "Lumina function" and "External + symbol" colors Documentation on variable CHCOL_FORMAT in module ida_kernwin: