import
importlib
import
inspect
import
sys
import
idaapi
def
require ( modulename, package
=
None
):
frame_obj, filename, line_number, function_name, lines, index
=
inspect.stack () [
1
]
importer_module
=
inspect.getmodule ( frame_obj )
if
importer_module
is
None
:
importer_module
=
sys.modules [
'__main__'
]
if
modulename
in
sys.modules:
del
sys.modules [ modulename ]
modules_to_reload
=
[ modulename ]
for
name, module
in
list
( sys.modules.items () ):
if
name.startswith ( modulename
+
"."
):
modules_to_reload.append ( name )
del
sys.modules [ name ]
m
=
importlib.import_module ( modulename, package )
setattr
( importer_module, modulename, m )
for
mod_name
in
modules_to_reload:
importlib.import_module ( mod_name, package )
return
m
class
Plugin ( idaapi.plugin_t ):
flags
=
idaapi.PLUGIN_FIX
comment
=
""
help
=
""
wanted_name
=
""
wanted_hotkey
=
""
def
init (
self
):
return
idaapi.PLUGIN_OK
def
run (
self
, arg ):
self
.term ()
require (
'You Pakcage Name'
)
self
.init ()
asg.test ()
return
0
def
term (
self
):
pass
def
PLUGIN_ENTRY ():
return
Plugin ()