mirror of
https://github.com/cemu-project/idapython.git
synced 2024-12-29 03:01:52 +01:00
idapython menus would duplicate each time a database is opened
This commit is contained in:
parent
d7c6f94f08
commit
a39ada9fb6
11
python.cpp
11
python.cpp
@ -53,6 +53,7 @@ extern "C"
|
|||||||
void init_idaapi(void);
|
void init_idaapi(void);
|
||||||
void idaapi run(int arg);
|
void idaapi run(int arg);
|
||||||
static int initialized = 0;
|
static int initialized = 0;
|
||||||
|
static bool menu_installed = false;
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// Some utility functions from pywraps / idaapi
|
// Some utility functions from pywraps / idaapi
|
||||||
int idcvar_to_pyvar(const idc_value_t &idc_var, PyObject **py_var);
|
int idcvar_to_pyvar(const idc_value_t &idc_var, PyObject **py_var);
|
||||||
@ -787,6 +788,9 @@ void print_banner()
|
|||||||
/* Install python menu items */
|
/* Install python menu items */
|
||||||
static void install_python_menus()
|
static void install_python_menus()
|
||||||
{
|
{
|
||||||
|
if (menu_installed)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Add menu items for all the functions */
|
/* Add menu items for all the functions */
|
||||||
/* Different paths are used for the GUI version */
|
/* Different paths are used for the GUI version */
|
||||||
add_menu_item("File/IDC command...", "P~y~thon command...",
|
add_menu_item("File/IDC command...", "P~y~thon command...",
|
||||||
@ -815,9 +819,12 @@ static void install_python_menus()
|
|||||||
"Alt-7", SETMENU_APP,
|
"Alt-7", SETMENU_APP,
|
||||||
(menu_item_callback_t *)IDAPython_Menu_Callback,
|
(menu_item_callback_t *)IDAPython_Menu_Callback,
|
||||||
(void *)IDAPYTHON_SCRIPTBOX);
|
(void *)IDAPYTHON_SCRIPTBOX);
|
||||||
|
|
||||||
|
menu_installed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum script_run_when {
|
enum script_run_when
|
||||||
|
{
|
||||||
run_on_db_open = 0, // run script after opening database (default)
|
run_on_db_open = 0, // run script after opening database (default)
|
||||||
run_on_ui_ready = 1, // run script when UI is ready
|
run_on_ui_ready = 1, // run script when UI is ready
|
||||||
run_on_init = 2, // run script immediately on plugin load (shortly after IDA starts)
|
run_on_init = 2, // run script immediately on plugin load (shortly after IDA starts)
|
||||||
@ -986,7 +993,7 @@ void IDAPython_Term(void)
|
|||||||
del_menu_item("File/Python file...");
|
del_menu_item("File/Python file...");
|
||||||
del_menu_item("File/Python command...");
|
del_menu_item("File/Python command...");
|
||||||
del_menu_item("View/Open subviews/Python Scripts");
|
del_menu_item("View/Open subviews/Python Scripts");
|
||||||
|
menu_installed = false;
|
||||||
#if IDA_SDK_VERSION >= 540
|
#if IDA_SDK_VERSION >= 540
|
||||||
/* Remove the CLI */
|
/* Remove the CLI */
|
||||||
enable_python_cli(false);
|
enable_python_cli(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user