mirror of
https://github.com/idapython/src
synced 2026-06-08 14:47:00 +00:00
Added missing support for ida_kernwin.Chooser.OnGetEA
This commit is contained in:
+6
-6
@@ -3993,14 +3993,14 @@ IDA, with a custom widget.
|
||||
|
||||
<li>APIs used
|
||||
<ul>
|
||||
<li>Choose</li>
|
||||
<li>Choose.ALL_CHANGED</li>
|
||||
<li>Choose.CHCOL_HEX</li>
|
||||
<li>Choose.CHCOL_PLAIN</li>
|
||||
<li>Choose.NOTHING_CHANGED</li>
|
||||
<li>ida_funcs.get_func_name</li>
|
||||
<li>ida_kernwin.Choose</li>
|
||||
<li>ida_kernwin.Choose.ALL_CHANGED</li>
|
||||
<li>ida_kernwin.Choose.CHCOL_FNAME</li>
|
||||
<li>ida_kernwin.Choose.CHCOL_HEX</li>
|
||||
<li>ida_kernwin.Choose.CHCOL_PLAIN</li>
|
||||
<li>idautils.Functions</li>
|
||||
<li>idc.del_func</li>
|
||||
<li>idc.jumpto</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
+6
-6
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Binary file not shown.
@@ -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 `<Enter>`
|
||||
| (`<Shift+Enter>` 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 `<Enter>` (`<Shift+Enter>` 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:
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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*/)
|
||||
{
|
||||
|
||||
@@ -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 `<Enter>`
|
||||
(`<Shift+Enter>` 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
|
||||
|
||||
@@ -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 `<Enter>`
|
||||
| (`<Shift+Enter>` 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 `<Enter>` (`<Shift+Enter>` 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:
|
||||
|
||||
|
||||
@@ -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 `<Enter>`
|
||||
| (`<Shift+Enter>` 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 `<Enter>` (`<Shift+Enter>` 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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user